public void SetCommandStatus(API.CAT.Status status, int?row = null) { Invoke((Action) delegate { Data.SetCell(ref BatchData, status.ToString(), (int)API.CAT.BatchFields.Status, row); }); }
/// ======================================================================================================= public void AddNamedOverlay(string name, string text, API.CAT.Status status) { Invoke((Action) delegate { RemoveOverlay(name); Label label = API.CAT.GetLabel(text, status, name); OverlayControlList.Add(new Overlay(label, AutoAlias)); Controls.Add(label); OrderOverlays(); }); }
/// ======================================================================================================= public void UpdateNamedOverlay(string name, string text, API.CAT.Status status) { Invoke((Action) delegate { foreach (Overlay overlaycontrol in OverlayControlList) { if (overlaycontrol.Label.Name == name) { overlaycontrol.Update(text, status); } } OrderOverlays(); }); }
/// ======================================================================================================= public static Control COMPOSE(string source_path, string timebase_ms, string resolution, string output_folder) { int numlines = 1; string[] sourcelines = null; string sourcepath = API.DISK.AutoAddExt(source_path, ".txt"); // Auto add format extension if (File.Exists(sourcepath)) { sourcelines = File.ReadAllLines(sourcepath); int num = sourcelines.Length; while (num % 2 != 0) { num++; } numlines = (int)Math.Round(num / 2.0); // Rounds } else { // Build Example to use File.WriteAllText(sourcepath, "Example1.wav\t1\r\n0," + timebase_ms + "\r\n" + output_folder + @"\Example2" + "\r\n0"); Thread.Sleep(1000); sourcelines = File.ReadAllLines(sourcepath); API.CAT.AddOverlay(API.CAT.InteractiveControlsFormName, "File did not exist so created example for " + sourcepath); } double timebasems = string.IsNullOrWhiteSpace(timebase_ms) ? 250 : Convert.ToDouble(timebase_ms); int res = string.IsNullOrWhiteSpace(resolution) ? 32 : Convert.ToInt16(resolution); string outputpath = output_folder + (output_folder.Last() == '\\' ? "" : @"\") + Path.GetFileNameWithoutExtension(sourcepath) + ".wav"; // Load data API.CAT.Status status = File.Exists(outputpath) ? API.CAT.Status.PASS : API.CAT.Status.FAIL; GroupBox gb = API.CAT.GetGroupBox("Source:" + sourcepath + " Timebase:" + timebasems + "ms Resolution:" + res + " Output:" + outputpath, status); // Main Menu int menuleft = 0; Label startpos = API.CAT.GetLabel("1", status, "StartPos", DockStyle.None, menuleft, MENU_TOP, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT, autosize: false); gb.Controls.Add(startpos); menuleft += MENU_ITEM_WIDTH; TrackBar starttb = CAT.GetTrackBar("1", 1, 1, res, "StartTrackBar", Orientation.Horizontal, CAT.Status.BUSY, DockStyle.None, menuleft, MENU_TOP, MENU_TRACKBAR_WIDTH, MENU_ITEM_HEIGHT); menuleft += MENU_TRACKBAR_WIDTH; starttb.ValueChanged += new EventHandler((object o, EventArgs e) => { CAT.InteractiveAddOverlay("Start position updated", API.CAT.Status.WARN); startpos.Text = starttb.Value.ToString(); }); gb.Controls.Add(starttb); Label endpos = API.CAT.GetLabel(res.ToString(), status, "EndPos", DockStyle.None, menuleft, MENU_TOP, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT, autosize: false); gb.Controls.Add(endpos); menuleft += MENU_ITEM_WIDTH; TrackBar endtb = CAT.GetTrackBar(res.ToString(), 1, res, res, "EndTrackBar", Orientation.Horizontal, CAT.Status.BUSY, DockStyle.None, menuleft, MENU_TOP, MENU_TRACKBAR_WIDTH, MENU_ITEM_HEIGHT); menuleft += MENU_TRACKBAR_WIDTH; endtb.ValueChanged += new EventHandler((object o, EventArgs e) => { CAT.InteractiveAddOverlay("End position updated", API.CAT.Status.WARN); endpos.Text = endtb.Value.ToString(); }); gb.Controls.Add(endtb); Label timebaser = API.CAT.GetLabel("1", status, "Timebaser", DockStyle.None, menuleft, MENU_TOP, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT, autosize: false); gb.Controls.Add(timebaser); menuleft += MENU_ITEM_WIDTH; TrackBar timebasertb = CAT.GetTrackBar("1", 1, 32, 64, "TimebaserTrackBar", Orientation.Horizontal, CAT.Status.BUSY, DockStyle.None, menuleft, MENU_TOP, MENU_TRACKBAR_WIDTH, MENU_ITEM_HEIGHT); menuleft += MENU_TRACKBAR_WIDTH; timebasertb.ValueChanged += new EventHandler((object o, EventArgs e) => { CAT.InteractiveAddOverlay("Timebase updated", API.CAT.Status.WARN); double value = timebasertb.Value < 32 ? ((double)(1.0 / (32.0 - timebasertb.Value + 1))) : (timebasertb.Value - 32.0 + 1.0); timebaser.Text = value.ToString(); }); gb.Controls.Add(timebasertb); Label scaler = API.CAT.GetLabel("1", status, "Scaler", DockStyle.None, menuleft, MENU_TOP, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT, autosize: false); gb.Controls.Add(scaler); menuleft += MENU_ITEM_WIDTH; TrackBar scalertb = CAT.GetTrackBar("1", 1, 32, 64, "ScalarTrackBar", Orientation.Horizontal, CAT.Status.BUSY, DockStyle.None, menuleft, MENU_TOP, MENU_TRACKBAR_WIDTH, MENU_ITEM_HEIGHT); menuleft += MENU_TRACKBAR_WIDTH; scalertb.ValueChanged += new EventHandler((object o, EventArgs e) => { CAT.InteractiveAddOverlay("Vertical scale updated", API.CAT.Status.WARN); double value = scalertb.Value < 32 ? ((double)(1.0 / (32.0 - scalertb.Value + 1))) : (scalertb.Value - 32.0 + 1.0); scaler.Text = value.ToString(); }); gb.Controls.Add(scalertb); AddItem(ref gb, "♫", () => WAVInteractivePlay(outputpath), status, ref menuleft); AddItem(ref gb, "۞", () => { BUILD(source_path, timebase_ms, resolution, output_folder); GroupBox newgb = (GroupBox)COMPOSE(source_path, timebase_ms, resolution, output_folder); CAT.InteractiveUpdate(gb.Name, newgb); }, status, ref menuleft); AddItem(ref gb, "<", () => Save(sourcepath, res, timebasems, gb, numlines), status, ref menuleft, true); AddItem(ref gb, "+", () => { Save(sourcepath, res, timebasems, gb, numlines + 1); GroupBox newgb = (GroupBox)COMPOSE(source_path, timebase_ms, resolution, output_folder); CAT.InteractiveUpdate(gb.Name, newgb); }, status, ref menuleft); AddItem(ref gb, "$", () => CAT.InteractiveShowReport(() => GraphItem(outputpath, "", (timebasems * Convert.ToDouble(timebaser.Text)).ToString(), (timebasems * Convert.ToDouble(timebaser.Text) * (Convert.ToInt16(startpos.Text) - 1)).ToString(), (timebasems * Convert.ToDouble(timebaser.Text) * Convert.ToInt16(endpos.Text)).ToString()), Convert.ToDouble(scaler.Text)), status, ref menuleft, true); AddItem(ref gb, "h", () => CAT.InteractiveShowReport(() => GraphItems(sourcepath, output_folder, (timebasems * Convert.ToDouble(timebaser.Text)).ToString()), Convert.ToDouble(scaler.Text)), status, ref menuleft, true); // Rows int row = 0; for (int line = 0; line < numlines * 2 - 1; line += 2) { Color rowcolor = LightColorMap[row % LightColorMap.Length]; row++; int rowtop = (row - 1) * ROW_HEIGHT + MENU_ITEM_HEIGHT + MENU_TOP + 2; int colpos = 0; string filestouse = sourcelines[line].Split('\t')[0]; string pathname = PathName(row); /*Play*/ AddRowButton(ref gb, "♪", "Play" + row, () => WAVInteractivePlay(((TextBox)gb.Controls.Find(pathname, true)[0]).Text, output_folder), rowcolor, ROW_PLAY_WIDTH, colpos, rowtop, false); colpos += ROW_PLAY_WIDTH; /*Path*/ gb.Controls.Add(API.CAT.GetTextBox(filestouse, PathName(row), rowcolor, height: ROW_HEIGHT, width: ROW_PATH_WIDTH, autosize: false, left: colpos, top: rowtop)); colpos += ROW_PATH_WIDTH; /*Vol*/ gb.Controls.Add(API.CAT.GetTextBox(sourcelines[line].Contains("\t") ? sourcelines[line].Split('\t')[1] : "", VolName(row), rowcolor, height: ROW_HEIGHT, width: ROW_VOL_WIDTH, autosize: false, left: colpos, top: rowtop)); colpos += ROW_VOL_WIDTH; // Row Delete Row Button btndelete = API.CAT.GetButton("3", "Delete" + row, forecolor: rowcolor, height: ROW_HEIGHT, width: ROW_DELETE_WIDTH, left: colpos, top: rowtop, symbol: true); btndelete.Click += new EventHandler((object o, EventArgs e) => { new Thread(() => { Save(sourcepath, res, timebasems, gb, numlines, Convert.ToUInt16(btndelete.Name.Substring(6))); CAT.InteractiveUpdate(gb.Name, (GroupBox)COMPOSE(source_path, timebase_ms, resolution, output_folder)); }).Start(); }); gb.Controls.Add(btndelete); colpos += ROW_DELETE_WIDTH; // Row Move Up Button btnup = API.CAT.GetButton("▲", "Up" + row, forecolor: rowcolor, height: ROW_HEIGHT, width: ROW_UP_WIDTH, left: colpos, top: rowtop); btnup.Click += new EventHandler((object o, EventArgs e) => { new Thread(() => { Save(sourcepath, res, timebasems, gb, numlines, Convert.ToUInt16(btnup.Name.Substring(2)), true); CAT.InteractiveUpdate(gb.Name, (GroupBox)COMPOSE(source_path, timebase_ms, resolution, output_folder)); }).Start(); }); gb.Controls.Add(btnup); colpos += ROW_UP_WIDTH; // Row Move Down Button btndown = API.CAT.GetButton("▼", "Down" + row, forecolor: rowcolor, height: ROW_HEIGHT, width: ROW_DOWN_WIDTH, left: colpos, top: rowtop); btndown.Click += new EventHandler((object o, EventArgs e) => { new Thread(() => { Save(sourcepath, res, timebasems, gb, numlines, Convert.ToUInt16(btndown.Name.Substring(4)), false); CAT.InteractiveUpdate(gb.Name, (GroupBox)COMPOSE(source_path, timebase_ms, resolution, output_folder)); }).Start(); }); gb.Controls.Add(btndown); colpos += ROW_DOWN_WIDTH; /*Row Graph*/ AddRowButton(ref gb, "h", "Graph" + row, () => CAT.InteractiveShowReport(() => GraphItem(((TextBox)gb.Controls.Find(pathname, true)[0]).Text, output_folder, (timebasems * Convert.ToDouble(timebaser.Text)).ToString(), (timebasems * (Convert.ToInt16(startpos.Text) - 1)).ToString(), (timebasems * Convert.ToInt16(endpos.Text)).ToString()), Convert.ToDouble(scaler.Text)), rowcolor, ROW_GRAPH_WIDTH, colpos, rowtop, true); colpos += ROW_GRAPH_WIDTH; /*Row Checkboxes*/ for (int col = 1; col <= res; col++) { gb.Controls.Add(API.CAT.GetCheckBox(rowcolor, col.ToString("00"), CheckBoxName(row, col), CheckState(sourcelines, line, col, timebasems, res), height: ROW_HEIGHT, width: ROW_CHECKBOX_WIDTH, autosize: false, left: colpos + 1, top: rowtop)); colpos += ROW_CHECKBOX_WIDTH + 2; } } return(gb); }
/// ======================================================================================================= public void Update(string text, API.CAT.Status status) { Label.Text = text; LastUpdated = DateTime.Now; Label.ForeColor = API.CAT.StatusForeColor(status); }
/// ======================================================================================================= public void AddMessage(string text, API.CAT.Status status) { Messages.Add(new Msg(text, status)); }
// Methods /// ======================================================================================================= public void Complete(API.CAT.Status text) { EndTime = DateTime.Now; ResultStatus = text; CommandComplete = true; }
/// ======================================================================================================= public static void InteractiveAddNamedOverlay(string name, string text, API.CAT.Status status = API.CAT.Status.INFO) { API.CAT.FormAccess(API.CAT.FormDelegates.AddNamedOverlay, new object[] { name, text, status }, API.CAT.InteractiveControlsFormName); }