Esempio n. 1
0
 public TunableButton()
 {
     Click += (sender, args) =>
     {
         ServiceCommand?.Invoke(this, new CommandEventArgs {
             Command = _command
         });
     };
 }
Esempio n. 2
0
        protected override void OnDoubleClick(EventArgs e)
        {
            base.OnDoubleClick(e);

            if (null == CurrentEntity)
            {
                return;
            }

            ServiceCommand?.Invoke(this,
                                   new CommandEventArgs {
                Command = CellMouseDoubleClickCommandName, Argument = CurrentEntity
            });
        }
Esempio n. 3
0
        public TunableList()
        {
            _container = new Container();

            // TunableMenu
            var commandMenu = new TunableMenu(_container)
            {
                MenuItemResolver = (entity, command) => null == MenuItemResolver ||
                                   MenuItemResolver(CurrentEntity, command)
            };

            commandMenu.ServiceCommand += (sender, args) =>
            {
                if (null == CurrentEntity)
                {
                    return;
                }

                ServiceCommand?.Invoke(this,
                                       new CommandEventArgs {
                    Command = args.Command, Argument = CurrentEntity
                });
            };

            commandMenu.Opening += (sender, args) =>
            {
                if (!_isCommandMenuAllowed)
                {
                    args.Cancel = true;
                    return;
                }

                _isCommandMenuAllowed = false;
            };

            _commandMenu = commandMenu;

            // ImageList
            _imageList            = new ImageList(_container);
            _imageList.ColorDepth = ColorDepth.Depth32Bit;

            // OwnerDraw
            DrawColumnHeader += OnDrawColumnHeader;
            DrawItem         += (sender, args) => args.DrawDefault = true;
            DrawSubItem      += (sender, args) => args.DrawDefault = true;
            ColumnClick      += OnColumnClick;

            InitializeComponent();
        }
        private void OnMenuItemClick(object sender, EventArgs e)
        {
            var toolStripItem = sender as ToolStripItem;

            var commandText = toolStripItem?.Tag as string;

            if (commandText == null)
            {
                return;
            }

            ServiceCommand?.Invoke(this, new CommandEventArgs {
                Command = commandText
            });
        }
Esempio n. 5
0
        public void ApplyTemplate(CertificateFormTemplate template)
        {
            if (null == template)
            {
                throw new ArgumentNullException(nameof(template));
            }

            if (null == template.CertificateRecordList)
            {
                throw new BadTemplateException("null == template.CertificateRecordList");
            }

            if (null == template.AttachedIdentifierList)
            {
                throw new BadTemplateException("null == template.AttachedIdentifierList");
            }

            certificateTunableList.ApplyTemplate(template.CertificateRecordList);
            attachedIdentifierTunableList.ApplyTemplate(template.AttachedIdentifierList);

            // Command buttons
            if (template.CommandButtons.Count > 0)
            {
                commandBarFlowLayoutPanel.SuspendLayout(); // SuspendLayout

                foreach (var buttonTemplate in template.CommandButtons)
                {
                    var button = new TunableButton
                    {
                        Width = 139
                    };

                    button.ApplyTemplate(buttonTemplate);
                    button.ServiceCommand += (sender, args) => ServiceCommand?.Invoke(sender, args);

                    commandBarFlowLayoutPanel.Controls.Add(button);
                }

                commandBarFlowLayoutPanel.ResumeLayout(); // ResumeLayout

                commandBarGroupBox.Visible = true;
            }
            else
            {
                commandBarGroupBox.Visible = false;
            }
        }
Esempio n. 6
0
        public void ApplyTemplate <TColumnTemplate>(SubmitFormTemplate <TColumnTemplate> template,
                                                    Dictionary <string, object> values = null)
            where TColumnTemplate : class, IShapeColumnTemplate
        {
            if (null == template)
            {
                throw new ArgumentNullException(nameof(template));
            }

            Reset();

            _templateName          = template.TemplateName;
            _templateBaseDirectory = template.BaseDirectory;

            Text = template.Text ?? throw new BadTemplateException("null == template.Text");

            foreach (var stepTemplate in template.Steps)
            {
                if (null == stepTemplate.TunableShape)
                {
                    throw new BadTemplateException("null == stepTemplate.TunableShape");
                }

                var tunableShape = new TunableShape
                {
                    Top    = 0,
                    Left   = 0,
                    Margin = new Padding(0, 0, 0, 0)
                };

                tunableShape.ApplyTemplate(stepTemplate.TunableShape);

                tunableShape.ServiceCommand += (sender, args) =>
                {
                    ServiceCommand?.Invoke(sender, args);
                };

                _steps.Add(new Step(tunableShape, stepTemplate.ActionText));
            }

            ApplyShape(values);

            previousButton.Visible = false;
        }
Esempio n. 7
0
        public CertificateForm(SessionContext context)
        {
            if (null == context)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _formattingService = context.UnityContainer.Resolve <IFormattingService>();

            InitializeComponent();

            certificateTunableList.ServiceCommand += (sender, args) =>
            {
                ServiceCommand?.Invoke(sender, args);
            };

            attachedIdentifierTunableList.ServiceCommand += (sender, args) =>
            {
                ServiceCommand?.Invoke(sender, args);
            };
        }
        public void ApplyTemplate <TColumnTemplate>(GroupBoxTemplate <TColumnTemplate> template)
            where TColumnTemplate : class, IShapeColumnTemplate
        {
            if (null == template)
            {
                throw new ArgumentNullException(nameof(template));
            }

            Reset();

            Text         = template.Desc;
            AutoSize     = true;
            AutoSizeMode = AutoSizeMode.GrowAndShrink;

            if (null != template.Name)
            {
                Name = template.Name;
            }

            var innerControlWidth = template.ControlWidth -
                                    (Padding.Left + Padding.Right + ControlTemplate.ControlMargin +
                                     ControlTemplate.ControlMargin);

            // Корректировка шаблонов вложенных элементов (устанавливаем ширину).
            foreach (var controlTemplate in template.Column.Controls)
            {
                controlTemplate.ControlWidth = innerControlWidth;
            }

            var controlHolders = ControlHolderHelper.BuildControlHolders(template.Column.Controls);

            var tunableShape = new TunableShape
            {
                AutoSize     = true,
                AutoSizeMode = AutoSizeMode.GrowAndShrink,
                Location     = new Point(DisplayRectangle.Location.X, DisplayRectangle.Location.Y)
            };

            tunableShape.BuildSingleColumn(controlHolders);

            SuspendLayout();
            Controls.Add(tunableShape);
            ResumeLayout();

            _controlHolders.AddRange(controlHolders);

            foreach (var controlHolder in ControlHolders)
            {
                var serviceControl = controlHolder.Control as IServiceControl;

                if (null == serviceControl)
                {
                    continue;
                }

                serviceControl.ServiceCommand += (sender, args) =>
                {
                    ServiceCommand?.Invoke(serviceControl, args);
                };
            }
        }