Example #1
0
        private void checkedListBox_selectControl_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.NewValue == e.CurrentValue)
            {
                return;
            }
            Control            control        = _controls[e.Index];
            ViewControlElement controlElement =
                _controlElements.Find(item => item.Name.Equals(control.Name));
            int rowIndex = -1;

            for (int i = 0; i < dataGridView_enabledSelect.Rows.Count; i++)
            {
                if (control.Name.Equals(dataGridView_enabledSelect.Rows[i].Cells[1].Value.ToString()))
                {
                    rowIndex = i;
                }
            }
            if (rowIndex >= 0)
            {
                dataGridView_enabledSelect.Rows.RemoveAt(rowIndex);
                dataGridView_visibleSelect.Rows.RemoveAt(rowIndex);
            }
            if (e.NewValue == CheckState.Checked)
            {
                AddDataToTable(controlElement);
            }
            RefreshSelectAllState();
        }
Example #2
0
 private void RefreshDataGridViewData(DataGridViewRowCollection rows, int propertyIndex, object defaultValue)
 {
     _isInternalRefreshOperation = true;
     if (listBox_stateNames.SelectedIndex < 0)
     {
         for (int i = 0; i < rows.Count; i++)
         {
             rows[i].Cells[0].Value = false;
             rows[i].Cells[2].Value = defaultValue.ToString();
         }
     }
     else
     {
         string currentState = listBox_stateNames.Text;
         for (int i = 0; i < rows.Count; i++)
         {
             DataGridViewRow    rowData        = rows[i];
             string             controlName    = rowData.Cells[1].Value.ToString();
             ViewControlElement controlElement = GetViewControlElement(controlName);
             object[]           values         = controlElement.GetValue(currentState);
             if (null == values)
             {
                 rows[i].Cells[0].Value = false;
                 rows[i].Cells[2].Value = defaultValue.ToString();
             }
             else
             {
                 object propertyValue = values[propertyIndex];
                 rows[i].Cells[0].Value = (null != propertyValue);
                 rows[i].Cells[2].Value = propertyValue?.ToString() ?? defaultValue.ToString();
             }
         }
     }
     _isInternalRefreshOperation = false;
 }
Example #3
0
        private ViewControlElement GetViewControlElement(string controlName)
        {
            ViewControlElement controlElement = _controlElements.First(item => item.Name.Equals(controlName));

            if (null == controlElement)
            {
                controlElement = new ViewControlElement(_controls.First(item => item.Name.Equals(controlName)));
                _controlElements.Add(controlElement);
            }
            return(controlElement);
        }
Example #4
0
 private void AddDataToTable(ViewControlElement controlElement)
 {
     object[] values = controlElement.GetValue(listBox_stateNames.Text);
     if (null == values)
     {
         dataGridView_enabledSelect.Rows.Add(false, controlElement.Name, ViewControlElement.DefaultValue[0].ToString());
         dataGridView_visibleSelect.Rows.Add(false, controlElement.Name, ViewControlElement.DefaultValue[1].ToString());
     }
     else
     {
         AddSingleTableData(dataGridView_enabledSelect.Rows, controlElement.Name, values[0], ViewControlElement.DefaultValue[0]);
         AddSingleTableData(dataGridView_visibleSelect.Rows, controlElement.Name, values[1], ViewControlElement.DefaultValue[1]);
     }
 }
Example #5
0
        private void RefreshControlElementValue(DataGridViewRowCollection rows, int propertyIndex,
                                                DataGridViewCellEventArgs eventArgs)
        {
            if (_isInternalRefreshOperation || 1 == eventArgs.ColumnIndex || eventArgs.RowIndex < 0)
            {
                return;
            }
            DataGridViewRow    rowData        = rows[eventArgs.RowIndex];
            string             controlName    = rowData.Cells[1].Value.ToString();
            ViewControlElement controlElement = GetViewControlElement(controlName);
            bool   isSelected    = (bool)rowData.Cells[0].Value;
            object propertyValue = isSelected ? rowData.Cells[2].Value : null;

            controlElement.SetValue(listBox_stateNames.Text, ViewControlElement.PropertyNames[propertyIndex],
                                    propertyValue);
            RefreshSelectAllState();
        }
Example #6
0
        public ViewControlElement Clone()
        {
            ViewControlElement cloneObj = new ViewControlElement(_control);

            foreach (string key in _values.Keys)
            {
                if (null == _values[key])
                {
                    continue;
                }
                for (int i = 0; i < PropertyNames.Length; i++)
                {
                    cloneObj.SetValue(key, PropertyNames[i], _values[key][i]);
                }
            }
            return(null);
        }
Example #7
0
        private void InitControlList(Form parentForm)
        {
            _controls.Clear();
            if (null == parentForm || 0 == parentForm.Controls.Count)
            {
                return;
            }
            RecursiveAddControlsToList(parentForm.Controls);

            for (int i = 0; i < _controls.Count; i++)
            {
                Control            item           = _controls[i];
                string             controlName    = item.Name;
                ViewControlElement controlElement = _controlElements.Find(control => controlName.Equals(control.Name));
                if (null == controlElement)
                {
                    _controlElements.Add(new ViewControlElement(item));
                }
                else if (!controlElement.IsEmpty)
                {
                    checkedListBox_selectControl.SetItemChecked(i, true);
                }
            }
        }