Esempio n. 1
0
        private void DrawItem(Graphics g, Item item, Bar bar, bool hot, bool pressed)
        {
            SolidBrush textBrush = new SolidBrush(hot ? m_ViewStyle.BarItemHotTextColor : m_ViewStyle.BarItemTextColor);
            ItemsStyle itemStyle = bar.ItemsStyleCurrent;

            if (!item.Enabled || !this.Enabled)
            {
                g.FillRectangle(new SolidBrush(m_ViewStyle.BarClientAreaColor), item.Bounds.X, item.Bounds.Y, item.Bounds.Width + 1, item.Bounds.Height + 1);
                textBrush = new SolidBrush(m_ViewStyle.BarItemDisabledTextColor);
            }
            else if (hot || item.Equals(m_StuckenItem))
            {
                Rectangle iRect = new Rectangle(item.Bounds.Location, item.Bounds.Size);
                //--- If item style is IconSelect
                if (itemStyle == ItemsStyle.IconSelect)
                {
                    iRect = new Rectangle(((this.Width - 32) / 2) - 1, item.Bounds.Y + 2, 34, 34);
                }

                //--- if not stucken(selected) item
                if (!item.Equals(m_StuckenItem))
                {
                    g.FillRectangle(new SolidBrush(pressed ? m_ViewStyle.BarItemPressedColor : m_ViewStyle.BarItemHotColor), iRect);
                }
                else                  //---- If stucken(selected) item
                {
                    g.FillRectangle(new SolidBrush(m_ViewStyle.BarItemSelectedColor), iRect);
                    textBrush = new SolidBrush(m_ViewStyle.BarItemSelectedTextColor);
                }

                // Draw border
                g.DrawRectangle(new Pen(m_ViewStyle.BarItemBorderHotColor), iRect);
            }
            else
            {
                g.FillRectangle(new SolidBrush(m_ViewStyle.BarClientAreaColor), item.Bounds.X, item.Bounds.Y, item.Bounds.Width + 1, item.Bounds.Height + 1);
            }

            //---- Draw item image
            Image image = item.Image;

            if (image != null)
            {
                //ControlPaint.DrawImageDisabled();
                if (item.Enabled)
                {
                    g.DrawImage(image, item.ImageRect);
                }
                else
                {
                    ControlPaint.DrawImageDisabled(g, image, item.ImageRect.X, item.ImageRect.Y, Color.Transparent);
                }
            }

            //---- Draw item text
            g.DrawString(GetText(item.Caption, item.TextID), bar.ItemsFont, textBrush, item.TextRect, bar.ItemsStringFormat);
        }
Esempio n. 2
0
        internal void DrawItem(Graphics g, bool hot, bool pressed)
        {
            Image image = null;

            if (this.ImageIndex > -1 && this.WOutlookBar.ImageList != null && this.ImageIndex < this.WOutlookBar.ImageList.Images.Count)
            {
                image = this.WOutlookBar.ImageList.Images[0];
            }

            if (hot || this.Equals(this.WOutlookBar.StuckenItem))
            {
                Rectangle iRect = new Rectangle(this.Bounds.Location, this.Bounds.Size);

                ItemsStyle itemStyle = this.Bar.ItemsStyle;

                //--- If must use default item style ---------//
                //--- First load from ViewStyle
                if (this.Bar.ItemsStyle == ItemsStyle.UseDefault)
                {
                    itemStyle = this.ViewStyle.BarItemsStyle;
                }

                //--- If ViewStyle retuned UseDefault, set IconSelect as default
                if (itemStyle == ItemsStyle.UseDefault)
                {
                    itemStyle = ItemsStyle.IconSelect;
                }
                //-------------------------------------------//

                //--- If item style is IconSelect
                if (itemStyle == ItemsStyle.IconSelect)
                {
                    iRect = new Rectangle(((this.Bounds.Width - 32) / 2) - 1, this.Bounds.Y + 2, 34, 34);
                }

                //------- Draw item -----------------------------------------------------------//
                //--- if not stucken(selected) item
                if (!this.Equals(this.WOutlookBar.StuckenItem))
                {
                    if (pressed)
                    {
                        g.FillRectangle(new SolidBrush(this.ViewStyle.BarItemPressedColor), iRect);
                    }
                    else
                    {
                        g.FillRectangle(new SolidBrush(this.ViewStyle.BarItemHotColor), iRect);
                    }
                }
                else                  //---- If stucken(selected) item
                {
                    g.FillRectangle(new SolidBrush(this.ViewStyle.BarItemSelectedColor), iRect);
                }

                g.DrawRectangle(new Pen(this.ViewStyle.BarItemBorderHotColor), iRect);
                //----------------------------------------------------------------------------//
            }
            else
            {
                g.FillRectangle(new SolidBrush(this.ViewStyle.BarClientAreaColor), this.Bounds.X, this.Bounds.Y, this.Bounds.Width + 1, this.Bounds.Height + 1);
            }


            //---- Draw image ---------------------------//
            Rectangle imgRect = new Rectangle((this.Bounds.Width - 32) / 2, this.Bounds.Y + 4, 32, 32);

            if (image != null)
            {
                g.DrawImage(image, imgRect);
            }
            //--------------------------------------------//

            //---- Draw items text ---------------------------------------------------------------//
            Rectangle txtRect = new Rectangle(1, imgRect.Bottom + 3, this.Bounds.Width - 2, this.Bounds.Bottom - imgRect.Bottom + 3);

            g.DrawString(this.Caption, this.Bar.ItemsFont, new SolidBrush(hot ? this.ViewStyle.BarItemHotTextColor : this.ViewStyle.BarItemTextColor), txtRect, this.Bar.ItemsStringFormat);
            //-------------------------------------------------------------------------------------//
        }
Esempio n. 3
0
        private void DrawItem(Graphics g, Item item, Bar bar, bool hot, bool pressed)
        {
            SolidBrush textBrush = new SolidBrush(hot ? m_ViewStyle.BarItemHotTextColor : m_ViewStyle.BarItemTextColor);

            if (hot || item.Equals(m_StuckenItem))
            {
                Rectangle iRect = new Rectangle(item.Bounds.Location, item.Bounds.Size);

                ItemsStyle itemStyle = bar.ItemsStyle;

                //--- If must use default item style ---------//
                //--- First load from ViewStyle
                if (bar.ItemsStyle == ItemsStyle.UseDefault)
                {
                    itemStyle = m_ViewStyle.BarItemsStyle;
                }

                //--- If ViewStyle retuned UseDefault, set IconSelect as default
                if (itemStyle == ItemsStyle.UseDefault)
                {
                    itemStyle = ItemsStyle.IconSelect;
                }
                //-------------------------------------------//

                //--- If item style is IconSelect
                if (itemStyle == ItemsStyle.IconSelect)
                {
                    iRect = new Rectangle(((this.Width - 32) / 2) - 1, item.Bounds.Y + 2, 34, 34);
                }

                //------- Draw item -----------------------------------------------------------//
                //--- if not stucken(selected) item
                if (!item.Equals(m_StuckenItem))
                {
                    if (pressed)
                    {
                        g.FillRectangle(new SolidBrush(m_ViewStyle.BarItemPressedColor), iRect);
                    }
                    else
                    {
                        g.FillRectangle(new SolidBrush(m_ViewStyle.BarItemHotColor), iRect);
                    }
                }
                else                  //---- If stucken(selected) item
                {
                    g.FillRectangle(new SolidBrush(m_ViewStyle.BarItemSelectedColor), iRect);
                    textBrush = new SolidBrush(m_ViewStyle.BarItemSelectedTextColor);
                }

                // Draw border
                g.DrawRectangle(new Pen(m_ViewStyle.BarItemBorderHotColor), iRect);
                //----------------------------------------------------------------------------//
            }
            else
            {
                g.FillRectangle(new SolidBrush(m_ViewStyle.BarClientAreaColor), item.Bounds.X, item.Bounds.Y, item.Bounds.Width + 1, item.Bounds.Height + 1);
            }


            //---- Draw image ---------------------------//
            Rectangle imgRect = new Rectangle((this.Width - 32) / 2, item.Bounds.Y + 4, 32, 32);

            if (item.ImageIndex > -1 && this.ImageList != null && item.ImageIndex < this.ImageList.Images.Count)
            {
                g.DrawImage(ImageList.Images[item.ImageIndex], imgRect);
            }
            //--------------------------------------------//

            //---- Draw items text ---------------------------------------------------------------//
            Rectangle txtRect = new Rectangle(item.Bounds.X + 2, imgRect.Bottom + 3, item.Bounds.Width, item.Bounds.Bottom - imgRect.Bottom + 3);

            g.DrawString(item.Caption, bar.ItemsFont, textBrush, txtRect, bar.ItemsStringFormat);
            //-------------------------------------------------------------------------------------//
        }