Ejemplo n.º 1
0
        protected CustomDataGridViewColumnDescriptorBuilder <TModelBasetype> nameColumnCreator <TModelBasetype>(CustomDataGridView <TModelBasetype> table, ItemListFormBaseManager <TModelBasetype> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod)
            where TModelBasetype : class, IModel, INotifyPropertyChanged
        {
            CustomDataGridViewColumnDescriptorBuilder <TModelBasetype> builder = builderGetterMethod();

            builder.Type(DataGridViewColumnType.TextBox);
            builder.Header("Name");
            builder.Width(150);
            builder.CellStyle(BOLD_TEXT_CELL_STYLE);
            builder.UpdaterMethod((item, cell) => { cell.Value = item.Name; });
            builder.AddChangeEvent(nameof(IModel.Name));
            return(builder);
        }
Ejemplo n.º 2
0
        protected CustomDataGridViewColumnDescriptorBuilder <TModelBasetype> deleteButtonColumnCreator <TModelBasetype>(CustomDataGridView <TModelBasetype> table, ItemListFormBaseManager <TModelBasetype> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod)
            where TModelBasetype : class, IModel, INotifyPropertyChanged
        {
            CustomDataGridViewColumnDescriptorBuilder <TModelBasetype> builder = builderGetterMethod();

            builder.Type(DataGridViewColumnType.Button);
            builder.Header("Delete");
            builder.Width(70);
            builder.DividerWidth(DEFAULT_DIVIDER_WIDTH);
            builder.ButtonText("Delete");
            builder.CellContentClickHandlerMethod((item, cell, e) => {
                string msgBoxText = string.Format("Do you really want to delete this {0}?\n{1}", SubjectSingular, item);
                var confirm       = MessageBox.Show(msgBoxText, "Delete confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (confirm == DialogResult.Yes)
                {
                    ((IModelListFormBaseManager)Manager).DeleteItem(item);
                }
            });
            return(builder);
        }
Ejemplo n.º 3
0
        protected CustomDataGridViewColumnDescriptorBuilder <TModelBasetype> idColumnCreator <TModelBasetype>(CustomDataGridView <TModelBasetype> table, ItemListFormBaseManager <TModelBasetype> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod)
            where TModelBasetype : class, IModel, INotifyPropertyChanged
        {
            CustomDataGridViewColumnDescriptorBuilder <TModelBasetype> builder = builderGetterMethod();

            builder.Type(DataGridViewColumnType.TextBox);
            builder.Header("ID");
            builder.Width(30);
            builder.UpdaterMethod((item, cell) => { cell.Value = string.Format("#{0}", item.ID); });
            builder.AddChangeEvent(nameof(IModel.ID));
            return(builder);
        }
Ejemplo n.º 4
0
        protected CustomDataGridViewColumnDescriptorBuilder <TModelBasetype> editButtonColumnCreator <TModelBasetype>(CustomDataGridView <TModelBasetype> table, ItemListFormBaseManager <TModelBasetype> .ColumnDescriptorBuilderGetterDelegate builderGetterMethod)
            where TModelBasetype : class, IModel, INotifyPropertyChanged
        {
            CustomDataGridViewColumnDescriptorBuilder <TModelBasetype> builder = builderGetterMethod();

            builder.Type(DataGridViewColumnType.Button);
            builder.Header("Edit");
            builder.Width(70);
            builder.ButtonText("Edit");
            builder.CellContentClickHandlerMethod((item, cell, e) => {
                ChildWindowBase editWindow = null;
                if (EditorFormTypeRegister != null)
                {
                    ModelEditorFormTypeRegister <TModelBasetype> typeRegisterCasted = EditorFormTypeRegister as ModelEditorFormTypeRegister <TModelBasetype>;
                    editWindow = typeRegisterCasted?.GetFormForModel(item) as ChildWindowBase;
                }
                else if (ModelEditorForm != null)
                {
                    editWindow = ModelEditorForm.GetInstance(item) as ChildWindowBase;
                }
                editWindow?.ShowAsChild();
            });
            return(builder);
        }