/// <summary>
        /// Загружает контент главной страницы
        /// </summary>
        public void LoadMainPage()
        {
            ContentLayoutPanel.Controls.Clear();

            GuiController.ControlCallback callback = delegate(string code) {
                ContentLayoutPanel.Controls.Clear();
                LinearButton sender = (LinearButton)GuiController.GetAssociatedControl(code);
                LoadContentPage?.Invoke(this, sender.GetCustomData <char[]>());
            };

            List <LinearButton> buttons = new List <LinearButton>();
            int index = 0;

            foreach (char[] words in alphabet)
            {
                LinearButton button = new LinearButton();
                button.ButtonText = string.Join("", words).ToUpper();

                button.Barcode         = button.RegisterControl(callback);
                button.ButtonBackColor = Color.DarkSeaGreen;
                button.Anchor          = AnchorStyles.Left | AnchorStyles.Top;
                button.CompactMode     = true;
                button.FontSize        = 9.25F;
                button.TabIndex        = index;
                button.Margin          = new Padding(0, 0, ContentMargins, ContentMargins);

                button.SetCustomData(alphabet[index]);

                buttons.Add(button);
                index++;
            }
            ContentLayoutPanel.Controls.AddRange(buttons.ToArray());
        }
Beispiel #2
0
        public UserSelect()
        {
            try {
                InitializeComponent();

                GuiController.IsMainActionsAllowed = false;

                CloseTabButton.Barcode = CloseTabButton.RegisterControl((c) => this.NavigateToMainPage());
                GuiController.ControlCallback SessionCallback = delegate(string code) {
                    string workerName = GuiController.GetAssociatedControl(code).GetCustomData <string>();
                    if (SessionManager.CreateNewSession(workerName))
                    {
                        GuiController.CreateMessage("Смена открыта под пользователем " + workerName, false);
                    }
                    else
                    {
                        GuiController.CreateMessage("Не удалось открыть смену. Проверьте конфигурационный файл", true);
                    }
                    this.NavigateToMainPage();
                };

                List <LinearButton> buttons = new List <LinearButton>();
                int index = 0;
                foreach (string user in AppHelper.Configuration.Users)
                {
                    LinearButton button = new LinearButton();
                    button.ButtonText      = user;
                    button.ButtonBackColor = Color.DimGray;
                    button.Image           = Properties.Resources.sad_64;
                    button.Barcode         = button.RegisterControl(SessionCallback);
                    button.Anchor          = AnchorStyles.Left | AnchorStyles.Top;
                    button.Height          = ContentHeight;
                    button.Width           = ContentWidth;
                    button.TabIndex        = index;
                    button.Margin          = new Padding(ContentMargins, ContentMargins, 0, 0);
                    button.SetCustomData(user);

                    buttons.Add(button);
                    index++;
                }
                ContentLayoutPanel.Controls.AddRange(buttons.ToArray());
            }
            catch (Exception ex) {
                GuiController.IsMainActionsAllowed = true;
                MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        public AddNewCartridge()
        {
            GuiController.IsMainActionsAllowed = false;

            InitializeComponent();

            Disposed += (s, e) => AppHelper.ComListener.BarcodeReaded -= CartridgeCodeReaded;
            AppHelper.ComListener.BarcodeReaded += CartridgeCodeReaded;
            DateBox.Text   = DateTime.Now.ToString("dd.MM.yyyy");
            WorkerBox.Text = SessionManager.WorkerName;

            CloseTabButton.Barcode = CloseTabButton.RegisterControl((c) => this.NavigateToMainPage());

            SaveButton.Barcode = SaveButton.RegisterControl((c) => this.NavigateToMainPage());

            GuiController.ControlCallback SessionCallback = delegate(string code) {
                ICodeButton sender = GuiController.GetAssociatedControl(code);
                sender.Checked = !sender.Checked;
            };

            string[]            types   = DatabaseHelper.GetCartridgeTypes().ToArray();
            List <LinearButton> buttons = new List <LinearButton>();
            int index = 0;

            foreach (string type in types)
            {
                LinearButton button = new LinearButton();
                button.ButtonText  = type;
                button.Barcode     = button.RegisterControl(SessionCallback);
                button.Anchor      = AnchorStyles.Left | AnchorStyles.Top;
                button.CompactMode = true;
                button.TabIndex    = index;
                button.Margin      = new Padding(0, 0, 0, ContentMargins);
                button.SetCustomData(type);

                buttons.Add(button);
                index++;
            }
            TypeLayoutPanel.Controls.AddRange(buttons.ToArray());

            string[] models = DatabaseHelper.GetCartridgeModels().ToArray();
            buttons = new List <LinearButton>();
            index   = 0;
            foreach (string model in models)
            {
                LinearButton button = new LinearButton();
                button.ButtonText  = model;
                button.Barcode     = button.RegisterControl(SessionCallback);
                button.Anchor      = AnchorStyles.Left | AnchorStyles.Top;
                button.CompactMode = true;
                button.TabIndex    = index;
                button.Margin      = new Padding(0, 0, ContentMargins, ContentMargins);
                button.SetCustomData(model);

                buttons.Add(button);
                index++;
            }
            ModelsLayoutPanel.Controls.AddRange(buttons.ToArray());

            LocationsBox.LoadContentPage += delegate(AlphabetBox sender, char[] words) {
                string[] locations = DatabaseHelper.GetCartridgeLocations().ToArray();
                locations = locations.Where(x => words.Contains(char.ToLowerInvariant(x.First()))).ToArray();
                buttons   = new List <LinearButton>();
                index     = 0;
                foreach (string location in locations)
                {
                    LinearButton button = new LinearButton();
                    button.ButtonText  = location;
                    button.Barcode     = button.RegisterControl(SessionCallback);
                    button.Anchor      = AnchorStyles.Left | AnchorStyles.Top;
                    button.CompactMode = true;
                    button.TabIndex    = index;
                    button.Margin      = new Padding(0, 0, ContentMargins, ContentMargins);
                    button.SetCustomData(location);

                    buttons.Add(button);
                    index++;
                }
                LinearButton backButton = new LinearButton();
                backButton.ButtonText      = "Вернуться назад";
                backButton.Image           = Properties.Resources.back_64;
                backButton.Barcode         = backButton.RegisterControl((c) => sender.LoadMainPage());
                backButton.ButtonBackColor = Color.LightSkyBlue;
                backButton.Anchor          = AnchorStyles.Left | AnchorStyles.Top;
                backButton.CompactMode     = true;
                backButton.FontSize        = 9.25F;
                backButton.TabIndex        = index;
                backButton.Margin          = new Padding(0, 0, ContentMargins, ContentMargins);
                buttons.Add(backButton);

                sender.ContentControls.AddRange(buttons.ToArray());
            };
        }