130 lines
4.5 KiB
C#
130 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Drawing.Printing;
|
|
using ZedGraph;
|
|
|
|
namespace GenesisDisplayTool
|
|
{
|
|
|
|
public partial class GENESIS_DISPLAY_TOOL : Form
|
|
{
|
|
|
|
public void WaitForBackgroundWorkers()
|
|
{
|
|
while
|
|
(
|
|
backgroundWorkerTofMean.IsBusy || backgroundWorkerTofMean2.IsBusy || backgroundWorkerTofMean3.IsBusy || backgroundWorkerTofMean4.IsBusy || backgroundWorkerTofMean5.IsBusy || backgroundWorkerTofMean6.IsBusy ||
|
|
backgroundDifTofMean.IsBusy || backgroundDifTofMean2.IsBusy || backgroundDifTofMean3.IsBusy || backgroundDifTofMean4.IsBusy || backgroundDifTofMean5.IsBusy || backgroundDifTofMean6.IsBusy||
|
|
backgroundWorkerMultiHitMean.IsBusy || backgroundWorkerMultiHitMean2.IsBusy || backgroundWorkerMultiHitMean3.IsBusy || backgroundWorkerMultiHitMean4.IsBusy || backgroundWorkerMultiHitMean5.IsBusy || backgroundWorkerMultiHitMean6.IsBusy||
|
|
backgroundStdDev.IsBusy || backgroundStdDev2.IsBusy || backgroundStdDev3.IsBusy || backgroundStdDev4.IsBusy || backgroundStdDev5.IsBusy || backgroundStdDev6.IsBusy||
|
|
backgroundFlow1.IsBusy || backgroundFlow2.IsBusy || backgroundFlow3.IsBusy || backgroundFlow4.IsBusy || backgroundFlow5.IsBusy || backgroundFlow6.IsBusy
|
|
)
|
|
Misc.WaitCondition(true);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
public static partial class Misc
|
|
{
|
|
public static void GarbageCollector(ref int counter)
|
|
{
|
|
#region Garbage collector
|
|
/*
|
|
counter++;
|
|
if (counter == 1000)
|
|
{
|
|
GC.Collect();
|
|
counter = 0;
|
|
}*/
|
|
#endregion
|
|
}
|
|
public static bool OnlyDecimalInString(string data)
|
|
{
|
|
return (System.Text.RegularExpressions.Regex.IsMatch(data, @"^[0-9]+(\.[0-9]+)?$"));
|
|
}
|
|
|
|
public static bool OnlyHexInString(string data)
|
|
{
|
|
// For C-style hex notation (0xFF) you can use @"\A\b(0[xX])?[0-9a-fA-F]+\b\Z"
|
|
return System.Text.RegularExpressions.Regex.IsMatch(data, @"\A\b[0-9a-fA-F]+\b\Z");
|
|
}
|
|
|
|
|
|
public static void WaitCondition(bool condition)
|
|
{
|
|
if(condition)
|
|
Application.DoEvents();
|
|
}
|
|
|
|
|
|
public static void WaitNSeconds(int seconds)
|
|
{
|
|
if (seconds < 1) return;
|
|
DateTime _desired = DateTime.Now.AddSeconds(seconds);
|
|
while (DateTime.Now < _desired)
|
|
{
|
|
Application.DoEvents();
|
|
Thread.Sleep(10);
|
|
}
|
|
}
|
|
|
|
public static void WaitNMilliseconds(int milliseconds)
|
|
{
|
|
if (milliseconds < 1) return;
|
|
DateTime _desired = DateTime.Now.AddMilliseconds(milliseconds);
|
|
while (DateTime.Now < _desired)
|
|
{
|
|
Application.DoEvents();
|
|
}
|
|
}
|
|
|
|
public delegate void ContextMenuBuilderEventHandler(
|
|
ZedGraphControl control,
|
|
ContextMenuStrip menuStrip,
|
|
Point mousePt,
|
|
ZedGraphControl.ContextMenuObjectState objState);
|
|
|
|
|
|
public static void MyContextMenuBuilder(ZedGraphControl control, ContextMenuStrip menuStrip, Point mousePt, ZedGraphControl.ContextMenuObjectState objState)
|
|
{
|
|
foreach (ToolStripMenuItem item in menuStrip.Items)
|
|
{
|
|
if ((string)item.Tag == "save_as")
|
|
{
|
|
// remove the menu item
|
|
menuStrip.Items.Remove(item);
|
|
// or, just disable the item with this
|
|
//item.Enabled = false;
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
foreach (ToolStripMenuItem item in menuStrip.Items)
|
|
{
|
|
if ((string)item.Tag == "set_default")
|
|
{
|
|
// remove the menu item
|
|
menuStrip.Items.Remove(item);
|
|
// or, just disable the item with this
|
|
//item.Enabled = false;
|
|
|
|
break;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
} |