/// <summary> /// 将当前所选页的工站配置更新到界面上 /// </summary> void UpdateCurrPage(bool isReload, bool enabled = false) { if (null == _station) { return; } TabPage currTP = tabControlCF1.SelectedTab; if (null == currTP) { return; } TableLayoutPanel currPanel = currTP.Controls[0] as TableLayoutPanel; JFXCfg cfg = _station.Config; if (isReload) { string category = currTP.Text; currPanel.Controls.Clear(); string[] itemNames = cfg.ItemNamesInTag(category); if (null == itemNames) { return; } foreach (string itemName in itemNames) { UcJFParamEdit ucParam = new UcJFParamEdit(); ucParam.IsHelpVisible = false; ucParam.Height = 50; ucParam.Width = 600; //ucParam.SetParamDesribe(JFParamDescribe.Create(itemName, cfg.GetItemValue(itemName).GetType(), JFValueLimit.NonLimit, null)); ucParam.SetParamDesribe(_station.GetCfgParamDescribe(itemName)); currPanel.Controls.Add(ucParam); } } foreach (UcJFParamEdit ucParam in currPanel.Controls) { //object paramVal = _station.GetCfgParamValue(ucParam.GetParamDesribe().DisplayName); object paramVal = cfg.GetItemValue(ucParam.GetParamDesribe().DisplayName); ucParam.SetParamValue(paramVal); ucParam.IsValueReadOnly = !enabled; } }
void AdjustStationView() { if (InvokeRequired) { Invoke(new Action(AdjustStationView)); return; } tabControlCF1.TabPages.Clear(); isEditting = false; btEditSave.Text = "编辑"; btCancel.Enabled = false; if (null == _cfg) { lbInfo.Text = "无配置项!"; btEditSave.Enabled = false; return; } lbInfo.Text = "文件路径:" + _cfg.FilePath; string[] namedCategorys = _cfg.AllTags; //if(null == categorys || categorys.Length < 2) //只有一个无名称Tag,由于保存私有配置 //{ // lbInfo.Text += " 无定制化参数"; // btEditSave.Enabled = false; // return; //} List <string> categorys = new List <string>(); if (!AllowedShowUnnameTag) { if (null == categorys || categorys.Count < 2) //只有一个无名称Tag,由于保存私有配置 { lbInfo.Text += " 无定制化参数"; btEditSave.Enabled = false; return; } } else { categorys.Add(""); } if (namedCategorys != null) { categorys.AddRange(namedCategorys); } btEditSave.Enabled = true; foreach (string category in categorys) { if (string.IsNullOrEmpty(category)) { continue; } TabPage tp = new TabPage(category); tabControlCF1.TabPages.Add(tp); string[] itemNames = _cfg.ItemNamesInTag(category); if (null == itemNames) { continue; } TableLayoutPanel panel = new TableLayoutPanel(); //panel.RowStyles[0] = new RowStyle(SizeType.Absolute, 55); panel.RowStyles.Add(new RowStyle(SizeType.Absolute, 55)); panel.ColumnCount = 1; panel.AutoScroll = true; panel.Dock = DockStyle.Fill; tp.Controls.Add(panel); for (int i = 0; i < itemNames.Length; i++)//foreach (string itemName in itemNames) { string itemName = itemNames[i]; UcJFParamEdit ucParam = new UcJFParamEdit(); ucParam.IsHelpVisible = false; ucParam.Height = 50; ucParam.Width = 600;//panel.Width*2/3; //ucParam.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right ; //ucParam.SetParamType(_cfg.GetItemValue(itemName).GetType());//ucParam.SetParamDesribe(_station.GetCfgParamDescribe(itemName)); ucParam.SetParamDesribe(JFParamDescribe.Create(itemName, _cfg.GetItemValue(itemName).GetType(), JFValueLimit.NonLimit, null)); ucParam.SetParamValue(_cfg.GetItemValue(itemName)); ucParam.IsValueReadOnly = false; panel.Controls.Add(ucParam); ucParam.IsValueReadOnly = true; //panel.RowStyles[i].SizeType = SizeType.Absolute; //panel.RowStyles[i].Height = 55; } } //if (tabControlCF1.TabCount > 0) // tabControlCF1.SelectedIndex = 0; }
void AdjustStationView() { if (InvokeRequired) { Invoke(new Action(AdjustStationView)); return; } tabControlCF1.TabPages.Clear(); isEditting = false; btEditSave.Text = "编辑"; btCancel.Enabled = false; if (null == _station) { lbInfo.Text = "工站未设置!"; btEditSave.Enabled = false; return; } lbInfo.Text = "工站:" + _station.Name; JFXCfg cfg = _station.Config; string[] categorys = cfg.AllTags; if (null == categorys || categorys.Length < 2) //只有一个无名称Tag,由于保存私有配置 { lbInfo.Text += " 无定制化参数"; btEditSave.Enabled = false; return; } btEditSave.Enabled = true; foreach (string category in categorys) { if (string.IsNullOrEmpty(category)) { continue; } TabPage tp = new TabPage(category); tabControlCF1.TabPages.Add(tp); string[] itemNames = cfg.ItemNamesInTag(category); if (null == itemNames) { continue; } TableLayoutPanel panel = new TableLayoutPanel(); panel.ColumnCount = 1; panel.AutoScroll = true; panel.Dock = DockStyle.Fill; tp.Controls.Add(panel); foreach (string itemName in itemNames) { UcJFParamEdit ucParam = new UcJFParamEdit(); ucParam.IsHelpVisible = false; ucParam.Height = 23; ucParam.SetParamDesribe(_station.GetCfgParamDescribe(itemName)); ucParam.SetParamValue(_station.GetCfgParamValue(itemName)); ucParam.IsValueReadOnly = false; panel.Controls.Add(ucParam); ucParam.IsValueReadOnly = true; } } //if (tabControlCF1.TabCount > 0) // tabControlCF1.SelectedIndex = 0; }