Simply3DScan
Simple3DScan.UI.ButtonRenderer Class Reference

Just a class for a special style of the toogle buttons More...

Inheritance diagram for Simple3DScan.UI.ButtonRenderer:
Collaboration diagram for Simple3DScan.UI.ButtonRenderer:

Public Member Functions

void DrawButton (PaintEventArgs e, ToggleButtonState toggleState, DisplayType displayMode, Font font, ActiveStateCollection activeState, InactiveStateCollection inactiveState, RightToLeft righttoLeft, bool isMouseHover, ToggleButton toggleButton)
 Method for Drawing the Button Frame for ToggleButton More...
 
void DrawSlider (PaintEventArgs e, Point p, ToggleButtonState toggleState, SliderCollection slider, Font font, RightToLeft righttoLeft, bool isMouseMove, bool isMouseHover)
 Method for Drawing the Slider in ToggleButton More...
 

Detailed Description

Just a class for a special style of the toogle buttons

Definition at line 14 of file ButtonRenderer.cs.

Member Function Documentation

void Simple3DScan.UI.ButtonRenderer.DrawButton ( PaintEventArgs  e,
ToggleButtonState  toggleState,
DisplayType  displayMode,
Font  font,
ActiveStateCollection  activeState,
InactiveStateCollection  inactiveState,
RightToLeft  righttoLeft,
bool  isMouseHover,
ToggleButton  toggleButton 
)

Method for Drawing the Button Frame for ToggleButton

Parameters
e
toggleState
displayMode
font
activeState
inactiveState
righttoLeft
isMouseHover
toggleButton

Definition at line 29 of file ButtonRenderer.cs.

30  {
31  string displayText = Singleton<Translate>.Instance.GetString(toggleState == ToggleButtonState.Active ? activeState.Text : inactiveState.Text, Singleton<Config>.Instance.Information.Language);
32  SizeF textSize = e.Graphics.MeasureString(displayText, font);
33  Rectangle controlRect = new Rectangle(e.ClipRectangle.X + 1, e.ClipRectangle.Y + 1, e.ClipRectangle.Width - 4, e.ClipRectangle.Height - 4);
34  e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
35  GraphicsPath gp = new GraphicsPath();
36 
37  if (controlRect.Height > 1)
38  {
39  gp.AddArc(controlRect.X, controlRect.Y, controlRect.Height, controlRect.Height, 180, 90);
40  gp.AddArc(controlRect.X + controlRect.Width - controlRect.Height, controlRect.Y, controlRect.Height,
41  controlRect.Height, 270, 90);
42  gp.AddArc(controlRect.X + controlRect.Width - controlRect.Height,
43  controlRect.Y + controlRect.Height - controlRect.Height, controlRect.Height, controlRect.Height, 0,
44  90);
45  gp.AddArc(controlRect.X, controlRect.Y + controlRect.Height - controlRect.Height, controlRect.Height,
46  controlRect.Height, 90, 90);
47  gp.CloseFigure();
48  e.Graphics.DrawPath(new Pen(Color.Tan, 2), gp);
49  }
50  GraphicsPath gp1 = new GraphicsPath();
51  using (LinearGradientBrush br = new LinearGradientBrush(e.ClipRectangle, Color.Tan, Color.PapayaWhip, LinearGradientMode.Vertical))
52  {
53  if (controlRect.Height > 1)
54  {
55  gp1.AddArc(controlRect.X, controlRect.Y + 1, controlRect.Height + 2, controlRect.Height, 180, 90);
56  gp1.AddArc(controlRect.X + controlRect.Width - controlRect.Height, controlRect.Y, controlRect.Height, controlRect.Height, 270, 90);
57  gp1.AddArc(controlRect.X + 1 + controlRect.Width - controlRect.Height, controlRect.Y + controlRect.Height - controlRect.Height, controlRect.Height, controlRect.Height, 0, 90);
58  gp1.AddArc(controlRect.X, controlRect.Y + controlRect.Height - controlRect.Height, controlRect.Height, controlRect.Height, 90, 90);
59  gp1.CloseFigure();
60  e.Graphics.FillPath(br, gp1);
61  gp1.Dispose();
62  }
63  }
64  if (isMouseHover)
65  using (SolidBrush br = new SolidBrush(Color.PapayaWhip))
66  {
67  e.Graphics.FillPath(br, gp);
68  }
69  PointF pt1 = new PointF(e.ClipRectangle.X + e.ClipRectangle.Width / 2 - textSize.Width / 2, e.ClipRectangle.Y + e.ClipRectangle.Height / 2 - textSize.Height / 2);
70  using (SolidBrush br = new SolidBrush(Color.Black))
71  {
72  if (displayMode == DisplayType.Text)
73  e.Graphics.DrawString(displayText, font, br, pt1);
74  }
75  gp.Dispose();
76  }
Class for creating a singleton for a generic class
Definition: Singleton.cs:9
static T Instance
Gets the instance.
Definition: Singleton.cs:27
void Simple3DScan.UI.ButtonRenderer.DrawSlider ( PaintEventArgs  e,
Point  p,
ToggleButtonState  toggleState,
SliderCollection  slider,
Font  font,
RightToLeft  righttoLeft,
bool  isMouseMove,
bool  isMouseHover 
)

Method for Drawing the Slider in ToggleButton

Parameters
e
p
toggleState
slider
font
righttoLeft
isMouseMove
isMouseHover

Definition at line 90 of file ButtonRenderer.cs.

91  {
92  e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
93  Rectangle sliderRectangle;
94  if (!isMouseMove)
95  {
96  sliderRectangle = toggleState == ToggleButtonState.Inactive ? new Rectangle(e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Height - 1, e.ClipRectangle.Height - 1) : new Rectangle(e.ClipRectangle.X + e.ClipRectangle.Width - e.ClipRectangle.Height, e.ClipRectangle.Y, e.ClipRectangle.Height - 1, e.ClipRectangle.Height - 1);
97  }
98  else
99  sliderRectangle = new Rectangle(p.X, e.ClipRectangle.Y, e.ClipRectangle.Height - 1, e.ClipRectangle.Height - 1);
100  if (isMouseHover)
101  {
102  using (SolidBrush br = new SolidBrush(slider.BackColor))
103  {
104  e.Graphics.FillEllipse(br, sliderRectangle);
105  using (Pen pn = new Pen(Color.Gray, 2))
106  e.Graphics.DrawEllipse(pn, sliderRectangle);
107  }
108  }
109  else
110  {
111  using (SolidBrush br = new SolidBrush(slider.BackColor))
112  {
113  e.Graphics.FillEllipse(br, sliderRectangle);
114  e.Graphics.DrawEllipse(Pens.Gray, sliderRectangle);
115  }
116  }
117  }

The documentation for this class was generated from the following file: