Skip to content

Commit a3b31b1

Browse files
committed
nothing really important
1 parent 6f86b5d commit a3b31b1

9 files changed

Lines changed: 59 additions & 19 deletions

File tree

System/Drawing/Font.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public override string ToString()
3737
}
3838
}
3939

40+
[Flags]
4041
public enum FontStyle
4142
{
4243
Regular = 0,

System/Drawing/Graphics.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ internal void GroupEnd()
3636

3737
public static PointF[] GetBezierApproximation(PointF[] controlPoints, int outputSegmentCount)
3838
{
39+
if (outputSegmentCount <= 0) return null;
3940
PointF[] points = new PointF[outputSegmentCount + 1];
4041
for (int i = 0; i <= outputSegmentCount; i++)
4142
{
@@ -332,7 +333,7 @@ public void DrawPoint(Color color, PointF point)
332333
}
333334
public void DrawPoint(Color color, int x, int y)
334335
{
335-
DrawPoint(color, x, y);
336+
DrawPoint(color, (float)x, (float)y);
336337
}
337338
public void DrawPoint(Color color, float x, float y)
338339
{

System/Windows/Forms/AnchorStyles.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace System.Windows.Forms
77
{
8+
[Flags]
89
public enum AnchorStyles
910
{
1011
// Сводка:

System/Windows/Forms/Application.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,14 @@ private Control _ControlAt(Control parentControl, System.Drawing.Point mousePosi
7272
{
7373
control = parentControl;
7474

75-
if (control != null)
76-
{
77-
if (parentControl.Controls.Count > 0)
78-
for (int i = 0; i < parentControl.Controls.Count; i++)
79-
{
80-
var childControl = parentControl.Controls[i];
81-
var childControlAt = _ControlAt(childControl, mousePosition);
82-
if (childControlAt != null)
83-
control = childControlAt;
84-
}
85-
}
75+
if (parentControl.Controls.Count > 0)
76+
for (int i = 0; i < parentControl.Controls.Count; i++)
77+
{
78+
var childControl = parentControl.Controls[i];
79+
var childControlAt = _ControlAt(childControl, mousePosition);
80+
if (childControlAt != null)
81+
control = childControlAt;
82+
}
8683
}
8784

8885
return control;

System/Windows/Forms/Button.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ public class Button : Control
1919
get { return NormalColor; }
2020
set { NormalColor = value; }
2121
}
22-
public virtual Color HoverBorderColor { get; set; }
23-
public virtual Color HoverColor { get; set; }
22+
public Color HoverBorderColor { get; set; }
23+
public Color HoverColor { get; set; }
2424
public Bitmap Image { get; set; }
2525
public Bitmap ImageHover { get; set; }
2626
public Color ImageColor { get; set; }
2727
public Color? ImageHoverColor { get; set; }
28-
public virtual Color NormalBorderColor { get; set; }
29-
public virtual Color NormalColor
28+
public Color NormalBorderColor { get; set; }
29+
public Color NormalColor
3030
{
3131
get { return _normalColor; }
3232
set

System/Windows/Forms/ListBox.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ protected override void OnPaint(PaintEventArgs e)
224224
for (int i = 0; i < _visibleItems && i + ScrollIndex < Items.Count; i++)
225225
{
226226
bool itemDisabled = Items.IsDisabled(i + ScrollIndex);
227-
bool itemSelected = i + _scrollIndex == SelectedIndex;
227+
bool itemSelected = (i + _scrollIndex) == SelectedIndex;
228228
bool itemHovered = i == _hoveredItem;
229229
if (itemSelected || itemHovered)
230230
{

System/Windows/Forms/ScrollEventArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ScrollEventArgs : EventArgs
1414
public ScrollEventArgs(ScrollEventType type, int newValue)
1515
{
1616
_scrollType = type;
17-
NewValue = NewValue;
17+
NewValue = newValue;
1818
}
1919
public ScrollEventArgs(ScrollEventType type, int oldValue, int newValue)
2020
{

System/Windows/Forms/ToolStripItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public abstract class ToolStripItem : Component
3131
protected internal ToolStrip Parent { get; set; }
3232
public virtual bool Pressed { get { return false; } }
3333
public virtual bool Selected { get; internal set; }
34-
public virtual Size Size { get { return new Size(Width, Height); } set { Width = value.Width; Height = value.Height; } }
34+
public Size Size { get { return new Size(Width, Height); } set { Width = value.Width; Height = value.Height; } }
3535
public virtual string Text { get; set; }
3636
public virtual StringFormat TextAlign { get; set; }
3737
public bool Visible { get; set; }

System/Windows/Forms/Utility/ControlHelper.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,38 @@ namespace System.Windows.Forms
1111
/// </summary>
1212
public static class ControlHelper
1313
{
14+
public static void AddDialogButtons(this Control f, Control buttonOk, Control buttonCancel, params Control[] additionalButtons)
15+
{
16+
if (buttonOk == null) buttonOk = new Button();
17+
if (buttonCancel == null) buttonCancel = new Button();
18+
19+
buttonCancel.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
20+
buttonCancel.Location = new Point(f.Width - buttonCancel.Width - 12, f.Height - buttonCancel.Height - 15);
21+
buttonCancel.Text = "Cancel";
22+
f.Controls.Add(buttonCancel);
23+
24+
buttonOk.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
25+
buttonOk.Location = new Point(buttonCancel.Location.X - buttonOk.Width - 9, buttonCancel.Location.Y);
26+
buttonOk.Text = "Ok";
27+
f.Controls.Add(buttonOk);
28+
29+
if (additionalButtons != null)
30+
{
31+
Point lastLocation = buttonOk.Location;
32+
33+
for (int i = 0; i < additionalButtons.Length; i++)
34+
{
35+
if (additionalButtons[i] == null)
36+
additionalButtons[i] = new Button();
37+
38+
additionalButtons[i].Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
39+
additionalButtons[i].Location = new Point(lastLocation.X - additionalButtons[i].Width - 9, lastLocation.Y);
40+
lastLocation = additionalButtons[i].Location;
41+
f.Controls.Add(additionalButtons[i]);
42+
}
43+
}
44+
}
45+
1446
/// <summary>
1547
/// Sets button's back and border colors for normal and hover state to specified color.
1648
/// </summary>
@@ -22,5 +54,13 @@ public static void ClearColor(this Button button, Color clearColor)
2254
button.HoverColor = clearColor;
2355
button.HoverBorderColor = clearColor;
2456
}
57+
58+
public static void ToCenter(this Form f)
59+
{
60+
f.Location = new Point(
61+
(Screen.PrimaryScreen.WorkingArea.Width - f.Width) / 2,
62+
(Screen.PrimaryScreen.WorkingArea.Height - f.Height) / 2
63+
);
64+
}
2565
}
2666
}

0 commit comments

Comments
 (0)