Пример #1
0
        private void show_devTb()
        {
            this.m_ininit = true;
            DataGridViewColumn sortedColumn = this.dgvAllDevices.SortedColumn;

            this.dgvAllDevices.Rows.Clear();
            System.Collections.Generic.Dictionary <long, CommParaClass> deviceRackMapping = DeviceOperation.GetDeviceRackMapping();
            System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
            foreach (TreeNode treeNode in this.m_rootNode.Nodes)
            {
                string     text       = treeNode.Text;
                long       num        = System.Convert.ToInt64(treeNode.Name);
                bool       flag       = false;
                DeviceInfo deviceInfo = null;
                for (int i = 0; i < allDevice.Count; i++)
                {
                    deviceInfo = allDevice[i];
                    if ((long)deviceInfo.DeviceID == num)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    string    text2     = "";
                    IPAddress iPAddress = IPAddress.Parse(deviceInfo.DeviceIP);
                    if (deviceRackMapping.ContainsKey(num))
                    {
                        text2 = deviceRackMapping[num].String_First;
                    }
                    string text3 = this.tbFilterKey.Text;
                    if (text3.Length <= 0 || text.Contains(text3) || deviceInfo.Mac.Contains(text3) || iPAddress.ToString().Contains(text3) || deviceInfo.Port.ToString().Contains(text3) || deviceInfo.ModelNm.Contains(text3) || text2.Contains(text3))
                    {
                        object[] values;
                        if (ClientAPI.IsDeviceOnline(deviceInfo.DeviceID))
                        {
                            values = new object[]
                            {
                                this.imgon,
                                text,
                                deviceInfo.Mac,
                                iPAddress,
                                deviceInfo.Port,
                                deviceInfo.ModelNm,
                                text2,
                                num.ToString()
                            };
                        }
                        else
                        {
                            if (ClientAPI.IsMACConflict(deviceInfo.Mac))
                            {
                                values = new object[]
                                {
                                    this.imgConflict,
                                    text,
                                    deviceInfo.Mac,
                                    iPAddress,
                                    deviceInfo.Port,
                                    deviceInfo.ModelNm,
                                    text2,
                                    num.ToString()
                                };
                            }
                            else
                            {
                                values = new object[]
                                {
                                    this.imgoff,
                                    text,
                                    deviceInfo.Mac,
                                    iPAddress,
                                    deviceInfo.Port,
                                    deviceInfo.ModelNm,
                                    text2,
                                    num.ToString()
                                };
                            }
                        }
                        this.dgvAllDevices.Rows.Add(values);
                    }
                }
            }
            foreach (DataGridViewRow dataGridViewRow in (System.Collections.IEnumerable) this.dgvAllDevices.Rows)
            {
                DataGridViewCell dataGridViewCell = dataGridViewRow.Cells[0];
                if (dataGridViewCell.Value.Equals(this.imgConflict))
                {
                    dataGridViewCell.ToolTipText = EcoLanguage.getMsg(LangRes.tips_MACMismatch, new string[0]);
                }
            }
            if (sortedColumn != null)
            {
                ListSortDirection direction = (this.dgvAllDevices.SortOrder == SortOrder.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending;
                this.dgvAllDevices.Sort(sortedColumn, direction);
            }
            if (this.dgvAllDevices.Rows.Count == 0)
            {
                this.butDevicesDel.Enabled    = false;
                this.butDeviceSetup.Enabled   = false;
                this.butSyncThreshold.Enabled = false;
            }
            else
            {
                this.butDevicesDel.Enabled    = true;
                this.butDeviceSetup.Enabled   = true;
                this.butSyncThreshold.Enabled = true;
            }
            this.m_ininit = false;
        }