Exemple #1
0
        public IntegerTypeEditor()
        {
            InitializeComponent();

            using (Graphics g = CreateGraphics())
            {
                var textSize = g.MeasureString(TEXT, Font);
                m_textHeight        = textSize.Height;
                m_textWidth         = textSize.Width;
                m_minLabelWidth     = MyMath.Ceiling(g.MeasureString(MIN_LABEL, Font).Width);
                m_maxLabelWidth     = MyMath.Ceiling(g.MeasureString(MAX_LABEL, Font).Width);
                m_defaultLabelWidth = MyMath.Ceiling(g.MeasureString(DEFAULT_LABEL, Font).Width);
            }

            m_name = new MyTextBox(drawWindow1, NameArea, MyTextBox.InputFormEnum.Text);
            m_name.Colors.BorderPen      = Colors.ControlBorder;
            m_name.RequestedAreaChanged += ResetSize;

            m_min = new MyNumericUpDown <int>(drawWindow1, MinNumericArea, false);
            m_min.RequestedAreaChanged += ResetSize;
            m_min.Colors.BorderPen      = Colors.ControlBorder;
            m_min.Minimum = int.MinValue;
            m_min.Maximum = int.MaxValue;

            m_max = new MyNumericUpDown <int>(drawWindow1, MaxNumericArea, false);
            m_max.RequestedAreaChanged += ResetSize;
            m_max.Colors.BorderPen      = Colors.ControlBorder;
            m_max.Minimum = int.MinValue;
            m_max.Maximum = int.MaxValue;

            m_default = new MyNumericUpDown <int>(drawWindow1, DefaultNumericArea, false);
            m_default.RequestedAreaChanged += ResetSize;
            m_default.Colors.BorderPen      = Colors.ControlBorder;
            m_default.Minimum = int.MinValue;
            m_default.Maximum = int.MaxValue;

            drawWindow1.MouseDown += (a, args) => drawWindow1.Focus(); //TODO: is this redundant?
            drawWindow1.Paint     += (a, args) => Paint(args.Graphics);
            drawWindow1.GotFocus  += (a, b) => { forwardTab.TabStop = false; backwardTab.TabStop = false; };
            forwardTab.GotFocus   += (a, b) => { MyControls.ForwardFocus(); drawWindow1.Focus(); };  //Focus draw window so we dont keep giving focus to forwardTab
            backwardTab.GotFocus  += (a, b) => { MyControls.BackwardFocus(); drawWindow1.Focus(); }; //Focus draw window so we dont keep giving focus to backwardTab

            this.Leave += (a, b) => { forwardTab.TabStop = true; backwardTab.TabStop = true; };

            forwardTab.Size     = Size.Empty;
            forwardTab.Location = new Point(-1, -1);

            backwardTab.Size     = Size.Empty;
            backwardTab.Location = new Point(-1, -1);

            MyControls = new ControlSet(m_name, m_min, m_max, m_default);
            MyControls.RegisterCallbacks(drawWindow1);

            ResetSize();
        }
        public DefaultIntegerEditor()
        {
            InitializeComponent();

            m_numericUpDown = new MyNumericUpDown <int>(drawWindow1, () => new RectangleF(0, 0, drawWindow1.Width, drawWindow1.Height), false, Fonts.Default);
            m_numericUpDown.RequestedAreaChanged += () =>
            {
                MinimumSize = new Size(0, (int)m_numericUpDown.RequestedArea.Height);
                Size        = m_numericUpDown.RequestedArea.ToSize();
            };
            m_numericUpDown.SetupCallbacks(drawWindow1);
        }