コード例 #1
0
        private void AddScript(IEditableScript script)
        {
            ListBoxItem newItem = new ListBoxItem {
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            // a DockPanel is used as the ItemsPanel, so that when nested Expanders are collapsed,
            // they don't leave a blank space
            DockPanel.SetDock(newItem, Dock.Top);
            lstScripts.Items.Add(newItem);

            if (script.Type != ScriptType.If)
            {
                Grid parentGrid = new Grid();
                parentGrid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                parentGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
                newItem.Content = parentGrid;

                AddScriptControls(newItem, parentGrid, script);
            }
            else
            {
                IfEditor newIfEditor = new IfEditor
                {
                    Padding             = new Thickness(3),
                    HorizontalAlignment = HorizontalAlignment.Stretch
                };
                AddEditorControl(newIfEditor, newItem, null);
                newItem.Content      = newIfEditor;
                newIfEditor.ReadOnly = m_readOnly;
                newIfEditor.Populate((EditableIfScript)script);

                // Ensure the expression responds to updates e.g. from undo/redo. The nested scripts will take
                // care of themselves.
                // TO DO: This isn't particularly efficient, as when m_scripts_Updated is triggered it repopulates
                // the entire "if" script when an if/elseif expression changes. It should only need to update the
                // changed expression.
                AddToScriptParameterControlMap(script, "0", newIfEditor);
            }
        }
コード例 #2
0
        private void AddScript(IEditableScript script)
        {
            ListBoxItem newItem = new ListBoxItem {HorizontalAlignment = HorizontalAlignment.Stretch};

            // a DockPanel is used as the ItemsPanel, so that when nested Expanders are collapsed,
            // they don't leave a blank space
            DockPanel.SetDock(newItem, Dock.Top);
            lstScripts.Items.Add(newItem);

            if (script.Type != ScriptType.If)
            {
                Grid parentGrid = new Grid();
                parentGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
                parentGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
                newItem.Content = parentGrid;

                AddScriptControls(newItem, parentGrid, script);
            }
            else
            {
                IfEditor newIfEditor = new IfEditor
                {
                    Padding = new Thickness(3),
                    HorizontalAlignment = HorizontalAlignment.Stretch
                };
                AddEditorControl(newIfEditor, newItem, null);
                newItem.Content = newIfEditor;
                newIfEditor.ReadOnly = m_readOnly;
                newIfEditor.Populate((EditableIfScript)script);

                // Ensure the expression responds to updates e.g. from undo/redo. The nested scripts will take
                // care of themselves.
                // TO DO: This isn't particularly efficient, as when m_scripts_Updated is triggered it repopulates
                // the entire "if" script when an if/elseif expression changes. It should only need to update the
                // changed expression.
                AddToScriptParameterControlMap(script, "0", newIfEditor);
            }
        }