2using System.Threading.Tasks;
20 private bool skipNextPosition =
false;
26 : this(WindowState.Normal, 0, 0, 0, 0, 0)
54 get => this.width.Value;
55 set => this.width.Value = value;
63 get => this.height.Value;
64 set => this.height.Value = value;
72 get => this.left.Value;
73 set => this.left.Value = value;
81 get => this.top.Value;
82 set => this.top.Value = value;
90 get => this.state.Value;
91 set => this.state.Value = value;
99 get => (int)this.tabIndex.Value;
100 set =>
this.tabIndex.Value = value;
110 this.skipNextPosition =
double.IsNaN(
MainWindow.currentInstance.Left);
112 MainWindow.currentInstance.WindowState =
this.State;
114 if (this.
Left > -25600)
117 if (this.
Top > -25600)
120 MainWindow.currentInstance.Width =
this.Width;
121 MainWindow.currentInstance.Height =
this.Height;
122 MainWindow.currentInstance.TabControl.SelectedIndex =
this.TabIndex;
123 MainWindow.currentInstance.Visibility = Visibility.Visible;
125 MainWindow.currentInstance.SizeChanged += WindowSizeChanged;
126 MainWindow.currentInstance.LocationChanged += WindowLocationChanged;
127 MainWindow.currentInstance.StateChanged += WindowStateChanged;
128 MainWindow.currentInstance.TabControl.SelectionChanged += TabIndexChanged;
130 return Task.CompletedTask;
141 MainWindow.currentInstance.SizeChanged -= WindowSizeChanged;
142 MainWindow.currentInstance.LocationChanged -= WindowLocationChanged;
143 MainWindow.currentInstance.StateChanged -= WindowStateChanged;
144 MainWindow.currentInstance.TabControl.SelectionChanged -= TabIndexChanged;
149 private void WindowSizeChanged(
object sender, SizeChangedEventArgs e)
151 if (
MainWindow.currentInstance.WindowState == WindowState.Normal)
153 if (e.WidthChanged && e.NewSize.Width > 0)
154 this.Width = e.NewSize.Width;
156 if (e.HeightChanged && e.NewSize.Height > 0)
157 this.Height = e.NewSize.Height;
161 private void WindowLocationChanged(
object sender, EventArgs e)
163 if (
MainWindow.currentInstance.WindowState == WindowState.Normal)
165 if (this.skipNextPosition)
167 if (
MainWindow.currentInstance.Left !=
this.Left)
168 MainWindow.currentInstance.Left = this.
Left;
170 if (
MainWindow.currentInstance.Top !=
this.Top)
171 MainWindow.currentInstance.Top = this.
Top;
173 this.skipNextPosition =
false;
177 if (MainWindow.currentInstance.Left > -25600)
178 this.Left = MainWindow.currentInstance.Left;
180 if (MainWindow.currentInstance.Top > -25600)
181 this.Top = MainWindow.currentInstance.Top;
186 private void WindowStateChanged(
object sender, EventArgs e)
188 this.State = MainWindow.currentInstance.WindowState;
191 private void TabIndexChanged(
object sender, System.Windows.Controls.SelectionChangedEventArgs e)
193 this.TabIndex = MainWindow.currentInstance.TabControl.SelectedIndex;
Interaction logic for MainWindow.xaml
static void UpdateGui(GuiDelegate Method)
Calls a method from the Main UI thread.
Abstract base class for persistant view models
void Add(IPersistedProperty Property)
Adds a persistant property
Generic class for persistant properties
double Left
Left of main window
WindowSizeModel()
Main window size model
override Task Start()
Starts the model.
double Height
Height of main window
double Top
Top of main window
WindowSizeModel(WindowState State, double Left, double Top, double Width, double Height, int TabIndex)
Main window size model
WindowState State
Window State
override Task Stop()
Stops the model.
double Width
Width of main window