示例#1
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;
        }
示例#2
0
 public Step(TunableShape shape, string actionText)
 {
     Shape      = shape;
     ActionText = actionText;
 }
        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);
                };
            }
        }