public UIDictionaryTypeCollection()
        {
            Width  = MIN_CONTROL_WIDTH;
            Height = MIN_CONTROL_HEIGHT;

            titleControl          = new UITitleControl("Dictionaries");
            copyrightControl      = new UICopyrightControl();
            listViewControl       = new ListView();
            buttonAdd             = new ReferenceButton();
            buttonReload          = new AvButton();
            buttonDelete          = new AvButton();
            buttonEdit            = new ReferenceButton();
            buttonHelp            = new HelpRequestingButton("Some page");//todo
            buttonClose           = new ReferenceButton();
            columnHeaderID        = new ListViewHeader(COLUMN_ID_TEXT, COLUMN_ID_WIDTH);
            columnHeaderSmallName = new ListViewHeader(COLUMN_SMALL_NAME_TEXT, COLUMN_SMALL_NAME_WIDTH);
            columnHeaderFullName  = new ListViewHeader(COLUMN_FULL_NAME_TEXT, COLUMN_FULL_NAME_WIDTH);
            icons = new Icons();

            titleControl.Dock     = DockStyle.Top;
            copyrightControl.Dock = DockStyle.Bottom;
            //
            // buttonAdd
            //
            buttonAdd.Location            = new Point(Width - buttonAdd.Width - BUTTONS_MARGIN, titleControl.Height + BUTTONS_MARGIN);
            buttonAdd.Image               = icons.Add;
            buttonAdd.Text                = "Add";
            buttonAdd.DisplayerText       = "Add";//todo
            buttonAdd.ReflectionType      = ReflectionTypes.DisplayInNew;
            buttonAdd.DisplayerRequested += buttonAdd_DisplayerRequested;
            //
            // buttonReload
            //
            buttonReload.Location = new Point(Width - buttonReload.Width - BUTTONS_MARGIN,
                                              titleControl.Height + BUTTONS_MARGIN + BUTTONS_INTERVAL + buttonDelete.Height);
            buttonReload.Image  = icons.Reload;
            buttonReload.Text   = "Reload";
            buttonReload.Click += buttonReload_Click;
            //
            // buttonDelete
            //
            buttonDelete.Location = new Point(Width - buttonDelete.Width - BUTTONS_MARGIN,
                                              titleControl.Height + BUTTONS_MARGIN + 2 * (BUTTONS_INTERVAL + buttonReload.Height));
            buttonDelete.Enabled = false;
            buttonDelete.Image   = icons.Delete;
            buttonDelete.Text    = "Delete";
            buttonDelete.Click  += buttonDelete_Click;
            //
            // buttonEdit
            //
            buttonEdit.Location = new Point(Width - buttonEdit.Width - BUTTONS_MARGIN,
                                            titleControl.Height + BUTTONS_MARGIN + 3 * (BUTTONS_INTERVAL + buttonEdit.Height));
            buttonEdit.Enabled             = false;
            buttonEdit.Image               = icons.Edit;
            buttonEdit.Text                = "Edit";
            buttonEdit.DisplayerText       = "Edit";
            buttonEdit.ReflectionType      = ReflectionTypes.DisplayInCurrent;
            buttonEdit.DisplayerRequested += buttonEdit_DisplayerRequested;
            //
            // buttonHelp
            //
            buttonHelp.Location = new Point(Width - buttonHelp.Width - BUTTONS_MARGIN,
                                            titleControl.Height + BUTTONS_MARGIN + 4 * (BUTTONS_INTERVAL + buttonHelp.Height));
            buttonHelp.Image = icons.Help;
            buttonHelp.Text  = "Help";
            //
            // buttonClose
            //
            buttonClose.Location = new Point(Width - buttonClose.Width - BUTTONS_MARGIN,
                                             titleControl.Height + BUTTONS_MARGIN + 5 * (BUTTONS_INTERVAL + buttonClose.Height));
            buttonClose.Image          = icons.Close;
            buttonClose.Text           = "Close";
            buttonClose.ReflectionType = ReflectionTypes.CloseSelected;
            //
            // listViewControl
            //
            listViewControl.Location              = new Point(BUTTONS_MARGIN, titleControl.Height + BUTTONS_MARGIN);
            listViewControl.Size                  = new Size(Width - buttonAdd.Width - 3 * BUTTONS_MARGIN, Height - titleControl.Height - copyrightControl.Height - 2 * BUTTONS_MARGIN);
            listViewControl.View                  = View.Details;
            listViewControl.SizeChanged          += listViewControl_SizeChanged;
            listViewControl.FullRowSelect         = true;
            listViewControl.ItemSelectionChanged += listViewControl_ItemSelectionChanged;

            listViewHeaders.CollectionChanged += listViewHeaders_CollectionChanged;

            Controls.Add(titleControl);
            Controls.Add(copyrightControl);
            Controls.Add(listViewControl);
            Controls.Add(buttonAdd);
            Controls.Add(buttonReload);
            Controls.Add(buttonDelete);
            Controls.Add(buttonEdit);
            Controls.Add(buttonHelp);
            Controls.Add(buttonClose);

            listViewHeaders.Add(columnHeaderID);
            listViewHeaders.Add(columnHeaderSmallName);
            listViewHeaders.Add(columnHeaderFullName);


            if (!(Users.CurrentUser.Role == UserRole.Administrator))
            {
                buttonDelete.Enabled = true;
                buttonEdit.Enabled   = true;
            }
            else
            {
                buttonDelete.Enabled = false;
                buttonEdit.Enabled   = false;
            }
        }
Пример #2
0
        /// <summary>
        /// Создает элемент управления для отображеия списка эксплуатантов
        /// </summary>
        public UIOperatorCollection()
        {
            titleControl      = new UITitleControl("Operators");
            copyrightControl  = new UICopyrightControl();
            buttonMenu        = new ReferenceButton();
            buttonReload      = new AvButton();
            buttonAddOperator = new ReferenceButton();
            buttonViewLog     = new ReferenceButton();
            buttonHelp        = new HelpRequestingButton("Some page");//todo
            buttonClose       = new ReferenceButton();
            displayerControl  = new UIDisplayerControl((buttonMenu.Width + BUTTONS_MARGIN * 2) * 2,
                                                       buttonMenu.Height * 6 + BUTTONS_INTERVAL * 5 + 2 * BUTTONS_MARGIN);
            icons   = new Icons();
            buttons = new List <ReferenceOperatorListItem>();

            Width                 = displayerControl.Width;
            Height                = titleControl.Height + displayerControl.Height + copyrightControl.Height;
            titleControl.Dock     = DockStyle.Top;
            copyrightControl.Dock = DockStyle.Bottom;
            displayerControl.DisplayerPanel.Padding = new Padding(BUTTONS_MARGIN - BUTTONS_INTERVAL);
            //
            // displayerControl
            //
            displayerControl.Top    = titleControl.Height;
            displayerControl.Left   = Left;
            displayerControl.Height = Height - titleControl.Height - copyrightControl.Height;
            displayerControl.Width  = Width;
            //
            // buttonMenu
            //
            buttonMenu.Location            = new Point(Width - buttonMenu.Width - BUTTONS_MARGIN, BUTTONS_MARGIN);
            buttonMenu.Image               = icons.Menu;
            buttonMenu.Text                = "Menu";
            buttonMenu.DisplayerText       = "StartPage";//todo
            buttonMenu.DisplayerRequested += buttonMenu_DisplayerRequested;
            buttonMenu.ReflectionType      = ReflectionTypes.DisplayInNew;
            //
            // buttonReload
            //
            buttonReload.Location = new Point(Width - buttonReload.Width - BUTTONS_MARGIN,
                                              BUTTONS_MARGIN + BUTTONS_INTERVAL + buttonReload.Height);
            buttonReload.Image  = icons.Reload;
            buttonReload.Text   = "Reload";
            buttonReload.Click += buttonReload_Click;
            //
            // buttonAddOperator
            //
            buttonAddOperator.Location = new Point(Width - buttonAddOperator.Width - BUTTONS_MARGIN,
                                                   BUTTONS_MARGIN + 2 * (BUTTONS_INTERVAL + buttonAddOperator.Height));
            buttonAddOperator.Image               = icons.Add;
            buttonAddOperator.Text                = "Add Operator";
            buttonAddOperator.DisplayerText       = "Add Operator";
            buttonAddOperator.DisplayerRequested += buttonAddOperator_DisplayerRequested;
            buttonAddOperator.ReflectionType      = ReflectionTypes.DisplayInNew;
            //
            // buttonViewLog
            //
            buttonViewLog.Location = new Point(Width - buttonViewLog.Width - BUTTONS_MARGIN,
                                               BUTTONS_MARGIN + 3 * (BUTTONS_INTERVAL + buttonViewLog.Height));
            buttonViewLog.Image               = icons.ViewLog;
            buttonViewLog.Text                = "View Log";
            buttonViewLog.DisplayerText       = "View Log";
            buttonViewLog.DisplayerRequested += buttonViewLog_DisplayerRequested;
            buttonViewLog.ReflectionType      = ReflectionTypes.DisplayInNew;
            //
            // buttonHelp
            //
            buttonHelp.Location = new Point(Width - buttonHelp.Width - BUTTONS_MARGIN,
                                            BUTTONS_MARGIN + 4 * (BUTTONS_INTERVAL + buttonHelp.Height));
            buttonHelp.Image = icons.Help;
            buttonHelp.Text  = "Help";
            //
            // buttonClose
            //
            buttonClose.Location = new Point(Width - buttonClose.Width - BUTTONS_MARGIN,
                                             BUTTONS_MARGIN + 5 * (BUTTONS_INTERVAL + buttonClose.Height));
            buttonClose.Image          = icons.Close;
            buttonClose.Text           = "Close";
            buttonClose.ReflectionType = ReflectionTypes.CloseSelected;

            Initialize();

            Controls.Add(titleControl);
            Controls.Add(copyrightControl);
            Controls.Add(displayerControl);

            displayerControl.Controls.Add(buttonMenu);
            displayerControl.Controls.Add(buttonReload);
            displayerControl.Controls.Add(buttonAddOperator);
            displayerControl.Controls.Add(buttonViewLog);
            displayerControl.Controls.Add(buttonHelp);
            displayerControl.Controls.Add(buttonClose);

            //WaitingControlReload.Start();
            //WaitingControlReload.Left = Width / 2 - WaitingControlReload.Width / 2;
            //WaitingControlReload.Height = Height / 2 - WaitingControlReload.Height / 2;
            //WaitingControlReload.Visible = false;//todo

            if (!(Users.CurrentUser.Role == UserRole.Administrator) && !(Users.CurrentUser.Role == UserRole.Technician))
            {
                buttonAddOperator.Enabled = false;
            }

            //MessageBox.Show("Ы-ы-ы!");
        }