private void TabAdd_Output(int nCpu, Win_ListView _ListView) { if (_ListView.Items.Count <= 0) { return; } TabPage _Page = new TabPage(); _Page.SuspendLayout(); _Page.Location = new System.Drawing.Point(4, 29); _Page.Padding = new System.Windows.Forms.Padding(3); _Page.TabIndex = nCpu; _Page.Text = string.Format("CPU#{0}", nCpu + 1); _Page.UseVisualStyleBackColor = true; _Page.Controls.Add(_ListView); _Page.ResumeLayout(false); Tab_Output.Controls.Owner.BackColor = Color.DimGray; Tab_Output.SuspendLayout(); Tab_Output.Controls.Add(_Page); Tab_Output.ResumeLayout(false); }
private void AddItems(Win_ListView _ListView, List <SRZ_IO> _IO_List) { for (int nIndex = 0; nIndex < _IO_List.Count; nIndex++) { if (SpareIO_Visable == false) { if (_IO_List[nIndex].IO_Name.IndexOf("SPARE") >= 0) { continue; } } ListViewItem list = null; list = _ListView.Items.Add(_IO_List[nIndex].IO_Name); list.SubItems.Add(_IO_List[nIndex].IO_Type.ToString()); if (_IO_List[nIndex].IO_Type == SRZ_IO_TYPE.DIO) { string _Val = _IO_List[nIndex].Value == 0 ? "OFF" : "ON"; list.SubItems.Add(_Val); } else { string _Val = _IO_List[nIndex].Value.ToString(); list.SubItems.Add(_Val); } } }
private void AddItems(Win_ListView _ListView, DNet_Module_Struct _Module) { for (int nIndex = 0; nIndex < _Module.IO_List.Count; nIndex++) { //테스트 // if (SpareIO_Visable == false) // { // if (_Module.IO_List[nIndex].IO_Name.IndexOf("SPARE") >= 0) // continue; // } ListViewItem list = null; if (_Module.IO_List[nIndex].IO_Name != "") { list = _ListView.Items.Add(_Module.IO_List[nIndex].IO_Name); } else { list = _ListView.Items.Add(string.Format("SPARE_{0:000}_{1:x04}_{2}" , _Module.IO_List[nIndex].Address , _Module.IO_List[nIndex].SubAddr , _Module.IO_List[nIndex].IO_Type)); } list.SubItems.Add(_Module.IO_List[nIndex].Address.ToString()); if (_Module.IO_Type == DNET_IO_TYPE.D_INPUT || _Module.IO_Type == DNET_IO_TYPE.D_OUTPUT) { list.SubItems.Add(string.Format("0x{0:x04}", _Module.IO_List[nIndex].SubAddr)); if (_Module.IO_List[nIndex].IsOn.Equals(true)) { list.SubItems.Add("ON"); } else { list.SubItems.Add("OFF"); } } else { list.SubItems.Add(_Module.IO_List[nIndex].SubAddr.ToString()); list.SubItems.Add(_Module.IO_List[nIndex].AnalogValue.ToString()); } list.SubItems.Add(_Module.IO_List[nIndex].Cable); list.SubItems.Add(_Module.IO_List[nIndex].IO_Type.ToString()); } }
private void TabAdd_Input(int nAdapter, Win_ListView _ListView) { if (_ListView.Items.Count <= 0) { return; } TabPage _Page = new TabPage(); _Page.SuspendLayout(); _Page.Location = new System.Drawing.Point(4, 29); _Page.Padding = new System.Windows.Forms.Padding(3); _Page.TabIndex = nAdapter; if (strTabNames == null) { _Page.Text = string.Format("#{0}", nAdapter + 1); } else { if (strTabNames.Length > nAdapter) { _Page.Text = strTabNames[nAdapter]; } else { _Page.Text = string.Format("#{0}", nAdapter + 1); } } _Page.UseVisualStyleBackColor = false; //_Page.BackColor = Color.DimGray; //_Page.ForeColor = Color.White; _Page.Controls.Add(_ListView); _Page.ResumeLayout(false); Tab_Input.Controls.Owner.BackColor = Color.DarkGray; Tab_Input.SuspendLayout(); Tab_Input.Controls.Add(_Page); Tab_Input.ResumeLayout(false); }
private void Init_List() { for (int nAdapter = 0; nAdapter < m_DNet_IoList.DNet_Adapter.Count; nAdapter++) { Win_ListView _Input_ListView = MakeListView(nAdapter); Win_ListView _Output_ListView = MakeListView(nAdapter); for (int nModule = 0; nModule < m_DNet_IoList.DNet_Adapter[nAdapter].Module_List.Count; nModule++) { if (m_DNet_IoList.DNet_Adapter[nAdapter].Module_List[nModule].IO_Type == DNET_IO_TYPE.D_INPUT || m_DNet_IoList.DNet_Adapter[nAdapter].Module_List[nModule].IO_Type == DNET_IO_TYPE.A_INPUT) { AddItems(_Input_ListView, m_DNet_IoList.DNet_Adapter[nAdapter].Module_List[nModule]); } else { AddItems(_Output_ListView, m_DNet_IoList.DNet_Adapter[nAdapter].Module_List[nModule]); } } TabAdd_Input(nAdapter, _Input_ListView); TabAdd_Output(nAdapter, _Output_ListView); } }
private void Init_List() { for (int nCpu = 0; nCpu < m_SRZ_IoList.SRZ_Cpu.Count; nCpu++) { Win_ListView _Input_ListView = MakeListView(nCpu, false); Win_ListView _Output_ListView = MakeListView(nCpu, true); // INPUT for (int nModule = 0; nModule < m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List.Count; nModule++) { if (m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List[nModule].IO_Type == SRZ_IO_TYPE.TIO_8888 || m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List[nModule].IO_Type == SRZ_IO_TYPE.TIO_VVVV) { AddItems(_Input_ListView, m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List[nModule].Read_Value); } } for (int nModule = 0; nModule < m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List.Count; nModule++) { if (m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List[nModule].IO_Type == SRZ_IO_TYPE.TIO_8888) { AddItems(_Input_ListView, m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List[nModule].Read_Out_Value); } } for (int nModule = 0; nModule < m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List.Count; nModule++) { if (m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List[nModule].IO_Type == SRZ_IO_TYPE.DIO) { AddItems(_Input_ListView, m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List[nModule].Read_Value); } } // OUTPUT for (int nModule = 0; nModule < m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List.Count; nModule++) { AddItems(_Output_ListView, m_SRZ_IoList.SRZ_Cpu[nCpu].Module_List[nModule].Set_Value); } TabAdd_Input(nCpu, _Input_ListView); TabAdd_Output(nCpu, _Output_ListView); } }
private Win_ListView MakeListView(int nAdapter, bool bDobuleClick) { Win_ListView _ListView = new Win_ListView(); _ListView.SuspendLayout(); ImageList dumImgList = new ImageList(); dumImgList.ImageSize = new System.Drawing.Size(1, 20); //리스트 뷰 라인 간격 조절용 _ListView.SmallImageList = dumImgList; //컬럼 만들기. System.Windows.Forms.ColumnHeader _Column1 = new System.Windows.Forms.ColumnHeader(); _Column1.Text = "Name"; _Column1.Width = 300; System.Windows.Forms.ColumnHeader _Column2 = new System.Windows.Forms.ColumnHeader(); _Column2.Text = "Type"; _Column2.Width = 100; System.Windows.Forms.ColumnHeader _Column3 = new System.Windows.Forms.ColumnHeader(); _Column3.Text = "Value"; _Column3.Width = 80; _ListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { _Column1, _Column2, _Column3 }); _ListView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; _ListView.Dock = System.Windows.Forms.DockStyle.Fill; _ListView.Font = new System.Drawing.Font("굴림체", 9F); _ListView.FullRowSelect = true; _ListView.GridLines = true; _ListView.OwnerDraw = true; _ListView.Location = new System.Drawing.Point(3, 3); _ListView.UseCompatibleStateImageBehavior = false; _ListView.View = System.Windows.Forms.View.Details; _ListView.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.ListView_DrawColumnHeader); _ListView.DrawSubItem += new System.Windows.Forms.DrawListViewSubItemEventHandler(this.ListView_DrawSubItem); if (bDobuleClick == true) { _ListView.DoubleClick += new System.EventHandler(this.ListView_Output_DoubleClick); } _ListView.ResumeLayout(false); return(_ListView); }
private void Refresh_IO_List(int nTabIndex, TabPage _Page) { if (nTabIndex < 0 || _Page == null) { return; } string strIO_Name = ""; string strIO_Type = ""; foreach (Control ctrl in _Page.Controls) { if (ctrl.GetType().Name == "Win_ListView") { Win_ListView listView = ctrl as Win_ListView; if (listView != null) { foreach (ListViewItem list in listView.Items) { strIO_Name = list.SubItems[0].Text; strIO_Type = list.SubItems[1].Text; SRZ_IO _IO = null; if (strIO_Type == SRZ_IO_TYPE.TIO_8888.ToString()) { _IO = m_SRZ_IoList.GetLinkData(strIO_Name, nTabIndex, SRZ_IO_TYPE.TIO_8888); } else if (strIO_Type == SRZ_IO_TYPE.TIO_VVVV.ToString()) { _IO = m_SRZ_IoList.GetLinkData(strIO_Name, nTabIndex, SRZ_IO_TYPE.TIO_VVVV); } else if (strIO_Type == SRZ_IO_TYPE.DIO.ToString()) { _IO = m_SRZ_IoList.GetLinkData(strIO_Name, nTabIndex, SRZ_IO_TYPE.DIO); } if (_IO != null) { if (_IO.IO_Type == SRZ_IO_TYPE.DIO) { string strVal = _IO.Value == 0 ? "OFF" : "ON"; if (strVal != list.SubItems[2].Text) { list.SubItems[2].Text = strVal; } } else { string strVal = _IO.Value.ToString(); if (strVal != list.SubItems[2].Text) { list.SubItems[2].Text = strVal; } } } } } } } }
private Win_ListView MakeListView(int nAdapter) { Win_ListView _ListView = new Win_ListView(); _ListView.SuspendLayout(); ImageList dumImgList = new ImageList(); dumImgList.ImageSize = new System.Drawing.Size(1, 30); //리스트 뷰 라인 간격 조절용 _ListView.SmallImageList = dumImgList; //컬럼 만들기. // System.Windows.Forms.ColumnHeader _Column1 = new System.Windows.Forms.ColumnHeader(); // _Column1.Text = "Name"; _Column1.Width = 230; // System.Windows.Forms.ColumnHeader _Column2 = new System.Windows.Forms.ColumnHeader(); // _Column2.Text = "Addr"; _Column2.Width = 50; // System.Windows.Forms.ColumnHeader _Column3 = new System.Windows.Forms.ColumnHeader(); // _Column3.Text = "SubAddr"; _Column3.Width = 60; // System.Windows.Forms.ColumnHeader _Column4 = new System.Windows.Forms.ColumnHeader(); // _Column4.Text = "Val"; _Column4.Width = 80; // System.Windows.Forms.ColumnHeader _Column5 = new System.Windows.Forms.ColumnHeader(); // _Column5.Text = "Cable"; _Column5.Width = 0;// 70; // System.Windows.Forms.ColumnHeader _Column6 = new System.Windows.Forms.ColumnHeader(); // _Column6.Text = "Type"; _Column6.Width = 0; System.Windows.Forms.ColumnHeader _Column1 = new System.Windows.Forms.ColumnHeader(); _Column1.Text = "Name"; _Column1.Width = 290; System.Windows.Forms.ColumnHeader _Column2 = new System.Windows.Forms.ColumnHeader(); _Column2.Text = "Addr"; _Column2.Width = 80; System.Windows.Forms.ColumnHeader _Column3 = new System.Windows.Forms.ColumnHeader(); _Column3.Text = "SubAddr"; _Column3.Width = 80; System.Windows.Forms.ColumnHeader _Column4 = new System.Windows.Forms.ColumnHeader(); _Column4.Text = "Val"; _Column4.Width = 80; System.Windows.Forms.ColumnHeader _Column5 = new System.Windows.Forms.ColumnHeader(); _Column5.Text = "Cable"; _Column5.Width = 0;// 70; System.Windows.Forms.ColumnHeader _Column6 = new System.Windows.Forms.ColumnHeader(); _Column6.Text = "Type"; _Column6.Width = 0; _Column1.TextAlign = HorizontalAlignment.Center; _Column2.TextAlign = HorizontalAlignment.Center; _Column3.TextAlign = HorizontalAlignment.Center; _Column4.TextAlign = HorizontalAlignment.Center; _Column5.TextAlign = HorizontalAlignment.Center; _Column6.TextAlign = HorizontalAlignment.Center; _ListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { _Column1, _Column2, _Column3, _Column4, _Column5, _Column6 }); _ListView.BorderStyle = System.Windows.Forms.BorderStyle.None; _ListView.Dock = System.Windows.Forms.DockStyle.Fill; //_ListView.Font = new System.Drawing.Font("굴림체", 9F); _ListView.Font = new System.Drawing.Font("고딕", 9F); // _ListView.BackColor = Color.DimGray; // _ListView.BackColor = Color.FromArgb(50,50,50); _ListView.ForeColor = Color.Black; _ListView.FullRowSelect = true; _ListView.GridLines = false; _ListView.OwnerDraw = true; _ListView.Location = new System.Drawing.Point(3, 3); _ListView.UseCompatibleStateImageBehavior = false; _ListView.View = System.Windows.Forms.View.Details; _ListView.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.ListView_DrawColumnHeader); _ListView.DrawSubItem += new System.Windows.Forms.DrawListViewSubItemEventHandler(this.ListView_DrawSubItem); _ListView.DoubleClick += new System.EventHandler(this.ListView_Output_DoubleClick); _ListView.ResumeLayout(false); return(_ListView); }
private void Refresh_IO_List(int nTabIndex, TabPage _Page) { if (nTabIndex < 0 || _Page == null) { return; } string strIO_Name = ""; string strIO_Type = ""; int nOutputTab = 0; foreach (Control ctrl in _Page.Controls) { if (ctrl.GetType().Name == "Win_ListView") { Win_ListView listView = ctrl as Win_ListView; if (listView != null) { foreach (ListViewItem list in listView.Items) { strIO_Name = list.SubItems[0].Text; strIO_Type = list.SubItems[5].Text; DeviceNetIO _IO = null; if (strIO_Type == DNET_IO_TYPE.D_INPUT.ToString()) { _IO = m_DNet_IoList.GetLinkData(strIO_Name, nTabIndex, DNET_IO_TYPE.D_INPUT); } else if (strIO_Type == DNET_IO_TYPE.D_OUTPUT.ToString()) { //if (nTabIndex == 1) nTabIndex = 2; //OUTPUT일 경우 TAB 2번이 없기 때문에 1번탭 이후1씩증가 if (nTabIndex >= 1) { nOutputTab = nTabIndex + 1; } _IO = m_DNet_IoList.GetLinkData(strIO_Name, nOutputTab, DNET_IO_TYPE.D_OUTPUT); } else if (strIO_Type == DNET_IO_TYPE.A_INPUT.ToString()) { _IO = m_DNet_IoList.GetLinkData(strIO_Name, nTabIndex, DNET_IO_TYPE.A_INPUT); } if (_IO != null) { if (_IO.IO_Type == DNET_IO_TYPE.D_INPUT || _IO.IO_Type == DNET_IO_TYPE.D_OUTPUT) { string strOnOff = _IO.IsOn == true ? "ON" : "OFF"; if (strOnOff != list.SubItems[3].Text) { list.SubItems[3].Text = strOnOff; } } else { list.SubItems[3].Text = _IO.AnalogValue.ToString(); } } } } } } }