| Autor |
Beitrag |
F.A Development
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Do 12.08.10 14:07
Ich habe bereits in VB einige Formstyles geschrieben, jetzt habe ich mich in C# drangewagt und auch eigentlich keine probleme bekommen, bis ich eine Form von der klasse erben lasse dann bekomme ich einen haufen fehler...
Hier ma der Code...
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544:
| using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; using System.ComponentModel; using System.Runtime.InteropServices;
namespace Orbit_FTP_Client { class FormStyle:Form { #region ContextMenuTaskbar const Int32 SC_SIZE = 0xf000; const Int32 SC_MOVE = 0xf010; const Int32 SC_MINIMIZE = 0xf020; const Int32 SC_MAXIMIZE = 0xf030; const Int32 SC_CLOSE = 0xf060; const Int32 SC_RESTORE = 0xf120; const Int32 MF_BYCOMMAND = 0x0; const Int32 MF_SEPARATOR = 0x800; private const int HTCAPTION = 2; private const int TPM_RETURNCMD = 0x100; private const int WM_SYSCOMMAND = 0x112;
[DllImport("user32.dll", EntryPoint = "EnableMenuItem")] private static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable);
[DllImport("user32.dll", EntryPoint = "ReleaseCapture")] private static extern int ReleaseCapture();
[DllImport("user32.dll", EntryPoint = "GetSystemMenu")] private static extern IntPtr GetSystemMenu(IntPtr hwnd, int bRevert);
[DllImport("user32.dll", EntryPoint = "TrackPopupMenuEx")] private static extern int TrackPopupMenuEx(IntPtr hMenu, int wFlags, int x, int y, IntPtr hWnd, int lpTpm);
protected override CreateParams CreateParams { get { const int WS_SYSMENU = 0x80000; const int WS_MAXIMIZEBOX = 0x10000; const int WS_MINIMIZEBOX = 0x20000; CreateParams oReturn = base.CreateParams; oReturn.Style = oReturn.Style | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; return oReturn; } } #endregion
#region Global Vars private Size titlebarLeft; private Size titlebarRight; private Size titlebarMid; private Size borderLeft; private Size borderRight; private Size borderBottom; private Size borderCornerLeft; private Size borderCornerRight; private Size closeButton; private Size maximizeButton; private Size minimizeButton; private Size closeButton_tool;
private Font TextFont_; private Color TextColor_;
private Image BG_Image = null; private Color BG_Color;
private WindowStyle_ curWinStyle = WindowStyle_.Sizeable;
private CursorState curstate_ = CursorState.Normal; private CursorState chSstate_ = CursorState.Normal;
private ButtonState closeButtonState = ButtonState.Normal; private ButtonState minimizeButtonState = ButtonState.Normal; private ButtonState maximizeButtonState = ButtonState.Normal;
private bool move_ = false; private bool mousedown_ = false;
private Point oldpos_; private bool mov_chS = false; private bool chS = false; private Point oldformpos_;
private Point oldscreenpos_; private Size oldsize_; #endregion
#region Enums public enum CursorState { TopLeft, TopMid, TopRight, BorderRight, BorderCornerRight, BorderBottom, BorderCornerLeft, BorderLeft, Normal } public enum ButtonState { Normal, Over, Down } public enum WindowStyle_ { ToolBox, MSG_Box, Sizeable, Fixed } #endregion
#region properties public Font Font_Title { get { return TextFont_; }
set { TextFont_ = value; } }
public Color ForeColor_Title { get { return TextColor_; }
set { TextColor_ = value; } }
public Image BackGroundImage_Form { get { return BG_Image; } set { BG_Image = value; } }
public Color BackGroundColor_Form { get { return BG_Color; }
set { BG_Color = value; } }
public WindowStyle_ Fensterstyle { get { return curWinStyle; }
set { curWinStyle = value; } } protected override System.Windows.Forms.Padding DefaultPadding { get { return new Padding(borderLeft.Width, titlebarMid.Height, borderRight.Width, borderBottom.Height); } }
[EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] public override System.Drawing.Color BackColor { get { return base.BackColor; } set { base.BackColor = this.TransparencyKey; } }
[EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] public override System.Drawing.Image BackgroundImage { get { return null; }
set { } } #endregion
#region Initalisiren public void New() { this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.DoubleBuffered = true; this.FormBorderStyle = FormBorderStyle.None; BG_Color = SystemColors.Control; this.BackColor = Color.LavenderBlush; this.TransparencyKey = Color.LavenderBlush; this.MaximizedBounds = SystemInformation.WorkingArea; titlebarLeft = Properties.Resources.titlebarLeft.Size; titlebarMid = new Size(this.Width - titlebarLeft.Width - titlebarRight.Width +2,titlebarRight.Height); titlebarRight = Properties.Resources.titlebarRight.Size; borderRight = new Size(7,this.Height-borderBottom.Height-titlebarLeft.Height +2); borderCornerRight = Properties.Resources.borderCornerRight.Size; borderBottom = new Size(this.Width, 7); borderCornerLeft = Properties.Resources.borderCornerLeft.Size; borderLeft = new Size(7, this.Height - titlebarMid.Height - borderCornerLeft.Height); closeButton = Properties.Resources.closeNormal.Size; closeButton_tool = Properties.Resources.closeNormal_tool.Size; maximizeButton = Properties.Resources.maximizeNormal.Size; minimizeButton = Properties.Resources.minimizeNorm.Size; TextColor_ = Color.Black; try { TextFont_ = new Font("Arial", 9, FontStyle.Regular); } catch { TextFont_ = this.Font; } } private void InitializeComponent() { this.SuspendLayout(); this.ClientSize = new System.Drawing.Size(284, 262); this.Name = "FormStyle"; this.Paint += new System.Windows.Forms.PaintEventHandler(this.FormStyle_Paint); this.ResumeLayout(false);
} #endregion
#region Zeichnen
private void DrawSizableWindow(object sender, PaintEventArgs e) { Graphics g = e.Graphics; SolidBrush borderColor_ = new SolidBrush(Color.FromArgb(102, 102, 102)); Rectangle B_Top = new Rectangle(titlebarLeft.Width -1,0,this.Width-titlebarLeft.Width-titlebarRight.Width +2,1); Rectangle T_Top = new Rectangle(titlebarLeft.Width - 1, 1, this.Width - titlebarLeft.Width - titlebarRight.Width + 2,6); Rectangle B_Bottom = new Rectangle(borderCornerLeft.Width - 1, this.Height - 1, this.Width - borderCornerLeft.Width - borderCornerRight.Width + 2, 1); Rectangle T_Bottom = new Rectangle(borderCornerLeft.Width - 1, this.Height - 7, this.Width - borderCornerLeft.Width - borderCornerRight.Width + 2, 6); Rectangle B_Right = new Rectangle(0,titlebarLeft.Height -1,1,this.Height-titlebarLeft.Height-borderCornerLeft.Height +2); Rectangle T_Right = new Rectangle(7, titlebarLeft.Height - 1, 6, this.Height - titlebarLeft.Height - borderCornerLeft.Height + 2); Rectangle B_Left = new Rectangle(this.Width - 1, titlebarRight.Height - 1, 1, this.Height - titlebarRight.Height - borderCornerRight.Height + 2); Rectangle T_Left = new Rectangle (this.Width - 7, titlebarRight.Height - 1, 6, this.Height - titlebarRight.Height - borderCornerRight.Height + 2); g.FillRectangle(borderColor_, B_Top); g.FillRectangle(borderColor_, B_Right); g.FillRectangle(borderColor_, B_Left); g.FillRectangle(borderColor_, B_Bottom);
g.FillRectangle(Brushes.White, T_Bottom); g.FillRectangle(Brushes.White, T_Left); g.FillRectangle(Brushes.White, T_Right); g.FillRectangle(Brushes.White, T_Top); }
private void FormStyle_Paint(object sender, PaintEventArgs e) { if(this.Fensterstyle == WindowStyle_.Sizeable) DrawSizableWindow(sender,e); } #endregion
#region Mouse Events
private void FormStyle_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mousedown_ = true;
if (new Rectangle(0, borderCornerLeft.Height, titlebarLeft.Width, this.Height - borderCornerLeft.Height - borderCornerLeft.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.TopLeft; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(0, 0, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.TopLeft; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(0, 0, this.Width - borderCornerLeft.Width, borderLeft.Width).Contains(e.X, e.Y)) { chSstate_ = CursorState.TopMid; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(this.Width - borderCornerLeft.Width, 0, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.TopRight; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(this.Width - borderCornerRight.Width, borderCornerLeft.Height, borderCornerRight.Width, this.Height - 2 * borderCornerLeft.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.BorderCornerRight; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(this.Width - borderCornerLeft.Width, this.Height - borderCornerLeft.Height, borderCornerRight.Width, borderCornerRight.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.BorderCornerRight; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(borderCornerLeft.Width, this.Height - borderBottom.Height, this.Width - 2 * borderCornerLeft.Width, borderBottom.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.BorderBottom; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(0, this.Height - borderCornerLeft.Height, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.BorderCornerLeft; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; }
if (minimizeButtonState == ButtonState.Over) { minimizeButtonState = ButtonState.Down; Invalidate(); } else if (maximizeButtonState == ButtonState.Over) { maximizeButtonState = ButtonState.Down; Invalidate(); } else if (closeButtonState == ButtonState.Over) { closeButtonState = ButtonState.Down; Invalidate(); } } }
private void FormStyle_MouseLeave(System.Object sender, System.EventArgs e) { minimizeButtonState = ButtonState.Normal; maximizeButtonState = ButtonState.Normal; closeButtonState = ButtonState.Normal; Invalidate(); }
private void IT_Tech_NET_Formstyle_MouseMove(System.Object sender, System.Windows.Forms.MouseEventArgs e) { Point pts = PointToScreen(e.Location);
if (move_) { this.Location = new Point(this.Location.X + e.X - oldpos_.X, this.Location.Y + e.Y - oldpos_.Y); } else { if (!mousedown_) { if (new Rectangle(this.Width - titlebarRight.Width + 2 - closeButton.Width - maximizeButton.Width - minimizeButton.Width, 0, minimizeButton.Width, minimizeButton.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.Default; minimizeButtonState = ButtonState.Over; maximizeButtonState = ButtonState.Normal; closeButtonState = ButtonState.Normal; } else if (new Rectangle(this.Width - titlebarRight.Width + 2 - closeButton.Width - maximizeButton.Width, 0, maximizeButton.Width, maximizeButton.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.Default; maximizeButtonState = ButtonState.Over; minimizeButtonState = ButtonState.Normal; closeButtonState = ButtonState.Normal; } else if (new Rectangle(this.Width - titlebarRight.Width + 2 - closeButton.Width, 0, closeButton.Width, closeButton.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.Default; closeButtonState = ButtonState.Over; minimizeButtonState = ButtonState.Normal; maximizeButtonState = ButtonState.Normal; } else { closeButtonState = ButtonState.Normal; minimizeButtonState = ButtonState.Normal; maximizeButtonState = ButtonState.Normal; } Invalidate(); }
if (new Rectangle(0, borderCornerLeft.Height, borderLeft.Width, this.Height - borderCornerLeft.Height - borderCornerLeft.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeWE; curstate_ = CursorState.BorderLeft; } else if (new Rectangle(0, 0, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNWSE; curstate_ = CursorState.TopLeft; } else if (new Rectangle(borderCornerLeft.Width, 0, this.Width - borderCornerLeft.Width - titlebarRight.Width + 2 - closeButton.Width - maximizeButton.Width - minimizeButton.Width, borderLeft.Width).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNS; curstate_ = CursorState.TopMid; } else if (new Rectangle(this.Width - borderCornerLeft.Width, 0, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNESW; curstate_ = CursorState.TopRight; } else if (new Rectangle(this.Width - borderRight.Width, borderCornerLeft.Height, borderRight.Width, this.Height - 2 * borderCornerLeft.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeWE; curstate_ = CursorState.BorderRight; } else if (new Rectangle(this.Width - borderCornerLeft.Width, this.Height - borderCornerLeft.Height, borderCornerRight.Width, borderCornerRight.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNWSE; curstate_ = CursorState.BorderCornerRight; } else if (new Rectangle(borderCornerLeft.Width, this.Height - borderBottom.Height, this.Width - 2 * borderCornerLeft.Width, borderBottom.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNS; curstate_ = CursorState.BorderBottom; } else if (new Rectangle(0, this.Height - borderCornerLeft.Height, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNESW; curstate_ = CursorState.BorderCornerLeft; } else { this.Cursor = Cursors.Default; curstate_ = CursorState.Normal; } }
if (chSstate_ == CursorState.TopLeft) { this.Location = pts; this.Size = new Size(oldsize_.Width + oldscreenpos_.X - pts.X, oldsize_.Height + oldscreenpos_.Y - pts.Y); } else if (chSstate_ == CursorState.TopRight) { this.Location = new Point(oldformpos_.X, pts.Y); this.Size = new Size(oldsize_.Width + pts.X - oldscreenpos_.X, oldsize_.Height + oldformpos_.Y - this.Location.Y); } else if (chSstate_ == CursorState.BorderCornerLeft) { this.Location = new Point(oldformpos_.X - oldscreenpos_.X + pts.X, oldformpos_.Y); this.Size = new Size(oldsize_.Width - pts.X + oldscreenpos_.X, oldsize_.Height + pts.Y - oldscreenpos_.Y); } else if (chSstate_ == CursorState.BorderCornerRight) { this.Size = new Size(oldsize_.Width + pts.X - oldscreenpos_.X, oldsize_.Height + pts.Y - oldscreenpos_.Y); } else if (chSstate_ == CursorState.TopMid) { this.Location = new Point(oldformpos_.X, oldformpos_.Y + pts.Y - oldscreenpos_.Y); this.Size = new Size(oldsize_.Width, oldsize_.Height - pts.Y + oldscreenpos_.Y); } else if (chSstate_ == CursorState.BorderLeft) { this.Location = new Point(oldformpos_.X - oldscreenpos_.X + pts.X, oldformpos_.Y); this.Size = new Size(oldsize_.Width - pts.X + oldscreenpos_.X, oldsize_.Height); } else if (chSstate_ == CursorState.BorderBottom) { this.Size = new Size(oldsize_.Width, oldsize_.Height + pts.Y - oldscreenpos_.Y); } else if (chSstate_ == CursorState.BorderRight) { this.Size = new Size(oldsize_.Width + pts.X - oldscreenpos_.X, oldsize_.Height); } }
private void FormStyle_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mousedown_ = false; move_ = false; mov_chS = false; chS = false; chSstate_ = CursorState.Normal;
if (closeButtonState == ButtonState.Down) { this.Close(); } else if ((minimizeButtonState == ButtonState.Down) & this.MinimizeBox) { this.WindowState = FormWindowState.Minimized; } else if ((maximizeButtonState == ButtonState.Down) & this.MaximizeBox) { if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } else if (this.WindowState == FormWindowState.Normal) { this.WindowState = FormWindowState.Maximized; } Invalidate(); } } }
private void FormStyle_MouseDoubleClick(System.Object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (new Rectangle(0, 0, this.Width - titlebarRight.Width, titlebarMid.Height).Contains(e.X, e.Y) & (curstate_ == CursorState.Normal)) { if (this.WindowState == FormWindowState.Normal) { this.WindowState = FormWindowState.Maximized; } else if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } Invalidate(); } else if (new Rectangle(this.Width - titlebarRight.Width, minimizeButton.Height, this.Width, 1).Contains(e.X, e.Y) & (curstate_ == CursorState.Normal)) { if (this.WindowState == FormWindowState.Normal) { this.WindowState = FormWindowState.Maximized; } else if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } Invalidate(); } } } #endregion
private Size ZoomSize(Size def, Size z) { double q = z.Width / z.Height; Size res = default(Size); if ((def.Width / def.Height) < q) { res = new Size(def.Width, Convert.ToInt32(def.Width / q)); } else if ((def.Width / def.Height) == q) { res = def; } else if ((def.Width / def.Height) > q) { res = new Size(Convert.ToInt32(def.Height * q), def.Height); } return res; }
} } |
Könnte mir vlt jemand sagn was ich falsch mache?
LG Fabian
|
|
bakachan
      
Beiträge: 503
Erhaltene Danke: 34
W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
|
Verfasst: Do 12.08.10 14:18
Wahrscheinlich trägst du das falsche Shirt beim programmieren.
Nein mal im ernst ohne zu wissen was für Fehler kommen ist es nicht so einfach zu helfen (vor allem da es ja doch ein nicht ganz so kleines Stück vom Code ist).
Aber so nebenbei: bei mir funktioniert dein Code (abgesehen von den 8 Ressourcen)
|
|
F.A Development
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Do 12.08.10 14:23
o.Ô ok... Erstmah danke für echt schnelle Antwort... Ich weiß ich bin im erklären hald nich so der pro... das es bei dir geht und bei mir nich kann ich mir jetz nich wirk erklären... hier die/der Fehler:
Fehler 1 Inkonsistenter Zugriff: Basisklasse "Orbit_FTP_Client.FormStyle" ist weniger zugreifbar als Klasse "Orbit_FTP_Client.Form1" C:\Users\Fabian\documents\visual studio 2010\Projects\Orbit FTP Client\Orbit FTP Client\Form1.Designer.cs 3 19 Orbit FTP Client
und noch die warnungen :
Warnung 2 Der Primärverweis "Microsoft.CSharp", bei dem es sich um eine Frameworkassembly handelt, konnte im derzeit als Ziel verwendeten Framework nicht aufgelöst werden. ".NETFramework,Version=v3.5". Zur Beseitigung des Problems muss entweder der Verweis "Microsoft.CSharp" entfernt oder die Anwendung erneut als Ziel für eine Frameworkversion verwendet werden, die ".NETFramework,Version=v3.5" enthält. Orbit FTP Client
Warnung 3 Die Komponente "Microsoft.CSharp", auf die verwiesen wird, wurde nicht gefunden.
Danke dir und euch
|
|
bakachan
      
Beiträge: 503
Erhaltene Danke: 34
W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
|
Verfasst: Do 12.08.10 14:34
Zum ersten Fehler:
Mach deine FormStyle-Klasse mal public.
Was die anderen beiden Fehler angeht:
Hast du zufällig auf ein anderes Zielframework umgestellt? (Properties, Application, Target framework)
So wies ausschaut benutzt du Verweise aus dem 3.5er Framework allerdings hast du wohl als Zielframework ein älteres angegeben.
|
|
F.A Development
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Do 12.08.10 14:47
Also ich habe die Class Public gemacht jetz bekomme ich keine fehler mehr... aber an der Form die ich erben lasse ändert sich leider auch nichts....ratlos
Danke
LG Fabian
|
|
bakachan
      
Beiträge: 503
Erhaltene Danke: 34
W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
|
Verfasst: Do 12.08.10 14:58
Ähm dir sollte klar sein das du keine Form erben lässt sondern von einer Form erbst.
|
|
F.A Development
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Do 12.08.10 15:35
jaja aber von der klasse kann ich erben lassen in vb is das zumindest so...
danke
|
|
bakachan
      
Beiträge: 503
Erhaltene Danke: 34
W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
|
Verfasst: Do 12.08.10 15:49
ähm ja logisch kannst du andere klassen davon ableiten
oder halt Instanzen deiner Klasse erstellen
aber daran wirds bestimmt nciht liegen das nichts geändert ist.
Schaun wir mal kurz in den Code...
Du hast direkt direkt von VB in C# geändert oder?
Es gibt da nen kleinen Unterschied bei Konstruktoren
VB:
Quelltext
Du hast
C#-Quelltext
und in C# müsst es heissen::
C#-Quelltext
Also wurde dein Kontruktor garnicht aufgerufen.
Zuletzt bearbeitet von bakachan am Do 12.08.10 16:35, insgesamt 2-mal bearbeitet
|
|
F.A Development
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Do 12.08.10 16:02
Danke dir dachte mir schon sowas in der art ich werdes sobal wie möglich probiern und dann ein danke spenden
LG Fabi
//EDIT:
Wenn ich es aber abänder bekomme ich folgenden Fehler -.-':
Membernamen dürfen nicht mit den Namen des einschließenden Typs Identisch sein.
Danke LG Fabi
|
|
bakachan
      
Beiträge: 503
Erhaltene Danke: 34
W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
|
Verfasst: Do 12.08.10 16:38
Dann hast du bestimmt
C#-Quelltext 1:
| public void FormStyle() |
geschrieben und nicht
C#-Quelltext
(ohne void weil ja deine Klasse dem Rückgabetyp entspricht)
|
|
F.A Development
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Do 12.08.10 16:43
Mit dem Code:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31:
| public CleanOrbit_WS() { this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.DoubleBuffered = true; this.FormBorderStyle = FormBorderStyle.None; BG_Color = SystemColors.Control; this.BackColor = Color.LavenderBlush; this.TransparencyKey = Color.LavenderBlush; this.MaximizedBounds = SystemInformation.WorkingArea; titlebarLeft = Properties.Resources.titlebarLeft.Size; titlebarMid = new Size(this.Width - titlebarLeft.Width - titlebarRight.Width +2,titlebarRight.Height); titlebarRight = Properties.Resources.titlebarRight.Size; borderRight = new Size(7,this.Height-borderBottom.Height-titlebarLeft.Height +2); borderCornerRight = Properties.Resources.borderCornerRight.Size; borderBottom = new Size(this.Width, 7); borderCornerLeft = Properties.Resources.borderCornerLeft.Size; borderLeft = new Size(7, this.Height - titlebarMid.Height - borderCornerLeft.Height); closeButton = Properties.Resources.closeNormal.Size; closeButton_tool = Properties.Resources.closeNormal_tool.Size; maximizeButton = Properties.Resources.maximizeNormal.Size; minimizeButton = Properties.Resources.minimizeNorm.Size; TextColor_ = Color.Black; try { TextFont_ = new Font("Arial", 9, FontStyle.Regular); } catch { TextFont_ = this.Font; } } |
kommt der Fehler
klasse heißt: CleanOrbit_WS
Danke
LG Fabi
|
|
bakachan
      
Beiträge: 503
Erhaltene Danke: 34
W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
|
Verfasst: Do 12.08.10 16:57
Find ich grade relativ seltsam eigentlich müsste es gehen.
Vielleicht hilft dir das hier weiter:
msdn.microsoft.com/d...k2xk%28VS.80%29.aspx
|
|
F.A Development
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Do 12.08.10 16:59
danke dir aber ich bin noch nich so bewandelt in C# ich kann damit nich wirk was anfangen ... und den Fehler kann ich mir auch nich wirk erklärn -.-'
Danke dir
LG Fabi
|
|
Kha
      
Beiträge: 3803
Erhaltene Danke: 176
Arch Linux
Python, C, C++ (vim)
|
Verfasst: Do 12.08.10 18:37
Poste bitte einmal die vollständige Klasse, der Fehler sollte wirklich nicht auftreten. Ist es denn wirklich die Konstruktor-Zeile?
_________________ >λ=
|
|
F.A Development
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Do 12.08.10 18:59
Siehe 1er Post, hat blos jetzt nen andren namen
siehe post's oben.
LG Fabi
|
|
Kha
      
Beiträge: 3803
Erhaltene Danke: 176
Arch Linux
Python, C, C++ (vim)
|
Verfasst: Do 12.08.10 20:49
Das zusammenkopiert funktioniert bei mir wie erwartet.
Was passiert denn, wenn du alles außer dem Konstruktor entfernst?
_________________ >λ=
|
|
F.A Development
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Do 12.08.10 22:20
Ich habe das proj. gerade wieder geöffnet... ich bekomme keinen Fehler mehr... bis jetzt funktioniert es wie ich mir es vorgestellt habe.. keine ahnung was da schiefgelaufen ist vorhin... ich tippe darauf das die IDE etwas gespunnen hat
danke euch
ich melde mich wenn ich genaueres weiß
LG Fabian
|
|
F.A Development
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Fr 13.08.10 00:09
Sorry für den Doppelpost bei zwingendem Grund füge ich die 2 Posts zusammen.
Ich habe nun keine Fehler mehr, jedoch habe ich nur eine Form im FormBorderStyle none...
Der code bisher:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668:
| using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.Drawing; using System.Windows.Forms; using System.ComponentModel; using System.Drawing.Drawing2D;
namespace Orbit_FTP___FTP_Client { public class formStyle : Form { #region ContextMenuTaskbar const Int32 SC_SIZE = 0xf000; const Int32 SC_MOVE = 0xf010; const Int32 SC_MINIMIZE = 0xf020; const Int32 SC_MAXIMIZE = 0xf030; const Int32 SC_CLOSE = 0xf060; const Int32 SC_RESTORE = 0xf120; const Int32 MF_BYCOMMAND = 0x0; const Int32 MF_SEPARATOR = 0x800; private const int HTCAPTION = 2; private const int TPM_RETURNCMD = 0x100; private const int WM_SYSCOMMAND = 0x112;
[DllImport("user32.dll", EntryPoint = "EnableMenuItem")] private static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable);
[DllImport("user32.dll", EntryPoint = "ReleaseCapture")] private static extern int ReleaseCapture();
[DllImport("user32.dll", EntryPoint = "GetSystemMenu")] private static extern IntPtr GetSystemMenu(IntPtr hwnd, int bRevert);
[DllImport("user32.dll", EntryPoint = "TrackPopupMenuEx")] private static extern int TrackPopupMenuEx(IntPtr hMenu, int wFlags, int x, int y, IntPtr hWnd, int lpTpm);
protected override CreateParams CreateParams { get { const int WS_SYSMENU = 0x80000; const int WS_MAXIMIZEBOX = 0x10000; const int WS_MINIMIZEBOX = 0x20000; CreateParams oReturn = base.CreateParams; oReturn.Style = oReturn.Style | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; return oReturn; } } #endregion
#region Global Vars private Size titlebarLeft; private Size titlebarRight; private Size titlebarMid; private Size borderLeft; private Size borderRight; private Size borderBottom; private Size borderCornerLeft; private Size borderCornerRight; private Size closeButton; private Size maximizeButton; private Size minimizeButton; private Size closeButton_tool;
private Font TextFont_; private Color TextColor_;
private Image BG_Image = null; private Color BG_Color;
private WindowStyle_ curWinStyle = WindowStyle_.Sizeable;
private CursorState curstate_ = CursorState.Normal; private CursorState chSstate_ = CursorState.Normal;
private ButtonState closeButtonState = ButtonState.Normal; private ButtonState minimizeButtonState = ButtonState.Normal; private ButtonState maximizeButtonState = ButtonState.Normal;
private bool move_ = false; private bool mousedown_ = false;
private Point oldpos_; private bool mov_chS = false; private bool chS = false; private Point oldformpos_;
private Point oldscreenpos_; private Size oldsize_; #endregion
#region Enums public enum CursorState { TopLeft, TopMid, TopRight, BorderRight, BorderCornerRight, BorderBottom, BorderCornerLeft, BorderLeft, Normal } public enum ButtonState { Normal, Over, Down } public enum WindowStyle_ { ToolBox, MSG_Box, Sizeable, Fixed } #endregion
#region properties public Font Font_Title { get { return TextFont_; }
set { TextFont_ = value; } }
public Color ForeColor_Title { get { return TextColor_; }
set { TextColor_ = value; } }
public Image BackGroundImage_Form { get { return BG_Image; } set { BG_Image = value; } }
public Color BackGroundColor_Form { get { return BG_Color; }
set { BG_Color = value; } }
public WindowStyle_ Fensterstyle { get { return curWinStyle; }
set { curWinStyle = value; } } protected override System.Windows.Forms.Padding DefaultPadding { get { return new Padding(borderLeft.Width, titlebarMid.Height, borderRight.Width, borderBottom.Height); } }
[EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] public override System.Drawing.Color BackColor { get { return base.BackColor; } set { base.BackColor = this.TransparencyKey; } }
[EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] public override System.Drawing.Image BackgroundImage { get { return null; }
set { } } #endregion
#region Initalisiren
public formStyle() { this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.DoubleBuffered = true; this.FormBorderStyle = FormBorderStyle.None; BG_Color = SystemColors.Control; this.BackColor = Color.LavenderBlush; this.TransparencyKey = Color.LavenderBlush; this.MaximizedBounds = SystemInformation.WorkingArea; titlebarLeft = new Size(Properties.Resources.titelbarLeft.Width,24); titlebarRight = new Size(Properties.Resources.titelbarRight.Width,24); titlebarMid = new Size(this.Width - titlebarLeft.Width -titlebarRight.Width ,24); borderRight = new Size(titlebarRight.Width,this.Height -titlebarRight.Height - borderCornerRight.Height); borderCornerRight = new Size(titlebarRight.Width,titlebarRight.Width); borderBottom = new Size(this.Width-borderCornerRight.Width-borderCornerLeft.Width,borderCornerLeft.Height); borderCornerLeft = new Size(titlebarLeft.Width,titlebarLeft.Width); borderLeft = new Size(titlebarLeft.Width,this.Height-titlebarLeft.Height-borderCornerLeft.Height); closeButton = Properties.Resources.closeNorm.Size; closeButton_tool = new Size(15,15); maximizeButton = Properties.Resources.maximizeNorm.Size; minimizeButton = Properties.Resources.minimizeNorm.Size; TextColor_ = Color.Black; try { TextFont_ = new Font("Arial", 9, FontStyle.Regular); } catch { TextFont_ = this.Font; } } private void InitializeComponent() { this.SuspendLayout(); this.ClientSize = new System.Drawing.Size(284, 262); this.Name = "formStyle"; this.Paint += new System.Windows.Forms.PaintEventHandler(this.formStyle_Paint); this.ResumeLayout(false);
} #endregion
#region Zeichnen
private void DrawSizableWindow(object sender, PaintEventArgs e) { this.BackColor = this.TransparencyKey; Graphics g = e.Graphics;
SolidBrush BorderBrush1 = new SolidBrush(Color.FromArgb(90, 90, 90)); SolidBrush BorderBrush2 = new SolidBrush(Color.FromArgb(171, 171, 170)); Rectangle RECTBorderLeft_1 = new Rectangle(0, titlebarMid.Height, 1, this.Height - titlebarMid.Height); Rectangle RECTBorderLeft_2 = new Rectangle(1, titlebarMid.Height, 3, this.Height - titlebarMid.Height - borderBottom.Height); Rectangle RECTBorderRight_1 = new Rectangle(this.Width - 1, titlebarMid.Height, 1, this.Height - titlebarMid.Height); Rectangle RECTBorderRight_2 = new Rectangle(this.Width - 4, titlebarMid.Height, 3, this.Height - titlebarMid.Height - borderBottom.Height); Rectangle RECTBorderBottom_1 = new Rectangle(0, this.Height - 1, this.Width, 1); Rectangle RECTBorderBottom_2 = new Rectangle(1, this.Height - 4, this.Width - 2, 3);
g.FillRectangle(BorderBrush1, RECTBorderBottom_1); g.FillRectangle(BorderBrush2, RECTBorderBottom_2); g.FillRectangle(BorderBrush1, RECTBorderLeft_1); g.FillRectangle(BorderBrush2, RECTBorderLeft_2); g.FillRectangle(BorderBrush1, RECTBorderRight_1); g.FillRectangle(BorderBrush2, RECTBorderRight_2);
g.DrawImage(Properties.Resources.titelbarLeft, 0, 0, 4, 24); g.DrawImage(Properties.Resources.titelbarMid_gross, 3, 0, this.Width - 6, 24); g.DrawImage(Properties.Resources.titelbarRight, this.Width - 4, 0, 4, 24);
g.DrawImage(Properties.Resources.closeNorm, this.Width - 4 - 18, 3, 18, 18); g.DrawImage(Properties.Resources.maximizeNorm, this.Width - 4 - 18 - 18 - 2, 3, 18, 18); g.DrawImage(Properties.Resources.minimizeNorm, this.Width - 4 - 18 - 18 - 18 - 4, 3, 18, 18);
switch (closeButtonState) { case ButtonState.Normal: g.DrawImage(Properties.Resources.closeNorm, this.Width - 4 - 18, 3, 18, 18); break; case ButtonState.Over: g.DrawImage(Properties.Resources.closeOver, this.Width - 4 - 18, 3, 18, 18); break; case ButtonState.Down: g.DrawImage(Properties.Resources.closeDown, this.Width - 4 - 18, 3, 18, 18); break; }
if (MaximizeBox == true) { if (this.WindowState == FormWindowState.Maximized) { switch (maximizeButtonState) { case ButtonState.Normal: g.DrawImage(Properties.Resources.normalizeNorm, this.Width - 4 - 18 - 18 - 2, 3, 18, 18); break; case ButtonState.Over: g.DrawImage(Properties.Resources.normalizeOver, this.Width - 4 - 18 - 18 - 2, 3, 18, 18); break; case ButtonState.Down: g.DrawImage(Properties.Resources.normalizeDown, this.Width - 4 - 18 - 18 - 2, 3, 18, 18); break; } } else { switch (maximizeButtonState) { case ButtonState.Normal: g.DrawImage(Properties.Resources.maximizeNorm, this.Width - 4 - 18 - 18 - 2, 3, 18, 18); break; case ButtonState.Over: g.DrawImage(Properties.Resources.maximizeOver, this.Width - 4 - 18 - 18 - 2, 3, 18, 18); break; case ButtonState.Down: g.DrawImage(Properties.Resources.maximizeDown, this.Width - 4 - 18 - 18 - 2, 3, 18, 18); break; } } }
if (MinimizeBox == true) { switch (minimizeButtonState) { case ButtonState.Normal: g.DrawImage(Properties.Resources.minimizeNorm, this.Width - 4 - 18 - 18 - 18 - 4, 3, 18, 18); break; case ButtonState.Over: g.DrawImage(Properties.Resources.minimizeOver, this.Width - 4 - 18 - 18 - 18 - 4, 3, 18, 18); break; case ButtonState.Down: g.DrawImage(Properties.Resources.minimizeDown, this.Width - 4 - 18 - 18 - 18 - 4, 3, 18, 18); break; } }
g.FillRectangle(new SolidBrush(BG_Color), borderLeft.Width, titlebarMid.Height, this.Width - borderRight.Width - borderLeft.Width, this.Height - titlebarMid.Height - borderBottom.Height);
this.MaximizedBounds = SystemInformation.WorkingArea; g.DrawImage(this.Icon.ToBitmap(), 9, 5, 16, 16);
g.SmoothingMode = SmoothingMode.HighQuality; g.DrawString(this.Text, TextFont_, new SolidBrush(TextColor_), 30, Convert.ToInt32(titlebarMid.Height / 2 - TextFont_.Height / 2)); g.SmoothingMode = SmoothingMode.Default;
if ((BG_Image != null)) { Rectangle ee = new Rectangle(borderLeft.Width, titlebarMid.Height, this.Width - borderLeft.Width - borderRight.Width, this.Height - titlebarMid.Height - borderBottom.Height); g.Clip = new Region(ee); switch (this.BackgroundImageLayout) { case ImageLayout.Center: g.DrawImage(BG_Image, ee.X + Convert.ToInt32(ee.Width / 2) - Convert.ToInt32(BG_Image.Width / 2), ee.Y + Convert.ToInt32(ee.Height / 2) - Convert.ToInt32(BG_Image.Height / 2), BG_Image.Width, BG_Image.Height); break; case ImageLayout.None: g.DrawImage(BG_Image, ee.X, ee.Y, BG_Image.Width, BG_Image.Height); break; case ImageLayout.Stretch: g.DrawImage(BG_Image, ee.X, ee.Y, ee.Width, ee.Height); break; case ImageLayout.Tile: for (int w = ee.X; w <= ee.X + ee.Width; w++) { for (int h = ee.Y; h <= ee.Y + ee.Height; h++) { g.DrawImage(BG_Image, w, h, BG_Image.Width, BG_Image.Height); h += BG_Image.Height - 1; } w += BG_Image.Width - 1; }
break; case ImageLayout.Zoom: Size s = ZoomSize(ee.Size, BG_Image.Size); g.DrawImage(BG_Image, ee.X + Convert.ToInt32(ee.Width / 2) - Convert.ToInt32(s.Width / 2), ee.Y + Convert.ToInt32(ee.Height / 2) - Convert.ToInt32(s.Height / 2), s.Width, s.Height); break; } g.ResetClip(); } }
private void formStyle_Paint(object sender, PaintEventArgs e) { if(this.Fensterstyle == WindowStyle_.Sizeable) DrawSizableWindow(sender,e); } #endregion
#region Mouse Events
private void formStyle_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mousedown_ = true;
if (new Rectangle(0, borderCornerLeft.Height, titlebarLeft.Width, this.Height - borderCornerLeft.Height - borderCornerLeft.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.TopLeft; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(0, 0, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.TopLeft; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(0, 0, this.Width - borderCornerLeft.Width, borderLeft.Width).Contains(e.X, e.Y)) { chSstate_ = CursorState.TopMid; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(this.Width - borderCornerLeft.Width, 0, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.TopRight; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(this.Width - borderCornerRight.Width, borderCornerLeft.Height, borderCornerRight.Width, this.Height - 2 * borderCornerLeft.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.BorderCornerRight; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(this.Width - borderCornerLeft.Width, this.Height - borderCornerLeft.Height, borderCornerRight.Width, borderCornerRight.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.BorderCornerRight; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(borderCornerLeft.Width, this.Height - borderBottom.Height, this.Width - 2 * borderCornerLeft.Width, borderBottom.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.BorderBottom; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; } else if (new Rectangle(0, this.Height - borderCornerLeft.Height, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { chSstate_ = CursorState.BorderCornerLeft; oldpos_ = e.Location; oldformpos_ = this.Location; oldscreenpos_ = PointToScreen(e.Location); oldsize_ = this.Size; }
if (minimizeButtonState == ButtonState.Over) { minimizeButtonState = ButtonState.Down; Invalidate(); } else if (maximizeButtonState == ButtonState.Over) { maximizeButtonState = ButtonState.Down; Invalidate(); } else if (closeButtonState == ButtonState.Over) { closeButtonState = ButtonState.Down; Invalidate(); } } }
private void formStyle_MouseLeave(System.Object sender, System.EventArgs e) { minimizeButtonState = ButtonState.Normal; maximizeButtonState = ButtonState.Normal; closeButtonState = ButtonState.Normal; Invalidate(); }
private void CleanOrbit_WS_MouseMove(System.Object sender, System.Windows.Forms.MouseEventArgs e) { Point pts = PointToScreen(e.Location);
if (move_) { this.Location = new Point(this.Location.X + e.X - oldpos_.X, this.Location.Y + e.Y - oldpos_.Y); } else { if (!mousedown_) { if (new Rectangle(this.Width - titlebarRight.Width + 2 - closeButton.Width - maximizeButton.Width - minimizeButton.Width, 0, minimizeButton.Width, minimizeButton.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.Default; minimizeButtonState = ButtonState.Over; maximizeButtonState = ButtonState.Normal; closeButtonState = ButtonState.Normal; } else if (new Rectangle(this.Width - titlebarRight.Width + 2 - closeButton.Width - maximizeButton.Width, 0, maximizeButton.Width, maximizeButton.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.Default; maximizeButtonState = ButtonState.Over; minimizeButtonState = ButtonState.Normal; closeButtonState = ButtonState.Normal; } else if (new Rectangle(this.Width - titlebarRight.Width + 2 - closeButton.Width, 0, closeButton.Width, closeButton.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.Default; closeButtonState = ButtonState.Over; minimizeButtonState = ButtonState.Normal; maximizeButtonState = ButtonState.Normal; } else { closeButtonState = ButtonState.Normal; minimizeButtonState = ButtonState.Normal; maximizeButtonState = ButtonState.Normal; } Invalidate(); }
if (new Rectangle(0, borderCornerLeft.Height, borderLeft.Width, this.Height - borderCornerLeft.Height - borderCornerLeft.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeWE; curstate_ = CursorState.BorderLeft; } else if (new Rectangle(0, 0, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNWSE; curstate_ = CursorState.TopLeft; } else if (new Rectangle(borderCornerLeft.Width, 0, this.Width - borderCornerLeft.Width - titlebarRight.Width + 2 - closeButton.Width - maximizeButton.Width - minimizeButton.Width, borderLeft.Width).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNS; curstate_ = CursorState.TopMid; } else if (new Rectangle(this.Width - borderCornerLeft.Width, 0, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNESW; curstate_ = CursorState.TopRight; } else if (new Rectangle(this.Width - borderRight.Width, borderCornerLeft.Height, borderRight.Width, this.Height - 2 * borderCornerLeft.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeWE; curstate_ = CursorState.BorderRight; } else if (new Rectangle(this.Width - borderCornerLeft.Width, this.Height - borderCornerLeft.Height, borderCornerRight.Width, borderCornerRight.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNWSE; curstate_ = CursorState.BorderCornerRight; } else if (new Rectangle(borderCornerLeft.Width, this.Height - borderBottom.Height, this.Width - 2 * borderCornerLeft.Width, borderBottom.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNS; curstate_ = CursorState.BorderBottom; } else if (new Rectangle(0, this.Height - borderCornerLeft.Height, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) { this.Cursor = Cursors.SizeNESW; curstate_ = CursorState.BorderCornerLeft; } else { this.Cursor = Cursors.Default; curstate_ = CursorState.Normal; } }
if (chSstate_ == CursorState.TopLeft) { this.Location = pts; this.Size = new Size(oldsize_.Width + oldscreenpos_.X - pts.X, oldsize_.Height + oldscreenpos_.Y - pts.Y); } else if (chSstate_ == CursorState.TopRight) { this.Location = new Point(oldformpos_.X, pts.Y); this.Size = new Size(oldsize_.Width + pts.X - oldscreenpos_.X, oldsize_.Height + oldformpos_.Y - this.Location.Y); } else if (chSstate_ == CursorState.BorderCornerLeft) { this.Location = new Point(oldformpos_.X - oldscreenpos_.X + pts.X, oldformpos_.Y); this.Size = new Size(oldsize_.Width - pts.X + oldscreenpos_.X, oldsize_.Height + pts.Y - oldscreenpos_.Y); } else if (chSstate_ == CursorState.BorderCornerRight) { this.Size = new Size(oldsize_.Width + pts.X - oldscreenpos_.X, oldsize_.Height + pts.Y - oldscreenpos_.Y); } else if (chSstate_ == CursorState.TopMid) { this.Location = new Point(oldformpos_.X, oldformpos_.Y + pts.Y - oldscreenpos_.Y); this.Size = new Size(oldsize_.Width, oldsize_.Height - pts.Y + oldscreenpos_.Y); } else if (chSstate_ == CursorState.BorderLeft) { this.Location = new Point(oldformpos_.X - oldscreenpos_.X + pts.X, oldformpos_.Y); this.Size = new Size(oldsize_.Width - pts.X + oldscreenpos_.X, oldsize_.Height); } else if (chSstate_ == CursorState.BorderBottom) { this.Size = new Size(oldsize_.Width, oldsize_.Height + pts.Y - oldscreenpos_.Y); } else if (chSstate_ == CursorState.BorderRight) { this.Size = new Size(oldsize_.Width + pts.X - oldscreenpos_.X, oldsize_.Height); } }
private void formStyle_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mousedown_ = false; move_ = false; mov_chS = false; chS = false; chSstate_ = CursorState.Normal;
if (closeButtonState == ButtonState.Down) { this.Close(); } else if ((minimizeButtonState == ButtonState.Down) & this.MinimizeBox) { this.WindowState = FormWindowState.Minimized; } else if ((maximizeButtonState == ButtonState.Down) & this.MaximizeBox) { if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } else if (this.WindowState == FormWindowState.Normal) { this.WindowState = FormWindowState.Maximized; } Invalidate(); } } }
private void formStyle_MouseDoubleClick(System.Object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (new Rectangle(0, 0, this.Width - titlebarRight.Width, titlebarMid.Height).Contains(e.X, e.Y) & (curstate_ == CursorState.Normal)) { if (this.WindowState == FormWindowState.Normal) { this.WindowState = FormWindowState.Maximized; } else if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } Invalidate(); } else if (new Rectangle(this.Width - titlebarRight.Width, minimizeButton.Height, this.Width, 1).Contains(e.X, e.Y) & (curstate_ == CursorState.Normal)) { if (this.WindowState == FormWindowState.Normal) { this.WindowState = FormWindowState.Maximized; } else if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } Invalidate(); } } } #endregion
private Size ZoomSize(Size def, Size z) { double q = z.Width / z.Height; Size res = default(Size); if ((def.Width / def.Height) < q) { res = new Size(def.Width, Convert.ToInt32(def.Width / q)); } else if ((def.Width / def.Height) == q) { res = def; } else if ((def.Width / def.Height) > q) { res = new Size(Convert.ToInt32(def.Height * q), def.Height); } return res; }
} } |
Danke Euch
LG Fabian
|
|
|