private void AddControl(IEditorControl ctl, string expression)
        {
            Control newControl = ControlFactory.CreateEditorControl(Controller, ctl.ControlType);

            stackPanel.Children.Add(newControl);

            newControl.VerticalAlignment = VerticalAlignment.Top;
            if (newControl is LabelControl)
            {
                newControl.Padding = new Thickness(3, 3, 3, 0);
            }
            else
            {
                newControl.Padding = new Thickness(3, 0, 3, 0);
            }

            IElementEditorControl elementEditor = newControl as IElementEditorControl;

            if (elementEditor != null)
            {
                elementEditor.Helper.DoInitialise(Controller, ctl);
                elementEditor.Populate(m_data);
                elementEditor.Helper.Dirty += SubControl_Dirty;
                elementEditor.Helper.RequestParentElementEditorSave += SubControl_RequestParentElementEditorSave;
                m_controls.Add(elementEditor);
            }
        }
Example #2
0
        private Control InitialiseEditorControl(string controlType)
        {
            Control newControl = ControlFactory.CreateEditorControl(m_controller, controlType);

            newControl.Margin = new Thickness(0, 8, 0, 0);
            return((Control)newControl);
        }
Example #3
0
        private Control InitialiseEditorControl(IEditorControl ctl)
        {
            Control newControl = ControlFactory.CreateEditorControl(m_controller, ctl.ControlType);

            IElementEditorControl newElementEditorControl = newControl as IElementEditorControl;

            if (newElementEditorControl != null)
            {
                m_controls.Add(newElementEditorControl);
                newElementEditorControl.Helper.Dirty += Control_Dirty;
                newElementEditorControl.Helper.RequestParentElementEditorSave += Control_RequestParentElementEditorSave;
                newElementEditorControl.Helper.DoInitialise(m_controller, ctl);
            }

            return((Control)newControl);
        }
Example #4
0
        private void AddScriptControls(ListBoxItem listItem, Grid parentGrid, IEditableScript script)
        {
            IEditorDefinition definition = m_controller.GetEditorDefinition(script);
            IEditorData       data       = m_controller.GetScriptEditorData(script);

            data.ReadOnly = m_readOnly;
            Grid grid = NewScriptControlGrid(parentGrid);

            foreach (IEditorControl ctl in definition.Controls)
            {
                bool   isFullWidthControl = false;
                string controlType        = ctl.ControlType;
                if (ctl.ControlType == "script")
                {
                    controlType        = "scriptexpander";
                    isFullWidthControl = true;
                }
                if (ctl.ControlType == "scriptdictionary" || ctl.ControlType == "list" || ctl.Expand)
                {
                    isFullWidthControl = true;
                }
                Control newControl = ControlFactory.CreateEditorControl(m_controller, controlType);
                newControl.VerticalAlignment = VerticalAlignment.Top;
                if (newControl is LabelControl)
                {
                    newControl.Padding = new Thickness(3, 6, 3, 3);
                }
                else
                {
                    newControl.Padding = new Thickness(3);
                }

                if (isFullWidthControl)
                {
                    newControl.HorizontalAlignment = HorizontalAlignment.Stretch;
                }

                if (ctl.GetBool("breakbefore"))
                {
                    // Create a "line break" by putting this and subsequent controls in a new horizontal grid,
                    // underneath the previous one. We're using a grid instead of a StackPanel as script expanders
                    // won't take the full width of the list otherwise.
                    grid = NewScriptControlGrid(parentGrid);

                    // Indent the new line
                    newControl.Padding = new Thickness(newControl.Padding.Left + 20, newControl.Padding.Top, newControl.Padding.Right, newControl.Padding.Bottom);
                }

                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, isFullWidthControl ? GridUnitType.Star : GridUnitType.Auto)
                });
                Grid.SetColumn(newControl, grid.ColumnDefinitions.Count - 1);
                grid.Children.Add(newControl);

                IElementEditorControl editorCtl = newControl as IElementEditorControl;
                if (editorCtl != null)
                {
                    AddEditorControl(editorCtl, listItem, ctl);
                    editorCtl.Populate(data);
                    AddToScriptParameterControlMap(script, ctl.Attribute, editorCtl);
                }
            }
        }