Пример #1
0
        private async Task RefreshModule(int modulenumber)
        {
            try
            {
                ModuleInformation moduleInformation = await _moduleManager.ReadModuleInformation(_deviceSpecification,
                                                                                                 Convert.ToByte(_deviceNumberTextBox.Text), modulenumber);

                if (_deviceSpecification.ControlType == ControlType.MRTYPE)
                {
                    MrModuleControl control = _panelControl.Controls[modulenumber] as MrModuleControl;
                    control.Information = moduleInformation;
                }
                else
                {
                    ModuleControl control = _panelControl.Controls[modulenumber] as ModuleControl;
                    control.Information = moduleInformation;
                }
            }
            catch (Exception e)
            {
                MessageErrorBox message = new MessageErrorBox(e.Message, "Не удалось прочитать информацию о модуле");
                message.ShowErrorMessageForm();
                _panelControl.Controls.Remove(_panelControl.Controls[modulenumber]);
            }
        }
Пример #2
0
        private async Task SetMrModuleControl()
        {
            _panelControl.Controls.Clear();
            int y = 0;

            try
            {
                for (int i = 0; i < _deviceSpecification.ModulesCount; i++)
                {
                    MrModuleControl   control           = new MrModuleControl();
                    ModuleInformation moduleInformation = await _moduleManager.ReadModuleInformation(_deviceSpecification, Convert.ToByte(_deviceNumberTextBox.Text), i);

                    control.Information = moduleInformation;
                    control.Anchor      = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top);
                    control.TypeModule  = _deviceSpecification.ModuleTypes[i];
                    control.Location    = new Point(0, y);
                    control.Width       = _panelControl.Width;
                    _panelControl.Controls.Add(control);
                    y = y + control.Height;
                    (control as IModuleControlInerface).NeedRefreshAction += (j) =>
                    {
                        RefreshModule(j);
                    };
                }
            }
            catch (Exception e)
            {
                MessageErrorBox message = new MessageErrorBox(e.Message, "Не удалось прочитать информацию о модулях");
                message.ShowErrorMessageForm();
            }
        }