private bool fullLoad2; // загружать 2-й журнал полностью /// <summary> /// Конструктор /// </summary> public FrmMain() { Application.EnableVisualStyles(); InitializeComponent(); // установка формата времени опроса КП timeKpTime.CustomFormat = Localization.Culture.DateTimeFormat.LongTimePattern; // установка имён столбцов списков для перевода формы colParamName.Name = "colParamName"; colParamValue.Name = "colParamValue"; colKpOrder.Name = "colKpOrder"; colKpActive.Name = "colKpActive"; colKpBind.Name = "colKpBind"; colKpNumber.Name = "colKpNumber"; colKpName.Name = "colKpName"; colKpDll.Name = "colKpDll"; colKpAddress.Name = "colKpAddress"; colCallNum.Name = "colCallNum"; colKpTimeout.Name = "colKpTimeout"; colKpDelay.Name = "colKpDelay"; colKpTime.Name = "colKpTime"; colKpPeriod.Name = "colKpPeriod"; colKpCmdLine.Name = "colKpCmdLine"; // инициализация полей appDirs = new AppDirs(); errLog = new Log(Log.Formats.Simple); errLog.Encoding = Encoding.UTF8; mutex = null; icoStart = Icon.FromHandle((ilMain.Images["star_on.ico"] as Bitmap).GetHicon()); icoStop = Icon.FromHandle((ilMain.Images["star_off.ico"] as Bitmap).GetHicon()); svcContr = null; prevSvcStatus = ServiceControllerStatus.Stopped; nodeCommonParams = treeView.Nodes["nodeCommonParams"]; nodeKpDlls = treeView.Nodes["nodeKpDlls"]; nodeLines = treeView.Nodes["nodeLines"]; nodeStats = treeView.Nodes["nodeStats"]; origSettings = new Settings(); modSettings = null; lastNode = null; lastLine = null; lastParam = null; lastParamItem = null; lastKP = null; lastKpItem = null; copiedKP = null; changing = false; serverComm = null; baseTablesReceived = false; tblCommLine = new DataTable(); tblKP = new DataTable(); tblKPType = new DataTable(); kpDllInfoList = new SortedList<string, KpDllInfo>(); commCnlParamsBuf = new Dictionary<string, SortedList<string, string>>(); lbLog1 = null; lbLog2 = null; logFileName1 = ""; logFileName2 = ""; logFileAge1 = DateTime.MinValue; logFileAge2 = DateTime.MinValue; fullLoad1 = false; fullLoad2 = false; Application.ThreadException += Application_ThreadException; }
private void miAddLine_Click(object sender, EventArgs e) { // добавление линии связи TreeNode selNode = treeView.SelectedNode; if (selNode != null) { Settings.CommLine newLine = new Settings.CommLine(); TreeNode newNode = NewLineNode(newLine); int newIndex = selNode == nodeLines ? selNode.Nodes.Count : selNode.Index + 1; nodeLines.Nodes.Insert(newIndex, newNode); modSettings.CommLines.Insert(newIndex, newLine); treeView.SelectedNode = newNode; SetModified(); } }
private void miImportLines_Click(object sender, EventArgs e) { // приём таблиц базы конфигурации при необходимости string errMsg; if (!baseTablesReceived && !ReceiveBaseTables(out errMsg)) { errLog.WriteAction(errMsg); ScadaUtils.ShowError(errMsg); } if (baseTablesReceived) { FrmImport frmImport; if (FrmImport.Import(tblCommLine, tblKP, errLog, out frmImport) == DialogResult.OK) { // импорт линий связи и КП try { treeView.BeginUpdate(); TreeNode selNode = treeView.SelectedNode; if (selNode != null) { int lineIndex = selNode == nodeLines ? selNode.Nodes.Count : selNode.Index + 1; TreeNode newLineNode = selNode; foreach (TreeNode nodeLine in frmImport.TreeView.Nodes) { if (nodeLine.Checked) { // импорт линии связи DataRowView rowLine = (DataRowView)nodeLine.Tag; Settings.CommLine newLine = new Settings.CommLine(); newLine.Number = (int)rowLine["CommLineNum"]; newLine.Name = Convert.ToString(rowLine["Name"]); newLineNode = NewLineNode(newLine); nodeLines.Nodes.Insert(lineIndex, newLineNode); modSettings.CommLines.Insert(lineIndex, newLine); lineIndex++; // импорт КП int kpIndex = 0; foreach (TreeNode nodeKP in nodeLine.Nodes) { if (nodeKP.Checked) { DataRowView rowKP = (DataRowView)nodeKP.Tag; Settings.KP newKP = new Settings.KP(); newKP.Number = (int)rowKP["KPNum"]; DefineKPProps(newKP, rowKP, true); newLine.ReqSequence.Add(newKP); kpIndex++; } } } } treeView.SelectedNode = newLineNode; } } catch (Exception ex) { errMsg = AppPhrases.ImportLinesAndKpError + ":\r\n" + ex.Message; errLog.WriteAction(errMsg); ScadaUtils.ShowError(errMsg); } finally { SetModified(); treeView.EndUpdate(); } } } }
private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode node = e.Node; NodeTag nodeTag = node == null ? null : node.Tag as NodeTag; if (nodeTag != null && node != lastNode) { Text = AppPhrases.MainFormTitle + " - " + node.Text; lastNode = node; lastLine = nodeTag.Obj as Settings.CommLine; lastKP = nodeTag.Obj as Settings.KP; if (lastKP != null) lastLine = ((NodeTag)node.Parent.Tag).Obj as Settings.CommLine; // отображение ассоциированных с узлом дерева страниц tabControl.TabPages.Clear(); foreach (TabPage tabPage in nodeTag.TabPages) { tabControl.TabPages.Add(tabPage); if (tabPage == pageCommonParams) CommonParamsToPage(); else if (tabPage == pageLineParams) LineParamsToPage(); else if (tabPage == pageCustomParams) CustomParamsToPage(); else if (tabPage == pageReqSequence) ReqSequenceToPage(); else if (tabPage == pageLineLog) chkLineLogPause.Checked = false; else if (tabPage == pageKpCmd) txtCmdPwd.Text = ""; } // определение отображаемых на странице журналов tabControl_SelectedIndexChanged(null, null); if (!treeView.Focused) treeView.Focus(); } }