public Preferences()
            : base()
        {
            InitializeComponent();

            Text = String.Concat(Locale.Current.Preferences.WindowTitle, " - ", Program.MainForm.Text);
            Icon = Program.MainForm.Icon;
            TopMost = true;

            _iconApps = Utilities.ResourceHelper.GetImage("gmail-limon.png");
            _iconStandard = Utilities.ResourceHelper.GetImage("gmail-bleu.png");

            _rendererListLarge = Shellscape.UI.VisualStyles.ControlPanel.GetRenderer(Shellscape.UI.VisualStyles.ControlPanel.ControlPanelPart.MessageText, 0, true);
            _rendererListSmall = Shellscape.UI.VisualStyles.ControlPanel.GetRenderer(Shellscape.UI.VisualStyles.ControlPanel.ControlPanelPart.BodyText, 0, true);
            _titleElement = Shellscape.UI.VisualStyles.ControlPanel.GetElement(
                Shellscape.UI.VisualStyles.ControlPanel.ControlPanelPart.Title,
                0,
                true
            );

            InitNavigation();
            InitGeneralPanel();
            InitAccountsPanel();
            InitAccountPanel();

            if (Config.Current.FirstRun) {
                InitFirstRun();
            }

            HidePanels();
            _PanelGeneral.Visible = true;
        }
Exemple #2
0
        /// <summary>
        /// Class constructor accepting a starting time value
        /// </summary>
        /// <param name="time">Array of integers specifying 
        /// <code>{days,hours,minutes,seconds}</code>
        /// </param>
        public Remit(int[] time)
        {
            /* set the timer values, so that it can continue if it just
             * switched over from normal mode */
            days = time[0];
            hours = time[1];
            minutes = time[2];
            seconds = time[3];

            bool vs = true; // visual styles work
            InitializeComponent();
            /* Just encase something odd happens and visual styles aren't available, don't
             * break the program entirely :) */
            try
            {
                vse = VisualStyleElement.Taskbar.BackgroundTop.Normal;
                vsr = new VisualStyleRenderer(vse);
            }
            catch (Exception ex)
            {
                vs = false; // ok, no they don't :(
                MessageBox.Show(
                    String.Format("Unable to aquire Visual Style renderer:\n {0}", ex.Message),
                    "Problem", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            // don't bother forcing user painting if we couldn't get the vsr
            if (vs)
            {
                this.SetStyle(ControlStyles.UserPaint, true);
                this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            }
        }
 public override void OnRendererTabPageArea(Graphics gfx, Rectangle tabPageAreaRct)
 {
     if (Application.RenderWithVisualStyles)
     {
         VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal);
         renderer.DrawBackground(gfx, tabPageAreaRct);
     }
     else
     {
         Rectangle linesRct = tabPageAreaRct;
         // Draw top 2px line.
         using (Brush brush = new SolidBrush(Color.FromArgb(2, 111, 194)))
             gfx.FillRectangle(brush, linesRct.Left, linesRct.Top, linesRct.Width, 2);
         // Draw left, right and bottom 1px lines.
         using (Pen pen = new Pen(Color.FromArgb(183, 192, 197)))
         {
             // Create border points.
             Point[] points = new Point[]
             {
                 // Left point.
                 new Point(linesRct.Left, linesRct.Top + 2),
                 // Bottom points.
                 new Point(linesRct.Left, linesRct.Bottom - 1),
                 new Point(linesRct.Right - 1, linesRct.Bottom - 1),
                 // Right point.
                 new Point(linesRct.Right - 1, linesRct.Top + 2)
             };
             gfx.DrawLines(pen, points);
         }
     }
 }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public CheckBoxColumnHeaderHandler(DataGridViewColumn col)
		{
			Debug.Assert(col != null);
			Debug.Assert(col is DataGridViewCheckBoxColumn);
			Debug.Assert(col.DataGridView != null);

			m_col = col;
			m_grid = col.DataGridView;
			m_grid.HandleDestroyed += HandleHandleDestroyed;
			m_grid.CellPainting += HandleHeaderCellPainting;
			m_grid.CellMouseMove += HandleHeaderCellMouseMove;
			m_grid.ColumnHeaderMouseClick += HandleHeaderCellMouseClick;
			m_grid.CellContentClick += HandleDataCellCellContentClick;
			m_grid.Scroll += HandleGridScroll;
			m_grid.RowsAdded += HandleGridRowsAdded;
			m_grid.RowsRemoved += HandleGridRowsRemoved;

			if (!Application.RenderWithVisualStyles)
			{
				m_szCheckBox = new Size(13, 13);
			}
			else
			{
				var element = VisualStyleElement.Button.CheckBox.CheckedNormal;
				var renderer = new VisualStyleRenderer(element);
				using (var g = m_grid.CreateGraphics())
					m_szCheckBox = renderer.GetPartSize(g, ThemeSizeType.True);
			}

			m_stringFormat = new StringFormat(StringFormat.GenericTypographic);
			m_stringFormat.Alignment = StringAlignment.Center;
			m_stringFormat.LineAlignment = StringAlignment.Center;
			m_stringFormat.Trimming = StringTrimming.EllipsisCharacter;
			m_stringFormat.FormatFlags |= StringFormatFlags.NoWrap;
		}
		public static void DrawHorizontalThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)
		{
			if (!IsSupported)
				throw new InvalidOperationException ();

			VisualStyleRenderer vsr;

			switch (state) {
				case TrackBarThumbState.Disabled:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Disabled);
					break;
				case TrackBarThumbState.Hot:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Hot);
					break;
				case TrackBarThumbState.Normal:
				default:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Normal);
					break;
				case TrackBarThumbState.Pressed:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Pressed);
					break;
			}

			vsr.DrawBackground (g, bounds);
		}
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            _renderer = _renderPressed;
            Invalidate();
        }
 public void SetTheme(VisualStyleElement element)
 {
     if (VisualStyleRenderer.IsSupported && VisualStyleRenderer.IsElementDefined(element))
         rnd = new VisualStyleRenderer(element);
     else
         rnd = null;
 }
Exemple #8
0
 public override void Draw(TreeNodeAdv node, DrawContext context)
 {
     if (node.CanExpand)
     {
         Rectangle r = context.Bounds;
         int dy = (int)Math.Round((float)(r.Height - ImageSize) / 2);
         if (Application.RenderWithVisualStyles)
         {
             VisualStyleRenderer renderer;
             if (node.IsExpanded)
                 renderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
             else
                 renderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
             renderer.DrawBackground(context.Graphics, new Rectangle(r.X, r.Y + dy, ImageSize, ImageSize));
         }
         else
         {
             Image img;
             if (node.IsExpanded)
                 img = _minus;
             else
                 img = _plus;
             context.Graphics.DrawImageUnscaled(img, new Point(r.X, r.Y + dy));
         }
     }
 }
 public override void Draw(TreeNodeAdv node, DrawContext context)
 {
     Rectangle r = context.Bounds;
     int dy = (int)Math.Round((float)(r.Height - ImageSize) / 2);
     CheckState state = GetCheckState(node);
     if (Application.RenderWithVisualStyles)
     {
         VisualStyleRenderer renderer;
         if (state == CheckState.Indeterminate)
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.MixedNormal);
         else if (state == CheckState.Checked)
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.CheckedNormal);
         else
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.UncheckedNormal);
         renderer.DrawBackground(context.Graphics, new Rectangle(r.X, r.Y + dy, ImageSize, ImageSize));
     }
     else
     {
         Image img;
         if (state == CheckState.Indeterminate)
             img = _unknown;
         else if (state == CheckState.Checked)
             img = _check;
         else
             img = _uncheck;
         context.Graphics.DrawImage(img, new Point(r.X, r.Y + dy));
         //ControlPaint.DrawCheckBox(context.Graphics, r, state2);
     }
 }
 protected override void Draw(Graphics dc, string title, string text, Rectangle rect, Rectangle titleRect, Rectangle bodyRect, Image img, int iconWidth)
 {
     if (IsDefined(VisualStyleElement.ToolTip.BalloonTitle.Normal) && IsDefined(VisualStyleElement.ToolTip.Balloon.Normal))
     {
         VisualStyleRenderer titleRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.BalloonTitle.Normal);
         VisualStyleRenderer balloonRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.Balloon.Normal);
         balloonRenderer.DrawBackground(dc, rect);
         // drawing title
         titleRenderer.DrawText(dc,
             new Rectangle(Padding.Left + iconWidth, Padding.Top, rect.Width - iconWidth - (Padding.Left + Padding.Right), titleRect.Height),
             title, false, TextFormatFlags.Left | TextFormatFlags.WordEllipsis | TextFormatFlags.VerticalCenter);
         // drawing text
         Rectangle balloonTextBounds = new Rectangle(Padding.Left + iconWidth, Padding.Top + titleRect.Height, rect.Width - iconWidth - (Padding.Left + Padding.Right), rect.Height - (Padding.Top + titleRect.Height + Padding.Bottom));
         balloonRenderer.DrawText(dc, balloonTextBounds,
             text, false, TextFormatFlags.Left | TextFormatFlags.WordBreak | TextFormatFlags.VerticalCenter);
     }
     else
     {
         dc.FillRectangle(SystemBrushes.Info, rect);
         dc.DrawRectangle(Pens.Black, new Rectangle(0, 0, rect.Width - 1, rect.Height - 1));
         dc.DrawString(title, new Font(SystemFonts.DefaultFont, FontStyle.Bold), SystemBrushes.InfoText,
             new PointF(Padding.Left + iconWidth, Padding.Top), new StringFormat(StringFormatFlags.NoWrap));
         dc.DrawString(text, SystemFonts.DefaultFont, SystemBrushes.InfoText,
             new RectangleF(Padding.Left + iconWidth, Padding.Top + titleRect.Height, bodyRect.Width, bodyRect.Height),
             new StringFormat());
     }
 }
Exemple #11
0
 public static void DrawThemeTextActive(
     Graphics aGraph,
     string aText,
     Point aLocation,
     SUxTextProperties aProp
     )
 {
     IntPtr lPriHdc = aGraph.GetHdc();
     VisualStyleRenderer lRenderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
     DTTOPTS lOpts = new DTTOPTS();
     lOpts.dwSize = Marshal.SizeOf(lOpts);
     lOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR;
     lOpts.crText = ColorTranslator.ToWin32(aProp.color);
     lOpts.iGlowSize = aProp.glowSize;
     RECT ltBounds = new RECT(0, 0, aProp.bounds.Width, aProp.bounds.Height);
     DrawThemeTextEx(
                 lRenderer.Handle,
                 lPriHdc,
                 0, 0,
                 aText,
                 -1,
                 (int)(aProp.flags),
                 ref ltBounds,
                 ref lOpts
             );
 }
		/// ------------------------------------------------------------------------------------
		public CheckBoxColumnHeaderHandler(DataGridViewColumn col)
		{
			Debug.Assert(col != null);
			Debug.Assert(col is DataGridViewCheckBoxColumn);
			Debug.Assert(col.DataGridView != null);

			_col = col;
			_owningGrid = col.DataGridView;
			_owningGrid.HandleDestroyed += HandleHandleDestroyed;
			_owningGrid.CellPainting += HandleHeaderCellPainting;
			_owningGrid.CellMouseMove += HandleHeaderCellMouseMove;
			_owningGrid.CellMouseClick += HandleHeaderCellMouseClick;
			_owningGrid.CellContentClick += HandleDataCellCellContentClick;
			_owningGrid.Scroll += HandleGridScroll;
			_owningGrid.RowsAdded += HandleGridRowsAdded;
			_owningGrid.RowsRemoved += HandleGridRowsRemoved;

			if (!BetterGrid.CanPaintVisualStyle())
				_szCheckBox = new Size(13, 13);
			else
			{
				var element = VisualStyleElement.Button.CheckBox.CheckedNormal;
				var renderer = new VisualStyleRenderer(element);
				using (var g = _owningGrid.CreateGraphics())
					_szCheckBox = renderer.GetPartSize(g, ThemeSizeType.True);
			}
		}
 public static void DrawCloseButton(IDeviceContext dc, Rectangle rect, Padding padding, ToolTipBalloonCloseButtonState buttonState)
 {
     VisualStyleElement btn = GetCloseButtonVS(buttonState);
     VisualStyleRenderer renderer = new VisualStyleRenderer(btn);
     Rectangle btnRect = GetCloseButtonRect(dc, rect, padding, buttonState);
     renderer.DrawBackground(dc, btnRect);
 }
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            TabStrip tabStrip = e.ToolStrip as TabStrip;
            ToolStripButton button = e.Item as ToolStripButton;
            Rectangle bounds = new Rectangle(Point.Empty, e.Item.Size);

            if (tabStrip != null) {
                System.Windows.Forms.VisualStyles.TabItemState tabState = System.Windows.Forms.VisualStyles.TabItemState.Normal;
                if (button.Checked) {
                    tabState |= System.Windows.Forms.VisualStyles.TabItemState.Selected;
                }
                if (button.Selected) {
                    tabState |= System.Windows.Forms.VisualStyles.TabItemState.Hot;
                }

                TabRenderer.DrawTabItem(e.Graphics, bounds, tabState);

                if (button.Checked) {
                    VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Hot);
                    Padding borderPadding = button.Padding;
                    borderPadding.Top += 4;
                    borderPadding.Bottom += 2;
                    borderPadding.Left -= 2;
                    borderPadding.Right -= 2;
                    Rectangle rect = LayoutUtils.DeflateRect(bounds, borderPadding);

                    ControlPaint.DrawFocusRectangle(e.Graphics, rect);
                }
            }
            else {
                base.OnRenderButtonBackground(e);
            }
        }
Exemple #15
0
 public override void Draw(TreeNodeAdv node, DrawContext context)
 {
     Rectangle bounds = GetBounds(node, context);
     CheckState state = GetCheckState(node);
     if (Application.RenderWithVisualStyles)
     {
         VisualStyleRenderer renderer;
         if (state == CheckState.Indeterminate)
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.MixedNormal);
         else if (state == CheckState.Checked)
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.CheckedNormal);
         else
             renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.UncheckedNormal);
         renderer.DrawBackground(context.Graphics, new Rectangle(bounds.X, bounds.Y, ImageSize, ImageSize));
     }
     else
     {
         Image img;
         if (state == CheckState.Indeterminate)
             img = _unknown;
         else if (state == CheckState.Checked)
             img = _check;
         else
             img = _uncheck;
         context.Graphics.DrawImage(img, bounds.Location);
     }
 }
        private static VisualStyleRenderer getRenderer(int x, int y)
        {
            Dictionary<int, VisualStyleRenderer> subDict;
            try
            {
                subDict = renderers[x];
            }
            catch (KeyNotFoundException)
            {
                subDict = new Dictionary<int, VisualStyleRenderer>();
                renderers[x] = subDict;
            }

            VisualStyleRenderer renderer;
            try
            {
                renderer = subDict[y];
            }
            catch (KeyNotFoundException)
            {
                renderer = new VisualStyleRenderer("Explorer::TreeView", x, y);
                subDict[y] = renderer;
            }

            return renderer;
        }
        public TreeGridView()
		{
            try
            {
                rOpen = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
                rClosed = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
            }
            catch (Exception)
            {
                rOpen = null;
                rClosed = null;
            }

			// Control when edit occurs because edit mode shouldn't start when expanding/collapsing
			this.EditMode = DataGridViewEditMode.EditProgrammatically;
            this.RowTemplate = new TreeGridNode() as DataGridViewRow;
			// This sample does not support adding or deleting rows by the user.
			this.AllowUserToAddRows = false;
			this.AllowUserToDeleteRows = false;
			this._root = new TreeGridNode(this);
			this._root.IsRoot = true;

			// Ensures that all rows are added unshared by listening to the CollectionChanged event.
			base.Rows.CollectionChanged += delegate(object sender, System.ComponentModel.CollectionChangeEventArgs e){};
        }
 public void RefreshVisualStyles()
 {
     if (ExplorerVisualStyle.VisualStylesEnabled)
     {
         try
         {
             _openedRenderer = ExplorerVisualStyle.TvOpenedRenderer;
             _closedRenderer = ExplorerVisualStyle.TvClosedRenderer;
         }
         catch
         {
             _openedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
             _closedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
         }
     }
     else
     {
         try
         {
             _openedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
             _closedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
         }
         catch
         {
         }
     }
 }
Exemple #19
0
 private static void DrawThemeBackground(IDeviceContext dc, VisualStyleElement element, Rectangle bounds, Rectangle clipRectangle)
 {
     if( DialogHelper.IsTaskDialogThemeSupported )
     {
         VisualStyleRenderer renderer = new VisualStyleRenderer(element);
         renderer.DrawBackground(dc, bounds, clipRectangle);
     }
 }
Exemple #20
0
 private void InitializeRenderer() {
     rendererDown_Normal = new VisualStyleRenderer(VisualStyleElement.Spin.DownHorizontal.Normal);
     rendererUp_Normal = new VisualStyleRenderer(VisualStyleElement.Spin.UpHorizontal.Normal);
     rendererDown_Hot = new VisualStyleRenderer(VisualStyleElement.Spin.DownHorizontal.Hot);
     rendererUp_Hot = new VisualStyleRenderer(VisualStyleElement.Spin.UpHorizontal.Hot);
     rendererDown_Pressed = new VisualStyleRenderer(VisualStyleElement.Spin.DownHorizontal.Pressed);
     rendererUp_Pressed = new VisualStyleRenderer(VisualStyleElement.Spin.UpHorizontal.Pressed);
 }
		protected override void OnPaint(PaintEventArgs e)
		{
			Graphics g = e.Graphics;
			if(g == null) { base.OnPaint(e); return; }

			int nNormalizedPos = m_nPosition - m_nMinimum;
			int nNormalizedMax = m_nMaximum - m_nMinimum;

			Rectangle rectClient = this.ClientRectangle;
			Rectangle rectDraw;
			if(VisualStyleRenderer.IsSupported)
			{
				VisualStyleRenderer vsr = new VisualStyleRenderer(
					VisualStyleElement.ProgressBar.Bar.Normal);
				vsr.DrawBackground(g, rectClient);

				rectDraw = vsr.GetBackgroundContentRectangle(g, rectClient);
			}
			else
			{
				g.FillRectangle(SystemBrushes.Control, rectClient);

				g.DrawLine(Pens.Gray, 0, 0, rectClient.Width - 1, 0);
				g.DrawLine(Pens.Gray, 0, 0, 0, rectClient.Height - 1);
				g.DrawLine(Pens.White, rectClient.Width - 1, 0,
					rectClient.Width - 1, rectClient.Height - 1);
				g.DrawLine(Pens.White, 0, rectClient.Height - 1,
					rectClient.Width - 1, rectClient.Height - 1);

				rectDraw = new Rectangle(rectClient.X + 1, rectClient.Y + 1,
					rectClient.Width - 2, rectClient.Height - 2);
			}

			Rectangle rectGradient = new Rectangle(rectDraw.X, rectDraw.Y,
				rectDraw.Width, rectDraw.Height);
			if((rectGradient.Width & 1) == 0) ++rectGradient.Width;

			int nDrawWidth = (int)((float)rectDraw.Width * ((float)nNormalizedPos /
				(float)nNormalizedMax));

			Color clrStart = Color.FromArgb(255, 128, 0);
			Color clrEnd = Color.FromArgb(0, 255, 0);

			bool bRtl = (this.RightToLeft == RightToLeft.Yes);
			if(bRtl)
			{
				Color clrTemp = clrStart;
				clrStart = clrEnd;
				clrEnd = clrTemp;
			}
			
			using(LinearGradientBrush brush = new LinearGradientBrush(rectGradient,
				clrStart, clrEnd, LinearGradientMode.Horizontal))
			{
				g.FillRectangle(brush, (bRtl ? (rectDraw.Width - nDrawWidth + 1) :
					rectDraw.Left), rectDraw.Top, nDrawWidth, rectDraw.Height);
			}
		}
 static RebarRenderer()
 {
     if (VisualStyleRenderer.IsSupported)
     {
         // For some reasons Rebar zero part (Rebar by itself) was not added to the VisualStyleElements.
         RebarRenderer.RebarStyleRenderer = new VisualStyleRenderer("Rebar", 0, 0);
         RebarRenderer.RebarBandStyleRenderer = new VisualStyleRenderer(VisualStyleElement.Rebar.Band.Normal);
     }
 }
Exemple #23
0
 // If possible, give the window that nice gradient look
 protected override void OnPaintBackground(PaintEventArgs e)
 {
     if (VisualStyleRenderer.IsSupported) {
       VisualStyleRenderer VSR = new VisualStyleRenderer(VisualStyleElement.Tab.Body.Normal);
     VSR.DrawBackground(e.Graphics, this.ClientRectangle, e.ClipRectangle);
       }
       else
     base.OnPaintBackground(e);
 }
		public static void DrawVerticalChunks (Graphics g, Rectangle bounds)
		{
			if (!IsSupported)
				throw new InvalidOperationException ();

			VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.ProgressBar.ChunkVertical.Normal);

			vsr.DrawBackground (g, bounds);
		}
Exemple #25
0
        public static void DrawTextBox(Graphics g, Rectangle bounds, ComboBoxState state) {
            if (visualStyleRenderer == null) {
                visualStyleRenderer = new VisualStyleRenderer(TextBoxElement.ClassName, TextBoxElement.Part, (int)state);
            }
            else {
                visualStyleRenderer.SetParameters(TextBoxElement.ClassName, TextBoxElement.Part, (int)state);
            }

            DrawBackground(g, bounds, state);
        }
Exemple #26
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ExpandButton" /> class.
 /// </summary>
 public ExpandButton()
 {
     if (Environment.OSVersion.Version.Major < 6)
         throw new NotSupportedException();
     ButtonRenderer = new VisualStyleRenderer("TaskDialog", 13, (int) ButtonState.Normal);
     SetStyle(
         ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw |
         ControlStyles.UserPaint, true);
     UpdateStyles();
 }
 private static void InitializeRenderer(int state)
 {
     if (visualStyleRenderer == null)
     {
         visualStyleRenderer = new VisualStyleRenderer(TextBoxElement.ClassName, TextBoxElement.Part, state);
     }
     else
     {
         visualStyleRenderer.SetParameters(TextBoxElement.ClassName, TextBoxElement.Part, state);
     }
 }
        public static void DrawText(Graphics graphics, string text, Font font, Rectangle bounds, Color color, TextFormatFlags flags, TextStyle textStyle)
        {
            if (!VisualStyleRenderer.IsSupported) {
                TextRenderer.DrawText(graphics, text, font, bounds, color, flags);
                return;
            }

            IntPtr primaryHdc = graphics.GetHdc();

            // Create a memory DC so we can work offscreen
            IntPtr memoryHdc = CreateCompatibleDC(primaryHdc);

            // Create a device-independent bitmap and select it into our DC
            BITMAPINFO info = new BITMAPINFO();
            info.biSize = Marshal.SizeOf(info);
            info.biWidth = bounds.Width;
            info.biHeight = -bounds.Height;
            info.biPlanes = 1;
            info.biBitCount = 32;
            info.biCompression = 0; // BI_RGB
            IntPtr dib = CreateDIBSection(primaryHdc, info, 0, 0, IntPtr.Zero, 0);
            SelectObject(memoryHdc, dib);

            // Create and select font
            IntPtr fontHandle = font.ToHfont();
            SelectObject(memoryHdc, fontHandle);

            // Draw glowing text
            VisualStyleRenderer renderer = new VisualStyleRenderer(System.Windows.Forms.VisualStyles.VisualStyleElement.Window.Caption.Active);
            DTTOPTS dttOpts = new DTTOPTS();
            dttOpts.dwSize = Marshal.SizeOf(typeof(DTTOPTS));

            if (textStyle == TextStyle.Glowing) {
                dttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR;
            }
            else {
                dttOpts.dwFlags = DTT_COMPOSITED | DTT_TEXTCOLOR;
            }
            dttOpts.crText = ColorTranslator.ToWin32(color);
            dttOpts.iGlowSize = 8; // This is about the size Microsoft Word 2007 uses
            RECT textBounds = new RECT(0, 0, bounds.Right - bounds.Left, bounds.Bottom - bounds.Top);
            DrawThemeTextEx(renderer.Handle, memoryHdc, 0, 0, text, -1, (int)flags, ref textBounds, ref dttOpts);

            // Copy to foreground
            const int SRCCOPY = 0x00CC0020;
            BitBlt(primaryHdc, bounds.Left, bounds.Top, bounds.Width, bounds.Height, memoryHdc, 0, 0, SRCCOPY);

            // Clean up
            DeleteObject(fontHandle);
            DeleteObject(dib);
            DeleteDC(memoryHdc);

            graphics.ReleaseHdc(primaryHdc);
        }
Exemple #29
0
		public static void DrawGroupBox (Graphics g, Rectangle bounds, string groupBoxText, Font font, Color textColor, TextFormatFlags flags, GroupBoxState state)
		{
			Size font_size = TextRenderer.MeasureText (groupBoxText, font);

			if (Application.RenderWithVisualStyles || always_use_visual_styles == true) {
				VisualStyleRenderer vsr;
				Rectangle new_bounds;

				switch (state) {
					case GroupBoxState.Normal:
					default:
						vsr = new VisualStyleRenderer (VisualStyleElement.Button.GroupBox.Normal);
						new_bounds = new Rectangle (bounds.Left, bounds.Top + (int)(font_size.Height / 2) - 1, bounds.Width, bounds.Height - (int)(font_size.Height / 2) + 1);
						break;
					case GroupBoxState.Disabled:
						vsr = new VisualStyleRenderer (VisualStyleElement.Button.GroupBox.Disabled);
						new_bounds = new Rectangle (bounds.Left, bounds.Top + (int)(font_size.Height / 2) - 2, bounds.Width, bounds.Height - (int)(font_size.Height / 2) + 2);
						break;
				}

				if (groupBoxText == String.Empty)
					vsr.DrawBackground (g, bounds);
				else
					vsr.DrawBackgroundExcludingArea (g, new_bounds, new Rectangle (bounds.Left + 9, bounds.Top, font_size.Width - 3, font_size.Height));

				if (textColor == Color.Empty)
					textColor = vsr.GetColor (ColorProperty.TextColor);

				if (groupBoxText != String.Empty)
					TextRenderer.DrawText (g, groupBoxText, font, new Point (bounds.Left + 8, bounds.Top), textColor, flags);
			}
			else {
				// MS has a pretty big bug when rendering the non-visual styles group box.  Instead of using the height
				// part of the bounds as height, they use it as the bottom, so the boxes are drawn in completely different
				// places.  Rather than emulate this bug, we do it correctly.  After googling for a while, I don't think
				// anyone has ever actually used this class for anything, so it should be fine.  :)
				Rectangle new_bounds = new Rectangle (bounds.Left, bounds.Top + (int)(font_size.Height / 2), bounds.Width, bounds.Height - (int)(font_size.Height / 2));
				
				// Don't paint over the background where we are going to put the text
				Region old_clip = g.Clip;
				g.SetClip (new Rectangle (bounds.Left + 9, bounds.Top, font_size.Width - 3, font_size.Height), System.Drawing.Drawing2D.CombineMode.Exclude);
				
				ControlPaint.DrawBorder3D (g, new_bounds, Border3DStyle.Etched);
				
				g.Clip = old_clip;

				if (groupBoxText != String.Empty) {
					if (textColor == Color.Empty)
						textColor = state == GroupBoxState.Normal ? SystemColors.ControlText :
							SystemColors.GrayText;
					TextRenderer.DrawText (g, groupBoxText, font, new Point (bounds.Left + 8, bounds.Top), textColor, flags);
				}
			}
		}
Exemple #30
0
        /// <summary>
        /// Paints the size grip.
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs" /> instance containing the event data.</param>
        public void PaintSizeGrip(PaintEventArgs e)
        {
            if (e == null || e.Graphics == null || !resizable)
            {
                return;
            }
            Size clientSize = content.ClientSize;

            if (Application.RenderWithVisualStyles)
            {
                if (this.sizeGripRenderer == null)
                {
                    this.sizeGripRenderer = new VS.VisualStyleRenderer(VS.VisualStyleElement.Status.Gripper.Normal);
                }
                this.sizeGripRenderer.DrawBackground(e.Graphics, new Rectangle(clientSize.Width - 0x10, clientSize.Height - 0x10, 0x10, 0x10));
            }
            else
            {
                ControlPaint.DrawSizeGrip(e.Graphics, content.BackColor, clientSize.Width - 0x10, clientSize.Height - 0x10, 0x10, 0x10);
            }
        }
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip      = e.ToolStrip;
            Graphics  g              = e.Graphics;
            Rectangle affectedBounds = e.AffectedBounds;

            if (base.ShouldPaintBackground(toolStrip))
            {
                if (toolStrip is StatusStrip)
                {
                    RenderStatusStripBackground(e);
                }
                else if (DisplayInformation.HighContrast)
                {
                    FillBackground(g, affectedBounds, SystemColors.ButtonFace);
                }
                else if (DisplayInformation.LowResolution)
                {
                    FillBackground(g, affectedBounds, (toolStrip is ToolStripDropDown) ? SystemColors.ControlLight : e.BackColor);
                }
                else if (toolStrip.IsDropDown)
                {
                    FillBackground(g, affectedBounds, !ToolStripManager.VisualStylesEnabled ? e.BackColor : SystemColors.Menu);
                }
                else if (toolStrip is MenuStrip)
                {
                    FillBackground(g, affectedBounds, !ToolStripManager.VisualStylesEnabled ? e.BackColor : SystemColors.MenuBar);
                }
                else if (ToolStripManager.VisualStylesEnabled && System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(VisualStyleElement.Rebar.Band.Normal))
                {
                    System.Windows.Forms.VisualStyles.VisualStyleRenderer visualStyleRenderer = VisualStyleRenderer;
                    visualStyleRenderer.SetParameters(VisualStyleElement.ToolBar.Bar.Normal);
                    visualStyleRenderer.DrawBackground(g, affectedBounds);
                }
                else
                {
                    FillBackground(g, affectedBounds, !ToolStripManager.VisualStylesEnabled ? e.BackColor : SystemColors.MenuBar);
                }
            }
        }
        protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripSplitButton item   = e.Item as ToolStripSplitButton;
            Graphics             dc     = e.Graphics;
            bool  rightToLeft           = item.RightToLeft == RightToLeft.Yes;
            Color arrowColor            = item.Enabled ? SystemColors.ControlText : SystemColors.ControlDark;
            VisualStyleElement element  = rightToLeft ? VisualStyleElement.ToolBar.SplitButton.Normal : VisualStyleElement.ToolBar.SplitButtonDropDown.Normal;
            VisualStyleElement element2 = rightToLeft ? VisualStyleElement.ToolBar.DropDownButton.Normal : VisualStyleElement.ToolBar.SplitButton.Normal;
            Rectangle          bounds   = new Rectangle(Point.Empty, item.Size);

            if ((ToolStripManager.VisualStylesEnabled && System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(element)) && System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(element2))
            {
                System.Windows.Forms.VisualStyles.VisualStyleRenderer visualStyleRenderer = VisualStyleRenderer;
                visualStyleRenderer.SetParameters(element2.ClassName, element2.Part, GetSplitButtonItemState(item));
                Rectangle buttonBounds = item.ButtonBounds;
                if (rightToLeft)
                {
                    buttonBounds.Inflate(2, 0);
                }
                visualStyleRenderer.DrawBackground(dc, buttonBounds);
                visualStyleRenderer.SetParameters(element.ClassName, element.Part, GetSplitButtonDropDownItemState(item));
                visualStyleRenderer.DrawBackground(dc, item.DropDownButtonBounds);
                Rectangle contentRectangle = item.ContentRectangle;
                if (item.BackgroundImage != null)
                {
                    ControlPaint.DrawBackgroundImage(dc, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, contentRectangle, contentRectangle);
                }
                this.RenderSeparatorInternal(dc, item, item.SplitterBounds, true);
                if (rightToLeft || (item.BackgroundImage != null))
                {
                    base.DrawArrow(new ToolStripArrowRenderEventArgs(dc, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                }
            }
            else
            {
                Rectangle rectangle4 = item.ButtonBounds;
                if (item.BackgroundImage != null)
                {
                    Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                    if (item.BackgroundImage != null)
                    {
                        ControlPaint.DrawBackgroundImage(dc, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, bounds, clipRect);
                    }
                }
                else
                {
                    FillBackground(dc, rectangle4, item.BackColor);
                }
                ToolBarState splitButtonToolBarState = GetSplitButtonToolBarState(item, false);
                this.RenderSmall3DBorderInternal(dc, rectangle4, splitButtonToolBarState, rightToLeft);
                Rectangle dropDownButtonBounds = item.DropDownButtonBounds;
                if (item.BackgroundImage == null)
                {
                    FillBackground(dc, dropDownButtonBounds, item.BackColor);
                }
                splitButtonToolBarState = GetSplitButtonToolBarState(item, true);
                switch (splitButtonToolBarState)
                {
                case ToolBarState.Pressed:
                case ToolBarState.Hot:
                    this.RenderSmall3DBorderInternal(dc, dropDownButtonBounds, splitButtonToolBarState, rightToLeft);
                    break;
                }
                base.DrawArrow(new ToolStripArrowRenderEventArgs(dc, item, dropDownButtonBounds, arrowColor, ArrowDirection.Down));
            }
        }
Exemple #33
0
 private static long GetHashCode(this VisualStyleRenderer r) => (long)r.Class.GetHashCode() << 32 | ((uint)r.Part << 16 | (ushort)r.State);
Exemple #34
0
        /// <summary>
        /// Gets the background image of the current visual style element within the specified background color. If <paramref name="states"/>
        /// is set, the resulting image will contain each of the state images side by side.
        /// </summary>
        /// <param name="rnd">The <see cref="VisualStyleRenderer"/> instance.</param>
        /// <param name="clr">The background color. This color cannot have an alpha channel.</param>
        /// <param name="states">The optional list of states to render side by side.</param>
        /// <returns>The background image.</returns>
        public static Bitmap GetBackgroundBitmap(this VisualStyleRenderer rnd, Color clr, int[] states = null)
        {
            const int wh = 200;

            if (rnd == null)
            {
                throw new ArgumentNullException(nameof(rnd));
            }
            rnd.SetParameters(rnd.Class, rnd.Part, 0);
            if (states == null)
            {
                states = new[] { rnd.State }
            }
            ;
            var i = states.Length;

            // Get image size
            Size imgSz;

            using (var sg = Graphics.FromHwnd(IntPtr.Zero))
                imgSz = rnd.GetPartSize(sg, new Rectangle(0, 0, wh, wh), ThemeSizeType.Draw);
            if (imgSz.Width == 0 || imgSz.Height == 0)
            {
                imgSz = new Size(rnd.GetInteger(IntegerProperty.Width), rnd.GetInteger(IntegerProperty.Height));
            }

            var bounds = new Rectangle(0, 0, imgSz.Width * i, imgSz.Height);

            // Draw each background linearly down the bitmap
            using (var memoryHdc = SafeDCHandle.ScreenCompatibleDCHandle)
            {
                // Create a device-independent bitmap and select it into our DC
                var info = new BITMAPINFO(bounds.Width, -bounds.Height);
                using (new SafeDCObjectHandle(memoryHdc, CreateDIBSection(SafeDCHandle.Null, ref info, DIBColorMode.DIB_RGB_COLORS, out var ppv, IntPtr.Zero, 0)))
                {
                    using (var memoryGraphics = Graphics.FromHdc(memoryHdc.DangerousGetHandle()))
                    {
                        // Setup graphics
                        memoryGraphics.CompositingMode    = CompositingMode.SourceOver;
                        memoryGraphics.CompositingQuality = CompositingQuality.HighQuality;
                        memoryGraphics.SmoothingMode      = SmoothingMode.HighQuality;
                        memoryGraphics.Clear(clr);

                        // Draw each background linearly down the bitmap
                        var rect = new Rectangle(0, 0, imgSz.Width, imgSz.Height);
                        foreach (var state in states)
                        {
                            rnd.SetParameters(rnd.Class, rnd.Part, state);
                            rnd.DrawBackground(memoryGraphics, rect);
                            rect.X += imgSz.Width;
                        }
                    }

                    // Copy DIB to Bitmap
                    var bmp = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb);
                    using (var primaryHdc = new SafeDCHandle(Graphics.FromImage(bmp)))
                        BitBlt(primaryHdc, bounds.Left, bounds.Top, bounds.Width, bounds.Height, memoryHdc, 0, 0, RasterOperationMode.SRCCOPY);
                    return(bmp);
                }
            }
        }
Exemple #35
0
        protected override void OnRenderButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            System.Drawing.Rectangle rectangle1;

            System.Drawing.Graphics graphics1 = e.Graphics;
            Oranikle.Studio.Controls.CtrlTabStrip       ctrlTabStrip       = e.ToolStrip as Oranikle.Studio.Controls.CtrlTabStrip;
            Oranikle.Studio.Controls.CtrlTabStripButton ctrlTabStripButton = e.Item as Oranikle.Studio.Controls.CtrlTabStripButton;
            if ((ctrlTabStrip == null) || (ctrlTabStripButton == null))
            {
                if (currentRenderer != null)
                {
                    currentRenderer.DrawButtonBackground(e);
                    return;
                }
                base.OnRenderButtonBackground(e);
                return;
            }
            bool flag1 = ctrlTabStripButton.Checked;
            bool flag2 = ctrlTabStripButton.Selected;
            int  i1 = 0, i2 = 0;

            System.Drawing.Rectangle rectangle3 = ctrlTabStripButton.Bounds;
            int i3 = rectangle3.Width - 1;

            System.Drawing.Rectangle rectangle4 = ctrlTabStripButton.Bounds;
            int i4 = rectangle4.Height - 1;

            if (UseVS)
            {
                if (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Horizontal)
                {
                    if (!flag1)
                    {
                        i1 = 2;
                        i4--;
                    }
                    else
                    {
                        i1 = 1;
                    }
                    rectangle1 = new System.Drawing.Rectangle(0, 0, i3, i4);
                }
                else
                {
                    if (!flag1)
                    {
                        i2 = 2;
                        i3--;
                    }
                    else
                    {
                        i2 = 1;
                    }
                    rectangle1 = new System.Drawing.Rectangle(0, 0, i4, i3);
                }
                using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(rectangle1.Width, rectangle1.Height))
                {
                    System.Windows.Forms.VisualStyles.VisualStyleElement visualStyleElement = System.Windows.Forms.VisualStyles.VisualStyleElement.Tab.TabItem.Normal;
                    if (flag1)
                    {
                        visualStyleElement = System.Windows.Forms.VisualStyles.VisualStyleElement.Tab.TabItem.Pressed;
                    }
                    if (flag2)
                    {
                        visualStyleElement = System.Windows.Forms.VisualStyles.VisualStyleElement.Tab.TabItem.Hot;
                    }
                    if (!ctrlTabStripButton.Enabled)
                    {
                        visualStyleElement = System.Windows.Forms.VisualStyles.VisualStyleElement.Tab.TabItem.Disabled;
                    }
                    if (!flag1 || flag2)
                    {
                        rectangle1.Width++;
                    }
                    else
                    {
                        rectangle1.Height++;
                    }
                    using (System.Drawing.Graphics graphics2 = System.Drawing.Graphics.FromImage(bitmap))
                    {
                        System.Windows.Forms.VisualStyles.VisualStyleRenderer visualStyleRenderer = new System.Windows.Forms.VisualStyles.VisualStyleRenderer(visualStyleElement);
                        visualStyleRenderer.DrawBackground(graphics2, rectangle1);
                        if (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Vertical)
                        {
                            if (Mirrored)
                            {
                                bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
                            }
                            else
                            {
                                bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipNone);
                            }
                        }
                        else if (Mirrored)
                        {
                            bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
                        }
                        if (Mirrored)
                        {
                            System.Drawing.Rectangle rectangle5 = ctrlTabStripButton.Bounds;
                            i2 = rectangle5.Width - bitmap.Width - i2;
                            System.Drawing.Rectangle rectangle6 = ctrlTabStripButton.Bounds;
                            i1 = rectangle6.Height - bitmap.Height - i1;
                        }
                        graphics1.DrawImage(bitmap, i2, i1);
                    }
                    return;
                }
            }
            if (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Horizontal)
            {
                if (!flag1)
                {
                    i1  = ctrlTabStripButton.VerticalOffsetInactive;
                    i4 -= ctrlTabStripButton.VerticalOffsetInactive - 1;
                }
                else
                {
                    i1 = ctrlTabStripButton.VerticalOffset;
                }
                if (Mirrored)
                {
                    i2 = 1;
                    i1 = 0;
                }
                else
                {
                    i1++;
                }
                i3--;
            }
            else
            {
                if (!flag1)
                {
                    i2 = 2;
                    i3--;
                }
                else
                {
                    i2 = 1;
                }
                if (Mirrored)
                {
                    i2 = 0;
                    i1 = 1;
                }
            }
            i4--;
            rectangle1 = new System.Drawing.Rectangle(i2, i1, i3, i4);
            using (System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath())
            {
                if (Mirrored && (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Horizontal))
                {
                    graphicsPath.AddLine(rectangle1.Left, rectangle1.Top, rectangle1.Left, rectangle1.Bottom - 2);
                    graphicsPath.AddArc(rectangle1.Left, rectangle1.Bottom - 3, 2, 2, 90.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Left + 2, rectangle1.Bottom, rectangle1.Right - 2, rectangle1.Bottom);
                    graphicsPath.AddArc(rectangle1.Right - 2, rectangle1.Bottom - 3, 2, 2, 0.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Right, rectangle1.Bottom - 2, rectangle1.Right, rectangle1.Top);
                }
                else if (!Mirrored && (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Horizontal))
                {
                    int i5 = 1, i6 = 3;
                    graphicsPath.AddLine(rectangle1.Left, rectangle1.Bottom, rectangle1.Left, rectangle1.Top + i6);
                    graphicsPath.AddArc(rectangle1.Left, rectangle1.Top + i6 - 1, i6, i6, 180.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Left + i6, rectangle1.Top, rectangle1.Right - i6 - i5, rectangle1.Top);
                    graphicsPath.AddArc(rectangle1.Right - i6 - i5, rectangle1.Top + i6 - 1, i6, i6, 270.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Right - i5, rectangle1.Top + i6, rectangle1.Right - i5, rectangle1.Bottom);
                }
                else if (Mirrored && (ctrlTabStrip.Orientation == System.Windows.Forms.Orientation.Vertical))
                {
                    graphicsPath.AddLine(rectangle1.Left, rectangle1.Top, rectangle1.Right - 2, rectangle1.Top);
                    graphicsPath.AddArc(rectangle1.Right - 2, rectangle1.Top + 1, 2, 2, 270.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Right, rectangle1.Top + 2, rectangle1.Right, rectangle1.Bottom - 2);
                    graphicsPath.AddArc(rectangle1.Right - 2, rectangle1.Bottom - 3, 2, 2, 0.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Right - 2, rectangle1.Bottom, rectangle1.Left, rectangle1.Bottom);
                }
                else
                {
                    graphicsPath.AddLine(rectangle1.Right, rectangle1.Top, rectangle1.Left + 2, rectangle1.Top);
                    graphicsPath.AddArc(rectangle1.Left, rectangle1.Top + 1, 2, 2, 180.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Left, rectangle1.Top + 2, rectangle1.Left, rectangle1.Bottom - 2);
                    graphicsPath.AddArc(rectangle1.Left, rectangle1.Bottom - 3, 2, 2, 90.0F, 90.0F);
                    graphicsPath.AddLine(rectangle1.Left + 2, rectangle1.Bottom, rectangle1.Right, rectangle1.Bottom);
                }
                System.Drawing.Color color1 = ctrlTabStripButton.BackColorInactive;
                if (flag1)
                {
                    color1 = ctrlTabStripButton.BackColor;
                }
                else if (flag2)
                {
                    color1 = ctrlTabStripButton.BackColorHot;
                }
                System.Drawing.Color color2 = ctrlTabStripButton.BackColor2Inactive;
                if (flag1)
                {
                    color2 = ctrlTabStripButton.BackColor2;
                }
                else if (flag2)
                {
                    color2 = ctrlTabStripButton.BackColor2Hot;
                }
                if (renderMode == System.Windows.Forms.ToolStripRenderMode.Professional)
                {
                    color1 = flag2 ? System.Windows.Forms.ProfessionalColors.ButtonCheckedGradientBegin : System.Windows.Forms.ProfessionalColors.ButtonCheckedGradientEnd;
                    using (System.Drawing.Drawing2D.LinearGradientBrush linearGradientBrush1 = new System.Drawing.Drawing2D.LinearGradientBrush(ctrlTabStripButton.ContentRectangle, color1, System.Windows.Forms.ProfessionalColors.ButtonCheckedGradientMiddle, System.Drawing.Drawing2D.LinearGradientMode.Vertical))
                    {
                        graphics1.FillPath(linearGradientBrush1, graphicsPath);
                        goto label_1;
                    }
                }
                using (System.Drawing.Drawing2D.LinearGradientBrush linearGradientBrush2 = new System.Drawing.Drawing2D.LinearGradientBrush(ctrlTabStripButton.ContentRectangle, color1, color2, System.Drawing.Drawing2D.LinearGradientMode.Vertical))
                {
                    graphics1.FillPath(linearGradientBrush2, graphicsPath);
                }
label_1:
                if (flag1)
                {
                    using (System.Drawing.Pen pen1 = new System.Drawing.Pen(ctrlTabStripButton.BorderColor))
                    {
                        graphics1.DrawPath(pen1, graphicsPath);
                        goto label_2;
                    }
                }
                if (flag2)
                {
                    using (System.Drawing.Pen pen2 = new System.Drawing.Pen(ctrlTabStripButton.BorderColorHot))
                    {
                        graphics1.DrawPath(pen2, graphicsPath);
                        goto label_2;
                    }
                }
                using (System.Drawing.Pen pen3 = new System.Drawing.Pen(ctrlTabStripButton.BorderColorInactive))
                {
                    graphics1.DrawPath(pen3, graphicsPath);
                }
label_2:
                if (ctrlTabStripButton.ShowCloseButton)
                {
                    System.Drawing.Image image = Oranikle.Studio.Controls.Properties.Resources.Icon_Close_Disabled_16;
                    if (flag2)
                    {
                        image = Oranikle.Studio.Controls.Properties.Resources.Icon_Close_16;
                    }
                    System.Drawing.Rectangle rectangle2 = new System.Drawing.Rectangle(i2 + i3 - ctrlTabStripButton.CloseButtonHorizontalOffset, ctrlTabStripButton.CloseButtonVerticalOffset, 8, 8);
                    graphics1.DrawImage(image, rectangle2);
                }
            }
        }
        public static void Draw(IDeviceContext dc, Size minSize, Size maxSize, string title, string text, Rectangle titleRect, Rectangle rect, ToolTipIcon icon, Padding padding)
        {
            if (Application.RenderWithVisualStyles)
            {
                VisualStyleRenderer titleRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.BalloonTitle.Normal);
                VisualStyleRenderer balloonRenderer = new VisualStyleRenderer(VisualStyleElement.ToolTip.Balloon.Normal);
                balloonRenderer.DrawBackground(dc, rect);

                if (icon == ToolTipIcon.None)
                {
                    titleRenderer.DrawText(dc, new Rectangle(padding.Left, padding.Top, rect.Width - (padding.Left + padding.Right), titleRect.Height),
                        title, false, TextFormatFlags.Left | TextFormatFlags.WordEllipsis | TextFormatFlags.VerticalCenter);

                    Rectangle balloonTextBounds = new Rectangle(padding.Left, padding.Top + titleRect.Height, rect.Width - (padding.Left + padding.Right), rect.Height - (padding.Top + titleRect.Height + padding.Bottom));

                    balloonRenderer.DrawText(dc, balloonTextBounds,
                        text, false, TextFormatFlags.Left | TextFormatFlags.WordBreak | TextFormatFlags.VerticalCenter);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }