Inheritance: System.Windows.Forms.DataGridViewCell, IDataGridViewEditingCell
		public void Defaults ()
		{
			DataGridViewCheckBoxCell cell = new DataGridViewCheckBoxCell ();

			Assert.AreEqual (null, cell.EditedFormattedValue, "A1");
			Assert.AreEqual (false, cell.EditingCellValueChanged, "A2");
			Assert.AreEqual (null, cell.EditType, "A3");
			Assert.AreEqual (null, cell.FalseValue, "A4");
			Assert.AreEqual (typeof (bool), cell.FormattedValueType, "A5");
			Assert.AreEqual (null, cell.IndeterminateValue, "A6");
			Assert.AreEqual (false, cell.ThreeState, "A7");
			Assert.AreEqual (null, cell.TrueValue, "A8");
			Assert.AreEqual (typeof (bool), cell.ValueType, "A9");

			Assert.AreEqual ("DataGridViewCheckBoxCell { ColumnIndex=-1, RowIndex=-1 }", cell.ToString (), "A10");
			
			cell.ThreeState = true;

			Assert.AreEqual (null, cell.EditedFormattedValue, "A11");
			Assert.AreEqual (false, cell.EditingCellValueChanged, "A12");
			Assert.AreEqual (null, cell.EditType, "A13");
			Assert.AreEqual (null, cell.FalseValue, "A14");
			Assert.AreEqual (typeof (CheckState), cell.FormattedValueType, "A15");
			Assert.AreEqual (null, cell.IndeterminateValue, "A16");
			Assert.AreEqual (true, cell.ThreeState, "A17");
			Assert.AreEqual (null, cell.TrueValue, "A18");
			Assert.AreEqual (typeof (CheckState), cell.ValueType, "A19");
		}
Example #2
0
        void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                System.Windows.Forms.DataGridViewCheckBoxCell chk = ((System.Windows.Forms.DataGridViewCheckBoxCell)(dataGridView3.Rows[e.RowIndex].Cells["CHECK"]));

                if (((System.Windows.Forms.DataGridViewCell)(chk)).State == DataGridViewElementStates.None || ((System.Windows.Forms.DataGridViewCell)(chk)).State == DataGridViewElementStates.Selected)
                {
                    dataGridView3.Rows[e.RowIndex].Cells["CHECK"].Value = dataGridView3.Rows[e.RowIndex].Cells["CHECK"].Value.ToString().Equals("true") ? "false" : "true";
                    (dataGridView3.DataSource as DataTable).AcceptChanges();
                    dataGridView3.Rows[e.RowIndex].Selected = true;
                }

                if (dataGridView3.Rows[e.RowIndex].Cells["CHECK"].Value.Equals("true"))
                {
                    //if ((dataGridView1.DataSource as DataTable).Rows.Count <= 0)
                    //{
                    //    return;
                    //}

                    //DataGridViewRow dgr = dataGridView1.CurrentRow;
                    //string ybid = dgr.Cells["id"].Value.ToString();
                    //string valideSql = string.Format("select * from jc_gf_blmx where xmid='{1}' and xmly='{2}' and ybbl_id<>'{0}' and del_bit=0", ybid, xmid, xmly);

                    //DataTable dtValid = FrmMdiMain.Database.GetDataTable(valideSql);
                    //int iNumCount = int.Parse(dtValid.Rows[0]["NUM"].ToString());
                    //if (iNumCount > 0)
                    //{

                    //}
                }
            }
            catch { }
        }
Example #3
0
        private void dtgComandos_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && e.RowIndex == -1)
            {
                chkTodos.Checked = !chkTodos.Checked;
                chkTodos_Click(chkTodos, null);
            }
            else if (e.ColumnIndex == 0 && e.RowIndex > -1)
            {
                DataGridViewCheckBoxCell ch1 = new DataGridViewCheckBoxCell();
                ch1 = (DataGridViewCheckBoxCell)dtgComandos.Rows[dtgComandos.CurrentRow.Index].Cells[0];

                if (ch1.Value == null)
                    ch1.Value = false;

                switch (ch1.Value.ToString())
                {
                    case "True":
                        ch1.Value = false;
                        break;
                    case "False":
                        ch1.Value = true;
                        break;
                }

                chkTodos.CheckState = StatusComandos();
            }
        }
Example #4
0
        public override void LoadDetail()
        {
            lblTableName.Text = "";
            //lblTableDBDesc.Text = "";//db_desc
            //lblTableLocalDesc.Text = "";//local_desc
            txtTableNewDesc.Text = "";//new_desc
            dgvSchema.Rows.Clear();

            this.node = App.Instance.SelectedNode;
            this.view = App.Instance.SelectedNode.Tag as IViewInfo;

            if (this.view != null)
            {
                lblTableName.Text = this.view.RawName;
                //lblTableDBDesc.Text = this.view.Description;//db_desc
                //lblTableLocalDesc.Text = this.view.Attributes.ContainsKey("local_desc") ? this.view.Attributes["local_desc"] : "";//local_desc
                //txtTableNewDesc.Text = this.view.Attributes.ContainsKey("new_desc") ? this.view.Attributes["new_desc"] : "";//new_desc
                txtTableNewDesc.Text = this.view["local_desc"] ?? "";//local_desc

                //foreach (var item in this.view.Columns)
                //{
                //    int index = dgvSchema.Rows.Add();
                //    DataGridViewRow row = dgvSchema.Rows[index];
                //    //row.Tag = item.IsPrimaryKey;
                //    row.Cells[0].Value = item.RawName;
                //    row.Cells[1].Value = SQLHelper.GetFullSqlType(item);
                //    row.Cells[2].Value = item.Nullable ? true : false;
                //    //row.Cells[3].Value = item.Description;
                //    //row.Cells[4].Value = item.Attributes.ContainsKey("local_desc") ? item.Attributes["local_desc"] : "";
                //    //row.Cells[5].Value = item.Attributes.ContainsKey("new_desc") ? item.Attributes["new_desc"] : "";
                //    row.Cells[3].Value = item["local_desc"] ?? "";
                //}

                List<DataGridViewRow> rlist = new List<DataGridViewRow>();
                foreach (var item in this.view.Columns)
                {
                    DataGridViewTextBoxCell col1 = new DataGridViewTextBoxCell();
                    col1.Value = item.RawName;

                    DataGridViewTextBoxCell col2 = new DataGridViewTextBoxCell();
                    col2.Value = SQLHelper.GetFullSqlType(item);

                    DataGridViewCheckBoxCell col3 = new DataGridViewCheckBoxCell();
                    col3.Value = item.Nullable ? true : false;

                    DataGridViewTextBoxCell col4 = new DataGridViewTextBoxCell();
                    col4.Value = item["local_desc"] ?? "";

                    DataGridViewTextBoxCell col5 = new DataGridViewTextBoxCell();

                    DataGridViewRow row = new DataGridViewRow();
                    row.Cells.AddRange(new DataGridViewCell[] { col1, col2, col3, col4, col5 });
                    rlist.Add(row);
                }

                dgvSchema.Rows.AddRange(rlist.ToArray());
            }
        }
		public void Value ()
		{
			DataGridViewCheckBoxCell tbc = new DataGridViewCheckBoxCell ();
			Assert.IsNull (tbc.Value, "#1");
			tbc.Value = string.Empty;
			Assert.AreEqual (string.Empty, tbc.Value, "#2");
			tbc.Value = 5;
			Assert.AreEqual (5, tbc.Value, "#3");
			tbc.Value = null;
			Assert.IsNull (tbc.Value, "#4");
		}
Example #6
0
 private void AddGenerationParameterAsCheckBox(String g, bool v)
 {
     DataGridViewRow r = new DataGridViewRow();
     DataGridViewCell rColumn1 = new DataGridViewTextBoxCell();
     DataGridViewCell rColumn2 = new DataGridViewCheckBoxCell();
     rColumn1.Value = g;
     rColumn2.Value = v;
     r.Cells.Add(rColumn1);
     r.Cells.Add(rColumn2);
     generationParametersTable.Rows.Add(r);
 }
Example #7
0
        //Fire check checkbox event
        private void Chk_Click(object sender, DataGridViewCellEventArgs e)
        {
            if (I_Table.Columns[e.ColumnIndex].Name == "Chk")
            {
                DataGridViewCheckBoxCell chk = new DataGridViewCheckBoxCell();

                chk = (DataGridViewCheckBoxCell)I_Table.Rows[I_Table.CurrentRow.Index].Cells["Chk"];

                chk.Value = !(bool)chk.Value;
            }
        }
        public void CheckBoxTest()
        {
            SWF.DataGridViewCheckBoxColumn column = new SWF.DataGridViewCheckBoxColumn();
            column.HeaderText = "CheckBox Column";

            SWF.DataGridViewCheckBoxCell cell = new SWF.DataGridViewCheckBoxCell();
            cell.Value = false;

            SWF.DataGridViewCheckBoxCell cell1 = new SWF.DataGridViewCheckBoxCell();
            cell1.Value = false;

            ColumnCellTest(column, cell, false, cell1);
        }
        public void addRow(DataGridView view, FileDirectory fd, string config)
        {
            DirectoryDataGridViewRow directoryDataGridViewRow = new DirectoryDataGridViewRow(fd);

            string text = DirectoryHandler.getInstance().getPathFromParent(fd, fd.getPath());
            DirectoryDataGridViewTextBoxCell directories = new DirectoryDataGridViewTextBoxCell(text);
            DataGridViewComboBoxCell commands = new DataGridViewComboBoxCell();
            DataGridViewCheckBoxCell include = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell echo = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell display = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell autoExit = new DataGridViewCheckBoxCell();
            DataGridViewCheckBoxCell waitForExit = new DataGridViewCheckBoxCell();
            if (text.Length > 50)
            {
                int i = text.Length;
                int num = 20;
                while (i > 50)
                {
                    i--;
                    num++;
                }
                text = text.Substring(0, 5) + "....." + text.Substring(num);
            }
            directories.Value = text;

            foreach(Command c in PreloadedConfigurationGetterService.getInstance().getCommandsFromXMLConfiguration(config)){
                commands.Items.Add(c.getName());
            }
            if(commands.Items.Count == 0) return;
            commands.Value = commands.Items[0];

            include.Value = true;
            echo.Value = true;
            display.Value = true;
            autoExit.Value = true;
            waitForExit.Value = true;
            directoryDataGridViewRow.Cells.Add(directories);
            directoryDataGridViewRow.Cells.Add(commands);
            directoryDataGridViewRow.Cells.Add(include);
            directoryDataGridViewRow.Cells.Add(display);
            directoryDataGridViewRow.Cells.Add(autoExit);
            directoryDataGridViewRow.Cells.Add(waitForExit);

            directories.ReadOnly = true;
            commands.ReadOnly = false;
            include.ReadOnly = false;
            echo.ReadOnly = false;
            display.ReadOnly = false;
            autoExit.ReadOnly = false;
            view.Rows.Add(directoryDataGridViewRow);
        }
Example #10
0
        void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                System.Windows.Forms.DataGridViewCheckBoxCell chk = ((System.Windows.Forms.DataGridViewCheckBoxCell)(dataGridView2.Rows[e.RowIndex].Cells["ISCHECK"]));

                if (((System.Windows.Forms.DataGridViewCell)(chk)).State == DataGridViewElementStates.None || ((System.Windows.Forms.DataGridViewCell)(chk)).State == DataGridViewElementStates.Selected)
                {
                    dataGridView2.Rows[e.RowIndex].Cells["ISCHECK"].Value = dataGridView2.Rows[e.RowIndex].Cells["ISCHECK"].Value.ToString().Equals("true") ? "false" : "true";
                    (dataGridView2.DataSource as DataTable).AcceptChanges();
                    dataGridView2.Rows[e.RowIndex].Selected = true;
                }
            }
            catch { }
        }
Example #11
0
        private void UpdateDisplay()
        {
            IVIHandler.Reset();
            IviHandler = IVIHandler.Instance;
            IviHandler.IviConfigStore.Deserialize(IviHandler.IviConfigStore.MasterLocation);

            AdapterConfigList.Rows.Clear();
            foreach (IIviSoftwareModule2 SoftwareModule in IviHandler.IviConfigStore.SoftwareModules)
            {
                if (!SoftwareModule.Name.StartsWith("nis"))
                {
                    DataGridViewRow Row = new DataGridViewRow();
                    DataGridViewCheckBoxCell UpdateCheckBox = new DataGridViewCheckBoxCell();
                    DataGridViewTextBoxCell SoftwareModuleTextBox = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell CurrentAdapterClassTextBox = new DataGridViewTextBoxCell();
                    DataGridViewComboBoxCell NewAdapterClassComboBox = new DataGridViewComboBoxCell();

                    UpdateCheckBox.Value = false;
                    SoftwareModuleTextBox.Value = SoftwareModule.Name;
                    string className = SoftwareModule.AssemblyQualifiedClassName;

                    if (!className.Equals(string.Empty))
                    {
                        Type type = Type.GetType(SoftwareModule.AssemblyQualifiedClassName);
                        if (type != null)
                        {
                            CurrentAdapterClassTextBox.Value = type.Name;
                        }
                    }

                    NewAdapterClassComboBox.Items.Add(string.Empty);
                    NewAdapterClassComboBox.Items.AddRange(IviCAdapterList);
                    NewAdapterClassComboBox.Value = NewAdapterClassComboBox.Items[0];

                    Row.Cells.Add(UpdateCheckBox);
                    Row.Cells.Add(SoftwareModuleTextBox);
                    Row.Cells.Add(CurrentAdapterClassTextBox);
                    Row.Cells.Add(NewAdapterClassComboBox);

                    AdapterConfigList.Rows.Add(Row);
                }
            }
        }
Example #12
0
        void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                System.Windows.Forms.DataGridViewCheckBoxCell chk = ((System.Windows.Forms.DataGridViewCheckBoxCell)(dataGridView3.Rows[e.RowIndex].Cells["IS_CHECK_Y"]));
                ////是否点击CheckBox
                //if ((Convert.ToBoolean(chk.EditedFormattedValue) == true && Convert.ToBoolean(chk.FormattedValue) == false) || (Convert.ToBoolean(chk.EditedFormattedValue) == false && Convert.ToBoolean(chk.FormattedValue) == false))
                //    return;

                if (((System.Windows.Forms.DataGridViewCell)(chk)).State == DataGridViewElementStates.None)
                {
                    dataGridView3.Rows[e.RowIndex].Cells["IS_CHECK_Y"].Value = dataGridView3.Rows[e.RowIndex].Cells["IS_CHECK_Y"].Value.ToString().Equals("0") ? "1" : "0";
                    //dataGridView2.Rows[e.RowIndex].Cells["IS_CHECK"].Value = dataGridView2.Rows[e.RowIndex].Cells["IS_CHECK"].Value.ToString().Equals("0") ? "1" : "0";
                    (dataGridView3.DataSource as DataTable).AcceptChanges();
                    dataGridView3.Rows[e.RowIndex].Selected = true;
                }
            }
            catch { }
        }
        private void FreshDG()
        {
            DG_In.Rows.Clear();
            DG_Out.Rows.Clear();
            dataset.Clear();
            dataset = ServiceContainer.GetService<IGasDAL>().QueryData("EquipName", "EquipTypeSlet");
            equipTypeNum = dataset.Tables[0].Rows.Count;
            int j = 0;
            foreach (DataRow dr in dataset.Tables[0].Rows)
            {

                DataGridViewRow row = new DataGridViewRow();
                DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
                textboxcell.Value = dataset.Tables[0].Rows[j][0];
                row.Cells.Add(textboxcell);
                DataGridViewCheckBoxCell checkcell = new DataGridViewCheckBoxCell();
                checkcell.Value = false;
                row.Cells.Add(checkcell);
                DataGridViewTextBoxCell txtboxcell = new DataGridViewTextBoxCell();
                row.Cells.Add(txtboxcell);
                DG_In.Rows.Add(row);

                DataGridViewRow row2 = new DataGridViewRow();
                DataGridViewTextBoxCell textboxcell2 = new DataGridViewTextBoxCell();
                textboxcell2.Value = dataset.Tables[0].Rows[j][0];
                row2.Cells.Add(textboxcell2);
                DataGridViewCheckBoxCell checkcell2 = new DataGridViewCheckBoxCell();
                checkcell2.Value = false;
                row2.Cells.Add(checkcell2);
                DataGridViewTextBoxCell txtboxcell2 = new DataGridViewTextBoxCell();
                row2.Cells.Add(txtboxcell2);
                DG_Out.Rows.Add(row2);

                //DataGridViewRow row = new DataGridViewRow();
                //row.Cells["设备名称"].Value = dataset.Tables[0].Rows[j][0];//设置row属性
                //DG_In.Rows.Add(row);
                //DG_Out.Rows.Add(row);
                //DG_In.Rows[j].Cells[0].Value = dataset.Tables[0].Rows[j][0];
                //DG_Out.Rows[j].Cells[0].Value = dataset.Tables[0].Rows[j][0];
                j++;
            }
        }
 public override object Clone()
 {
     DataGridViewCheckBoxCell cell;
     System.Type type = base.GetType();
     if (type == cellType)
     {
         cell = new DataGridViewCheckBoxCell();
     }
     else
     {
         cell = (DataGridViewCheckBoxCell) Activator.CreateInstance(type);
     }
     base.CloneInternal(cell);
     cell.ThreeStateInternal = this.ThreeState;
     cell.TrueValueInternal = this.TrueValue;
     cell.FalseValueInternal = this.FalseValue;
     cell.IndeterminateValueInternal = this.IndeterminateValue;
     cell.FlatStyleInternal = this.FlatStyle;
     return cell;
 }
        DataGridViewCell CreateCellTemplate(System.Reflection.FieldInfo Info)
        {
            DataGridViewCell Cell = new DataGridViewTextBoxCell();
            Type FieldType = Info.FieldType;
            if (FieldType == typeof(bool))
            {
                Cell = new DataGridViewCheckBoxCell();
            }
            //else if (FieldType == typeof(Enum))
            //{
            //    Cell = new DataGridViewTextBoxCell();
            //}
            //else if (   FieldType == typeof(int) || FieldType == typeof(float) || FieldType == typeof(uint) || FieldType == typeof(short) ||
            //            FieldType == typeof(ushort) || FieldType == typeof(byte) || FieldType == typeof(float))
            //{
            //    Cell = new Datagridview
            //}

            return Cell;
        }
        /*============PrivateFunction=======*/

        private void BindGrid()
        {
            dgvChapterList.AutoGenerateColumns = false;

            DataGridViewCell indexCell = new DataGridViewTextBoxCell();
            DataGridViewCell chapterTitleCell = new DataGridViewTextBoxCell();
            DataGridViewCheckBoxCell hasReadCell = new DataGridViewCheckBoxCell();

            DataGridViewTextBoxColumn indexColumn = new DataGridViewTextBoxColumn()
            {
                CellTemplate = indexCell,
                Name = "Index",
                HeaderText = "Index",
                DataPropertyName = "Index",
                Width = 75
            };

            DataGridViewTextBoxColumn titleColumn = new DataGridViewTextBoxColumn()
            {
                CellTemplate = indexCell,
                Name = "ChapterTitle",
                HeaderText = "Chapter Title",
                DataPropertyName = "ChapterTitle",
                Width = 200
            };

            DataGridViewCheckBoxColumn makeAudioColumn = new DataGridViewCheckBoxColumn()
            {
                CellTemplate = hasReadCell,
                Name = "Read",
                HeaderText = "Read",
                DataPropertyName = "Read",
                Width = 75,
            };

            dgvChapterList.Columns.Add(titleColumn);
            dgvChapterList.Columns.Add(indexColumn);
            dgvChapterList.Columns.Add(makeAudioColumn);
        }
        private void CarregaGridViewParametros()
        {
            dgParametros.Rows.Clear();
            foreach (var param in _parametros)
            {
                var row = new DataGridViewRow();

                var nome = new DataGridViewTextBoxCell { Value = param.ParameterName };
                var valor = new DataGridViewMaskedTextCell { Value = param.ParameterValue };
                var defineNull = new DataGridViewCheckBoxCell { Value = param.DefineNull };
                var lista = new DataGridViewComboBoxCell { DataSource = _tiposDadosParametros, DisplayMember = "Key", ValueMember = "Value", Value = "System.Object|" };
                row.Cells.Add(nome);
                row.Cells.Add(defineNull);
                row.Cells.Add(lista);
                row.Cells.Add(valor);

                dgParametros.Rows.Add(row);
            }
        }
        /*============PrivateFunction=======*/

        private void BindGrid()
        {
            dgvNovelList.AutoGenerateColumns = false;

            DataGridViewCell novelTitleCell = new DataGridViewTextBoxCell();
            DataGridViewCell rankingCell = new DataGridViewTextBoxCell();
            DataGridViewCell chapterCountCell = new DataGridViewTextBoxCell();
            DataGridViewCell newChapterCountCell = new DataGridViewTextBoxCell();
            DataGridViewCheckBoxCell makeAudioCell = new DataGridViewCheckBoxCell();
            UpdateDataGridViewProgressCell updateProgressCell = new UpdateDataGridViewProgressCell();

            DataGridViewTextBoxColumn novelTitleColumn = new DataGridViewTextBoxColumn()
            {
                CellTemplate = novelTitleCell,
                Name = "NovelTitle",
                HeaderText = "Novel Title",
                DataPropertyName = "NovelTitle",
                Width = 200,
                ReadOnly = true
            };

            DataGridViewTextBoxColumn rankingColumn = new DataGridViewTextBoxColumn()
            {
                CellTemplate = rankingCell,
                Name = "Rank",
                HeaderText = "Rank",
                DataPropertyName = "Rank",
                Width = 100,
                ReadOnly = true
            };

            DataGridViewTextBoxColumn chapterCountColumn = new DataGridViewTextBoxColumn()
            {
                CellTemplate = chapterCountCell,
                Name = "ChapterCount",
                HeaderText = "Chapter Count",
                DataPropertyName = "ChapterCount",
                Width = 150,
                ReadOnly = true
            };

            DataGridViewTextBoxColumn newChapterCountColumn = new DataGridViewTextBoxColumn()
            {
                CellTemplate = newChapterCountCell,
                Name = "NewChapterCount",
                HeaderText = "New Chapter Count",
                DataPropertyName = "NewChapterCount",
                Width = 150,
                ReadOnly = true
            };

            DataGridViewComboBoxColumn stateColumn = new DataGridViewComboBoxColumn()
            {
                Name = "State",
                HeaderText = "State",
                DataPropertyName = "State",
                DataSource = Enum.GetValues(typeof(Novel.NovelState)),
                ValueType = typeof(Novel.NovelState),
                Width = 100
            };

            DataGridViewCheckBoxColumn makeAudioColumn = new DataGridViewCheckBoxColumn()
            {
                CellTemplate = makeAudioCell,
                Name = "MakeAudio",
                HeaderText = "Make Audio",
                DataPropertyName = "MakeAudio",
                Width = 100,
            };

            UpdateDataGridViewProgressColumn updateProgressColumn = new UpdateDataGridViewProgressColumn()
            {
                CellTemplate = updateProgressCell,
                Name = "UpdateProgress",
                HeaderText = "Update Progress",
                DataPropertyName = "UpdateProgress",
                Width = 100,
            };
            
            dgvNovelList.Columns.Add(novelTitleColumn);
            dgvNovelList.Columns.Add(rankingColumn);
            dgvNovelList.Columns.Add(chapterCountColumn);
            dgvNovelList.Columns.Add(newChapterCountColumn);
            dgvNovelList.Columns.Add(stateColumn);
            dgvNovelList.Columns.Add(makeAudioColumn);
            dgvNovelList.Columns.Add(updateProgressColumn);

            dgvNovelList.DataSource = NovelLibrary.Instance.NovelList;


        }
        private void CostCodeSelector_Load(object sender, EventArgs e)
        {
            try
            {
                // get a list of cost codes
                var codes = Accounting.GetCostCodes();

                var _selected = Env.GetConfigVar("nonbillablecostcodes", "0", true).Split(',').Where(c => c != "");
                var selected = _selected.Select(c => decimal.Parse(c));
                Data = (from code in codes
                            select new
                            {
                                NonBillable = selected.Contains(code.Recnum),
                                CostCode = code.Recnum,
                                Description = code.Description,
                            }).ToDataTable("codes");

                this.dataGridView1.DataSource = Data;
                var ctemplate = new DataGridViewCheckBoxCell();
                this.dataGridView1.Columns["NonBillable"].CellTemplate = ctemplate;
                this.dataGridView1.Columns["Description"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                this.dataGridView1.AutoResizeColumns();
                this.Deactivate += new EventHandler(CostCodeSelector_Deactivate);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #20
0
        private void dgv_infos_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0) {
                if (dgv_infos.CurrentCell is DataGridViewCheckBoxCell) {
                    DataGridViewCheckBoxCell tmp = new DataGridViewCheckBoxCell();
                    tmp = (DataGridViewCheckBoxCell)dgv_infos.CurrentCell;
                    if (tmp.Value == null)
                        tmp.Value = false;
                    switch (tmp.Value.ToString()) {
                        case "True":
                            tmp.Value = true;
                            break;
                        case "False":
                            tmp.Value = false;
                            break;
                    }
                    if((bool)tmp.Value)
                        nbLignesCochees--;
                    else
                        nbLignesCochees++;
                    if (nbLignesCochees == 0) {
                        btn_connect.Enabled = false;
                    }
                    else {
                        if (nbLignesCochees > 1)
                            btn_connect.Enabled = false;
                        else
                            btn_connect.Enabled = true;
                    }

                    switch (tmp.Value.ToString()) {
                        case "True":
                            tmp.Value = false;
                            break;
                        case "False":
                            tmp.Value = true;
                            break;
                    }
                }
            }
        }
Example #21
0
            private void SetupCells()
            {
                _poolCheckBoxCell = new DataGridViewCheckBoxCell { ThreeState = true };

                _expansionCell = new DataGridViewImageCell();

                if (Tag is Pool || (Tag is Host && !_hasPool))
                    _poolIconHostCheckCell = new DataGridViewIconCell();
                else
                    _poolIconHostCheckCell = new DataGridViewCheckBoxCell();

                _nameCell = new DataGridViewNameCell();
                _versionCell = new DataGridViewTextBoxCell();

                Cells.AddRange(new[] { _expansionCell, _poolCheckBoxCell, _poolIconHostCheckCell, _nameCell, _versionCell });

                this.UpdateDetails();
            }
            public SrRow(SR.SRInfo srInfo, SR.SRTypes type, bool poolMetadataDetected, bool selected)
            {
                SrInfo = srInfo;
                HasMetadata = poolMetadataDetected;

                var cellTick = new DataGridViewCheckBoxCell { Value = selected };
                var cellName = new DataGridViewTextBoxCell { Value = srInfo.Name };
                var cellDesc = new DataGridViewTextBoxCell { Value = srInfo.Description };
                var cellType = new DataGridViewTextBoxCell { Value = SR.getFriendlyTypeName(type) };
                var cellMetadata = new DataGridViewTextBoxCell { Value = poolMetadataDetected.ToStringI18n() };
                Cells.AddRange(cellTick, cellName, cellDesc, cellType, cellMetadata);
            }
            public SrRow(SR sr, bool poolMetadataDetected, bool selected)
            {
                Sr = sr;
                HasMetadata = poolMetadataDetected;

                var cellTick = new DataGridViewCheckBoxCell { Value = selected };
                var cellName = new DataGridViewTextBoxCell { Value = sr.Name };
                var cellDesc = new DataGridViewTextBoxCell { Value = sr.Description };
                var cellType = new DataGridViewTextBoxCell { Value = sr.FriendlyTypeName };
                var cellMetadata = new DataGridViewTextBoxCell { Value = poolMetadataDetected.ToStringI18n() };
                Cells.AddRange(cellTick, cellName, cellDesc, cellType, cellMetadata);
            }
 public DataGridViewCheckBoxColumn(bool threeState)
 {
     CellTemplate = new DataGridViewCheckBoxCell(threeState);
 }
        private void RowCheckBoxClick(DataGridViewCheckBoxCell RCheckBox)
        {
            if (RCheckBox != null)
            {
                //Modify Counter;            
                if ((bool)RCheckBox.Value && TotalCheckedCheckBoxes < TotalCheckBoxes)
                    TotalCheckedCheckBoxes++;
                else if (TotalCheckedCheckBoxes > 0)
                    TotalCheckedCheckBoxes--;

                //Change state of the header CheckBox.
                if (TotalCheckedCheckBoxes < TotalCheckBoxes)
                    HeaderCheckBox.Checked = false;
                else if (TotalCheckedCheckBoxes == TotalCheckBoxes)
                    HeaderCheckBox.Checked = true;
            }
        }
        private void fuzzyDataGridViewRules_Loader(FuzzyRuleSet _frsFuzzyRuleSet)
        {
            int irows = _frsFuzzyRuleSet.Rules.GetLength(0);
            int icolumns = _frsFuzzyRuleSet.Rules.GetLength(1);

            for (int i = 0; i < irows; i++)
            {
                DataGridViewRow dgvrow = new DataGridViewRow();
                DataGridViewTextBoxCell celltextbox = new DataGridViewTextBoxCell();
                celltextbox.Value = i + 1;
                dgvrow.Cells.Add(celltextbox);
                for (int j=0; j < icolumns-2; j++)
                {
                    DataGridViewCheckBoxCell cellcheckbox = new DataGridViewCheckBoxCell();
                    DataGridViewComboBoxCell cellcombobox = new DataGridViewComboBoxCell();
                    if (_frsFuzzyRuleSet.Rules[i, j] < 0) cellcheckbox.Value = 1;
                    int index = Math.Abs(Convert.ToInt32(_frsFuzzyRuleSet.Rules[i, j]));
                    if (j < _frsFuzzyRuleSet.Inputs.Count)
                    {
                        cellcombobox.Items.Add("<none>");
                        foreach (FuzzyMF mf in _frsFuzzyRuleSet.Inputs[j].MFs)
                        {
                            cellcombobox.Items.Add(mf.Name.ToString());
                        }
                        if (index != 0) cellcombobox.Value = _frsFuzzyRuleSet.Inputs[j].MFs[index - 1].Name.ToString();
                        else cellcombobox.Value = "<none>";
                    }
                    else
                    {
                        cellcombobox.Items.Add("<none>");
                        foreach (FuzzyMF mf in _frsFuzzyRuleSet.Outputs[j - _frsFuzzyRuleSet.Inputs.Count].MFs)
                        {
                            cellcombobox.Items.Add(mf.Name.ToString());
                        }
                        if(index != 0) cellcombobox.Value = _frsFuzzyRuleSet.Outputs[j - _frsFuzzyRuleSet.Inputs.Count].MFs[index-1].Name.ToString();
                        else cellcombobox.Value = "<none>";
                    }
                    dgvrow.Cells.AddRange(cellcheckbox, cellcombobox);
                }
                DataGridViewComboBoxCell cellcombobox_connection = new DataGridViewComboBoxCell();
                cellcombobox_connection.Items.AddRange("AND", "OR");
                if (_frsFuzzyRuleSet.Rules[i, icolumns - 1] == 1) cellcombobox_connection.Value = "AND";
                else if(_frsFuzzyRuleSet.Rules[i, icolumns - 1] == 2) cellcombobox_connection.Value = "OR";
                DataGridViewComboBoxCell cellcombobox_weight = new DataGridViewComboBoxCell();
                cellcombobox_weight.Items.AddRange(new object[] {"0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1"});
                cellcombobox_weight.Value = Convert.ToString(_frsFuzzyRuleSet.Rules[i, icolumns - 2], System.Globalization.CultureInfo.InvariantCulture);
                dgvrow.Cells.AddRange(cellcombobox_connection, cellcombobox_weight);
                this.fuzzyDataGridView.Rows.Add(dgvrow);
                this.numberOfRulesNumericUpDown.Enabled = true;
            }
        }
Example #27
0
 private DataRow CreateNewRow(DataTable dt)
 {
     DataRow dr;
     List<object> items = new List<object>();
     dr = dt.NewRow();
     DataGridViewRow row;
     DataGridViewCell cell;
     DataColumn primaryKeyColumn = dt.PrimaryKey.Length == 0 ? null : dt.PrimaryKey[0];
     for (int i = 0; i < dt.Columns.Count; i++) {
         row = new DataGridViewRow();
         foreach (DataRelation dataRel in dt.ParentRelations) {
             if (dataRel.ChildColumns[0] == dt.Columns[i]) {
                 cell = new DataGridViewComboBoxCell();
                 foreach (DataRow drR in dbFile.Tables[dataRel.ParentColumns[0].Table.TableName].Rows) {
                     if (drR.RowState != DataRowState.Deleted) {
                         ((DataGridViewComboBoxCell)cell).Items.Add(drR.ItemArray[dataRel.ParentColumns[0].Ordinal]);
                     }
                     if (((DataGridViewComboBoxCell)cell).Items.Count > 0) {
                         break;
                     }
                 }
                 row.Cells.Add(cell);
                 break;
             }
         }
         if (row.Cells.Count == 0) {
             row.Cells.Clear();
             if (dt.Columns[i].DataType == typeof(bool)) {
                 cell = new DataGridViewCheckBoxCell();
                 row.Cells.Add(cell);
             } else if (dt.Columns[i].DataType == typeof(string)) {
                 cell = new DataGridViewTextBoxCell();
                 row.Cells.Add(cell);
             } else if (dt.Columns[i].DataType == typeof(int) || dt.Columns[i].DataType == typeof(float)) {
                 cell = new DataGridViewTextBoxCell();
                 row.Cells.Add(cell);
             } else {
                 cell = new DataGridViewTextBoxCell();
                 row.Cells.Add(cell);
             }
         }
         if (row.Cells[0] is DataGridViewComboBoxCell) {
             if (((DataGridViewComboBoxCell)row.Cells[0]).Items.Count > 0) {
                 ((DataGridViewComboBoxCell)row.Cells[0]).Value = ((DataGridViewComboBoxCell)row.Cells[0]).Items[0];
             } else {
                 ((DataGridViewComboBoxCell)row.Cells[0]).Items.Add(dt.Columns[i].DefaultValue);
                 ((DataGridViewComboBoxCell)row.Cells[0]).Value = dt.Columns[i].DefaultValue;
             }
         } else {
             row.Cells[0].Value = dt.Columns[i].DefaultValue;
         }
         row.Cells[0].ValueType = dt.Columns[i].DataType;
         // Set Up PrimaryKey Row Values for Validation
         if (dt.Columns[i] == primaryKeyColumn) {
             int largestIndex = 1;
             foreach (DataRow dRPK in dt.Rows) {
                 if (dRPK.RowState != DataRowState.Deleted) {
                     if (dRPK.ItemArray[i] is int) {
                         largestIndex = Math.Max(largestIndex, (int)dRPK.ItemArray[i]);
                     }
                 }
             }
             if (row.Cells[0].ValueType == typeof(int)) {
                 row.Cells[0].Value = largestIndex + 1;
             }
         }
         items.Add(row.Cells[0].Value);
     }
     // Finish
     dr.ItemArray = items.ToArray();
     return dr;
 }
		public DataGridViewCheckBoxColumn (bool threeState) {
			CellTemplate = new DataGridViewCheckBoxCell (threeState);
		}
        private void FreshDG()
        {
            try
            {

                DG_In.Rows.Clear();
                DG_Out.Rows.Clear();
                dataset.Clear();
                dataset = ServiceContainer.GetService<IGasDAL>().QueryData("EquipTypeSlet");
                equipTypeNum = dataset.Tables[0].Rows.Count;

                foreach (DataRow dr in dataset.Tables[0].Rows)
                {
                    if (dr["PorC"].ToString() == "True")
                    {
                        DataGridViewRow row = new DataGridViewRow();
                        DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
                        textboxcell.Value = dr[0];
                        row.Cells.Add(textboxcell);
                        DataGridViewCheckBoxCell checkcell = new DataGridViewCheckBoxCell();
                        checkcell.Value = false;
                        row.Cells.Add(checkcell);
                        DataGridViewTextBoxCell txtboxcell = new DataGridViewTextBoxCell();
                        row.Cells.Add(txtboxcell);
                        DG_In.Rows.Add(row);
                    }
                    else
                    {
                        DataGridViewRow row2 = new DataGridViewRow();
                        DataGridViewTextBoxCell textboxcell2 = new DataGridViewTextBoxCell();
                        textboxcell2.Value = dr[0];
                        row2.Cells.Add(textboxcell2);
                        DataGridViewCheckBoxCell checkcell2 = new DataGridViewCheckBoxCell();
                        checkcell2.Value = false;
                        row2.Cells.Add(checkcell2);
                        DataGridViewTextBoxCell txtboxcell2 = new DataGridViewTextBoxCell();
                        row2.Cells.Add(txtboxcell2);
                        DG_Out.Rows.Add(row2);
                    }

                    //DataGridViewRow row = new DataGridViewRow();
                    //row.Cells["设备名称"].Value = dataset.Tables[0].Rows[j][0];//设置row属性
                    //DG_In.Rows.Add(row);
                    //DG_Out.Rows.Add(row);
                    //DG_In.Rows[j].Cells[0].Value = dataset.Tables[0].Rows[j][0];
                    //DG_Out.Rows[j].Cells[0].Value = dataset.Tables[0].Rows[j][0];

                }
            }
            catch(Exception ex)
            {
                Console.WriteLine("查询异常" + ex.Message);
                return;
            }
        }
Example #30
0
        public static void ParametersToDataGridView(DataGridView dg,
			IEcasParameterized p, IEcasObject objDefaults)
        {
            if(dg == null) throw new ArgumentNullException("dg");
            if(p == null) throw new ArgumentNullException("p");
            if(p.Parameters == null) throw new ArgumentException();
            if(objDefaults == null) throw new ArgumentNullException("objDefaults");
            if(objDefaults.Parameters == null) throw new ArgumentException();

            dg.Rows.Clear();
            dg.Columns.Clear();

            Color clrBack = dg.DefaultCellStyle.BackColor;
            Color clrValueBack = dg.DefaultCellStyle.BackColor;
            if(clrValueBack.GetBrightness() >= 0.5)
                clrValueBack = UIUtil.DarkenColor(clrValueBack, 0.075);
            else clrValueBack = UIUtil.LightenColor(clrValueBack, 0.075);

            dg.ColumnHeadersVisible = false;
            dg.RowHeadersVisible = false;
            dg.GridColor = clrBack;
            dg.BackgroundColor = clrBack;
            dg.DefaultCellStyle.SelectionBackColor = clrBack;
            dg.DefaultCellStyle.SelectionForeColor = dg.DefaultCellStyle.ForeColor;
            dg.EditMode = DataGridViewEditMode.EditOnEnter;
            dg.AllowDrop = false;
            dg.AllowUserToAddRows = false;
            dg.AllowUserToDeleteRows = false;
            dg.AllowUserToOrderColumns = false;
            dg.AllowUserToResizeColumns = false;
            dg.AllowUserToResizeRows = false;

            int nWidth = (dg.ClientSize.Width - UIUtil.GetVScrollBarWidth());
            dg.Columns.Add("Name", KPRes.FieldName);
            dg.Columns.Add("Value", KPRes.FieldValue);
            dg.Columns[0].Width = (nWidth / 2);
            dg.Columns[1].Width = (nWidth / 2);

            for(int i = 0; i < p.Parameters.Length; ++i)
            {
                EcasParameter ep = p.Parameters[i];

                dg.Rows.Add();
                DataGridViewRow row = dg.Rows[dg.Rows.Count - 1];
                DataGridViewCellCollection cc = row.Cells;

                Debug.Assert(cc.Count == 2);
                cc[0].Value = ep.Name;
                cc[0].ReadOnly = true;

                string strParam = EcasUtil.GetParamString(objDefaults.Parameters, i);
                DataGridViewCell c = null;

                switch(ep.Type)
                {
                    case EcasValueType.String:
                        c = new DataGridViewTextBoxCell();
                        c.Value = strParam;
                        break;

                    case EcasValueType.Bool:
                        c = new DataGridViewCheckBoxCell(false);
                        (c as DataGridViewCheckBoxCell).Value =
                            StrUtil.StringToBool(strParam);
                        break;

                    case EcasValueType.EnumStrings:
                        DataGridViewComboBoxCell cmb = new DataGridViewComboBoxCell();
                        cmb.Sorted = false;
                        cmb.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
                        int iFound = -1;
                        for(int e = 0; e < ep.EnumValues.ItemCount; ++e)
                        {
                            EcasEnumItem eei = ep.EnumValues.Items[e];
                            cmb.Items.Add(eei.Name);
                            if(eei.ID.ToString() == strParam) iFound = e;
                        }
                        if(iFound >= 0) cmb.Value = ep.EnumValues.Items[iFound].Name;
                        else if(ep.EnumValues.ItemCount > 0) cmb.Value = ep.EnumValues.Items[0].Name;
                        else { Debug.Assert(false); }
                        c = cmb;
                        break;

                    case EcasValueType.Int64:
                        c = new DataGridViewTextBoxCell();
                        c.Value = FilterTypeI64(strParam);
                        break;

                    case EcasValueType.UInt64:
                        c = new DataGridViewTextBoxCell();
                        c.Value = FilterTypeU64(strParam);
                        break;

                    default:
                        Debug.Assert(false);
                        break;
                }

                if(c != null) cc[1] = c;
                cc[1].ReadOnly = false;
                cc[1].Style.BackColor = clrValueBack;
                cc[1].Style.SelectionBackColor = clrValueBack;
            }
        }
Example #31
0
        private void addNodeToGrid(string nodeName)
        {
            var a = new Action(() =>
            {
                var row = new DataGridViewRow();

                var c = new DataGridViewCheckBoxCell();
                c.Value = true;
                row.Cells.Add(c);

                var s = new DataGridViewTextBoxCell();
                s.Value = nodeName;
                row.Cells.Add(s);

                serverGridView.Rows.Add(row);
            });
            condInvoke(a);
        }
Example #32
0
        public void DrawRow(CheckableDataGridViewRow gvRow)
        {
            SuspendLayout();
            try
            {
                CheckableDataGridViewRow row = gvRow;
                if(Rows.Contains(row))
                    Rows.Remove(row);
                row.Cells.Clear();
                DataGridViewCheckBoxCell cbCell = new DataGridViewCheckBoxCell { Value = gvRow.Checked };
                row.Cells.Add(cbCell);
                foreach (object cellValue in gvRow.CellText)
                {
                    DataGridViewCellStyle style = row.Disabled ? RowStyle(true) : UpdatingRowStyle(row.CellDataLoaded);
                    row.Cells.Add(GetCell(style, cellValue));
                }

                Rows.Add(row);
            }
            finally
            {
                ResumeLayout();
            }
        }
Example #33
0
        private void addVMNodeToGrid(string nodeName, string powerState)
        {
            var addPowerStateCol = new Action(() =>
            {
                if (!serverGridView.Columns.Contains("VM Power State"))
                {
                    DataGridViewTextBoxColumn powerStateCol = new DataGridViewTextBoxColumn();
                    powerStateCol.DataPropertyName = "VM Power State";
                    powerStateCol.HeaderText = "VM Power State";
                    powerStateCol.Name = "VM Power State";
                    powerStateCol.SortMode = DataGridViewColumnSortMode.Programmatic;
                    serverGridView.Columns.Add(powerStateCol);
                }
                var row = new DataGridViewRow();
                var c = new DataGridViewCheckBoxCell();
                c.Value = true;
                row.Cells.Add(c);

                var s = new DataGridViewTextBoxCell();
                s.Value = nodeName;
                row.Cells.Add(s);
                int index = serverGridView.Rows.Add(row);
                serverGridView.Rows[index].Cells["VM Power State"].Value = powerState;
            });
            condInvoke(addPowerStateCol);
        }
Example #34
0
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        #endregion
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        #region Methods
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /// <summary>
        /// Обработчик события загрузки формы
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EventHandler_FormTestPort_Load(object sender, EventArgs e)
        {
            ToolStripSeparator separator;
            DataGridViewColumn column;
            DataGridViewRow row;
            DataGridViewCheckBoxColumn chxColumn;
            DataGridViewCheckBoxCell chxCell;

            this.Text = "CAN-порт Fastwel NIM-351";
            this.Icon = NGK.Properties.Resources.faviconMy;
            
            // Настраиваем элементы формы
            this._MenuStripMain = new MenuStrip();
            this._MenuFile = new ToolStripMenuItem();
            this._MenuFileExit = new ToolStripLabel();
            this._MenuPort = new ToolStripMenuItem();
            this._MenuPortOpen = new ToolStripLabel();
            this._MenuPortClose = new ToolStripLabel();
            this._MenuPortActiveLine = new ToolStripLabel();
            this._MenuPortPassiveLine = new ToolStripLabel();
            this._MenuPortResetLine = new ToolStripLabel();
            this._MenuPortSendMessage = new ToolStripLabel();
            this._MenuHelp = new ToolStripMenuItem();
            this._MenuHelpAbout = new ToolStripLabel();
            this._StatusStripMain = new StatusStrip();
            this._SplitContainerMain = new SplitContainer();
            this._StatusStripMain.SuspendLayout();
            this._SplitContainerLeftPanel = new SplitContainer();
            this._SplitContainerLeftPanel.SuspendLayout();
            this._SplitContainerRightPanel = new SplitContainer();
            this._SplitContainerRightPanel.SuspendLayout();
            this._TreeViewSystem = new TreeView();
            this._TreeNodeRoot = new TreeNode();
            this._TreeNodePortSettings = new TreeNode();
            this._TreeNodeStatistics = new TreeNode();
            this._DataGridViewIncomingMessages = new DataGridView();
            this._DataGridViewOutcomingMessages = new DataGridView();
            this._DataGridViewStatistics = new DataGridView();
            this._PropertyGridPortSettings = new PropertyGrid();
            this._LabelInformation = new Label();

            this.SuspendLayout();

            // Инициализация меню для "Файл"
            this._MenuFile.Name = "MenuFile";
            this._MenuFile.Text = "&Файл";
            this._MenuStripMain.Items.Add(this._MenuFile);

            // Инициализация подменю для "Файл"->"..."
            this._MenuFileExit.Name = "MenuFileExit";
            this._MenuFileExit.Text = "Выход";
            this._MenuFileExit.Click += new EventHandler(EventHandler_Menu_Click);
            this._MenuFile.DropDownItems.Add(this._MenuFileExit);

            // Инициализация меню для "Порт"
            this._MenuPort.Name = "MenuPort";
            this._MenuPort.Text = "&Порт";
            this._MenuStripMain.Items.Add(this._MenuPort);

            // Инициализация подменю для "Порт"->"..."
            this._MenuPortOpen.Name = "MenuPortOpen";
            this._MenuPortOpen.Text = "Открыть";
            this._MenuPortOpen.Click += new EventHandler(EventHandler_Menu_Click);
            this._MenuPort.DropDownItems.Add(this._MenuPortOpen);

            this._MenuPortClose.Name = "MenuPortClose";
            this._MenuPortClose.Text = "Закрыть";
            this._MenuPortClose.Enabled = false;
            this._MenuPortClose.Click += new EventHandler(EventHandler_Menu_Click);
            this._MenuPort.DropDownItems.Add(this._MenuPortClose);

            separator = new ToolStripSeparator();
            separator.Name = "MenuPortSeparator1";
            this._MenuPort.DropDownItems.Add(separator);
           
            this._MenuPortActiveLine.Name = "MenuPortActiveLine";
            this._MenuPortActiveLine.Text = "Подключиться к шине";
            this._MenuPortActiveLine.Enabled = false;
            this._MenuPortActiveLine.Click += new EventHandler(EventHandler_Menu_Click);
            this._MenuPort.DropDownItems.Add(this._MenuPortActiveLine);

            this._MenuPortPassiveLine.Name = "MenuPortPassiveLine";
            this._MenuPortPassiveLine.Text = "Отключиться от шины";
            this._MenuPortPassiveLine.Enabled = false;
            this._MenuPortPassiveLine.Click += new EventHandler(EventHandler_Menu_Click);
            this._MenuPort.DropDownItems.Add(this._MenuPortPassiveLine);

            this._MenuPortResetLine.Name = "MenuPortResetLine";
            this._MenuPortResetLine.Text = "Reset";
            this._MenuPortResetLine.Enabled = false;
            this._MenuPortResetLine.Click += new EventHandler(EventHandler_Menu_Click);
            this._MenuPort.DropDownItems.Add(this._MenuPortResetLine);

            separator = new ToolStripSeparator();
            separator.Name = "MenuPortSeparator2";
            this._MenuPort.DropDownItems.Add(separator);

            this._MenuPortSendMessage.Name = "MenuPortSendMessage";
            this._MenuPortSendMessage.Text = "Отправить сообщение";
            this._MenuPortSendMessage.Enabled = true;
            this._MenuPortSendMessage.Click += new EventHandler(EventHandler_Menu_Click);
            this._MenuPort.DropDownItems.Add(this._MenuPortSendMessage); 

            // Инициализация меню для "Помощь"
            this._MenuHelp.Name = "MenuHelp";
            this._MenuHelp.AutoSize = true;
            this._MenuHelp.Text = "&Помощь";
            this._MenuStripMain.Items.Add(this._MenuHelp);

            // Инициализация подменю для "Помощь"->"..."
            this._MenuHelpAbout.Name = "MenuHelpAbout";
            this._MenuHelpAbout.AutoSize = true;
            this._MenuHelpAbout.Text = "О программе";
            this._MenuHelpAbout.Click += new EventHandler(EventHandler_Menu_Click);
            this._MenuHelp.DropDownItems.Add(this._MenuHelpAbout);

            // Инициализируем строку состояния
            this._StatusStripMain.Name = "StatusStripMain";
           
            // Главный контейнер для формирования верхнего и нижнего окна
            this._SplitContainerMain.SuspendLayout();
            this._SplitContainerMain.Name = "SplitContainerMain";
            this._SplitContainerMain.Dock = DockStyle.Fill;
            this._SplitContainerMain.Orientation = Orientation.Vertical;
            this.Controls.Add(this._SplitContainerMain);

            // Контейнер для вертикального деления верхнего окна
            this._SplitContainerLeftPanel.Name = "SplitContainerLeftPanel";
            this._SplitContainerLeftPanel.Dock = DockStyle.Fill;
            this._SplitContainerLeftPanel.Orientation = Orientation.Horizontal;
            this._SplitContainerMain.Panel1.Controls.Add(this._SplitContainerLeftPanel);

            // Контейнер для вертикального деления ниженго окна
            this._SplitContainerRightPanel.Name = "SplitContainerRightPanel.Name";
            this._SplitContainerRightPanel.Dock = DockStyle.Fill;
            this._SplitContainerRightPanel.Orientation = Orientation.Horizontal;
            this._SplitContainerMain.Panel2.Controls.Add(this._SplitContainerRightPanel);

            // Инициализируем дерево объектов
            this._TreeViewSystem.Name = "TreeViewSystem";
            this._TreeViewSystem.Dock = DockStyle.Fill;
            this._TreeViewSystem.AfterSelect += new TreeViewEventHandler(EventHandler_TreeViewSystem_AfterSelect);
            this._SplitContainerLeftPanel.Panel1.Controls.Add(this._TreeViewSystem);
            
            //
            this._TreeNodeRoot.Name = "TreeNodeRoot";
            this._TreeNodeRoot.Text = "NIM-351";
            this._TreeViewSystem.Nodes.Add(this._TreeNodeRoot);
            this._TreeViewSystem.TopNode = this._TreeNodeRoot;
            //
            this._TreeNodePortSettings.Name = "TreeNodePortSettings";
            this._TreeNodePortSettings.Text = "CAN-порт";
            this._TreeViewSystem.TopNode.Nodes.Add(this._TreeNodePortSettings);
            //
            this._TreeNodeStatistics.Name = "TreeNodeStatistics";
            this._TreeNodeStatistics.Text = "Статистика";
            this._TreeViewSystem.TopNode.Nodes.Add(this._TreeNodeStatistics);

            this._TreeViewSystem.ExpandAll();

            // Настраиваем стиль для заголовков столбцов гридов
            DataGridViewCellStyle headerCellStyle = new DataGridViewCellStyle();
            headerCellStyle.Font = new Font(this._DataGridViewOutcomingMessages.Font, FontStyle.Bold);
            headerCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            headerCellStyle.WrapMode = DataGridViewTriState.True;

            // Грид для отображения входящих сообщений
            this._DataGridViewIncomingMessages.Name = "DataGridViewIncomingMessages";
            this._DataGridViewIncomingMessages.AllowUserToAddRows = false;
            this._DataGridViewIncomingMessages.AllowUserToDeleteRows = false;
            this._DataGridViewIncomingMessages.AllowUserToOrderColumns = false;
            this._DataGridViewIncomingMessages.AutoGenerateColumns = false;
            this._DataGridViewIncomingMessages.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            this._DataGridViewIncomingMessages.MultiSelect = false;
            this._DataGridViewIncomingMessages.RowHeadersVisible = false;
            this._DataGridViewIncomingMessages.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this._DataGridViewIncomingMessages.Dock = DockStyle.Fill;
            this._DataGridViewIncomingMessages.ColumnHeadersDefaultCellStyle = headerCellStyle;
            this._DataGridViewIncomingMessages.CellFormatting += new DataGridViewCellFormattingEventHandler(EventHandler_DataGridViewIncomingMessages_CellFormatting);

            this._SplitContainerRightPanel.Panel1.Controls.Add(this._DataGridViewIncomingMessages);

            column = new DataGridViewColumn();
            column.Name = "DataGridViewColumnDateTime";
            column.HeaderText = "Дата/время";
            column.ReadOnly = true;
            column.CellTemplate = new DataGridViewTextBoxCell();
            column.ValueType = typeof(DateTime);
            column.DefaultCellStyle = new DataGridViewCellStyle();
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            column.DefaultCellStyle.Format = "HH:mm:ss dd.MM.yy";
            this._DataGridViewIncomingMessages.Columns.Add(column);

            column = new DataGridViewColumn();
            column.Name = "DataGridViewColumnTimeStamp";
            column.HeaderText = "Time Stamp";
            column.ReadOnly = true;
            column.CellTemplate = new DataGridViewTextBoxCell();
            column.ValueType = typeof(UInt32);
            column.DefaultCellStyle = new DataGridViewCellStyle();
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this._DataGridViewIncomingMessages.Columns.Add(column);

            column = new DataGridViewColumn();
            column.Name = "DataGridViewColumnIndentifier";
            column.HeaderText = "Id, hex";
            column.ReadOnly = true;
            column.CellTemplate = new DataGridViewTextBoxCell();
            column.ValueType = typeof(UInt32);
            column.DefaultCellStyle = new DataGridViewCellStyle();
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            column.DefaultCellStyle.Format = "X";
            this._DataGridViewIncomingMessages.Columns.Add(column);

            column = new DataGridViewColumn();
            column.Name = "DataGridViewColumnFormatFrame";
            column.HeaderText = "Ext.";
            column.ReadOnly = true;
            column.CellTemplate = new DataGridViewTextBoxCell();
            column.ValueType = typeof(FrameFormat);
            column.DefaultCellStyle = new DataGridViewCellStyle();
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this._DataGridViewIncomingMessages.Columns.Add(column);

            column = new DataGridViewColumn();
            column.Name = "DataGridViewColumnFrameType";
            column.HeaderText = "RTR";
            column.ReadOnly = true;
            column.CellTemplate = new DataGridViewTextBoxCell();
            column.ValueType = typeof(FrameType);
            column.DefaultCellStyle = new DataGridViewCellStyle();
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this._DataGridViewIncomingMessages.Columns.Add(column);

            column = new DataGridViewColumn();
            column.Name = "DataGridViewColumnData";
            column.HeaderText = "Данные";
            column.ReadOnly = true;
            column.CellTemplate = new DataGridViewTextBoxCell();
            column.ValueType = typeof(String);
            column.DefaultCellStyle = new DataGridViewCellStyle();
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            this._DataGridViewIncomingMessages.Columns.Add(column);

            #region Code For Debug 
            int index = this._DataGridViewIncomingMessages.Rows.Add(1);
            row = this._DataGridViewIncomingMessages.Rows[index];

            row.Cells[0].Value = DateTime.Now;
            row.Cells[1].Value = 134;
            row.Cells[2].Value = 10;
            row.Cells[3].Value = Message.FrameFormat.ExtendedFrame;
            row.Cells[4].Value = Message.FrameType.DATAFRAME;
            row.Cells[5].Value = new Byte[] { 01, 02, 03};
            #endregion

            // Контекстное меню для грида входящих сообщений
            this._ContextMenuStripIncomingBox = new ContextMenuStrip();
            this._ContextMenuStripIncomingBox.Name = "ContextMenuStripIncomingBox";
            //
            this._ContextMenuIncomingBoxClear = new ToolStripMenuItem();
            this._ContextMenuIncomingBoxClear.Name = "ContextMenuIncomingBoxClear";
            this._ContextMenuIncomingBoxClear.Text = "Очистить";
            this._ContextMenuIncomingBoxClear.Click += new EventHandler(_ContextMenuIncomingBoxClear_Click);
            this._ContextMenuStripIncomingBox.Items.Add(this._ContextMenuIncomingBoxClear);
            this._DataGridViewIncomingMessages.ContextMenuStrip = this._ContextMenuStripIncomingBox;


            // Грид для отображения исходящий сообещий
            this._DataGridViewOutcomingMessages.Name = "DataGridViewIncomingMessages";
            this._DataGridViewOutcomingMessages.AllowUserToAddRows = false;
            this._DataGridViewOutcomingMessages.AllowUserToDeleteRows = false;
            this._DataGridViewOutcomingMessages.AllowUserToOrderColumns = false;
            this._DataGridViewOutcomingMessages.AutoGenerateColumns = false;
            this._DataGridViewOutcomingMessages.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            this._DataGridViewOutcomingMessages.MultiSelect = false;
            this._DataGridViewOutcomingMessages.RowHeadersVisible = false;
            this._DataGridViewOutcomingMessages.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this._DataGridViewOutcomingMessages.Dock = DockStyle.Fill;
            this._DataGridViewOutcomingMessages.ColumnHeadersDefaultCellStyle = headerCellStyle;
            this._DataGridViewOutcomingMessages.CellClick += 
                new DataGridViewCellEventHandler(EventHandler_DataGridViewOutcomingMessages_CellClick);
            this._DataGridViewOutcomingMessages.EditingControlShowing += 
                new DataGridViewEditingControlShowingEventHandler(
                EventHandler_DataGridViewOutcomingMessages_EditingControlShowing);
            this._DataGridViewOutcomingMessages.CellParsing += 
                new DataGridViewCellParsingEventHandler(
                EventHandler_DataGridViewOutcomingMessages_CellParsing);
            this._DataGridViewOutcomingMessages.CellFormatting += 
                new DataGridViewCellFormattingEventHandler(EventHandler_DataGridViewOutcomingMessages_CellFormatting);
            this._DataGridViewOutcomingMessages.CellEndEdit += 
                new DataGridViewCellEventHandler(EventHandler_DataGridViewOutcomingMessages_CellEndEdit);
            this._DataGridViewOutcomingMessages.DataError += 
                new DataGridViewDataErrorEventHandler(EventHandler_DataGridViewOutcomingMessages_DataError);
            this._SplitContainerRightPanel.Panel2.Controls.Add(this._DataGridViewOutcomingMessages);
            
           

            column = new DataGridViewButtonColumn();
            column.Name = "DataGridViewColumnSend";
            column.HeaderText = "";
            column.ReadOnly = false;
            column.CellTemplate = new DataGridViewButtonCell();
            column.CellTemplate.Value = "OK";
            column.CellTemplate.ValueType = typeof(String);
            column.ValueType = typeof(String);
            //column.ValueType = typeof(NGK.CAN.OSIModel.Message.FrameType);
            this._DataGridViewOutcomingMessages.Columns.Add(column);

            column = new DataGridViewColumn();
            column.Name = "DataGridViewColumnIndentifier";
            column.HeaderText = "Id, hex";
            column.ReadOnly = false;
            column.ValueType = typeof(UInt32);
            column.CellTemplate = new DataGridViewTextBoxCell();
            column.CellTemplate.ValueType = typeof(UInt32);
            column.CellTemplate.Value = (UInt32)1;
            column.DefaultCellStyle = new DataGridViewCellStyle();
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            column.DefaultCellStyle.Format = "X";
            this._DataGridViewOutcomingMessages.Columns.Add(column);

            chxColumn = new DataGridViewCheckBoxColumn();
            chxColumn.Name = "DataGridViewColumnFormatFrame";
            chxColumn.HeaderText = "Ext.";
            chxColumn.ReadOnly = false;
            chxColumn.ValueType = typeof(FrameFormat);
            chxCell = new DataGridViewCheckBoxCell();
            chxCell.ValueType = typeof(FrameFormat);
            chxCell.Value = FrameFormat.StandardFrame;
            chxColumn.CellTemplate = chxCell;
            this._DataGridViewOutcomingMessages.Columns.Add(chxColumn);

            chxColumn = new DataGridViewCheckBoxColumn();
            chxColumn.Name = "DataGridViewColumnFrameType";
            chxColumn.HeaderText = "RTR";
            chxColumn.ReadOnly = false;
            chxColumn.ValueType = typeof(FrameType);
            chxCell = new DataGridViewCheckBoxCell();
            chxCell.ValueType = typeof(FrameType);
            chxColumn.CellTemplate = chxCell;
            chxColumn.ValueType = typeof(FrameType);
            this._DataGridViewOutcomingMessages.Columns.Add(chxColumn);

            column = new DataGridViewColumn();
            column.Name = "DataGridViewColumnData";
            column.HeaderText = "Данные";
            column.ReadOnly = false;
            column.CellTemplate = new DataGridViewTextBoxCell();
            column.CellTemplate.ValueType = typeof(Byte[]);
            column.CellTemplate.Value = new Byte[0];
            column.ValueType = typeof(Byte[]);
            this._DataGridViewOutcomingMessages.Columns.Add(column);

            this._DataGridViewOutcomingMessages.Rows.Add(5);
            for (int i = 0; i < this._DataGridViewOutcomingMessages.Rows.Count; i++)
            {
                //((DataGridViewComboBoxCell)this._DataGridViewOutcomingMessages.Rows[i].Cells[2]).Items.AddRange(
                //    Enum.GetNames(typeof(NGK.CAN.OSIModel.Message.FrameFormat)));
                this._DataGridViewOutcomingMessages.Rows[i].Cells[0].Value = "Отправить";
                this._DataGridViewOutcomingMessages.Rows[i].Cells[1].Value = (UInt32)15;
                this._DataGridViewOutcomingMessages.Rows[i].Cells[2].Value = FrameFormat.StandardFrame;
                this._DataGridViewOutcomingMessages.Rows[i].Cells[3].Value = FrameType.DATAFRAME;
                this._DataGridViewOutcomingMessages.Rows[i].Cells[4].Value = new Byte[0];
            }

            //
            this._PropertyGridPortSettings.Dock = DockStyle.Fill;
            this._PropertyGridPortSettings.SelectedObject = null;
            this._PropertyGridPortSettings.Visible = false;
            this._SplitContainerLeftPanel.Panel2.Controls.Add(this._PropertyGridPortSettings);
            
            //
            this._DataGridViewStatistics.AllowUserToAddRows = false;
            this._DataGridViewStatistics.AllowUserToDeleteRows = false;
            this._DataGridViewStatistics.AllowUserToOrderColumns = false;
            this._DataGridViewStatistics.AutoGenerateColumns = false;
            this._DataGridViewStatistics.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            this._DataGridViewStatistics.MultiSelect = false;
            this._DataGridViewStatistics.RowHeadersVisible = false;
            this._DataGridViewStatistics.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this._DataGridViewStatistics.Dock = DockStyle.Fill;
            this._DataGridViewStatistics.Visible = false;
            this._DataGridViewStatistics.ColumnHeadersDefaultCellStyle = headerCellStyle;
            this._SplitContainerLeftPanel.Panel2.Controls.Add(this._DataGridViewStatistics);

            column = new DataGridViewColumn();
            column.Name = "Parameter";
            column.ReadOnly = true;
            column.HeaderText = "Параметр";
            column.ValueType = typeof(String);
            column.CellTemplate = new DataGridViewTextBoxCell();
            this._DataGridViewStatistics.Columns.Add(column);

            column = new DataGridViewColumn();
            column.Name = "Value";
            column.ReadOnly = true;
            column.HeaderText = "Значение";
            column.ValueType = typeof(UInt32);
            column.CellTemplate = new DataGridViewTextBoxCell();
            column.DefaultCellStyle = new DataGridViewCellStyle();
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this._DataGridViewStatistics.Columns.Add(column);

            System.Reflection.FieldInfo[] fields =
                (typeof(F_CAN_STATS)).GetFields();

            this._DataGridViewStatistics.Rows.Clear();

            for (int i = 0; i < fields.Length; i++)
            {
                row = new DataGridViewRow();
                row.Cells.Add((DataGridViewCell)this._DataGridViewStatistics.Columns[0].CellTemplate.Clone());
                row.Cells.Add((DataGridViewCell)this._DataGridViewStatistics.Columns[1].CellTemplate.Clone());
                row.Cells[0].Value = fields[i].Name;
                Object[] objs = fields[i].GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
                //row.Cells[0].Value = fields[i].Name;
                row.Cells[0].Value = ((System.ComponentModel.DescriptionAttribute)objs[0]).Description;
                //row.Cells[1].Value = fields[i].GetValue(statistics);
                row.Cells[1].Value = 0;
                this._DataGridViewStatistics.Rows.Add(row);
            }

            // Контекстное меню 
            this._ContextMenuStripStatistics = new ContextMenuStrip();
            this._ContextMenuStripStatistics.Name = "ContextMenuStripStatistics";
            this._ContextMenuStripStatistics.Opening += new CancelEventHandler(_ContextMenuStripStatistics_Opening);
            this._DataGridViewStatistics.ContextMenuStrip = this._ContextMenuStripStatistics;
            //
            this._ContexMenuStatisticsClear = new ToolStripMenuItem();
            this._ContexMenuStatisticsClear.Name = "ContexMenuStatisticsClear";
            this._ContexMenuStatisticsClear.Text = "Очистить статистику";
            this._ContexMenuStatisticsClear.Click += new EventHandler(EventHandler_ContexMenuStatisticsClear_Click);
            this._ContextMenuStripStatistics.Items.Add(this._ContexMenuStatisticsClear);
          
            //
            this._LabelInformation.Text = String.Empty;
            this._LabelInformation.TextAlign = ContentAlignment.MiddleCenter;
            this._LabelInformation.Dock = DockStyle.Fill;
            this._LabelInformation.Visible = false;
            this._SplitContainerLeftPanel.Panel2.Controls.Add(this._LabelInformation);
            
            //
            this.Controls.Add(this._MenuStripMain);
            this.MainMenuStrip = this._MenuStripMain;
            this.Controls.Add(this._StatusStripMain);
            //
            this._StatusStripMain.ResumeLayout(false);
            this._SplitContainerMain.ResumeLayout(false);
            this._SplitContainerLeftPanel.ResumeLayout(false);
            this._SplitContainerRightPanel.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

            // Инициализируем CAN-порт
            //this._CanPort = new CanPort();
            //this._CanPort.MessageReceived += 
            //    new EventHandler(EventHandler_CanPort_MessageReceived);
            //this._CanPort.PortChangedStatus += 
            //    new EventHandlerPortChangesStatus(EventHandler_CanPort_PortChangedStatus);
            //this._PropertyGridPortSettings.SelectedObject = this._CanPort;
            if (_CanPort != null)
            {
                this._CanPort.MessageReceived +=
                    new EventHandler(EventHandler_CanPort_MessageReceived);
                this._CanPort.PortChangedStatus +=
                    new EventHandlerPortChangesStatus(EventHandler_CanPort_PortChangedStatus);
                this._PropertyGridPortSettings.SelectedObject = this._CanPort; 
            }

            // Инициализируем таймер
            this._Timer = new Timer();
            this._Timer.Interval = 500;
            this._Timer.Tick += new EventHandler(EventHandler_Timer_Tick);
            this._Timer.Start();

            return;
        }
        void ProjectsDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var ch1 = new DataGridViewCheckBoxCell();
            if (e.ColumnIndex != 0) return;

            if (ProjectsDataGridView.CurrentRow != null)
                ch1 = (DataGridViewCheckBoxCell)ProjectsDataGridView.Rows[ProjectsDataGridView.CurrentRow.Index].Cells[0];

            if (ch1.Value == null)
                ch1.Value = false;
            switch (ch1.Value.ToString())
            {
                case "True":
                    ch1.Value = false;
                    break;
                case "False":
                    ch1.Value = true;
                    break;
            }
        }