private void btnOK_Click(object sender, EventArgs e) { if (!Directory.Exists(txtWebDir.Text)) { ScadaUiUtils.ShowWarning(AppPhrases.WebDirNotExists); } settings.WebDir = txtWebDir.Text; DialogResult = DialogResult.OK; }
/// <summary> /// Validates the form fields. /// </summary> private bool ValidateFields() { // unacceptable errors StringBuilder sbError = new StringBuilder(); if (string.IsNullOrWhiteSpace(txtServerDir.Text)) { sbError.AppendError(lblServerDir, CommonPhrases.NonemptyRequired); } else if (!Directory.Exists(txtServerDir.Text)) { sbError.AppendError(lblServerDir, CommonPhrases.DirNotExists); } if (string.IsNullOrWhiteSpace(txtCommDir.Text)) { sbError.AppendError(lblCommDir, CommonPhrases.NonemptyRequired); } else if (!Directory.Exists(txtCommDir.Text)) { sbError.AppendError(lblCommDir, CommonPhrases.DirNotExists); } if (sbError.Length > 0) { sbError.Insert(0, AppPhrases.CorrectErrors + Environment.NewLine); ScadaUiUtils.ShowError(sbError.ToString()); return(false); } // warnings StringBuilder sbWarn = new StringBuilder(); if (!string.IsNullOrWhiteSpace(txtSchemeEditorPath.Text) && !File.Exists(txtSchemeEditorPath.Text)) { sbWarn.AppendError(lblSchemeEditorPath, CommonPhrases.FileNotFound); } if (!string.IsNullOrWhiteSpace(txtTableEditorPath.Text) && !File.Exists(txtTableEditorPath.Text)) { sbWarn.AppendError(lblTableEditorPath, CommonPhrases.FileNotFound); } if (!string.IsNullOrWhiteSpace(txtTextEditorPath.Text) && !File.Exists(txtTextEditorPath.Text)) { sbWarn.AppendError(lblTextEditorPath, CommonPhrases.FileNotFound); } if (sbWarn.Length > 0) { ScadaUiUtils.ShowWarning(sbWarn.ToString()); } return(true); }
private void btnImport_Click(object sender, EventArgs e) { Import(out bool noData); if (noData) { ScadaUiUtils.ShowWarning(AppPhrases.NoDataSelected); } else { DialogResult = DialogResult.OK; } }
/// <summary> /// Validates the form fields. /// </summary> private bool ValidateFields() { // unacceptable errors StringBuilder sbError = new StringBuilder(); if (string.IsNullOrWhiteSpace(txtServerDir.Text)) { sbError.AppendError(lblServerDir, CommonPhrases.NonemptyRequired); } else if (!Directory.Exists(txtServerDir.Text)) { sbError.AppendError(lblServerDir, CommonPhrases.DirNotExists); } if (string.IsNullOrWhiteSpace(txtCommDir.Text)) { sbError.AppendError(lblCommDir, CommonPhrases.NonemptyRequired); } else if (!Directory.Exists(txtCommDir.Text)) { sbError.AppendError(lblCommDir, CommonPhrases.DirNotExists); } if (sbError.Length > 0) { sbError.Insert(0, AppPhrases.CorrectErrors + Environment.NewLine); ScadaUiUtils.ShowError(sbError.ToString()); return(false); } // warnings StringBuilder sbWarn = new StringBuilder(); foreach (ListViewItem item in lvAssociations.Items) { string path = item.SubItems[1].Text; if (!string.IsNullOrWhiteSpace(path) && !File.Exists(path)) { sbWarn.AppendLine(string.Format(CommonPhrases.NamedFileNotFound, path)); } } if (sbWarn.Length > 0) { ScadaUiUtils.ShowWarning(sbWarn.ToString()); } return(true); }
private void btnOK_Click(object sender, EventArgs e) { // validation of parameters var sbErr = new StringBuilder(); var fatalError = false; if (!File.Exists(txtBaseSDFFile.Text)) { sbErr.AppendLine(AppPhrases.BaseSDFFileNotExists); fatalError = true; } if (!Directory.Exists(txtBaseDATDir.Text)) { sbErr.AppendLine(CommonPhrases.BaseDATDirNotExists); fatalError = true; } if (!Directory.Exists(txtBackupDir.Text)) { sbErr.AppendLine(AppPhrases.BackupDirNotExists); fatalError = true; } if (!Directory.Exists(txtCommDir.Text)) { sbErr.AppendLine(AppPhrases.CommDirNotExists); } if (sbErr.Length > 0) { string errMsg = sbErr.ToString().TrimEnd(); if (fatalError) { ScadaUiUtils.ShowError(errMsg); } else { ScadaUiUtils.ShowWarning(errMsg); } } if (!fatalError) { DialogResult = DialogResult.OK; } }
/// <summary> /// Opens the project. /// </summary> private void OpenProject(ProjectItem item) { if (!item.IsEmpty) { if (File.Exists(item.Path)) { ChildFormTag.SendMessage(this, AppMessage.OpenProject, new Dictionary <string, object> { { "Path", item.Path } }); } else { ScadaUiUtils.ShowWarning(CommonPhrases.NamedFileNotFound, item.Path); RemoveProjectFromList(item); } } }
private void btnDeviceProps_Click(object sender, EventArgs e) { // show the device properties if possible if (environment.TryGetKPView(kp, false, commLine.CustomParams, out KPView kpView, out string errMsg)) { if (kpView.CanShowProps) { kpView.ShowProps(); if (kpView.KPProps.Modified) { kp.CmdLine = kpView.KPProps.CmdLine; ChildFormTag.SendMessage(this, CommMessage.UpdateLineParams); } } else { ScadaUiUtils.ShowWarning(CommShellPhrases.NoDeviceProps); } }
private void btnBrowseTemplate_Click(object sender, EventArgs e) { ofdScheme.FileName = ""; if (string.IsNullOrEmpty(interfaceDir)) { ScadaUiUtils.ShowWarning(AppPhrases.UnableOpenTemplate); } else if (ofdScheme.ShowDialog() == DialogResult.OK) { if (ofdScheme.FileName.StartsWith(interfaceDir, StringComparison.OrdinalIgnoreCase)) { txtTemplateFileName.Text = ofdScheme.FileName.Substring(interfaceDir.Length); LoadSchemeTemplate(true); } else { ScadaUiUtils.ShowWarning(AppPhrases.WrongTemplatePath); } } }
/// <summary> /// Установить настройки в соответствии с элементами управления /// </summary> public void ControlsToSettings() { if (!Directory.Exists(txtWebDir.Text)) { ScadaUiUtils.ShowWarning(AppPhrases.WebDirNotExists); } settings.WebDir = txtWebDir.Text; if (rbChrome.Checked) { settings.Browser = Settings.Browsers.Chrome; } else if (rbFirefox.Checked) { settings.Browser = Settings.Browsers.Firefox; } else { settings.Browser = Settings.Browsers.Default; } }
private void btnSave_Click(object sender, EventArgs e) { try { if (dataTable == null) { ScadaUiUtils.ShowWarning("Table is not initialized."); } else { if (rbSnapshot.Checked) { var sa = new SrezAdapter { FileName = txtFileName.Text }; sa.Update(srezTable); } else if (rbEvent.Checked) { var ea = new EventAdapter { FileName = txtFileName.Text }; ea.Update(dataTable); } else // rbBase.Checked { var ba = new BaseAdapter { FileName = txtFileName.Text }; ba.Update(dataTable); } ScadaUiUtils.ShowInfo("Data saved successfully."); } } catch (Exception ex) { ScadaUiUtils.ShowError(ex.Message); } }
/// <summary> /// Loads a scheme template if possible. /// </summary> private void LoadSchemeTemplate(bool showMsg) { // display empty data changing = true; cbTitleComponent.DataSource = null; bsBindings.DataSource = null; if (string.IsNullOrEmpty(interfaceDir)) { if (showMsg) { ScadaUiUtils.ShowWarning(AppPhrases.UnableLoadTemplate); } } else { string templateFileName = Path.Combine(interfaceDir, txtTemplateFileName.Text); if (File.Exists(templateFileName)) { if (SchemeParser.Parse(templateFileName, out List <ComponentItem> components, out List <ComponentBindingItem> newComponentBindings, out string errMsg)) { // merge bindings foreach (ComponentBindingItem bindingItem in newComponentBindings) { if (templateBindings.ComponentBindings.TryGetValue(bindingItem.CompID, out ComponentBinding binding)) { bindingItem.InCnlNum = binding.InCnlNum; bindingItem.CtrlCnlNum = binding.CtrlCnlNum; } } templateBindings.ComponentBindings.Clear(); newComponentBindings.ForEach(x => { templateBindings.ComponentBindings[x.CompID] = x; }); // fill the component combo box components.Sort(); cbTitleComponent.ValueMember = "ID"; cbTitleComponent.DisplayMember = "DisplayName"; cbTitleComponent.DataSource = components; cbTitleComponent.SelectedValue = templateBindings.TitleCompID; // display bindings bsBindings.DataSource = templateBindings.ComponentBindings.Values; if (showMsg) { ScadaUiUtils.ShowInfo(AppPhrases.TemplateLoaded); } } else { bsBindings.DataSource = null; ScadaUiUtils.ShowError(errMsg); } } else if (showMsg) { ScadaUiUtils.ShowWarning(string.Format(AppPhrases.TemplateNotFound, templateFileName)); } } changing = false; }