protected override void OnCreateControl()
 {
     base.OnCreateControl();
     if (!_themeManager.ThemingActive)
     {
         return;
     }
     ForeColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Foreground");
     BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Background");
     SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
     //Hide those nonthemable butons
     if (Controls.Count > 0)
     {
         Controls[0].Hide();
     }
     //Add new themable buttons
     Up = new NGButton
     {
         Text = "\u25B2",
         Font = new Font(Font.FontFamily, 6f)
     };
     Up.SetBounds(Width - 17, 1, 16, Height / 2 - 1);
     Up.Click += Up_Click;
     Down      = new NGButton
     {
         Text = "\u25BC",
         Font = new Font(Font.FontFamily, 6f)
     };
     Down.SetBounds(Width - 17, Height / 2, 16, Height / 2 - 1);
     Down.Click += Down_Click;
     Controls.Add(Up);
     Controls.Add(Down);
     Invalidate();
 }
Example #2
0
        protected override void OnCreateControl()
        {
            base.OnCreateControl();
            if (!_themeManager.ActiveAndExtended)
            {
                return;
            }
            ForeColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Foreground");
            BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Background");
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);

            if (Controls.Count > 0)
            {
                for (var i = 0; i < Controls.Count; i++)
                {
                    //Remove those non-themable buttons
                    if (Controls[i].GetType().ToString().Equals("System.Windows.Forms.UpDownBase+UpDownButtons"))
                    {
                        Controls.Remove(Controls[i]);
                    }

                    /* This is a bit of a hack.
                     * But if we have the buttons that we created already, redraw/return and don't add any more...
                     *
                     * OptionsPages are an example where the control is potentially created twice:
                     * AddOptionsPagesToListView and then LstOptionPages_SelectedIndexChanged
                     */
                    if (!(Controls[i] is NGButton))
                    {
                        continue;
                    }
                    if (!Controls[i].Text.Equals("\u25B2") && !Controls[i].Text.Equals("\u25BC"))
                    {
                        continue;
                    }
                    Invalidate();
                    return;
                }
            }

            //Add new themable buttons
            Up = new NGButton
            {
                Text = "\u25B2",
                Font = new Font(Font.FontFamily, 5f)
            };
            Up.SetBounds(Controls.Owner.Width - 17, 2, 16, Controls.Owner.Height / 2 - 1);
            Up.Click += Up_Click;
            Down      = new NGButton
            {
                Text = "\u25BC",
                Font = new Font(Font.FontFamily, 5f)
            };
            Down.SetBounds(Controls.Owner.Width - 17, Controls.Owner.Height / 2 + 1, 16, Controls.Owner.Height / 2 - 1);
            Down.Click += Down_Click;
            Controls.Add(Up);
            Controls.Add(Down);
            Invalidate();
        }