private void DrawButton(CaptionButton button)
        {
            if (IsHandleCreated)
            {
                // MSDN states that only WINDOW and INTERSECTRGN are needed,
                // but other sources confirm that CACHE is required on Win9x
                // and you need CLIPSIBLINGS to prevent painting on overlapping windows.
                IntPtr hDC = NativeMethods.GetDCEx(this.Handle, (IntPtr)1,
                                                   (int)(NativeMethods.DCX.DCX_WINDOW | NativeMethods.DCX.DCX_INTERSECTRGN
                                                         | NativeMethods.DCX.DCX_CACHE | NativeMethods.DCX.DCX_CLIPSIBLINGS));

                if (hDC == IntPtr.Zero)
                {
                    hDC = NativeMethods.GetWindowDC(this.Handle);
                }

                if (hDC != IntPtr.Zero)
                {
                    using (Graphics g = Graphics.FromHdc(hDC))
                    {
                        button.DrawButton(g, true);
                    }
                }

                NativeMethods.ReleaseDC(this.Handle, hDC);
            }
        }
 /// <summary>
 /// Gets the character to render the specified button type
 /// </summary>
 /// <param name="type">type of button</param>
 /// <returns>Character to use with Marlett font in Windows, some other representative characters when in other O.S.</returns>
 public static string GetCharFor(CaptionButton type)
 {
     if (WinApi.IsWindows)
     {
         switch (type)
         {
             case CaptionButton.Minimize:
                 return "0";
             case CaptionButton.Maximize:
                 return "1";
             case CaptionButton.Restore:
                 return "2";
             case CaptionButton.Close:
                 return "r";
             default:
                 return "?";
         }
     }
     else
     {
         switch (type)
         {
             case CaptionButton.Minimize:
                 return "_";
             case CaptionButton.Maximize:
                 return "+";
             case CaptionButton.Restore:
                 return "^";
             case CaptionButton.Close:
                 return "X";
             default:
                 return "?";
         }
     }
 } 
		public CustomBorderForm()
		{
			closeButton = new CaptionButton();
			closeButton.Key = "close";
			closeButton.Visible = true;
			closeButton.HitTestCode = (int)NativeMethods.NCHITTEST.HTCLOSE;
			_captionButtons.Add(closeButton);

			maximizeButton = new CaptionButton();
			maximizeButton.Key = "maximize";
            maximizeButton.Enabled = this.MaximizeBox;
			maximizeButton.HitTestCode = (int)NativeMethods.NCHITTEST.HTMAXBUTTON;
			_captionButtons.Add(maximizeButton);

			minimizeButton = new CaptionButton();
			minimizeButton.Key = "minimize";
			minimizeButton.Enabled = this.MinimizeBox;
			minimizeButton.HitTestCode = (int)NativeMethods.NCHITTEST.HTMINBUTTON;
			_captionButtons.Add(minimizeButton);

			this.minimizeButton.Visible = this.maximizeButton.Visible
				= this.maximizeButton.Enabled | this.minimizeButton.Enabled;

			helpButton = new CaptionButton();
			helpButton.Key = "help";
			helpButton.Visible = this.HelpButton;
			helpButton.HitTestCode = (int)NativeMethods.NCHITTEST.HTHELP;
			_captionButtons.Add(helpButton);

            UpdateActiveFormStyle();
            FormStyleManager.StyleChanged += new EventHandler(FormStyleManager_StyleChanged);
		}
Beispiel #4
0
 /// <summary>
 /// Gets the character to render the specified button type
 /// </summary>
 /// <param name="type">type of button</param>
 /// <returns>Character to use with "Marlett" font in Windows, some other representative characters when in other O.S.</returns>
 public static string GetCharFor(CaptionButton type)
 {
    if (WinApi.IsWindows)
    {
       switch (type)
       {
          case CaptionButton.Minimize:
             return "0";
          case CaptionButton.Maximize:
             return "1";
          case CaptionButton.Restore:
             return "2";
          case CaptionButton.Close:
             return "r";
          default:
             return "?";
       }
    }
    else
    {
       switch (type)
       {
          case CaptionButton.Minimize:
             return "_";
          case CaptionButton.Maximize:
             return "+";
          case CaptionButton.Restore:
             return "^";
          case CaptionButton.Close:
             return "X";
          default:
             return "?";
       }
    }
 }
Beispiel #5
0
        public CustomBorderForm()
        {
            closeButton             = new CaptionButton();
            closeButton.Key         = "close";
            closeButton.Visible     = true;
            closeButton.HitTestCode = (int)NativeMethods.NCHITTEST.HTCLOSE;
            _captionButtons.Add(closeButton);

            maximizeButton             = new CaptionButton();
            maximizeButton.Key         = "maximize";
            maximizeButton.Enabled     = this.MaximizeBox;
            maximizeButton.HitTestCode = (int)NativeMethods.NCHITTEST.HTMAXBUTTON;
            _captionButtons.Add(maximizeButton);

            minimizeButton             = new CaptionButton();
            minimizeButton.Key         = "minimize";
            minimizeButton.Enabled     = this.MinimizeBox;
            minimizeButton.HitTestCode = (int)NativeMethods.NCHITTEST.HTMINBUTTON;
            _captionButtons.Add(minimizeButton);

            this.minimizeButton.Visible             = this.maximizeButton.Visible
                                                    = this.maximizeButton.Enabled | this.minimizeButton.Enabled;

            helpButton             = new CaptionButton();
            helpButton.Key         = "help";
            helpButton.Visible     = this.HelpButton;
            helpButton.HitTestCode = (int)NativeMethods.NCHITTEST.HTHELP;
            _captionButtons.Add(helpButton);

            UpdateActiveFormStyle();
            FormStyleManager.StyleChanged += new EventHandler(FormStyleManager_StyleChanged);
        }
Beispiel #6
0
 public static void DrawCaptionButton
     (Graphics graphics, int x, int y, int width, int height,
     CaptionButton button, ButtonState state)
 {
     ThemeManager.MainPainter.DrawCaptionButton
         (graphics, x, y, width, height, button, state);
 }
Beispiel #7
0
 // Draw a caption button control.
 public static void DrawCaptionButton
     (Graphics graphics, Rectangle rectangle,
     CaptionButton button, ButtonState state)
 {
     DrawCaptionButton(graphics, rectangle.X, rectangle.Y,
                       rectangle.Width, rectangle.Height,
                       button, state);
 }
Beispiel #8
0
        /// <summary>
        /// Draws a caption button control.
        /// </summary>
        /// <param name="graphics">The <see cref="Graphics"/> to draw on.</param>
        /// <param name="rectangle">The <see cref="Rectangle"/> that represents the dimensions of the caption button.</param>
        /// <param name="button">One of the <see cref="CaptionButton"/> values that specifies the type of caption button to draw.</param>
        /// <param name="state">A bitwise combination of the <see cref="ButtonState"/> values that specifies the state to draw the button in.</param>
        public static void DrawCaptionButton(Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state)
        {
            IntPtr hdc = graphics.GetHdc();

            RECT r = RECT.FromXYWH(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);

            NativeMethods.DrawFrameControl(hdc, ref r, NativeMethods.DFC.CAPTION, (NativeMethods.DFCS)button | (NativeMethods.DFCS)state);

            graphics.ReleaseHdc(hdc);
        }
Beispiel #9
0
        /// <summary>
        /// Gets the character to render the specified button type
        /// </summary>
        /// <param name="type">type of button</param>
        /// <returns>Character to use with "Marlett" font in Windows, some other representative characters when in other O.S.</returns>
        public static string GetCharFor(CaptionButton type)
        {
            if (WinApi.IsWindows)
            {
                switch (type)
                {
                case CaptionButton.Minimize:
                    return("0");

                case CaptionButton.Maximize:
                    return("1");

                case CaptionButton.Restore:
                    return("2");

                case CaptionButton.Close:
                    return("r");

                default:
                    return("?");
                }
            }
            else
            {
                switch (type)
                {
                case CaptionButton.Minimize:
                    return("_");

                case CaptionButton.Maximize:
                    return("+");

                case CaptionButton.Restore:
                    return("^");

                case CaptionButton.Close:
                    return("X");

                default:
                    return("?");
                }
            }
        }
	// Draw a caption button control.
	public virtual void DrawCaptionButton
				(Graphics graphics, int x, int y, int width, int height,
				 CaptionButton button, ButtonState state)
			{
				Color color;

				// Draw the border on the button.
				DrawButton(graphics, x, y, width, height, state,
						   SystemColors.ControlText, SystemColors.Control,
						   false);

				// Adjust the glyph position if necessary.
				if((state & ButtonState.Pushed) != 0)
				{
					++x;
					++y;
				}

				// Draw the inactive drop shadow glyph on the button.
				if((state & ButtonState.Inactive) != 0)
				{
					color = SystemColors.ControlLightLight;
					switch(button)
					{
						case CaptionButton.Close:
						{
							DrawGlyph(graphics, x + 1, y + 1, width, height,
									  Glyphs.close_button_bits,
									  Glyphs.close_button_width,
									  Glyphs.close_button_height, color);
						}
						break;

						case CaptionButton.Minimize:
						{
							DrawGlyph(graphics, x + 1, y + 1, width, height,
									  Glyphs.minimize_button_bits,
									  Glyphs.minimize_button_width,
									  Glyphs.minimize_button_height, color);
						}
						break;

						case CaptionButton.Maximize:
						{
							DrawGlyph(graphics, x + 1, y + 1, width, height,
									  Glyphs.maximize_button_bits,
									  Glyphs.maximize_button_width,
									  Glyphs.maximize_button_height, color);
						}
						break;

						case CaptionButton.Restore:
						{
							DrawGlyph(graphics, x + 1, y + 1, width, height,
									  Glyphs.restore_button_bits,
									  Glyphs.restore_button_width,
									  Glyphs.restore_button_height, color);
						}
						break;

						case CaptionButton.Help:
						{
							DrawGlyph(graphics, x + 1, y + 1, width, height,
									  Glyphs.help_button_bits,
									  Glyphs.help_button_width,
									  Glyphs.help_button_height, color);
						}
						break;
					}
				}

				// Determine the color to use for the glyph.
				if((state & ButtonState.Inactive) != 0)
				{
					color = SystemColors.ControlDark;
				}
				else
				{
					color = SystemColors.ControlText;
				}

				// Draw the glyph on the button.
				switch(button)
				{
					case CaptionButton.Close:
					{
						DrawGlyph(graphics, x, y, width, height,
								  Glyphs.close_button_bits,
								  Glyphs.close_button_width,
								  Glyphs.close_button_height, color);
					}
					break;

					case CaptionButton.Minimize:
					{
						DrawGlyph(graphics, x, y, width, height,
								  Glyphs.minimize_button_bits,
								  Glyphs.minimize_button_width,
								  Glyphs.minimize_button_height, color);
					}
					break;

					case CaptionButton.Maximize:
					{
						DrawGlyph(graphics, x, y, width, height,
								  Glyphs.maximize_button_bits,
								  Glyphs.maximize_button_width,
								  Glyphs.maximize_button_height, color);
					}
					break;

					case CaptionButton.Restore:
					{
						DrawGlyph(graphics, x, y, width, height,
								  Glyphs.restore_button_bits,
								  Glyphs.restore_button_width,
								  Glyphs.restore_button_height, color);
					}
					break;

					case CaptionButton.Help:
					{
						DrawGlyph(graphics, x, y, width, height,
								  Glyphs.help_button_bits,
								  Glyphs.help_button_width,
								  Glyphs.help_button_height, color);
					}
					break;
				}
			}
		private void DrawButton(CaptionButton button)
		{
            if (IsHandleCreated)
            {
                // MSDN states that only WINDOW and INTERSECTRGN are needed,
                // but other sources confirm that CACHE is required on Win9x
                // and you need CLIPSIBLINGS to prevent painting on overlapping windows.
                IntPtr hDC = NativeMethods.GetDCEx(this.Handle, (IntPtr)1,
                    (int)(NativeMethods.DCX.DCX_WINDOW | NativeMethods.DCX.DCX_INTERSECTRGN
                        | NativeMethods.DCX.DCX_CACHE | NativeMethods.DCX.DCX_CLIPSIBLINGS));

			    if (hDC != IntPtr.Zero)
			    {
				    using (Graphics g = Graphics.FromHdc(hDC))
				    {
					    button.DrawButton(g, true);
				    }
			    }

                NativeMethods.ReleaseDC(this.Handle, hDC);
            }
		}
		private bool DepressButton(CaptionButton currentButton)
		{
			bool result = false;
			try
			{
				// callect all mouse events until WL_BUTTONUP
				this.Capture = true;		// hopefully doeas the same as SetCapture(handle)
				
				// draw button in pressed mode
				currentButton.State = CaptionButtonState.Pressed;
				DrawButton(currentButton);

				// loop untill button is released
				bool done = false;
				while (!done)
				{
					// NOTE: This struct needs to be here. We had strange error (starting from Beta 2).
					// when this was defined at begining of this method. also check if types are correct (no overlap). 
					Message m = new Message();
					if (NativeMethods.PeekMessage(ref m, IntPtr.Zero,
						(int)NativeMethods.WindowMessages.WM_MOUSEFIRST, (int)NativeMethods.WindowMessages.WM_MOUSELAST,
						(int)NativeMethods.PeekMessageOptions.PM_REMOVE))
					{
						Log(MethodInfo.GetCurrentMethod(), "Message = {0}, Button = {1}", (NativeMethods.WindowMessages)m.Msg, currentButton);
						switch(m.Msg)
						{
						    case (int)NativeMethods.WindowMessages.WM_LBUTTONUP:
								{
									if (currentButton.State == CaptionButtonState.Pressed)
									{
										currentButton.State = CaptionButtonState.Normal;
										DrawButton(currentButton);
									}
									Point pt = PointToWindow(PointToScreen(new Point(m.LParam.ToInt32())));
									Log(MethodInfo.GetCurrentMethod(), "### Point = ({0}, {1})", pt.X, pt.Y);
									result = currentButton.Bounds.Contains(pt);
									done = true;
									break;
								}
							case (int)NativeMethods.WindowMessages.WM_MOUSEMOVE:
								{
									Point clientPoint = PointToWindow(PointToScreen(new Point(m.LParam.ToInt32())));
									if (currentButton.Bounds.Contains(clientPoint))
									{
										if (currentButton.State == CaptionButtonState.Normal)
										{
											currentButton.State = CaptionButtonState.Pressed;
											DrawButton(currentButton);
										}
									}
									else
									{
										if (currentButton.State == CaptionButtonState.Pressed)
										{
											currentButton.State = CaptionButtonState.Normal;
											DrawButton(currentButton);
										}
									}
									break;
								}
						}
					}
				}
			}
			finally 
			{
				this.Capture = false;
			}

			return result;
		}
Beispiel #13
0
 internal bool IsSystemButton(CaptionButton id)
 {
     return(SystemButtonID.HasValue && SystemButtonID.Value == id);
 }
 public static void DrawCaptionButton(Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state)
 {
     DrawCaptionButton(graphics, new Rectangle(x, y, width, height), button, state);
 }
	public static void DrawCaptionButton(System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, CaptionButton button, ButtonState state) {}
		public override void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state)
		{
			if (!RenderClientAreas ||
				(state & ButtonState.Flat) == ButtonState.Flat ||
				(state & ButtonState.Checked) == ButtonState.Checked) {
				base.CPDrawCaptionButton (graphics, rectangle, button, state);
				return;
			}
			VisualStyleElement element = GetCaptionButtonVisualStyleElement (button, state);
			if (!VisualStyleRenderer.IsElementDefined (element)) {
				base.CPDrawCaptionButton (graphics, rectangle, button, state);
				return;
			}
			new VisualStyleRenderer (element).DrawBackground (graphics, rectangle);
		}
Beispiel #17
0
 /// <summary>
 /// Sets value to the type of caption button
 /// </summary>
 /// <param name="buttonType"></param>
 internal void SetCaptionButtonType(CaptionButton buttonType)
 {
     Text = GetCharFor(buttonType);
     _captionButtonType = buttonType;
 }
Beispiel #18
0
		public override void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state) {
			Rectangle	captionRect;
			int			lineWidth;

			CPDrawButtonInternal (graphics, rectangle, state, SystemPens.ControlDarkDark, SystemPens.ControlDark, SystemPens.ControlLightLight);

			if (rectangle.Width<rectangle.Height) {
				captionRect=new Rectangle(rectangle.X+1, rectangle.Y+rectangle.Height/2-rectangle.Width/2+1, rectangle.Width-4, rectangle.Width-4);
			} else {
				captionRect=new Rectangle(rectangle.X+rectangle.Width/2-rectangle.Height/2+1, rectangle.Y+1, rectangle.Height-4, rectangle.Height-4);
			}

			if ((state & ButtonState.Pushed)!=0) {
				captionRect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-3, rectangle.Height-3);
			}

			/* Make sure we've got at least a line width of 1 */
			lineWidth=Math.Max(1, captionRect.Width/7);

			switch(button) {
			case CaptionButton.Close: {
				Pen	pen;

				if ((state & ButtonState.Inactive)!=0) {
					pen = ResPool.GetSizedPen (ColorControlLight, lineWidth);
					DrawCaptionHelper(graphics, ColorControlLight, pen, lineWidth, 1, captionRect, button);

					pen = ResPool.GetSizedPen (ColorControlDark, lineWidth);
					DrawCaptionHelper(graphics, ColorControlDark, pen, lineWidth, 0, captionRect, button);
					return;
				} else {
					pen = ResPool.GetSizedPen (ColorControlText, lineWidth);
					DrawCaptionHelper(graphics, ColorControlText, pen, lineWidth, 0, captionRect, button);
					return;
				}
			}

			case CaptionButton.Help:
			case CaptionButton.Maximize:
			case CaptionButton.Minimize:
			case CaptionButton.Restore: {
				if ((state & ButtonState.Inactive)!=0) {
					DrawCaptionHelper(graphics, ColorControlLight, SystemPens.ControlLightLight, lineWidth, 1, captionRect, button);

					DrawCaptionHelper(graphics, ColorControlDark, SystemPens.ControlDark, lineWidth, 0, captionRect, button);
					return;
				} else {
					DrawCaptionHelper(graphics, ColorControlText, SystemPens.ControlText, lineWidth, 0, captionRect, button);
					return;
				}
			}
			}
		}
Beispiel #19
0
 public void Add(CaptionButton button)
 {
     this.List.Add(button);
 }
Beispiel #20
0
		public abstract void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state);
 public static void DrawCaptionButton(System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, CaptionButton button, ButtonState state)
 {
 }
Beispiel #22
0
        private bool DepressButton(CaptionButton currentButton)
        {
            bool result = false;

            try
            {
                // callect all mouse events until WL_BUTTONUP
                this.Capture = true;                            // hopefully doeas the same as SetCapture(handle)

                // draw button in pressed mode
                currentButton.State = CaptionButtonState.Pressed;
                DrawButton(currentButton);

                // loop untill button is released
                bool done = false;
                while (!done)
                {
                    // NOTE: This struct needs to be here. We had strange error (starting from Beta 2).
                    // when this was defined at begining of this method. also check if types are correct (no overlap).
                    Message m = new Message();
                    if (NativeMethods.PeekMessage(ref m, IntPtr.Zero,
                                                  (int)NativeMethods.WindowMessages.WM_MOUSEFIRST, (int)NativeMethods.WindowMessages.WM_MOUSELAST,
                                                  (int)NativeMethods.PeekMessageOptions.PM_REMOVE))
                    {
                        Log(MethodInfo.GetCurrentMethod(), "Message = {0}, Button = {1}", (NativeMethods.WindowMessages)m.Msg, currentButton);
                        switch (m.Msg)
                        {
                        case (int)NativeMethods.WindowMessages.WM_LBUTTONUP:
                        {
                            if (currentButton.State == CaptionButtonState.Pressed)
                            {
                                currentButton.State = CaptionButtonState.Normal;
                                DrawButton(currentButton);
                            }
                            Point pt = PointToWindow(PointToScreen(new Point(m.LParam.ToInt32())));
                            Log(MethodInfo.GetCurrentMethod(), "### Point = ({0}, {1})", pt.X, pt.Y);
                            result = currentButton.Bounds.Contains(pt);
                            done   = true;
                            break;
                        }

                        case (int)NativeMethods.WindowMessages.WM_MOUSEMOVE:
                        {
                            Point clientPoint = PointToWindow(PointToScreen(new Point(m.LParam.ToInt32())));
                            if (currentButton.Bounds.Contains(clientPoint))
                            {
                                if (currentButton.State == CaptionButtonState.Normal)
                                {
                                    currentButton.State = CaptionButtonState.Pressed;
                                    DrawButton(currentButton);
                                }
                            }
                            else
                            {
                                if (currentButton.State == CaptionButtonState.Pressed)
                                {
                                    currentButton.State = CaptionButtonState.Normal;
                                    DrawButton(currentButton);
                                }
                            }
                            break;
                        }
                        }
                    }
                }
            }
            finally
            {
                this.Capture = false;
            }

            return(result);
        }
 public static void DrawCaptionButton(Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state)
 {
     ThemeEngine.Current.CPDrawCaptionButton(graphics, rectangle, button, state);
 }
			public void Add(CaptionButton button)
			{
				this.List.Add(button);
			}
Beispiel #25
0
 public abstract void CPDrawCaptionButton(Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state);
Beispiel #26
0
		public TitleButton (CaptionButton caption, EventHandler clicked)
		{
			Caption = caption;
			Clicked = clicked;
		}
	public static void DrawCaptionButton
				(Graphics graphics, int x, int y, int width, int height,
				 CaptionButton button, ButtonState state)
			{
				ThemeManager.MainPainter.DrawCaptionButton
					(graphics, x, y, width, height, button, state);
			}
	public static void DrawCaptionButton(System.Drawing.Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state) {}
 public static void DrawCaptionButton(Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state)
 {
     DrawCaptionButton(graphics, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, button, state);
 }
		static VisualStyleElement GetCaptionButtonVisualStyleElement (CaptionButton button, ButtonState state)
		{
			switch (button) {
			case CaptionButton.Minimize:
				if ((state & ButtonState.Inactive) == ButtonState.Inactive)
					return VisualStyleElement.Window.MinButton.Disabled;
				else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
					return VisualStyleElement.Window.MinButton.Pressed;
				else
					return VisualStyleElement.Window.MinButton.Normal;
			case CaptionButton.Maximize:
				if ((state & ButtonState.Inactive) == ButtonState.Inactive)
					return VisualStyleElement.Window.MaxButton.Disabled;
				else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
					return VisualStyleElement.Window.MaxButton.Pressed;
				else
					return VisualStyleElement.Window.MaxButton.Normal;
			case CaptionButton.Close:
				if ((state & ButtonState.Inactive) == ButtonState.Inactive)
					return VisualStyleElement.Window.CloseButton.Disabled;
				else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
					return VisualStyleElement.Window.CloseButton.Pressed;
				else
					return VisualStyleElement.Window.CloseButton.Normal;
			case CaptionButton.Restore:
				if ((state & ButtonState.Inactive) == ButtonState.Inactive)
					return VisualStyleElement.Window.RestoreButton.Disabled;
				else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
					return VisualStyleElement.Window.RestoreButton.Pressed;
				else
					return VisualStyleElement.Window.RestoreButton.Normal;
			default:
				if ((state & ButtonState.Inactive) == ButtonState.Inactive)
					return VisualStyleElement.Window.HelpButton.Disabled;
				else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
					return VisualStyleElement.Window.HelpButton.Pressed;
				else
					return VisualStyleElement.Window.HelpButton.Normal;
			}
		}
Beispiel #31
0
 internal CaptionButtonInfo(string text, CaptionButton systemButtonID)
 {
     Text           = text;
     SystemButtonID = systemButtonID;
     Visible        = true;
 }
Beispiel #32
0
 /// <summary>
 /// Creates a new CaptionButton
 /// </summary>
 /// <param name="buttonType"></param>
 public RibbonCaptionButton(CaptionButton buttonType)
 {
     SetCaptionButtonType(buttonType);
 }
 public static void DrawCaptionButton(System.Drawing.Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state)
 {
 }
Beispiel #34
0
 public TitleButton(CaptionButton caption, EventHandler clicked)
 {
     Caption = caption;
     Clicked = clicked;
 }
Beispiel #35
0
 public static void DrawCaptionButton(Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state)
 {
     throw null;
 }
Beispiel #36
0
		/*
			This function actually draws the various caption elements.
			This way we can scale them nicely, no matter what size, and they
			still look like MS's scaled caption buttons. (as opposed to scaling a bitmap)
		*/

		private void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
			switch(button) {
			case CaptionButton.Close: {
				if (lineWidth<2) {
					graphics.DrawLine(pen, captionRect.Left+2*lineWidth+1+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+1+shift, captionRect.Bottom-2*lineWidth+shift);
					graphics.DrawLine(pen, captionRect.Right-2*lineWidth+1+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+1+shift, captionRect.Bottom-2*lineWidth+shift);
				}

				graphics.DrawLine(pen, captionRect.Left+2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
				graphics.DrawLine(pen, captionRect.Right-2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
				return;
			}

			case CaptionButton.Help: {
				StringFormat	sf = new StringFormat();				
				Font				font = new Font("Microsoft Sans Serif", captionRect.Height, FontStyle.Bold, GraphicsUnit.Pixel);

				sf.Alignment=StringAlignment.Center;
				sf.LineAlignment=StringAlignment.Center;


				graphics.DrawString("?", font, ResPool.GetSolidBrush (color), captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);

				sf.Dispose();				
				font.Dispose();

				return;
			}

			case CaptionButton.Maximize: {
				/* Top 'caption bar' line */
				for (int i=0; i<Math.Max(2, lineWidth); i++) {
					graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Top+2*lineWidth+shift+i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+2*lineWidth+shift+i);
				}

				/* Left side line */
				for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
					graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
				}

				/* Right side line */
				for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
					graphics.DrawLine(pen, captionRect.Right-lineWidth-lineWidth/2+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Right-lineWidth-lineWidth/2+shift+i, captionRect.Bottom-lineWidth+shift);
				}

				/* Bottom line */
				for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
					graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
				}
				return;
			}

			case CaptionButton.Minimize: {
				/* Bottom line */
				for (int i=0; i<Math.Max(2, lineWidth); i++) {
					graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth+shift, captionRect.Bottom-lineWidth+shift-i);
				}
				return;
			}

			case CaptionButton.Restore: {
				/** First 'window' **/
				/* Top 'caption bar' line */
				for (int i=0; i<Math.Max(2, lineWidth); i++) {
					graphics.DrawLine(pen, captionRect.Left+3*lineWidth+shift, captionRect.Top+2*lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+2*lineWidth+shift-i);
				}

				/* Left side line */
				for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
					graphics.DrawLine(pen, captionRect.Left+3*lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+3*lineWidth+shift+i, captionRect.Top+4*lineWidth+shift);
				}

				/* Right side line */
				for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
					graphics.DrawLine(pen, captionRect.Right-lineWidth-lineWidth/2+shift-i, captionRect.Top+2*lineWidth+shift, captionRect.Right-lineWidth-lineWidth/2+shift-i, captionRect.Top+5*lineWidth-lineWidth/2+shift);
				}

				/* Bottom line */
				for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
					graphics.DrawLine(pen, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Top+5*lineWidth-lineWidth/2+shift+1+i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+5*lineWidth-lineWidth/2+shift+1+i);
				}

				/** Second 'window' **/
				/* Top 'caption bar' line */
				for (int i=0; i<Math.Max(2, lineWidth); i++) {
					graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Top+4*lineWidth+shift+1-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Top+4*lineWidth+shift+1-i);
				}

				/* Left side line */
				for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
					graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+4*lineWidth+shift+1, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
				}

				/* Right side line */
				for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
					graphics.DrawLine(pen, captionRect.Right-3*lineWidth-lineWidth/2+shift-i, captionRect.Top+4*lineWidth+shift+1, captionRect.Right-3*lineWidth-lineWidth/2+shift-i, captionRect.Bottom-lineWidth+shift);
				}

				/* Bottom line */
				for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
					graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
				}

				return;
			}

			}
		}
Beispiel #37
0
 public static void DrawCaptionButton(Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state)
 {
     throw null;
 }
 /// <summary>
 /// Sets value to the type of caption button
 /// </summary>
 /// <param name="buttonType"></param>
 internal void SetCaptionButtonType(CaptionButton buttonType)
 {
     Text = GetCharFor(buttonType);
     _captionButtonType = buttonType;
 }
		public static void DrawCaptionButton(Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state) {
			DrawCaptionButton(graphics, new Rectangle(x, y, width, height), button, state);
		}
 /// <summary>
 /// Creates a new CaptionButton
 /// </summary>
 /// <param name="buttonType"></param>
 public RibbonCaptionButton(CaptionButton buttonType)
 {
     SetCaptionButtonType(buttonType);
 } 
		public static void DrawCaptionButton(Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state) {

			ThemeEngine.Current.CPDrawCaptionButton (graphics, rectangle, button, state);
		}
 public static void DrawCaptionButton(Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state)
 {
     DrawFrameControl(graphics, x, y, width, height, 1, (int) (button | ((CaptionButton) ((int) state))), Color.Empty, Color.Empty);
 }
 /// <include file='doc\ControlPaint.uex' path='docs/doc[@for="ControlPaint.DrawCaptionButton1"]/*' />
 /// <devdoc>
 ///     Draws a Win32 window caption button in the given rectangle with the given state.
 /// </devdoc>
 public static void DrawCaptionButton(Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state) {
     DrawFrameControl(graphics, x, y, width, height, NativeMethods.DFC_CAPTION,
                      (int) button | (int) state, Color.Empty, Color.Empty);
 }