Wenn du mir eine "Debuggable" Mappe hochlädtst, gucke ich mir das gern mal an (wenn innerhalb von 30 Minuten, dann heute noch, ansonsten morgen)
Derweil würde ich dir den Tipp geben, dringend an deinen Naming-Conventions zu arbeiten...
Variablennamen mit einem oder zwei Buchstaben = NoGo, sowas ist bad codestyle und macht man nicht.
Variablennamen haben sprechend zu sein, damit man auch in 20 Jahren noch weiß, wozu die sind, ohne vorher den ganzen Code lesen zu müssen.
(und damit Andere wie z.B. jetzt gerade ich, den Code besser lesen können!)
Sachen wie h_Height kenne ich sonst nur aus C/C++, in der .NET-Welt nimmt man entweder "height" oder z.B. "windowHeight"
Capitalization Rules:
DO use PascalCasing for all public member, type, and namespace names consisting of multiple words.
Zeilen die Breiter als maximal 120 (eher 80, um auch kleinere Bildschirme zu unterstützen) Zeichen sind, sollen nach Möglichkeit umgebrochen werden, so wird horizontales Scrollen vermieden, was episch nervt wenn man am Coden ist... also die Productivity stört.
Code wird NICHT besser lesbar, nur weil er in 1 Zeile steht und die Zeile dafür 1000 Zeichen breit ist!
Diese Regeln gibt es nicht umsonst, und auch nicht weil irgendein Freak meinte "whoa, gefällt mir, müssen jetzt Alle so machen", sondern weil es die Lesbarkeit von Code enorm erhöht.
Ich selbst halte mich auch nicht IMMER an ALLE davon, aber zumindest die Basics wie Variablennamen sollte man drin haben...
Java:
Spoiler:
Lustige Quotes:
Spoiler:
Zitat von Hydra
Hier (in Deutschland) kann man keine andere tolle Aktivitäten machen, als zu chillen, shoppen, saufen und Partys feiern xD Ich habe nichts gegen ab und zu mal saufen und Partys feiern, aber das ist doch nicht wirklich das wahre Leben o_o
Wieso das Internet für die meisten Leute gefährlich ist:
Zitat von Silent
Ich weiß ja nicht was der Sinn dahinter steckt es heißt immer "security reasons".
The Following User Says Thank You to Sky.NET For This Useful Post:
Beherzige den Beitrag von Sky.NET. Konventionen sind wichtig. Je früher du es lernst, desto besser.
Alles Mögliche packst du in 'ner using-Anweisung, aber Font in Zeile 58 nicht?
Und dann lügst du die Garbage Collection in deiner Dispose-Methode (die du hast, obwohl du nicht die IDisposable-Schnittstelle implementierst (oder vielleicht vererbt?)) an, dass schon alles aufgeräumt sei (GC.SuppressFinalize).
The Following User Says Thank You to Nuebel For This Useful Post:
new public void Dispose()
{
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
[DefaultEvent("Click")] public class MangoEButtonOrange : Control
{
#region " MouseStates "
MouseState State = MouseState.None;
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
base.OnMouseDown(e);
State = MouseState.Down;
this.Invalidate();
}
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
{
base.OnMouseUp(e);
State = MouseState.Over;
this.Invalidate();
}
protected override void OnMouseEnter(System.EventArgs e)
{
base.OnMouseEnter(e);
State = MouseState.Over;
this.Invalidate();
}
protected override void OnMouseLeave(System.EventArgs e)
{
base.OnMouseLeave(e);
State = MouseState.None;
this.Invalidate();
}
#endregion
public MangoEButtonOrange()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.FixedHeight, true);
this.UpdateStyles();
this.BackColor = Color.Transparent;
ForeColor = Color.FromArgb(86, 109, 109);
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
using (Bitmap B = new Bitmap(Width, Height))
{
using (Graphics G = Graphics.FromImage(B))
{
Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1);
base.OnPaint(e);
G.SmoothingMode = SmoothingMode.HighQuality;
Font drawFont = new Font("Tahoma", 11, FontStyle.Regular);
Pen p = new Pen(Color.FromArgb(157, 118, 103), 1);
Brush nb = new SolidBrush(Color.FromArgb(86, 109, 109));
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
switch (State)
{
case MouseState.None:
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
using (Bitmap B = new Bitmap(Width, Height))
{
using (Graphics G = Graphics.FromImage(B))
{
Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1);
base.OnPaint(e);
G.SmoothingMode = SmoothingMode.HighQuality;
Font drawFont = new Font("Tahoma", 11, FontStyle.Regular);
Pen p = new Pen(Color.FromArgb(166, 166, 166), 1);
Brush nb = new SolidBrush(Color.FromArgb(80, 84, 82));
new public void Dispose()
{
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
[DefaultEvent("CheckedChanged")] public class MangoECheckBox : Control
{
foreach (Control C in Parent.Controls)
{
if (!object.ReferenceEquals(C, this) && C is MangoERadioButton) ((MangoERadioButton)C).Checked = false;
}
}
#endregion
new public void Dispose()
{
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
[DefaultEvent("TextChanged")] public class MangoETextBox : Control
{
private TextBox tB = new TextBox();
#region "Control Help - Properties & Flicker Control"
private bool _passmask = false;
public bool UseSystemPasswordChar
{
get {return _passmask;}
set
{
if (value.Equals(_passmask)) return;
tB.UseSystemPasswordChar = UseSystemPasswordChar;
_passmask = value;
this.Invalidate();
}
}
private int _maxchars = 32767;
public int MaxLength
{
get {return _maxchars;}
set
{
if (value == _maxchars) return;
_maxchars = value;
tB.MaxLength = MaxLength;
this.Invalidate();
}
}
private HorizontalAlignment _align;
public HorizontalAlignment TextAlignment
{
get {return _align;}
set
{
if (value.Equals(_align)) return;
_align = value;
this.Invalidate();
}
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
using (Bitmap B = new Bitmap(Width, Height))
{
using (Graphics G = Graphics.FromImage(B))
{
new public void Dispose()
{
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
[DefaultEvent("Click")] public class StudioMinimizeButton : Control
{
public enum State : short
{
DeActivated = 0,
Activated = 1
}
private State CurrSt = State.DeActivated;
private struct ButtonState
{
public readonly Bitmap CurrButton;
public ButtonState(Bitmap button) { this.CurrButton = button; }
}
private ButtonState[] buttonStates =
{
new ButtonState(MangoETheme.Properties.Resources.MinimizeUnlighted),
new ButtonState(MangoETheme.Properties.Resources.MinimizeLighted)
};
public StudioMinimizeButton()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.FixedHeight, true);
this.UpdateStyles();
this.MinimumSize = new Size(11, 4);
this.MaximumSize = new Size(11, 4);
this.Size = new Size(11, 4);
this.BackColor = Color.Transparent;
}
private void Redraw(Graphics gr)
{
ButtonState buttonState = buttonStates[(int)CurrSt];
gr.DrawImage(buttonState.CurrButton, new Point(0, 0));
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pevent) { Redraw(pevent.Graphics); }
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs mevent)
{
CurrSt = State.Activated;
this.Invalidate();
base.OnMouseDown(mevent);
}
protected override void OnMouseEnter(System.EventArgs e)
{
CurrSt = State.Activated;
this.Invalidate();
base.OnMouseEnter(e);
}
protected override void OnLeave(System.EventArgs e)
{
CurrSt = State.DeActivated;
this.Invalidate();
base.OnLeave(e);
}
protected override void OnMouseLeave(System.EventArgs e)
{
CurrSt = State.DeActivated;
this.Invalidate();
base.OnMouseLeave(e);
}
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs mevent)
{
CurrSt = State.Activated;
this.Invalidate();
base.OnMouseUp(mevent);
}
new public void Dispose()
{
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
[DefaultEvent("Click")] public class StudioExitButton : Control
{
public enum State : short
{
DeActivated = 0,
Activated = 1
}
private State CurrSt = State.DeActivated;
private struct ButtonState
{
public readonly Bitmap CurrButton;
public ButtonState(Bitmap button){this.CurrButton = button;}
}
private ButtonState[] buttonStates =
{
new ButtonState(MangoETheme.Properties.Resources.ExitUnlighted),
new ButtonState(MangoETheme.Properties.Resources.ExitLighted)
};
public StudioExitButton()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.FixedHeight, true);
this.UpdateStyles();
this.MinimumSize = new Size(11, 12);
this.MaximumSize = new Size(11, 12);
this.Size = new Size(11, 12);
this.BackColor = Color.Transparent;
}
private void Redraw(Graphics gr)
{
ButtonState buttonState = buttonStates[(int)CurrSt];
gr.DrawImage(buttonState.CurrButton, new Point(0, 0));
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pevent){Redraw(pevent.Graphics);}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs mevent)
{
CurrSt = State.Activated;
this.Invalidate();
base.OnMouseDown(mevent);
}
protected override void OnMouseEnter(System.EventArgs e)
{
CurrSt = State.Activated;
this.Invalidate();
base.OnMouseEnter(e);
}
protected override void OnLeave(System.EventArgs e)
{
CurrSt = State.DeActivated;
this.Invalidate();
base.OnLeave(e);
}
protected override void OnMouseLeave(System.EventArgs e)
{
CurrSt = State.DeActivated;
this.Invalidate();
base.OnMouseLeave(e);
}
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs mevent)
{
CurrSt = State.Activated;
this.Invalidate();
base.OnMouseUp(mevent);
}
new public void Dispose()
{
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
[DefaultEvent("CheckedChanged")]public class AppleCheckBox : Control
{
public event EventHandler CheckedChanged;
private bool Checkd = false;
public enum State : short
{
DeActivated = 0,
Activated = 1
}
private State CurrSt = State.DeActivated;
private struct ButtonState
{
public readonly Bitmap CurrButton;
public ButtonState(Bitmap button) { this.CurrButton = button; }
}
private ButtonState[] buttonStates =
{
new ButtonState(MangoETheme.Properties.Resources.AppleCheckBoxUnChecked),
new ButtonState(MangoETheme.Properties.Resources.AppleCheckBoxChecked)
};
[Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public bool Checked
{
get {return Checkd;}
set
{
if (Checkd == value) return;
Checkd = value;
if (Checkd) CurrSt = State.Activated; else CurrSt = State.DeActivated;
this.Invalidate();
if (CheckedChanged != null) CheckedChanged(this, EventArgs.Empty);
}
}
public override Font Font
{
get { return base.Font; }
set
{
if (base.Font.Equals(value)) return;
base.Font = value;
this.Invalidate();
}
}
new public void Dispose()
{
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
[DefaultEvent("CheckedChanged")] public class AppleRadioButton : Control
{
public event EventHandler CheckedChanged;
private bool Checkd = false;
public enum State : short
{
DeActivated = 0,
Activated = 1
}
private State CurrSt = State.DeActivated;
private struct ButtonState
{
public readonly Bitmap CurrButton;
public ButtonState(Bitmap button){this.CurrButton = button;}
}
private ButtonState[] buttonStates =
{
new ButtonState(MangoETheme.Properties.Resources.AppleRadioButtonUnChecked),
new ButtonState(MangoETheme.Properties.Resources.AppleRadioButtonChecked)
};
[Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public bool Checked
{
get { return Checkd; }
set
{
if (Checkd == value) return;
Checkd = value;
if (Checkd) CurrSt = State.Activated; else CurrSt = State.DeActivated;
this.Invalidate();
if (CheckedChanged != null) CheckedChanged(this, EventArgs.Empty);
}
}
public override Font Font
{
get {return base.Font;}
set
{
if (base.Font.Equals(value)) return;
base.Font = value;
Invalidate();
}
}
new public void Dispose()
{
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
[DefaultEvent("Click")] public class FakeMacButton : Control
{
private State CurrSt = State.Normal;
private struct ButtonState
{
public readonly Bitmap Li,Mi,Ri;
public ButtonState(Bitmap left, Bitmap middle, Bitmap right)
{
this.Li = left;
this.Mi = middle;
this.Ri = right;
}
}
private ButtonState[] buttonStates =
{
new ButtonState(MangoETheme.Properties.Resources.MacBtnLeft, MangoETheme.Properties.Resources.MacBtnMiddle, MangoETheme.Properties.Resources.MacBtnRight),
new ButtonState(MangoETheme.Properties.Resources.MacBtnLeftEntered, MangoETheme.Properties.Resources.MacBtnMiddleEntered, MangoETheme.Properties.Resources.MacBtnRightEntered),
new ButtonState(MangoETheme.Properties.Resources.MacBtnLeftPressed, MangoETheme.Properties.Resources.MacBtnMiddlePressed, MangoETheme.Properties.Resources.MacBtnRightPressed)
};
public enum State : short
{
Normal = 0,
Entered = 1,
Down = 2
}
public FakeMacButton()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
this.UpdateStyles();
this.MinimumSize = new Size(53, 20);
this.Size = new Size(53, 20);
this.BackColor = Color.Transparent;
}
public void Redraw(Graphics gr)
{
ButtonState buttonState = buttonStates[(int) CurrSt];
gr.DrawImage(buttonState.Li, 0, 0, buttonState.Li.Width, this.Height);
for (int i = buttonState.Li.Width; i <= this.Width - buttonState.Ri.Width - 1; i++) {
gr.DrawImage(buttonState.Mi, i, 0, buttonState.Mi.Width, this.Height);
}
gr.DrawImage(buttonState.Ri, this.Width - buttonState.Ri.Width, 0, buttonState.Ri.Width, this.Height);
public override Font Font
{
get {return base.Font;}
set
{
if (base.Font.Equals(value)) return;
base.Font = value;
this.Invalidate();
}
}
[Browsable(true), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public override Color ForeColor
{
get {return Color.Empty;}
set
{
if (base.ForeColor.Equals(value)) return;
base.ForeColor = value;
this.Invalidate();
}
}
protected override void OnMouseDown(MouseEventArgs mevent)
{
CurrSt = State.Down;
this.Invalidate();
base.OnMouseDown(mevent);
}
protected override void OnMouseEnter(EventArgs e)
{
CurrSt = State.Entered;
this.Invalidate();
base.OnMouseEnter(e);
}
protected override void OnLeave(EventArgs e)
{
CurrSt = State.Normal;
this.Invalidate();
base.OnLeave(e);
}
protected override void OnMouseLeave(EventArgs e)
{
CurrSt = State.Normal;
this.Invalidate();
base.OnMouseLeave(e);
}
protected override void OnMouseUp(MouseEventArgs mevent)
{
CurrSt = State.Entered;
this.Invalidate();
base.OnMouseUp(mevent);
}
protected override void OnPaint(PaintEventArgs pevent){Redraw(pevent.Graphics);}
new public void Dispose()
{
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
[DefaultEvent("ValueChanged")] public class MangoETrackBar : Control
{
public enum AndroidTrackBarState : short
{
Normal = 1,
Pressed = 2,
Hover = 3
}
private Color _valuelinecolor = Color.FromArgb(70, 151, 196);
private Color _nonvaluelinecolor = Color.FromArgb(229, 229, 229);
private Color _outercircle = Color.FromArgb(119, 206, 234);
private AndroidTrackBarState _state = AndroidTrackBarState.Normal;
private int spectrum, x, y;
private bool ismousein = false;
private Rectangle mover = new Rectangle();
private int _value = 0;
private int _minimum = 0;
private int _maximum = 100;
private int _largechange = 0;
public int Value
{
get {return this._value;}
set {
if (value <= _maximum && value >= _minimum)
_value = value;
this.Invalidate();
}
}
public int Maximum
{
get {return this._maximum;}
set {
if (_value <= value && value >= _minimum)
_maximum = value;
this.Invalidate();
}
}
public int Minimum
{
get {return this._minimum;}
set {
if (value <= _maximum && _value >= value)
_minimum = value;
this.Invalidate();
}
}
public int LargeChange
{
get {return this._largechange;}
set {
if(_largechange != value)
_largechange = value;
this.Invalidate();
}
}
public MangoETrackBar()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
this.UpdateStyles();
this.MinimumSize = new Size(26, 24);
this.Size = new Size(75, 24);
this.BackColor = Color.Transparent;
}
#region Events
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.CompositingQuality = CompositingQuality.HighQuality;
e.Graphics.DrawLine(new Pen(_nonvaluelinecolor), new Point(12, (int)Height / 2), new Point(Width - 12, (int)Height / 2));
spectrum = Maximum - Minimum;
Rectangle gr = new Rectangle((int)pix - 12, currsi - 12, 24, 24);
Rectangle grt = new Rectangle((int)pix - 5, currsi - 5, 10, 10);
mover = gr;
if(_state == AndroidTrackBarState.Normal)
{
using (SolidBrush sb = new SolidBrush(_outercircle)) { e.Graphics.FillEllipse(sb, gr); }
using (SolidBrush sbb = new SolidBrush(_valuelinecolor)) { e.Graphics.FillEllipse(sbb, grt); }
using (SolidBrush sb = new SolidBrush(darkcolor)){g.FillEllipse(sb, gr);}
using (SolidBrush sbb = new SolidBrush(_valuelinecolor)){g.FillEllipse(sbb, grt);}
g.DrawLine(new Pen(_valuelinecolor, 3), new Point(12, (int)(Height / 2)), new Point((int)pix, (int)Height / 2));
}
base.OnPaint(e);
e.Graphics.DrawString(this.Value.ToString(), new Font("Segoe UI", 7), Brushes.Black, new Point(7, this.Height - 10));
}
protected override void OnMouseDown(MouseEventArgs e)
{
if(x > mover.X && x < (mover.Width + mover.X) && y > mover.Y && y < (mover.Height + mover.Y))
{
ismousein = true;
_state = AndroidTrackBarState.Normal;
}
base.OnMouseDown(e);
}
protected override void OnMouseMove(MouseEventArgs e)
{
x = e.X;
y = e.Y;
if(ismousein)
{
mover.X = e.X;
float toch = (float)((float)e.X / (float)Width) * (float)spectrum - (float)Math.Abs(Minimum);
if (toch > Maximum) toch = Maximum;
if (toch < Minimum) toch = Minimum;
Value = (int)Math.Ceiling(toch);
}
else
{
if (x > mover.X && x < (mover.Width + mover.X))
{
if (y > mover.Y && y < (mover.Height + mover.Y)) _state = AndroidTrackBarState.Hover; else _state = AndroidTrackBarState.Normal;
new public void Dispose()
{
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
}
Problem ist noch nicht gelöst. Also nur an Using liegt es nicht.
Das mit .Clone() ist irgendwie schwachsinnig wurde mir gesagt, sollte lieber eine klassenglobale Variable nutzen.
Dennoch weiß ich nicht, wie ich dass dann mit der Size machen soll bei dem ContainerControl für die Form beispielsweise.
The Following User Says Thank You to !lkay For This Useful Post:
Ich hatte um eine Projektmappe gebeten, das war ernst gemeint.
Ich bastel mir doch jetzt kein komplettes Projekt zusammen, nur um den Fehler in deinem Code zu finden 0o.
Nimm deinen Code, mach den in eine Beispielmappe, guck dass du den Code da irgendwie zur Verwendung bringst, damit man ihn zur Laufzeit debuggen kann, pack die Mappe in ein Zip und benutz die Anhang-Funktion vom Forum. Wenn du das nicht machst werde zumindest ich mich mit dem Thema nicht weiter beschäftigen, ist mir dann zu viel Aufwand.
Java:
Spoiler:
Lustige Quotes:
Spoiler:
Zitat von Hydra
Hier (in Deutschland) kann man keine andere tolle Aktivitäten machen, als zu chillen, shoppen, saufen und Partys feiern xD Ich habe nichts gegen ab und zu mal saufen und Partys feiern, aber das ist doch nicht wirklich das wahre Leben o_o
Wieso das Internet für die meisten Leute gefährlich ist:
Zitat von Silent
Ich weiß ja nicht was der Sinn dahinter steckt es heißt immer "security reasons".
Wenn nein, stelle es dir vor, als wenn dieses Refactoring Folgendes:
Spoiler:
switch (State)
{
case MouseState.None:
using (LinearGradientBrush bg = new LinearGradientBrush(bgr, ARGBC(60, 59, 55), ARGBC(60, 59, 55), 90)) { G.FillPath(bg, Draw.RoundRectF(bgr, 10)); }
using (LinearGradientBrush lgb1 = new LinearGradientBrush(MinBtn, ARGBC(152, 151, 146), ARGBC(56, 55, 51), 90)) {G.FillEllipse(lgb1, MinBtn); }
G.DrawEllipse(Pens.DimGray, MinBtn);
G.DrawString("0", Font, new SolidBrush(ARGBC(58, 57, 53)), new RectangleF((float)5.5, (float)6, (float)0, (float)0));
using (LinearGradientBrush lgb2 = new LinearGradientBrush(MaxBtn, ARGBC(152, 151, 146), ARGBC(56, 55, 51), 90)) { G.FillEllipse(lgb2, MaxBtn); }
G.DrawEllipse(Pens.DimGray, MaxBtn);
G.DrawString("1", Font, new SolidBrush(ARGBC(58, 57, 53)), new Rectangle(26, 7, 0, 0));
using (LinearGradientBrush lgb3 = new LinearGradientBrush(CloseBtn, ARGBC(247, 150, 116), ARGBC(223, 81, 6), 90)) { G.FillEllipse(lgb3, CloseBtn); }
G.DrawEllipse(Pens.DimGray, CloseBtn);
G.DrawString("r", Font, new SolidBrush(ARGBC(58, 57, 53)), new Rectangle(46, 7, 0, 0));
break;
case MouseState.Over:
if (X > 3 && X < 20)
{
using (LinearGradientBrush bgx = new LinearGradientBrush(bgr, ARGBC(60, 59, 55), ARGBC(60, 59, 55), 90)) { G.FillPath(bgx, Draw.RoundRectF(bgr, 10)); }
using (LinearGradientBrush lgby = new LinearGradientBrush(MinBtn, ARGBC(172, 171, 166), ARGBC(76, 75, 71), 90)) { G.FillEllipse(lgby, MinBtn); }
G.DrawEllipse(Pens.DimGray, MinBtn);
G.DrawString("0", Font, new SolidBrush(ARGBC(58, 57, 53)), new RectangleF((float)5.5, (float)6, (float)0, (float)0));
using (LinearGradientBrush lgbz = new LinearGradientBrush(MaxBtn, ARGBC(152, 151, 146), ARGBC(56, 55, 51), 90)) { G.FillEllipse(lgbz, MaxBtn); }
G.DrawEllipse(Pens.DimGray, MaxBtn);
G.DrawString("1", Font, new SolidBrush(ARGBC(58, 57, 53)), new Rectangle(26, 7, 0, 0));
using (LinearGradientBrush lgbAA = new LinearGradientBrush(CloseBtn, ARGBC(247, 150, 116), ARGBC(223, 81, 6), 90)) { G.FillEllipse(lgbAA, CloseBtn); }
G.DrawEllipse(Pens.DimGray, CloseBtn);
G.DrawString("r", Font, new SolidBrush(ARGBC(58, 57, 53)), new Rectangle(46, 7, 0, 0));
}
else if (X > 23 && X < 40)
{
using (LinearGradientBrush bgWW = new LinearGradientBrush(bgr, ARGBC(60, 59, 55), ARGBC(60, 59, 55), 90)) { G.FillPath(bgWW, Draw.RoundRectF(bgr, 10)); }
using (LinearGradientBrush lgbXX = new LinearGradientBrush(MinBtn, ARGBC(152, 151, 146), ARGBC(56, 55, 51), 90)) { G.FillEllipse(lgbXX, MinBtn); }
G.DrawEllipse(Pens.DimGray, MinBtn);
G.DrawString("0", Font, new SolidBrush(ARGBC(58, 57, 53)), new RectangleF((float)5.5, (float)6, (float)0, (float)0));
using (LinearGradientBrush lgbJJ = new LinearGradientBrush(MaxBtn, ARGBC(172, 171, 166), ARGBC(76, 75, 71), 90)) { G.FillEllipse(lgbJJ, MaxBtn); }
G.DrawEllipse(Pens.DimGray, MaxBtn);
G.DrawString("1", Font, new SolidBrush(ARGBC(58, 57, 53)), new Rectangle(26, 7, 0, 0));
using (LinearGradientBrush lgbKK = new LinearGradientBrush(CloseBtn, ARGBC(247, 150, 116), ARGBC(223, 81, 6), 90)) { G.FillEllipse(lgbKK, CloseBtn); }
G.DrawEllipse(Pens.DimGray, CloseBtn);
G.DrawString("r", Font, new SolidBrush(ARGBC(58, 57, 53)), new Rectangle(46, 7, 0, 0));
}
else if (X > 43 && X < 60)
{
using (LinearGradientBrush bgPP = new LinearGradientBrush(bgr, ARGBC(60, 59, 55), ARGBC(60, 59, 55), 90)) { G.FillPath(bgPP, Draw.RoundRectF(bgr, 10)); }
using (LinearGradientBrush lgb1SS = new LinearGradientBrush(MinBtn, ARGBC(152, 151, 146), ARGBC(56, 55, 51), 90)) { G.FillEllipse(lgb1SS, MinBtn); }
G.DrawEllipse(Pens.DimGray, MinBtn);
G.DrawString("0", Font, new SolidBrush(ARGBC(58, 57, 53)), new RectangleF((float)5.5, (float)6, (float)0, (float)0));
using (LinearGradientBrush lgbRR = new LinearGradientBrush(MaxBtn, ARGBC(152, 151, 146), ARGBC(56, 55, 51), 90)) { G.FillEllipse(lgbRR, MaxBtn); }
G.DrawEllipse(Pens.DimGray, MaxBtn);
G.DrawString("1", Font, new SolidBrush(ARGBC(58, 57, 53)), new Rectangle(26, 7, 0, 0));
using (LinearGradientBrush lgbCC = new LinearGradientBrush(CloseBtn, ARGBC(255, 170, 136), ARGBC(243, 101, 26), 90)) { G.FillEllipse(lgbCC, CloseBtn); }
G.DrawEllipse(Pens.DimGray, CloseBtn);
G.DrawString("r", Font, new SolidBrush(ARGBC(58, 57, 53)), new Rectangle(46, 7, 0, 0));
}
break;
default:
using (LinearGradientBrush bga = new LinearGradientBrush(bgr, ARGBC(60, 59, 55), ARGBC(60, 59, 55), 90)) { G.FillPath(bga, Draw.RoundRectF(bgr, 10)); }
using (LinearGradientBrush lgbb = new LinearGradientBrush(MinBtn, ARGBC(152, 151, 146), ARGBC(56, 55, 51), 90)) { G.FillEllipse(lgbb, MinBtn); }
G.DrawEllipse(Pens.DimGray, MinBtn);
G.DrawString("0", Font, new SolidBrush(ARGBC(58, 57, 53)), new RectangleF((float)5.5, (float)6, (float)0, (float)0));
using (LinearGradientBrush lgbc = new LinearGradientBrush(MaxBtn, ARGBC(152, 151, 146), ARGBC(56, 55, 51), 90)) { G.FillEllipse(lgbc, MaxBtn); }
G.DrawEllipse(Pens.DimGray, MaxBtn);
G.DrawString("1", Font, new SolidBrush(ARGBC(58, 57, 53)), new Rectangle(26, 7, 0, 0));
using (LinearGradientBrush lgbd = new LinearGradientBrush(CloseBtn, ARGBC(247, 150, 116), ARGBC(223, 81, 6), 90)) { G.FillEllipse(lgbd, CloseBtn); }
G.DrawEllipse(Pens.DimGray, CloseBtn);
G.DrawString("r", Font, new SolidBrush(ARGBC(58, 57, 53)), new Rectangle(46, 7, 0, 0));
break;
}
in eine lesbare(re) Form bringt. Ich habe nicht genau drüber geschaut, aber ich wette, da ist eine Menge boilerplate code. Visual Studio unterstützt einen sicher beim Refactoring. Versuch es einfach mal!
Wenn das dein gesamter Code ist, dann ist ja noch nicht zu spät vielleicht mal zu WPF zu schielen?! Ich meine, wenn ich das so sehe, lässt sich WindowsForms wohl mit Javas Swing vergleichen. Custom-Controls zu schreiben erzeugt bei beiden hässlichen Code.
The Following 2 Users Say Thank You to Nuebel For This Useful Post:
Custom-Controls zu schreiben erzeugt [...] hässlichen Code.
Trifft zumindest auf Forms zu.
Java:
Spoiler:
Lustige Quotes:
Spoiler:
Zitat von Hydra
Hier (in Deutschland) kann man keine andere tolle Aktivitäten machen, als zu chillen, shoppen, saufen und Partys feiern xD Ich habe nichts gegen ab und zu mal saufen und Partys feiern, aber das ist doch nicht wirklich das wahre Leben o_o
Wieso das Internet für die meisten Leute gefährlich ist:
Zitat von Silent
Ich weiß ja nicht was der Sinn dahinter steckt es heißt immer "security reasons".
Sofern Du von der Tabpage betitelt "C" auf "D" wechselst, siehst Du schon,
dass das nicht richtig gezeichnet wird (beim Debuggen).
Und im Designer von Visual Studio (also Grafisch) , kannst Du ja auch
mal von C auf D wechseln und dann auf der Tabpage D klicken irgendwo,
die wird dann neu gezeichnet.
The Following User Says Thank You to !lkay For This Useful Post: