test_form-aufruf_test_visua.../MyForm/Window.cs

154 lines
4.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OwnForms
{
public class Window
{
/// <summary>
/// Controls the appearance of a window.
/// </summary>
public Window()
{
SetWindowSize(Size.Micro); //Initialisiere ein Fenster
}
public enum Size
{
Nano,
Micro,
Mini,
Midi,
Maxi,
Magnum
}
public enum ControlBox
{
Off,
On
}
public enum BorderStyle
{
Fix,
Sizeable
}
public enum TopMost
{
Off,
On
}
/// <summary>
/// Stores the current window size.
/// </summary>
public Size CurrentWindowSize { private set; get; }
/// <summary>
/// Stores the size values of the current window.
/// </summary>
public int[] CurrentWindowSizeValue { private set; get; }
/// <summary>
/// Stores the current control box setting.
/// </summary>
public ControlBox CurrentControlBox { private set; get; }
/// <summary>
/// Stores the border sizeable setting.
/// </summary>
public BorderStyle CurrentBorderStyle { private set; get; }
/// <summary>
/// Stores the window most on top setting.
/// </summary>
public TopMost CurrentTopMostStatus { private set; get; }
/// <summary>
/// Sets the widht and height size of a window.
/// </summary>
/// <param name="size">A valid window size. Possible options are: 'Nano' (360x270), 'Micro' (480x360), 'Mini' (640x480), 'Midi' (850x640), 'Maxi' (1020x770) und 'Magnum' (1360x1020).</param>
/// <returns>Returns the widht and height value of the window.</returns>
public int[] SetWindowSize(Size size)
{
int[] windowsSize = new int[2];
switch (size)
{
case Size.Nano:
windowsSize[0] = 360;
windowsSize[1] = 270;
break;
case Size.Micro:
windowsSize[0] = 480;
windowsSize[1] = 360;
break;
case Size.Mini:
windowsSize[0] = 640;
windowsSize[1] = 480;
break;
case Size.Midi:
windowsSize[0] = 850;
windowsSize[1] = 640;
break;
case Size.Maxi:
windowsSize[0] = 1020;
windowsSize[1] = 770;
break;
case Size.Magnum:
windowsSize[0] = 1360;
windowsSize[1] = 1020;
break;
default:
windowsSize[0] = 480;
windowsSize[1] = 360;
break; //Size.Micro
}
CurrentWindowSize = size;
CurrentWindowSizeValue = windowsSize;
return CurrentWindowSizeValue;
}
/// <summary>
/// Sets the controlbox of a window.
/// </summary>
/// <param name="controlBox">A valid option. Possible options are 'Off' and 'On'.</param>
/// <returns>Returns the control box status.</returns>
public Window.ControlBox SetControlBox(ControlBox controlBox)
{
CurrentControlBox = controlBox;
return controlBox;
}
/// <summary>
/// Sets the border style of a window.
/// </summary>
/// <param name="borderStyle">A valid option. Possible options are 'Fix' and 'Sizeable'.</param>
/// <returns>Returns the control box status.</returns>
public Window.BorderStyle SetBorderStyle(BorderStyle borderStyle)
{
CurrentBorderStyle = borderStyle;
return borderStyle;
}
/// <summary>
/// Sets whether the window is most on top.
/// </summary>
/// <param name="topMost">A valid option. Possible options are 'Off' and 'On'.</param>
/// <returns>Returns the most on top status.</returns>
public Window.TopMost SetTopMost(TopMost topMost)
{
CurrentTopMostStatus = topMost;
return topMost;
}
}
}