コード例 #1
0
        private void AddComboBox()
        {
            TControl comboBox = null;

            comboBox = new TControl(drawWindow1, () => new RectangleF(IndexOfCombo(comboBox) * (COMBO_WIDTH + drawWindow1.Height), 0, COMBO_WIDTH, drawWindow1.Height), true, m_comboBoxItems, Fonts.Default);
            comboBox.RequestedAreaChanged += () =>
            {
                MinimumSize      = new Size(0, (int)comboBox.RequestedArea.Height);
                Size             = m_comboBoxes.Select(b => b.RequestedArea.ToSize()).Aggregate(Size.Empty, (a, b) => new Size(a.Width + COMBO_WIDTH + drawWindow1.Height, Math.Max(a.Height, b.Height)));
                drawWindow1.Size = Size; //This should not be necessary, due to docking, but for some reason is.
            };

            comboBox.RegisterCallbacks(m_focusProvider, drawWindow1);
            m_focusProvider.LastFocused = comboBox;

            comboBox.SelectionChanged += () => SelectionChanged(comboBox);

            if (Scheme != null)
            {
                SetupColors(Scheme, comboBox);
            }

            //comboBox.EnterPressed += () => { Ok.Execute(); };
            m_comboBoxes.Add(comboBox);
            Size             = m_comboBoxes.Select(b => b.RequestedArea.ToSize()).Aggregate(Size.Empty, (a, b) => new Size(a.Width + COMBO_WIDTH + drawWindow1.Height, Math.Max(a.Height, b.Height)));
            drawWindow1.Size = Size; //This should not be necessary, due to docking, but for some reason is.

            if (m_comboBoxes.Count > 1)
            {
                int         i      = m_comboBoxes.Count - 2;
                CrossButton button = null;
                try
                {
                    button = new CrossButton(() => new RectangleF(i * (COMBO_WIDTH + drawWindow1.Height) + COMBO_WIDTH, 0, drawWindow1.Height, drawWindow1.Height), () => { Remove(i); }, Scheme.ControlBorder, Scheme.BackgroundBrush);
                    button.RegisterCallbacks(m_focusProvider, drawWindow1);
                    m_buttons.Add(button);
                    button = null;
                }
                finally
                {
                    if (button != null)
                    {
                        button.Dispose();
                    }
                }
            }
        }
コード例 #2
0
        public UnknownParameterEditor()
        {
            InitializeComponent();

            const int BUTTON_SIZE = 16;

            m_textBox = new MyTextBox(drawWindow1, () => new RectangleF(0, 0, drawWindow1.Width - BUTTON_SIZE, Math.Max(BUTTON_SIZE, drawWindow1.Height)), MyTextBox.InputFormEnum.None, null, x => MyTextBox.TextBoxBorderDaniel, 4, Fonts.Default);
            m_textBox.RequestedAreaChanged += () =>
            {
                //Draw window is the whole control so we can just modify the control
                MinimumSize = new Size(BUTTON_SIZE, (int)m_textBox.RequestedArea.Height);
                Size size = m_textBox.RequestedArea.ToSize();
                size.Width += BUTTON_SIZE;
                Size        = size;
            };
            m_textBox.RegisterCallbacks(this, drawWindow1);
            //MyTextBox.SetupCallbacks(drawWindow1, m_textBox);

            m_button = new CrossButton(() => new RectangleF(drawWindow1.Width - BUTTON_SIZE, (drawWindow1.Height - BUTTON_SIZE) / 2, BUTTON_SIZE, BUTTON_SIZE), () => { Remove.Execute(); m_remove = true; }, Pens.Magenta, Brushes.Magenta);
            m_button.RegisterCallbacks(this, drawWindow1);

            LastFocused = m_textBox;
        }