Пример #1
0
        private void initializeTable()
        {
            table = CreateTable <IBoolean>();

            CustomDataGridViewColumnDescriptorBuilder <IBoolean> builder;

            // Custom styles
            DataGridViewCellStyle stateColumnStyle = BOLD_TEXT_CELL_STYLE.Clone();

            stateColumnStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

            // Column: name
            builder = GetColumnDescriptorBuilderForTable <IBoolean>();
            builder.Type(DataGridViewColumnType.TextBox);
            builder.Header("Name");
            builder.CellStyle(BOLD_TEXT_CELL_STYLE);
            builder.Width(220);
            builder.UpdaterMethod((boolean, cell) => { cell.Value = boolean.Name; });
            builder.AddChangeEvent(nameof(IBoolean.Name));
            builder.BuildAndAdd();

            // Column: description
            builder = GetColumnDescriptorBuilderForTable <IBoolean>();
            builder.Type(DataGridViewColumnType.TextBox);
            builder.Header("Description");
            builder.Width(450);
            builder.UpdaterMethod((boolean, cell) => { cell.Value = boolean.Description; });
            builder.AddChangeEvent(nameof(IBoolean.Description));
            builder.BuildAndAdd();

            // Column: state
            builder = GetColumnDescriptorBuilderForTable <IBoolean>();
            builder.Type(DataGridViewColumnType.TextBox);
            builder.Header("State");
            builder.CellStyle(stateColumnStyle);
            builder.Width(80);
            builder.UpdaterMethod((boolean, cell) => {
                bool booleanCurrentState = boolean.CurrentState;
                cell.Value           = booleanCurrentState ? "- on -" : "";
                cell.Style.BackColor = booleanCurrentState ? boolean.Color : OFF_COLOR;
            });
            builder.AddChangeEvent(nameof(IBoolean.CurrentState));
            builder.BuildAndAdd();

            // Bind database
            table.BoundCollection = BooleanRegister.Instance;
        }
Пример #2
0
        private void baseColumnCreator(CustomDataGridView <IBoolean> table, ItemListFormBaseManager <IBoolean> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod)
        {
            CustomDataGridViewColumnDescriptorBuilder <IBoolean> builder;

            // Custom styles
            DataGridViewCellStyle stateColumnStyle = BOLD_TEXT_CELL_STYLE.Clone();

            stateColumnStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

            // Column: name
            builder = builderGetterMethod();
            builder.Type(DataGridViewColumnType.TextBox);
            builder.Header("Name");
            builder.CellStyle(BOLD_TEXT_CELL_STYLE);
            builder.Width(220);
            builder.UpdaterMethod((boolean, cell) => { cell.Value = boolean.Name; });
            builder.AddChangeEvent(nameof(IBoolean.Name));

            // Column: description
            builder = builderGetterMethod();
            builder.Type(DataGridViewColumnType.TextBox);
            builder.Header("Description");
            builder.Width(450);
            builder.UpdaterMethod((boolean, cell) => { cell.Value = boolean.Description; });
            builder.AddChangeEvent(nameof(IBoolean.Description));

            // Column: state
            builder = builderGetterMethod();
            builder.Type(DataGridViewColumnType.TextBox);
            builder.Header("State");
            builder.CellStyle(stateColumnStyle);
            builder.Width(80);
            builder.UpdaterMethod((boolean, cell) => {
                bool booleanCurrentState = boolean.CurrentState;
                cell.Value           = booleanCurrentState ? "- on -" : "";
                cell.Style.BackColor = booleanCurrentState ? boolean.Color : OFF_COLOR;
            });
            builder.AddChangeEvent(nameof(IBoolean.CurrentState));
        }