Esempio n. 1
0
        public MainForm()
        {
            InitializeComponent();

            GuiController.MainForm = this;

            try {
                // Запускаем таймер для отображения часов
                ClockTimer = new System.Threading.Timer(delegate(object s) {
                    try {
                        MainStrip.InvokeIfRequired(() => TimeStripLabel.Text = DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss"));
                    }
                    catch { }
                }, null, 0, 300);

                if (AppHelper.Configuration.RunInFullScreen)
                {
                    this.SwitchFullScreenMode();
                }

                // Начинаем прослушивать COM порт
                AppHelper.ComListener = new ComListener(AppHelper.Configuration.BarcodeScanner.ComPort,
                                                        AppHelper.Configuration.BarcodeScanner.BaudRate);
                AppHelper.ComListener.BarcodeReaded += BarcodeReaded;
                AppHelper.ComListener.Listen();

                // Если смена была ранее открыта, то возобновляем её
                if (!string.IsNullOrEmpty(AppHelper.Configuration.SessionUserName))
                {
                    if (!SessionManager.CreateNewSession(AppHelper.Configuration.SessionUserName))
                    {
                        GuiController.CreateMessage("Не удалось возобновить смену. Проверьте конфигурационный файл", true);
                    }
                    else
                    {
                        GuiController.CreateMessage("Возобновлена смена под пользователем " + SessionManager.WorkerName, false);
                    }
                }

                /*PrivateFontCollection fontCollection = new PrivateFontCollection();
                 * fontCollection.AddFontFile(@".\Fonts\Century-Gothic.ttf");
                 * FontFamily fontFamily = new FontFamily("Century Gothic", fontCollection);
                 * Font = new Font(fontFamily, 8);*/
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Load += (s, e) => GuiController.ExitApplication();
            }
        }
Esempio n. 2
0
        private void BarcodeReaded(string code)
        {
            try {
                GuiController.CreateMessage("", false);

                long lCode = long.Parse(code);
                if (ActionsHelper.IsServiceCode(lCode) && GuiController.IsMainActionsAllowed)
                {
                    GuiController.InvokeAssociatedCallback(code);
                }
                else
                {
                    if (lCode >= GuiController.START_RANGE && lCode <= GuiController.END_RANGE)
                    {
                        GuiController.InvokeAssociatedCallback(code);
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }