private void btn保存_Click(object sender, EventArgs e) { try { try { gridView2.FocusedRowHandle -= 1; gridView2.FocusedRowHandle += 1; } catch { } string sErr = ""; for (int i = 0; i < gridView2.RowCount; i++) { } } catch (Exception ee) { FrmMsgBox f = new FrmMsgBox(); f.Text = "提示"; f.richTextBox1.Text = ee.Message; f.ShowDialog(); } }
protected override void BtnClick(string sBtnName, string sBtnText) { try { switch (sBtnName.ToLower()) { case "sel": btnSel(); break; case "save": btnSave(); break; default: break; } } catch (Exception ee) { FrmMsgBox fMsgBos = new FrmMsgBox(); fMsgBos.Text = "提示"; fMsgBos.richTextBox1.Text = ee.Message; fMsgBos.ShowDialog(); } }
private void toolStripMenuItem2_Click(object sender, EventArgs e) { FrmMsgBox.ShowOkCancel(this, this.Text, "Note: PLSR requires the R library \"pls\" to function.", FrmMsgBox.EDontShowAgainId.PlsrMode, DialogResult.OK); this._method = EMethod.Plsr; this.UpdateScores(); }
private void _btnOk_Click(object sender, EventArgs e) { // Get the pointer mode UiControls.EStartupPath mode = this._radLocal.Checked ? UiControls.EStartupPath.Local : this._radUser.Checked ? UiControls.EStartupPath.User : this._radMachine.Checked ? UiControls.EStartupPath.Machine : UiControls.EStartupPath.None; // The file browser should have already checked for write-access, but check again just to make sure string text = "This is a test file and should have been automatically deleted by " + Path.GetFileName(Application.ExecutablePath) + ". This file is safe to remove."; string dir = mode == UiControls.EStartupPath.None ? Application.StartupPath : this._txtDataFolder.Text; string testFile = Path.Combine(dir, "delete-me (822FBADE-2869-4D82-8E1D-56D8D2A22D11).txt"); try { File.WriteAllText(testFile, text); File.Delete(testFile); } catch (Exception ex) { FrmMsgBox.ShowError(this, ex); return; } // Set the path and restart UiControls.SetStartupPath(this._txtDataFolder.Text, mode); UiControls.RestartProgram(this); }
private void ctlTitleBar1_HelpClicked(object sender, CancelEventArgs e) { if (FrmMsgBox.ShowYesNo(this, "Cancel", "Are you sure you wish to cancel the task?")) { this._prog.SetCancelAsync(true); } }
/// <summary> /// Button: Load /// </summary> private void _btnLoad_Click_1(object sender, EventArgs e) { ClusterEvaluationPointer res = this.PickResults(); if (res == null) { return; } ClusterEvaluationResults set = FrmWait.Show(this, "Loading results", null, z => this.LoadResults(res.FileName, z)); if (res.Configuration == null) { // The results didn't have known config, they do now! this._core.EvaluationResultFiles.Remove(res); this._core.EvaluationResultFiles.Add(new ClusterEvaluationPointer(res.FileName, set.Configuration)); FrmMsgBox.ShowInfo(this, "Imported results", "The details on this result set have been imported into the current session. You will have to save the session to view these details in future.", FrmMsgBox.EDontShowAgainId.ImportResultsDetailNotice); } if (set != null) { this.SelectResults(res.FileName, set); } }
private void find_archetype() { Cluster p = this.PickCluster(); if (p == null) { return; } var average = p.GetCentre(ECentreMode.Average, ECandidateMode.Assignments)[0]; Vector clV = null; double clD = double.MaxValue; foreach (Vector v in p.Assignments.Vectors) { double d = Maths.Euclidean(v.Values, average); if (d < clD) { clV = v; clD = d; } } FrmMsgBox.ShowCompleted(this, this.Text, "Info: The most similar variable to the Euclidean mean of cluster " + p.DisplayName + " is " + clV.ToString()); }
private OtherExportInfo EditOtherExport(DataSet <OtherExportInfo> .EditItemArgs input) { if (input.ReadOnly) { FrmMsgBox.ShowInfo(input.Owner, input.DefaultValue.DataSet.ToUiString(), "This dataset will be written to:\r\n" + input.DefaultValue.FileName); return(null); } var invalid = (EDataSet)(-1); var existing = (input.DefaultValue != null) ? input.DefaultValue.DataSet : invalid; var existingFn = (input.DefaultValue != null) ? input.DefaultValue.FileName : null; EDataSet value = DataSet.ForDiscreteEnum <EDataSet>(this._core, "Datasets", EDataSet.Acquisitions).ShowList(input.Owner, existing); if (value == invalid) { return(null); } string fn = UiControls.BrowseForFile(input.Owner, existingFn, UiControls.EFileExtension.Csv, FileDialogMode.SaveAs, UiControls.EInitialFolder.ExportedData); if (fn == null) { return(null); } return(new OtherExportInfo(value, fn)); }
/// <summary> /// Private helper method: Checks script editability /// </summary> private static void _ScriptReplace(Form owner, AlgoBase find, AlgoBase replace) { if (find == null || find == replace) { // Nothing removed or item reinserted return; } if (find.Script == null) { FrmMsgBox.ShowInfo(owner, "Unavailable", "This algorithm is stored in binary format and cannot be viewed or modified."); return; } if (find.Script.FileName == null) { FrmMsgBox.ShowInfo(owner, "Unavailable", "This script is inbuilt. Make a copy if you wish to modify it."); return; } if (replace == null) // Direct delete { if (FrmMsgBox.ShowYesNo(owner, "Delete script file from disk?", find.Script.FileName, Resources.MsgWarning)) { File.Delete(find.Script.FileName); Algo.Instance.Rebuild(); } } }
private void btnUnAudit() { bCheck = false; ArrayList aList = new ArrayList(); string sSQL = ""; try { gridView1.FocusedRowHandle -= 1; gridView1.FocusedRowHandle += 1; } catch { } string sErr = ""; for (int i = 0; i < gridView1.RowCount; i++) { if (gridView1.GetRowCellValue(i, gridColbChoose).ToString().Trim() != "√") { continue; } sSQL = @"select * from UFDLImport..Records_Import where RDID = " + gridView1.GetRowCellValue(i, gridColRdsID).ToString().Trim(); DataTable dt = clsSQLCommond.ExecQuery(sSQL); if (dt == null || dt.Rows.Count == 0) { sErr = sErr + "行 " + (i + 1).ToString() + " 加载数据失败\n"; continue; } if (dt.Rows[0]["Saver_Red"].ToString().Trim() == "") { sErr = sErr + "行 " + (i + 1).ToString() + " 尚未确认\n"; continue; } if (dt.Rows[0]["Auditer_Red"].ToString().Trim() == "") { sErr = sErr + "行 " + (i + 1).ToString() + " 尚未审核\n"; continue; } sSQL = @"update UFDLImport..Records_Import set Auditer_Red = null,dtmSave_Red = null where RDID = " + gridView1.GetRowCellValue(i, gridColRdsID).ToString().Trim(); aList.Add(sSQL); } if (sErr.Trim() != "") { FrmMsgBox fMsgBos = new FrmMsgBox(); fMsgBos.Text = "弃审"; fMsgBos.richTextBox1.Text = sErr; fMsgBos.ShowDialog(); } if (aList.Count > 0) { clsSQLCommond.ExecSqlTran(aList); MessageBox.Show("弃审" + aList.Count + "条数据成功!"); GetGrid(); } }
private void button5_Click(object sender, EventArgs e) { Control ctl = (Control)sender; string txt = this.toolTip1.GetToolTip(ctl); FrmMsgBox.ShowInfo(this, this.Text, txt); }
void break_query() { Debugger.Break(); FrmMsgBox.ShowInfo(this, "Message", "This is a message"); FrmInputMultiLine.ShowFixed(this, "Break query", "Allow debugger to take control", "Showing text stored in temporary string", ""); }
private static ProgressReporter.LogRecord DisplayLog(DataSet <ProgressReporter.LogRecord> .EditItemArgs input) { if (input.DefaultValue != null) { FrmMsgBox.Show(input.Owner, input.DefaultValue.Level, input.DefaultValue.Message); } return(null); }
private void _btnEditId_Click(object sender, EventArgs e) { FrmMsgBox.ShowWarning(this, "Edit ID", "The ID represents the identifier used when the data was first loaded. It must be unique. Changing the ID may have unintended consequences.", FrmMsgBox.EDontShowAgainId.ChangeExperimentalGroupsId); string newId = FrmInputSingleLine.Show(this, this.Text, "Edit ID", this._group.DisplayName, this._txtId.Text); if (newId != null) { this._txtId.Text = newId; } }
/// <summary> /// Private helper method: Shows error and remove results dialogues /// </summary> private static bool _ShowEditPreamble(DataSet <ConfigurationBase> .EditItemArgs args) { if (args.DefaultValue != null) { if (args.DefaultValue.HasError) { MsgBoxButton[] btns = { new MsgBoxButton(args.ReadOnly ? "View" : "Edit", Resources.MnuAccept, DialogResult.Yes), new MsgBoxButton("Clear error", Resources.MnuDelete, DialogResult.No), new MsgBoxButton("Cancel", Resources.MnuCancel, DialogResult.Cancel) }; switch (FrmMsgBox.Show(args.Owner, "Error report", "Last time this configuration was run it reported an error", args.DefaultValue.Error, Resources.MsgWarning, btns)) { case DialogResult.Yes: break; case DialogResult.No: args.DefaultValue.ClearResults(); return(false); case DialogResult.Cancel: return(false); default: throw new SwitchException(); } } if (args.DefaultValue.HasResults && !args.ReadOnly) { string text1 = "The configuration to be modified has results associated with it"; string text2 = "Changing this configuration will result in the loss of the associated results."; MsgBoxButton[] btns = { new MsgBoxButton("Replace", Resources.MnuAccept, DialogResult.No), new MsgBoxButton("Cancel", Resources.MnuCancel, DialogResult.Cancel) }; switch (FrmMsgBox.Show(args.Owner, args.Owner.Text, text1, text2, Resources.MsgHelp, btns, FrmMsgBox.EDontShowAgainId.EditWithResults, DialogResult.No)) { case DialogResult.No: break; case DialogResult.Cancel: return(false); default: throw new SwitchException(); } } } return(true); }
internal static bool ShowCannotEditError(Form owner, ArgsBase def) { if (def != null && !def.CheckIsAvailable()) { FrmMsgBox.ShowWarning(owner, "Missing algorithm", "This algorithm uses an algorithm not installed on this machine and its parameters cannot be modified."); return(true); } return(false); }
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { LinkLabel ll = (LinkLabel)sender; try { UiControls.StartProcess(this, ll.Text); } catch (Exception ex) { FrmMsgBox.ShowError(this, ex.Message); } }
/// <summary> /// Button: Import /// </summary> private void _btnImport_Click(object sender, EventArgs e) { string fn = UiControls.BrowseForFile(this, null, UiControls.EFileExtension.EvaluationResults, FileDialogMode.Open, UiControls.EInitialFolder.Evaluations); if (fn == null) { return; } this._core.EvaluationResultFiles.Add(new ClusterEvaluationPointer(fn)); FrmMsgBox.ShowInfo(this, "Import Results", "The file(s) have been imported into the current session. The complete details for these will not be available until the results are loaded.", FrmMsgBox.EDontShowAgainId.ImportResultsNotice); }
void evaluate_cluster_performance() { bool warning; double d; int di; double dz; int dzi; double best; double worst; int bwcount; List <Tuple <Peak, double> > all = new List <Tuple <Peak, double> >(); QuantifyAssignments(this._core, out warning, out d, out di, out dz, out dzi, out worst, out best, out bwcount, all); var all2 = all.Where(λ => λ.Item1.FindAssignments(this._core).All(z => z.Cluster.States == Cluster.EStates.None)); StringBuilder sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine("Value = Σ(i) ( Distance( x(i) - c(i) ) )"); sb.AppendLine(" Where x = values(i), Distance = Euclidean and c(x) = Closest centre in assigned cluster for i."); sb.AppendLine(); sb.AppendLine("All clusters"); sb.AppendLine(" Observations = " + di); sb.AppendLine(" Value = " + d); sb.AppendLine(" Average = " + (double)d / di); sb.AppendLine(); sb.AppendLine("All significant clusters"); sb.AppendLine(" Observations = " + dzi); sb.AppendLine(" Value = " + dz); sb.AppendLine(" Average = " + (double)dz / dzi); sb.AppendLine(); sb.AppendLine("Best/worst 10% in significant clusters"); sb.AppendLine(" Observations = " + bwcount); sb.AppendLine(" Best = " + best); sb.AppendLine(" Worst = " + worst); sb.AppendLine(" Avg. Best = " + best / bwcount); sb.AppendLine(" Avg. Worst = " + worst / bwcount); sb.AppendLine(); sb.AppendLine("Distribution"); sb.AppendLine(" all.names = c(" + StringHelper.ArrayToString(all, λ => "\"" + λ.Item1.DisplayName + "\"") + " )"); sb.AppendLine(" all.values = c(" + StringHelper.ArrayToString(all, λ => λ.Item2.ToString()) + " )"); sb.AppendLine(" signif.names = c(" + StringHelper.ArrayToString(all2, λ => λ.Item1.DisplayName) + " )"); sb.AppendLine(" signif.values = c(" + StringHelper.ArrayToString(all2, λ => λ.Item2.ToString()) + " )"); if (warning) { FrmMsgBox.ShowWarning(this, "Performance", "One or more clusters had no centres, their centres were set to the average of the assignments."); } FrmInputMultiLine.ShowFixed(this, "Performance", "Performance", null, sb.ToString()); }
private void btnDelRow_Click(object sender, EventArgs e) { try { gridView2.DeleteRow(gridView2.FocusedRowHandle); } catch (Exception ee) { FrmMsgBox f = new FrmMsgBox(); f.Text = "提示"; f.richTextBox1.Text = ee.Message; f.ShowDialog(); } }
private void btn保存_Click(object sender, EventArgs e) { try { sSave(); } catch (Exception ee) { FrmMsgBox f = new FrmMsgBox(); f.Text = "提示"; f.richTextBox1.Text = ee.Message; f.ShowDialog(); } }
private void ctlButton1_Click(object sender, EventArgs e) { var sel = this.GetSelection(); if (sel == null) { FrmMsgBox.ShowError(this, "Parameter Optimiser", "A valid configuration must be selected prior to parameter optimisation."); return; } FrmActEvaluate.Show(this, this._core, sel); return; }
public static bool Show(Form owner, string windowText, string mainTitle, string subTitle, string defaultName, ref string name, ref string comments, bool readOnly, Visualisable supports) { bool canRename = supports == null || IVisualisableExtensions.SupportsRename(supports); bool canComment = supports == null || IVisualisableExtensions.SupportsComment(supports); if (!canRename && !canComment) { FrmMsgBox.ShowInfo(owner, defaultName, "This item cannot be renamed."); return(false); } using (FrmEditINameable frm = new FrmEditINameable()) { frm.Text = windowText; frm.textBox1.Watermark = defaultName; frm.textBox1.Text = name; frm._txtInput.Text = comments; frm.ctlTitleBar1.Text = mainTitle; frm.ctlTitleBar1.SubText = subTitle; frm.AcceptButton = null; frm.CancelButton = frm._btnCancel; frm.textBox1.Visible = canRename; frm.label6.Visible = !canRename; frm.label6.Text = defaultName; frm._txtInput.Visible = canComment; frm.label2.Visible = canComment; if (readOnly) { frm._btnOk.Visible = false; frm._btnCancel.Text = " Close"; frm.AcceptButton = frm._btnCancel; frm.textBox1.ReadOnly = true; frm._txtInput.ReadOnly = true; } if (UiControls.ShowWithDim(owner, frm) == DialogResult.OK) { name = frm.textBox1.Text; comments = frm._txtInput.Text; return(true); } return(false); } }
private void saveImageToolStripMenuItem_Click(object sender, EventArgs e) { string fileName = UiControls.BrowseForFile(this, null, UiControls.EFileExtension.PngOrEmf, FileDialogMode.SaveAs, UiControls.EInitialFolder.SavedImages); if (fileName != null) { try { this._chart.DrawToBitmap().Save(fileName); } catch (Exception ex) { FrmMsgBox.ShowError(this, ex); } } }
/// <summary> /// Handles button: Save results /// </summary> private void _btnSave_Click(object sender, EventArgs e) { if (this._selectedResults == null) { return; } string fn = UiControls.BrowseForFile(this, null, UiControls.EFileExtension.EvaluationResults, FileDialogMode.SaveAs, UiControls.EInitialFolder.Evaluations); if (fn == null) { return; } FrmWait.Show(this, "Please wait", null, z => SaveResults(this._core, fn, null, this._selectedResults, z)); FrmMsgBox.ShowInfo(this, "Export Notice", "Results have been exported. Exported data will only be compatible with the current data set.", FrmMsgBox.EDontShowAgainId.ExportDataNotice); }
void do_something_in_r() { string text = FrmInputMultiLine.Show(this, "R", "Enter command", null, "a = 42\r\na"); if (text != null) { try { string newText = Arr.Instance.Evaluate(text).ToString(); FrmInputMultiLine.ShowFixed(this, "R", "Result of user command", null, newText); } catch (Exception ex) { FrmMsgBox.ShowError(this, ex.Message); } } }
private void ctlButton1_Click(object sender, EventArgs e) { using (Bitmap bitmap = this.RenderBitmap()) { if (this._chkClipboard.Checked) { Clipboard.SetImage(bitmap); } else { string fileName; if (string.IsNullOrWhiteSpace(this._txtFileName.Text)) { fileName = UiControls.BrowseForFile(this, null, UiControls.EFileExtension.PngOrEmf, FileDialogMode.SaveAs, UiControls.EInitialFolder.SavedImages); if (fileName == null) { return; } } else { fileName = this._txtFileName.Text; if (!fileName.Contains("\\")) { fileName = UiControls.GetNewFile(Path.Combine(UiControls.GetOrCreateFixedFolder(UiControls.EInitialFolder.SavedImages), fileName)); } } try { bitmap.Save(fileName); this.DialogResult = DialogResult.OK; } catch (Exception ex) { FrmMsgBox.ShowError(this, ex); } } } }
private void find_most_different() { FrmMsgBox.ShowError(this, "This method is not available."); /* * Peak a = null; * Peak b = null; * double maxD = double.MinValue; * * Cluster p = PickCluster(); * * if (p == null) * { * return; * } * * for (int vi = 0; vi < p.Assignments.Count; vi++) * { * Peak v = p.Assignments.List[vi].Peak; * * for (int wi = vi + 1; wi < p.Assignments.Count; wi++) * { * Peak w = p.Assignments.List[wi].Peak; * * double d = Maths.Euclidean(v.Values, w.Values); * * if (d > maxD) * { * a = v; * b = w; * maxD = d; * } * } * } * * _core.DeleteCluster(p); * * Cluster aP = new Cluster(p.Name + "-" + a.Name, "MostDifferent"); * ClusterAssignment.Make(a, aP, double.NaN); * * Cluster bP = new Cluster(p.Name + "-" + b.Name, "MostDifferent"); * ClusterAssignment.Make(b, bP, double.NaN); * */ }
/// <summary> /// Shows a message describing the logs (if any) /// </summary> private static void ShowLogMessage(Form owner, IReadOnlyList <ProgressReporter.LogRecord> logs) { if (logs.Count == 1) { // One line messagebox if one log var l = logs[0]; FrmMsgBox.Show(owner, l.Level, l.Message); } else if (logs.Count != 0) { // Messagebox with "details" buttons for multiple logs // (Messagebox icon reflects the highest log level) StringBuilder sb = new StringBuilder(); DataSet <ProgressReporter.LogRecord> ds = new DataSet <ProgressReporter.LogRecord>() { ListSource = logs, ListTitle = "Logs", HandleEdit = DisplayLog, }; ELogLevel max = logs.Max(z => z.Level); string msg; MsgBoxButton[] bts; if (max == ELogLevel.Information) { msg = "Update complete."; bts = new MsgBoxButton[] { new MsgBoxButton(DialogResult.OK), new MsgBoxButton("Details", Resources.MnuNext, DialogResult.Cancel) }; } else { msg = $"One or more {max.ToUiString().ToLower()}s were reported."; bts = new MsgBoxButton[] { new MsgBoxButton("Details", Resources.MnuNext, DialogResult.Cancel), new MsgBoxButton("Ignore", Resources.MnuCancel, DialogResult.OK) }; } if (FrmMsgBox.Show(owner, max.ToUiString(), null, msg, FrmMsgBox.GetIcon(max), bts) == DialogResult.Cancel) { ds.ShowListEditor(owner, FrmBigList.EShow.ReadOnly, null); } } }
private void _btnOk_Click(object sender, EventArgs e) { this._selectionResult = _listViewHelper.Selection; this._keepChanges = true; try { FrmWait.Show(this, "Applying changes", null, z => this._config.UntypedApplyChanges(this._list, z, false)); } catch (TaskCanceledException ex) { FrmMsgBox.ShowError(this, ex); return; } this._config.UntypedAfterApply(this, this._list); this.DialogResult = DialogResult.OK; }