SystemWindow.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. namespace System.Windows.Forms
  2. {
  3. public class SystemWindow : Window, IForm
  4. {
  5. public System.Windows.Controls.ContentControl ContentControl => this;
  6. public bool ExtendedAppArea { get; set; } // not supported
  7. public double ExtendedAppAreaSize { get; set; } // not supported
  8. public System.Drawing.Size ClientSizeDelta => NativeMethods.GetClientSizeDelta(this);
  9. private FormBorderStyle formBorderStyle;
  10. public FormBorderStyle FormBorderStyle
  11. {
  12. get => formBorderStyle;
  13. set
  14. {
  15. formBorderStyle = value;
  16. ResizeMode = value == FormBorderStyle.FixedDialog || value == FormBorderStyle.FixedToolWindow ? ResizeMode.NoResize : ResizeMode.CanResize;
  17. WindowStyle = value switch
  18. {
  19. FormBorderStyle.None => WindowStyle.None,
  20. FormBorderStyle.FixedToolWindow => WindowStyle.ToolWindow,
  21. FormBorderStyle.SizableToolWindow => WindowStyle.ToolWindow,
  22. _ => WindowStyle.SingleBorderWindow
  23. };
  24. if (value == FormBorderStyle.FixedDialog)
  25. {
  26. MinimizeBox = MaximizeBox = ShowIcon = false;
  27. }
  28. else if (value == FormBorderStyle.None)
  29. ResizeMode = ResizeMode.NoResize;
  30. }
  31. }
  32. public bool MaximizeBox { get; set; }
  33. public bool MinimizeBox { get; set; }
  34. public bool ShowIcon { get; set; }
  35. public SystemWindow()
  36. {
  37. Loaded += (s, e) => NativeMethods.RemoveWindowItems(this, ShowIcon, MinimizeBox, MaximizeBox);
  38. }
  39. }
  40. }