Exemple #1
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);
        }
Exemple #2
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);
                }
            }
        }