private void lvUserParams_SelectedIndexChanged(object sender, EventArgs e) { changing = true; if (lvUserParams.SelectedItems.Count > 0) { lastParamItem = lvUserParams.SelectedItems[0]; lastParam = lastParamItem.Tag as Settings.UserParam; if (lastParam == null) { lastParamItem = null; } else { txtParamOrder.Text = (lastParamItem.Index + 1).ToString(); txtParamName.Text = lastParam.Name; txtParamValue.Text = lastParam.Value; txtParamDescr.Text = lastParam.Descr; gbSelectedParam.Enabled = true; } } else { lastParam = null; lastParamItem = null; txtParamOrder.Text = ""; txtParamName.Text = ""; txtParamValue.Text = ""; txtParamDescr.Text = ""; gbSelectedParam.Enabled = false; } // установка доступности кнопок для действий с пользовательским параметром bool itemSelected = lastParamItem != null; btnMoveUpParam.Enabled = itemSelected && lastParamItem.Index > 0; btnMoveDownParam.Enabled = itemSelected && lastParamItem.Index < lvUserParams.Items.Count - 1; btnDelParam.Enabled = itemSelected; changing = false; }
private void btnAddParam_Click(object sender, EventArgs e) { if (lastLine != null) { Settings.UserParam newParam = new Settings.UserParam(); int newIndex = lastLine.UserParams.IndexOf(lastParam); if (newIndex < 0) newIndex = lastLine.UserParams.Count; else newIndex++; ListViewItem newItem = new ListViewItem(new string[] { (newIndex + 1).ToString(), "", "", "" }); newItem.Tag = newParam; if (newIndex < lastLine.UserParams.Count) { lastLine.UserParams.Insert(newIndex, newParam); lvUserParams.Items.Insert(newIndex, newItem); for (int i = newIndex + 1; i < lvUserParams.Items.Count; i++) lvUserParams.Items[i].Text = (i + 1).ToString(); } else { lastLine.UserParams.Add(newParam); lvUserParams.Items.Add(newItem); } newItem.Selected = true; txtParamName.Focus(); SetModified(); } }
private DataTable tblKPType; // таблица типов КП из базы конфигурации #endregion Fields #region Constructors /// <summary> /// Конструктор /// </summary> public FrmMain() { Application.EnableVisualStyles(); InitializeComponent(); // установка формата времени опроса КП timeKpTime.CustomFormat = Localization.Culture.DateTimeFormat.LongTimePattern; // установка имён столбцов списков для перевода формы colParamOrder.Name = "colParamOrder"; colParamName.Name = "colParamName"; colParamValue.Name = "colParamValue"; colParamDescr.Name = "colParamDescr"; 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"; // инициализация полей exeDir = ""; configDir = ""; langDir = ""; logDir = ""; kpDir = ""; cmdDir = ""; 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>(); lbLog1 = null; lbLog2 = null; logFileName1 = ""; logFileName2 = ""; logFileAge1 = DateTime.MinValue; logFileAge2 = DateTime.MinValue; fullLoad1 = false; fullLoad2 = false; }