Пример #1
0
        private void UninitialiseSimpleEditor()
        {
            TextBox textBox = m_simpleEditor as TextBox;

            if (textBox != null)
            {
                textBox.TextChanged -= SimpleEditor_TextChanged;
                textBox.LostFocus   -= SimpleEditor_LostFocus;
            }

            FileControl fileControl = m_simpleEditor as FileControl;

            if (fileControl != null)
            {
                fileControl.Helper.DoUninitialise();
                fileControl.Helper.Dirty     -= SimpleEditor_Dirty;
                fileControl.SelectionChanged -= FileControl_SelectionChanged;
            }

            DropDownObjectsControl dropDownObjects = m_simpleEditor as DropDownObjectsControl;

            if (dropDownObjects != null)
            {
                dropDownObjects.Helper.DoUninitialise();
                dropDownObjects.Helper.Dirty -= SimpleEditor_Dirty;
                dropDownObjects.lstDropdown.SelectionChanged -= DropDownObjects_SelectionChanged;
            }

            NumberControl number = m_simpleEditor as NumberControl;

            if (number != null)
            {
                number.Helper.DoUninitialise();
                number.Helper.Dirty -= SimpleEditor_Dirty;
                number.LostFocus    -= SimpleEditor_LostFocus;
            }

            NumberDoubleControl numberDouble = m_simpleEditor as NumberDoubleControl;

            if (numberDouble != null)
            {
                numberDouble.Helper.DoUninitialise();
                numberDouble.Helper.Dirty -= SimpleEditor_Dirty;
                numberDouble.LostFocus    -= SimpleEditor_LostFocus;
            }

            DropDownControl dropDown = m_simpleEditor as DropDownControl;

            if (dropDown != null)
            {
                dropDown.Helper.DoUninitialise();
                dropDown.Helper.Dirty -= SimpleEditor_Dirty;
                dropDown.lstDropdown.SelectionChanged -= DropDown_SelectionChanged;
                dropDown.LostFocus -= SimpleEditor_LostFocus;
            }
        }
Пример #2
0
        private void InitialiseSimpleEditor()
        {
            string simpleEditor = m_helper.ControlDefinition.GetString("simpleeditor") ?? "textbox";

            m_updatingList = true;

            switch (simpleEditor)
            {
            case "textbox":
                TextBox newTextBox = new TextBox();
                newTextBox.MinHeight = 20;
                newTextBox.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
                newTextBox.TextChanged += SimpleEditor_TextChanged;
                newTextBox.LostFocus   += SimpleEditor_LostFocus;
                if (m_helper.ControlDefinition.GetBool("multiline"))
                {
                    newTextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                    newTextBox.TextWrapping  = TextWrapping.Wrap;
                    newTextBox.AcceptsReturn = true;
                }
                m_simpleEditor = newTextBox;
                break;

            case "file":
                FileControl newFileControl = new FileControl();
                newFileControl.Helper.DoInitialise(m_helper.Controller, m_helper.ControlDefinition);
                newFileControl.RefreshFileList();
                newFileControl.Helper.Dirty     += SimpleEditor_Dirty;
                newFileControl.SelectionChanged += FileControl_SelectionChanged;
                m_simpleEditor = newFileControl;
                break;

            case "boolean":
                m_simpleEditor = null;
                lstType.Items.Add("yes");
                lstType.Items.Add("no");
                m_booleanEditor = true;
                break;

            case "objects":
                DropDownObjectsControl newDropDownObjects = new DropDownObjectsControl();
                newDropDownObjects.Helper.DoInitialise(m_helper.Controller, m_helper.ControlDefinition);
                newDropDownObjects.Helper.Dirty += SimpleEditor_Dirty;
                newDropDownObjects.lstDropdown.SelectionChanged += DropDownObjects_SelectionChanged;
                m_simpleEditor = newDropDownObjects;
                break;

            case "number":
                NumberControl newNumber = new NumberControl();
                newNumber.Helper.DoInitialise(m_helper.Controller, m_helper.ControlDefinition);
                newNumber.Helper.Dirty += SimpleEditor_Dirty;
                newNumber.LostFocus    += SimpleEditor_LostFocus;
                m_simpleEditor          = newNumber;
                break;

            case "numberdouble":
                NumberDoubleControl newNumberDouble = new NumberDoubleControl();
                newNumberDouble.Helper.DoInitialise(m_helper.Controller, m_helper.ControlDefinition);
                newNumberDouble.Helper.Dirty += SimpleEditor_Dirty;
                newNumberDouble.LostFocus    += SimpleEditor_LostFocus;
                m_simpleEditor = newNumberDouble;
                break;

            case "dropdown":
                DropDownControl newDropDown = new DropDownControl();
                newDropDown.Helper.DoInitialise(m_helper.Controller, m_helper.ControlDefinition);
                newDropDown.Helper.Dirty += SimpleEditor_Dirty;
                newDropDown.lstDropdown.SelectionChanged += DropDown_SelectionChanged;
                newDropDown.LostFocus += SimpleEditor_LostFocus;
                m_simpleEditor         = newDropDown;
                break;

            default:
                throw new InvalidOperationException("Invalid control type for expression");
            }

            if (m_simpleEditor != null)
            {
                m_simpleEditor.MinWidth = 40;
                Grid.SetRow(m_simpleEditor, Grid.GetRow(txtExpression));
                Grid.SetColumn(m_simpleEditor, Grid.GetColumn(txtExpression));
                grid.Children.Add(m_simpleEditor);
            }

            if (m_simpleEditor != null)
            {
                lstType.Items.Add(m_helper.ControlDefinition.GetString("simple"));
            }
            lstType.Items.Add("expression");
            m_updatingList = false;
        }
Пример #3
0
        private void InitialiseSimpleEditor()
        {
            string simpleEditor = m_helper.ControlDefinition.GetString("simpleeditor") ?? "textbox";

            m_updatingList = true;

            switch (simpleEditor)
            {
                case "textbox":
                    TextBox newTextBox = new TextBox();
                    newTextBox.MinHeight = 20;
                    newTextBox.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
                    newTextBox.TextChanged += SimpleEditor_TextChanged;
                    newTextBox.LostFocus += SimpleEditor_LostFocus;
                    if (m_helper.ControlDefinition.GetBool("multiline"))
                    {
                        newTextBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                        newTextBox.TextWrapping = TextWrapping.Wrap;
                        newTextBox.AcceptsReturn = true;
                    }
                    m_simpleEditor = newTextBox;
                    break;
                case "file":
                    FileControl newFileControl = new FileControl();
                    newFileControl.Helper.DoInitialise(m_helper.Controller, m_helper.ControlDefinition);
                    newFileControl.RefreshFileList();
                    newFileControl.Helper.Dirty += SimpleEditor_Dirty;
                    newFileControl.SelectionChanged += FileControl_SelectionChanged;
                    m_simpleEditor = newFileControl;
                    break;
                case "boolean":
                    m_simpleEditor = null;
                    lstType.Items.Add("yes");
                    lstType.Items.Add("no");
                    m_booleanEditor = true;
                    break;
                case "objects":
                    DropDownObjectsControl newDropDownObjects = new DropDownObjectsControl();
                    newDropDownObjects.Helper.DoInitialise(m_helper.Controller, m_helper.ControlDefinition);
                    newDropDownObjects.Helper.Dirty += SimpleEditor_Dirty;
                    newDropDownObjects.lstDropdown.SelectionChanged += DropDownObjects_SelectionChanged;
                    m_simpleEditor = newDropDownObjects;
                    break;
                case "number":
                    NumberControl newNumber = new NumberControl();
                    newNumber.Helper.DoInitialise(m_helper.Controller, m_helper.ControlDefinition);
                    newNumber.Helper.Dirty += SimpleEditor_Dirty;
                    newNumber.LostFocus += SimpleEditor_LostFocus;
                    m_simpleEditor = newNumber;
                    break;
                case "numberdouble":
                    NumberDoubleControl newNumberDouble = new NumberDoubleControl();
                    newNumberDouble.Helper.DoInitialise(m_helper.Controller, m_helper.ControlDefinition);
                    newNumberDouble.Helper.Dirty += SimpleEditor_Dirty;
                    newNumberDouble.LostFocus += SimpleEditor_LostFocus;
                    m_simpleEditor = newNumberDouble;
                    break;
                case "dropdown":
                    DropDownControl newDropDown = new DropDownControl();
                    newDropDown.Helper.DoInitialise(m_helper.Controller, m_helper.ControlDefinition);
                    newDropDown.Helper.Dirty += SimpleEditor_Dirty;
                    newDropDown.lstDropdown.SelectionChanged += DropDown_SelectionChanged;
                    newDropDown.LostFocus += SimpleEditor_LostFocus;
                    m_simpleEditor = newDropDown;
                    break;
                default:
                    throw new InvalidOperationException("Invalid control type for expression");
            }

            if (m_simpleEditor != null)
            {
                m_simpleEditor.MinWidth = 40;
                Grid.SetRow(m_simpleEditor, Grid.GetRow(txtExpression));
                Grid.SetColumn(m_simpleEditor, Grid.GetColumn(txtExpression));
                grid.Children.Add(m_simpleEditor);
            }

            if (m_simpleEditor != null)
            {
                lstType.Items.Add(m_helper.ControlDefinition.GetString("simple"));
            }
            lstType.Items.Add("expression");
            m_updatingList = false;
        }