Beispiel #1
0
        void DrawBackground(int index, Graphics g, Rectangle listbounds, DrawItemState state, bool isWithDraw)
        {
            if (!isWithDraw)
            {
                return;
            }

            if ((state & DrawItemState.Selected) > 0)
            {//選択色
                Brush brush = new SolidBrush(OptionForm.Color_List_SelectedColor());
                g.FillRectangle(brush, listbounds);
                brush.Dispose();

                return;
            }

            if (index != this.LastHoverIndex)
            {//通常
                Brush brush = new SolidBrush(OptionForm.Color_Input_BackColor());
                g.FillRectangle(brush, listbounds);
                brush.Dispose();
            }
            else
            {//hover
                Brush brush = new SolidBrush(OptionForm.Color_List_HoverColor());
                g.FillRectangle(brush, listbounds);
                brush.Dispose();
            }
        }
        public NotifyDirectInjectionNotifyUserControl()
        {
            InitializeComponent();

            Color Color_Notify_BackColor = OptionForm.Color_List_HoverColor();
            Color Color_Notify_ForeColor = OptionForm.Color_Control_ForeColor();

            this.BackColor = Color_Notify_BackColor;
            this.ForeColor = Color_Notify_ForeColor;

            this.BIG_TEXT.BackColor = Color_Notify_BackColor;
            this.BIG_TEXT.ForeColor = Color_Notify_ForeColor;

            this.AllowLabel.BackColor = Color_Notify_BackColor;
            this.AllowLabel.ForeColor = Color_Notify_ForeColor;
        }
Beispiel #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            //TabControlの背景を塗る
            if (this.DesignMode)
            {
                e.Graphics.FillRectangle(SystemBrushes.Control, this.ClientRectangle);
                return;
            }
            else
            {
                Color backColor = OptionForm.Color_Control_BackColor();
                Brush backBrush = new System.Drawing.SolidBrush(backColor);
                e.Graphics.FillRectangle(backBrush, this.ClientRectangle);
                backBrush.Dispose();
            }


            if (this.TabCount == 0)
            {
                return;
            }
            if (this.SelectedIndex < 0 || this.SelectedIndex >= this.TabCount)
            {
                return;
            }

            //TabPageの枠を描画する
            TabPage   page     = this.TabPages[this.SelectedIndex];
            Rectangle pageRect = new Rectangle(
                page.Bounds.X - 2,
                page.Bounds.Y - 2,
                page.Bounds.Width + 5,
                page.Bounds.Height + 5);

            if (Application.RenderWithVisualStyles)
            {
                TabRenderer.DrawTabPage(e.Graphics, pageRect);
            }

            //タブを描画する
            for (int i = 0; i < this.TabCount; i++)
            {
                page = this.TabPages[i];
                Rectangle tabRect = this.GetTabRect(i);

                bool focused = false;
                //選択されたタブとページの間の境界線を消すために、
                //描画する範囲を大きくする
                if (this.SelectedIndex == i)
                {
                    tabRect.Height += 1;
                    focused         = true;
                }

                //画像のサイズを決定する
                Size imgSize = tabRect.Size;

                //タブの画像を作成する
                Bitmap   bmp = new Bitmap(imgSize.Width, imgSize.Height);
                Graphics g   = Graphics.FromImage(bmp);
                //高さに1足しているのは、下にできる空白部分を消すため
                Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height + 1);

                if (Application.RenderWithVisualStyles)
                {
                    //表示するタブの状態を決定する
                    System.Windows.Forms.VisualStyles.TabItemState state;
                    if (!this.Enabled)
                    {
                        state = System.Windows.Forms.VisualStyles.TabItemState.Disabled;
                    }
                    else if (focused)
                    {
                        state = System.Windows.Forms.VisualStyles.TabItemState.Selected;
                    }
                    else
                    {
                        state = System.Windows.Forms.VisualStyles.TabItemState.Normal;
                    }

                    TabRenderer.DrawTabItem(g,
                                            rect,
                                            false,
                                            state);
                }
                else
                {
                    if (focused)
                    {
                        g.FillRectangle(SystemBrushes.Control, rect);
                    }
                    else
                    {
                        g.FillRectangle(SystemBrushes.ControlDark, rect);
                        g.DrawRectangle(new Pen(SystemBrushes.ControlDarkDark), rect);
                    }
                }

                if (page.Text.Length > 10)
                {
                    g.DrawString(page.Text, page.Font, SystemBrushes.ControlText, new Rectangle(rect.Left + 6, rect.Top + 4, rect.Width - 20, rect.Height - 4));
                }
                else
                {
                    g.DrawString(page.Text, page.Font, SystemBrushes.ControlText, new Rectangle(rect.Left + 12, rect.Top + 4, rect.Width - 20, rect.Height - 4));
                }

                Rectangle closeButton = TabRectToCloseButtonRect(tabRect);
                if (closeButton.Contains(this.LastMouseCursor))
                {//マウスカーソルが当たっている、ボタンの背景の色を変える.
                    Brush     hoverBrush = new SolidBrush(OptionForm.Color_List_HoverColor());
                    Rectangle rc         = new Rectangle(closeButton.X - tabRect.X, closeButton.Y - tabRect.Y, closeButton.Width, closeButton.Height);
                    g.FillRectangle(hoverBrush, rc);
                    hoverBrush.Dispose();
                }
                g.DrawString("x", page.Font, SystemBrushes.ControlText, rect.Right - 15, rect.Top + 4);
                g.Dispose();

                //画像を描画する
                e.Graphics.DrawImage(bmp, tabRect.X, tabRect.Y, bmp.Width, bmp.Height);


                bmp.Dispose();
            }
        }