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); }
public static void Show(Form owner, Core core) { using (FrmActExport frm = new FrmActExport(core)) { UiControls.ShowWithDim(owner, frm); } }
public static bool Show(Form owner, Core core, ChartHelper chart, string title, string caption) { using (FrmActExportImage frm = new FrmActExportImage(core, chart, title, caption)) { return(UiControls.ShowWithDim(owner, frm) == DialogResult.OK); } }
internal static void Show(Form owner, Core session) { using (FrmSession frm = new FrmSession(session)) { UiControls.ShowWithDim(owner, frm); } }
/// <summary> /// Gets the overlapping time range for the specified [groups]. /// </summary> private static Range GetOverlappingTimeRange(Core core, IntensityMatrix source, IEnumerable <GroupInfo> groups) { int min = int.MinValue; // sic int max = int.MaxValue; foreach (GroupInfo type in groups) { int minA = int.MaxValue; int maxA = int.MinValue; foreach (ObservationInfo cond in source.Columns.Select(z => z.Observation)) { if (cond.Group == type) { minA = Math.Min(minA, cond.Time); maxA = Math.Max(maxA, cond.Time); } } UiControls.Assert(minA != int.MaxValue && maxA != int.MinValue, "Failed to determine overlapping time range (type)."); min = Math.Max(minA, min); max = Math.Min(maxA, max); } UiControls.Assert(min != int.MinValue && max != int.MaxValue, "Failed to determine overlapping time range (all)."); return(new Range(min, max)); }
private FrmEditConfigurationCluster() { this.InitializeComponent(); UiControls.SetIcon(this); ctlContextHelp1.Bind(this, this.ctlTitleBar1, this.toolTip1, CtlContextHelp.EFlags.HelpOnClick | CtlContextHelp.EFlags.HelpOnFocus); }
public FrmActEvaluate() { this.InitializeComponent(); UiControls.SetIcon(this); this._imageList = new ImageListIndexHelper(this.imageList1); }
private void SavePresets() { Settings.Presets.Ui.CurvesNo = UiControls.TryGetValue <int>(uiPnlId_Crvs1No_Num); Settings.Presets.Ui.StartX = UiControls.TryGetValue <double>(uiPnlId_StartX_Num); Settings.Presets.Ui.EndX = UiControls.TryGetValue <double>(uiPnlId_EndX_Num); Settings.Presets.Ui.PointsNo = UiControls.TryGetValue <int>(uiPnlId_Dens_Num); }
private bool IsHidden(ToolStripButton button) { bool isChecked = _view.Contains(button); button.Image = UiControls.RecolourImage(isChecked ? Resources.MnuChecked : Resources.MnuUnchecked, button.ForeColor); return(!isChecked); }
private void OnCurveTypeSelection(object sender, EventArgs e) { DataSetCurveType curveType = (DataSetCurveType)UiControls.TryGetSelectedIndex(uiPnlMod_CrvT_ComBx); log.Info(MethodBase.GetCurrentMethod().Name + '(' + curveType + ')'); switch (curveType) { case DataSetCurveType.Modified: uiPnlMod_CrvIdx_Num.Enabled = true; uiPnlMod_CrvIdx_TrBr.Enabled = true; UpdateUiByShowingCurveOnChart(DataSetCurveType.Modified, UiControls.TryGetValue <int>(uiPnlMod_CrvIdx_TrBr)); break; case DataSetCurveType.Ideal: uiPnlMod_CrvIdx_Num.Enabled = false; uiPnlMod_CrvIdx_TrBr.Enabled = false; UpdateUiByShowingCurveOnChart(DataSetCurveType.Ideal); break; case DataSetCurveType.Average: uiPnlMod_CrvIdx_Num.Enabled = false; uiPnlMod_CrvIdx_TrBr.Enabled = false; UpdateUiByShowingCurveOnChart(DataSetCurveType.Average); break; } }
private void OnGenerateSetClick(object sender, EventArgs e) { if (uiPnlId_Def_Btn.Text == new MainWindowStrings().Ui.Panel.IdealScaffoldNone.GetString()) { log.Info(MethodBase.GetCurrentMethod().Name + '(' + uiPnlId_Def_Btn.Text + ')'); AppMessages.MainWindow.StopOfPatternCurveNotChosen(); return; } SavePresets(); bool result = DataChart.GenerateIdealCurve( Settings.Presets.Pcd.Scaffold, Settings.Presets.Pcd.Parameters, Settings.Presets.Ui.StartX, Settings.Presets.Ui.EndX, Settings.Presets.Ui.PointsNo ); if (!result) { DataChart.RemoveInvalidPoints(DataSetCurveType.Ideal); AppMessages.MainWindow.ExclamationOfPointsNotValidToChart(); } UpdateUiByShowingCurveOnChart(DataSetCurveType.Ideal); DataChart.PropagateIdealCurve(Settings.Presets.Ui.CurvesNo); UpdateUiByCurveControlsRanges(); UiControls.TrySetSelectedIndex(uiPnlMod_CrvT_ComBx, (int)DataSetCurveType.Modified); log.Info(MethodBase.GetCurrentMethod().Name + '(' + Settings.Presets.Ui.ToString() + ')'); }
private void OnApplyClick(object sender, EventArgs e) { if (DataChart.IdealCurve.Points.Count == 0) { log.Info(MethodBase.GetCurrentMethod().Name + '(' + nameof(DataChart.IdealCurve) + ')'); AppMessages.MainWindow.ExclamationOfSeriesSelection(); return; } MeanType meanType = (MeanType)UiControls.TryGetSelectedIndex(uiPnlAvg_MeanT_ComBx); int curvesNo = UiControls.TryGetValue <int>(uiPnlAvg_Crvs2No_Num); bool? result = DataChart.TryMakeAverageCurve(meanType, curvesNo); log.Info(MethodBase.GetCurrentMethod().Name + '(' + meanType + ',' + curvesNo + ',' + result.HasValue + ')'); if (!result.Value) { DataChart.RemoveInvalidPoints(DataSetCurveType.Average); AppMessages.MainWindow.ExclamationOfPointsNotValidToChart(); } UiControls.TrySetSelectedIndex(uiPnlMod_CrvT_ComBx, (int)DataSetCurveType.Average); UpdateUiByShowingCurveOnChart(DataSetCurveType.Average); double standardDeviation = Mathematics.GetRelativeStandardDeviation(SeriesAssist.GetValues(DataChart.AverageCurve), SeriesAssist.GetValues(DataChart.IdealCurve)); uiPnlAvg_StdDev2_TxtBx.Text = Strings.TryFormatAsNumeric(8, standardDeviation); }
private void OnMalformClick(object sender, EventArgs e) { if (DataChart.IdealCurve.Points.Count == 0) { log.Info(MethodBase.GetCurrentMethod().Name + '(' + nameof(DataChart.IdealCurve) + ')'); AppMessages.MainWindow.ExclamationOfSeriesSelection(); return; } int curvesNo = UiControls.TryGetValue <int>(uiPnlMod_CrvNo_Num); double surrounding = UiControls.TryGetValue <double>(uiPnlMod_Surr_Num); bool? result = DataChart.MakeNoiseOfGaussian(curvesNo, surrounding); log.Info(MethodBase.GetCurrentMethod().Name + '(' + curvesNo + ',' + surrounding + ',' + result.HasValue + ')'); if (result == null) { AppMessages.MainWindow.ExclamationOfSpecifiedCurveDoesNotExist(); return; } if (!result.Value) { AppMessages.MainWindow.StopOfOperationMalformRejected(); return; } UiControls.TrySetSelectedIndex(uiPnlMod_CrvT_ComBx, (int)DataSetCurveType.Modified); UpdateUiByShowingCurveOnChart(DataSetCurveType.Modified); }
private static MCharting.Series GetOrCreateSeriesForValue(MCharting.Plot plot, Column column, Visualisable vis, ref bool isGroup) { object value = column.GetRow(vis); MCharting.Series series = plot.Series.FirstOrDefault(z => (z.Tag == null && value == null) || (z.Tag != null && z.Tag.Equals(value))); if (series == null) { series = new MCharting.Series(); series.Name = Column.AsString(value, column.DisplayMode); series.Tag = value; if (value is GroupInfoBase) { GroupInfoBase group = (GroupInfoBase)value; UiControls.CreateIcon(series, group); isGroup = true; } else { series.Style.DrawPoints = new SolidBrush(column.GetColour(vis)); } plot.Series.Add(series); } return(series); }
private void OnShowDatasetClick(object sender, EventArgs e) { int curveIndex = UiControls.TryGetValue <int>(uiRChartDown_CrvIdx_Num); string signature = MethodBase.GetCurrentMethod().Name + '(' + curveIndex + ')'; log.Info(signature); if (curveIndex < 0 || curveIndex >= Settings.Ui.CurvesNo) { return; } try { Series controlsSpecifiedSeries = GetUiSpecifiedSeries(); using (var dialog = new GridPreviewer(controlsSpecifiedSeries)) { WindowDimensions dimensions = new WindowDimensions(); dialog.Width = dimensions.GridPreviewer.Width; dialog.Height = dimensions.GridPreviewer.Height; UiControls.TryShowDialog(dialog, this); } } catch (OutOfMemoryException ex) { AppMessages.General.StopOfOutOfMemoryException(); log.Fatal(signature, ex); } catch (Exception ex) { log.Fatal(signature, ex); } }
internal FrmEditColumns(IEnumerable <Column> available, IEnumerable <Column> selected, bool multiSelect, string title) { this.InitializeComponent(); UiControls.SetIcon(this); this._available = available.ToList(); this._selected = selected?.Unique() ?? new HashSet <Column>(); this.ctlTitleBar1.Text = title; this._chkAdvanced.ForeColor = ColumnManager.COLCOL_ADVANCED; this._chkMetaFields.ForeColor = ColumnManager.COLCOL_META; this._chkNormal.ForeColor = ColumnManager.COLCOL_NORMAL; this._chkProperties.ForeColor = ColumnManager.COLCOL_PROPERTY; this._chkStatistics.ForeColor = ColumnManager.COLCOL_STATISTIC; this._chkDefault.ForeColor = ColumnManager.COLCOL_VISIBLE; this._chkFolders.ForeColor = ColumnManager.COLCOL_FOLDER; this._multiSelect = multiSelect; _view.AddRange(new[] { _chkMetaFields, _chkNormal, _chkStatistics, _chkDefault, _chkFolders }); ctlContextHelp1.Bind(this, ctlTitleBar1, null, CtlContextHelp.EFlags.None); this.RefreshView(); }
private void SaveParameters() { switch (Settings.Scaffold) { case IdealCurveScaffold.Polynomial: Settings.Parameters.Polynomial.A = UiControls.TryGetValue <double>(uiCntPol_a_Num); Settings.Parameters.Polynomial.B = UiControls.TryGetValue <double>(uiCntPol_b_Num); Settings.Parameters.Polynomial.C = UiControls.TryGetValue <double>(uiCntPol_c_Num); Settings.Parameters.Polynomial.D = UiControls.TryGetValue <double>(uiCntPol_d_Num); Settings.Parameters.Polynomial.E = UiControls.TryGetValue <double>(uiCntPol_e_Num); Settings.Parameters.Polynomial.F = UiControls.TryGetValue <double>(uiCntPol_f_Num); Settings.Parameters.Polynomial.I = UiControls.TryGetValue <double>(uiCntPol_i_Num); break; case IdealCurveScaffold.Hyperbolic: double userValue = UiControls.TryGetValue <double>(uiCntHyp_f_Num); Settings.Parameters.Hyperbolic.F = Mathematics.IsZero(userValue) ? 0.0001 : userValue; Settings.Parameters.Hyperbolic.A = UiControls.TryGetValue <double>(uiCntHyp_a_Num); Settings.Parameters.Hyperbolic.B = UiControls.TryGetValue <double>(uiCntHyp_b_Num); Settings.Parameters.Hyperbolic.C = UiControls.TryGetValue <double>(uiCntHyp_c_Num); Settings.Parameters.Hyperbolic.D = UiControls.TryGetValue <double>(uiCntHyp_d_Num); Settings.Parameters.Hyperbolic.I = UiControls.TryGetValue <double>(uiCntHyp_i_Num); break; case IdealCurveScaffold.WaveformSine: case IdealCurveScaffold.WaveformSquare: case IdealCurveScaffold.WaveformTriangle: case IdealCurveScaffold.WaveformSawtooth: Settings.Parameters.Waveform.M = UiControls.TryGetValue <double>(uiCntWave_m_Num); Settings.Parameters.Waveform.N = UiControls.TryGetValue <double>(uiCntWave_n_Num); Settings.Parameters.Waveform.O = UiControls.TryGetValue <double>(uiCntWave_o_Num); Settings.Parameters.Waveform.K = UiControls.TryGetValue <double>(uiCntWave_k_Num); break; } }
/// <summary> /// Adds the algorithms stored on disk and in the SCRIPTS.RESX file. /// </summary> private static void PopulateFiles <T>(AlgoCollection <T> targetCollection, UiControls.EInitialFolder searchFolder, Delegate_Constructor <T> constructorMethod) where T : AlgoBase { string folder = UiControls.GetOrCreateFixedFolder(searchFolder); string resourcePrefix = "scripts~" + Path.GetFileName(folder).ToLower() + "~"; ResourceSet resources = UiControls.GetScriptsResources(); // Search Scripts.resx foreach (DictionaryEntry resource in resources) { string key = (string)resource.Key; if (key.StartsWith(resourcePrefix)) { string subPart = key.Substring(resourcePrefix.Length); string id = GetId(searchFolder, subPart, true); targetCollection.Add(constructorMethod(Encoding.UTF8.GetString((byte[])resource.Value), id, subPart.Replace("_", " "), null)); } } // Search folder foreach (string fileName in Directory.GetFiles(folder, "*.r")) { string id = GetId(searchFolder, fileName, false); string name = Path.GetFileName(fileName); targetCollection.Add(constructorMethod(File.ReadAllText(fileName), id, name, fileName)); } }
/// <summary> /// Shows the form /// </summary> internal static void Show(Form owner, Core core, ArgsClusterer config) { using (FrmActEvaluate frm = new FrmActEvaluate(core, config)) { UiControls.ShowWithDim(owner, frm); } }
public static void Show(Form owner) { using (FrmActAlarm frm = new FrmActAlarm()) { UiControls.ShowWithDim(owner, frm); } }
/// <summary> /// I wrote this when the program crashed after an hour. /// Intermediate results can now be saved to avoid losing data. /// </summary> private static ResultClusterer TryLoadIntermediateResult(Core core, Guid guid, int value, int repetition, ProgressReporter proggy) { string fileName = UiControls.GetTemporaryFile("." + value + "." + repetition + ".intermediate.dat", guid); if (!File.Exists(fileName)) { return(null); } LookupByGuidSerialiser guidS = core.GetLookups(); proggy.Enter("Loading saved results"); ResultClusterer result; try { result = XmlSettings.LoadOrDefault <ResultClusterer>(new FileDescriptor(fileName, SerialisationFormat.MSerialiserFastBinary), null, guidS, proggy); } catch { proggy.Leave(); // Result will probably be NULL rather than throwing an exception return(null); } UiControls.Assert(!guidS.HasLookupTableChanged, "Didn't expect the GUID lookup table to change when loading data."); proggy.Leave(); return(result); }
private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) { if (this.DrawHBar) { UiControls.DrawHBar(e.Graphics, this.tableLayoutPanel1, this.tableLayoutPanel1.BackColor, this.tableLayoutPanel1.ForeColor); } }
private FrmEditConfigurationStatistic(Core core, ArgsStatistic defaultSelection, Peak defaultPeak, bool readOnly) : this() { this._core = core; this._previewPeak = defaultPeak; this._ecbFilter1 = DataSet.ForObsFilter(core).CreateComboBox(this._lstFilter1, this._btnFilter1, EditableComboBox.EFlags.IncludeAll); this._ecbFilter2 = DataSet.ForObsFilter(core).CreateComboBox(this._lstFilter2, this._btnFilter2, EditableComboBox.EFlags.IncludeAll); this._ecbSource = DataSet.ForMatrixProviders(core).CreateComboBox(this._lstSource, this._btnSource, EditableComboBox.EFlags.None); this._ecbMeasure = DataSet.ForStatisticsAlgorithms(core).CreateComboBox(this._lstMethod, this._btnNewStatistic, EditableComboBox.EFlags.None); this._ecbDiffPeak = DataSet.ForPeaks(core).CreateComboBox(this._lstDiffPeak, this._btnSelectDiffPeak, EditableComboBox.EFlags.None); this._ecbDiffPeak.SelectedItem = defaultPeak; if (defaultSelection != null) { this._txtName.Text = defaultSelection.OverrideDisplayName; this.ctlTitleBar1.SubText = defaultSelection.AlgoName; this._comments = defaultSelection.Comment; this._ecbMeasure.SelectedItem = (StatisticBase)defaultSelection.GetAlgorithmOrNull(); this._txtParams.Text = AlgoParameterCollection.ParamsToReversableString(defaultSelection.Parameters, this._core); this._ecbSource.SelectedItem = defaultSelection.SourceProvider; this._radBCorTime.Checked = defaultSelection.VectorBSource == EAlgoInputBSource.Time; this._radBDiffPeak.Checked = defaultSelection.VectorBSource == EAlgoInputBSource.AltPeak; this._radSamePeak.Checked = defaultSelection.VectorBSource == EAlgoInputBSource.SamePeak; this._ecbFilter1.SelectedItem = defaultSelection.VectorAConstraint; this._ecbFilter2.SelectedItem = defaultSelection.VectorBConstraint; if (defaultSelection.VectorBPeak != null) { this._ecbDiffPeak.SelectedItem = defaultSelection.VectorBPeak; } } this.SetStatuses(); this._readOnly = readOnly; if (readOnly) { UiControls.MakeReadOnly(this, this._tlpPreivew); this._btnComment.Enabled = true; this.ctlTitleBar1.Text = "View Statistic"; } else if (defaultSelection != null) { this.ctlTitleBar1.Text = "Edit Statistic"; } else { this.ctlTitleBar1.Text = "New Statistic"; } // UiControls.CompensateForVisualStyles(this); }
static void Main() { Mutex mutex = new Mutex(false, "{46A11243-B4F7-43EA-BC19-D3C27BF2218C}"); try { // Wait a little while in case we are restarting if (!mutex.WaitOne(2000, true)) { MessageBox.Show("Application already running."); return; } } catch { // Ignore } if (!System.Diagnostics.Debugger.IsAttached) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; } UiControls.Initialise(new System.Drawing.Font("Segoe UI", 12)); MainSettings.Initialise(); CtlError.DefaultIcon = Icon.FromHandle(Resources.IconInputError.GetHicon()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FrmMain()); }
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)); }
private void OnTabSelection(object sender, EventArgs e) { int selection = UiControls.TryGetSelectedIndex(uiL_TbCtrl); UiControls.TrySetSelectedIndex(uiRChartDown_Phen_ComBx, selection); log.Info(MethodBase.GetCurrentMethod().Name + '(' + (Phenomenon)selection + ')'); }
private FrmActHeatMap(Core core, CtlAutoList lvh, Column source1D, DistanceMatrix source2D) { this.InitializeComponent(); UiControls.SetIcon(this); this._maxColour = core.Options.HeatMapMaxColour; this._nanColour = core.Options.HeatMapNanColour; this._minColour = core.Options.HeatMapMinColour; this._oorColour = core.Options.HeatMapOorColour; this._core = core; this._sourceList = lvh; this._source1D = source1D; this._source2D = source2D; if (source1D != null) { this.Text = UiControls.GetFileName(source1D.DisplayName); } else { this.Text = UiControls.GetFileName("Distance matrix"); } this.ctlTitleBar1.Text = this.Text; this.GenerateHeat(); }
private void OnCurveTypeSelection(object sender, EventArgs e) { DataSetCurveType curveType = (DataSetCurveType)UiControls.TryGetSelectedIndex(uiRChartDown_CrvT_ComBx); switch (curveType) { case DataSetCurveType.Modified: uiRChartDown_CrvIdx_Num.Enabled = true; uiRChartDown_MeanT_ComBx.Enabled = false; break; case DataSetCurveType.Average: uiRChartDown_CrvIdx_Num.Enabled = false; uiRChartDown_MeanT_ComBx.Enabled = true; break; case DataSetCurveType.Ideal: uiRChartDown_CrvIdx_Num.Enabled = false; uiRChartDown_MeanT_ComBx.Enabled = false; break; } if (IsFormShown) { UpdateUiByRefreshingChart(); } log.Info(MethodBase.GetCurrentMethod().Name + '(' + IsFormShown + ',' + curveType + ')'); }
public static void Show(IWin32Window owner, Core core) { using (FrmExport2 frm = new FrmExport2(core)) { UiControls.ShowWithDim(owner, frm); } }
private FrmSetupWorkspace() { this.InitializeComponent(); UiControls.SetIcon(this); this._txtDataFolder.Text = UiControls.StartupPath; switch (UiControls.StartupPathMode) { case UiControls.EStartupPath.Local: case UiControls.EStartupPath.None: this._radLocal.Checked = true; break; case UiControls.EStartupPath.Machine: this._radMachine.Checked = true; break; case UiControls.EStartupPath.User: this._radUser.Checked = true; break; default: throw new SwitchException(UiControls.StartupPathMode); } // UiControls.CompensateForVisualStyles(this); }