mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 12:46:30 +00:00
save window position and left and right panel size
This commit is contained in:
@@ -64,10 +64,19 @@ public partial class MainWindow
|
||||
InitControls();
|
||||
|
||||
_suspendLayout = true;
|
||||
|
||||
Left = _config.WindowLocation.X;
|
||||
Top = _config.WindowLocation.Y;
|
||||
|
||||
Width = _config.WindowSize.Width;
|
||||
Height = _config.WindowSize.Height;
|
||||
|
||||
MainGrid.ColumnDefinitions.FirstOrDefault()!.Width = new GridLength(_config.LeftPanelWidth);
|
||||
MainGrid.ColumnDefinitions.LastOrDefault()!.Width = new GridLength(_config.RightPanelWidth);
|
||||
|
||||
if (_config.FullScreen)
|
||||
WindowState = WindowState.Maximized;
|
||||
|
||||
_suspendLayout = false;
|
||||
|
||||
ReloadFiles();
|
||||
@@ -132,31 +141,30 @@ public partial class MainWindow
|
||||
VideoSlider.KeyDown += (sender, args) => _mediator.Publish(new KeyEvent(sender, args));
|
||||
|
||||
Volume.ValueChanged += (_, newValue) => _mediator.Publish(new VolumeChangedEvent((int)newValue));
|
||||
|
||||
SizeChanged += (sender, args) =>
|
||||
{
|
||||
if (!_suspendLayout)
|
||||
{
|
||||
_config.WindowSize = args.NewSize;
|
||||
var saveConfigFn = () => _configRepository.Save(_config);
|
||||
saveConfigFn.Debounce(TimeSpan.FromSeconds(7)).Invoke();
|
||||
}
|
||||
};
|
||||
LocationChanged += (_, _) =>
|
||||
{
|
||||
if (!_suspendLayout)
|
||||
{
|
||||
_config.WindowLocation = new Point(Left, Top);
|
||||
var saveConfigFn = () => _configRepository.Save(_config);
|
||||
saveConfigFn.Debounce(TimeSpan.FromSeconds(7)).Invoke();
|
||||
}
|
||||
};
|
||||
|
||||
SizeChanged += (_, _) => SaveUserSettings();
|
||||
LocationChanged += (_, _) => SaveUserSettings();
|
||||
StateChanged += (_, _) => SaveUserSettings();
|
||||
|
||||
Editor.FormState = _formState;
|
||||
Editor.Mediator = _mediator;
|
||||
DgAnnotations.ItemsSource = _formState.AnnotationResults;
|
||||
}
|
||||
|
||||
private void SaveUserSettings()
|
||||
{
|
||||
if (_suspendLayout)
|
||||
return;
|
||||
|
||||
_config.LeftPanelWidth = MainGrid.ColumnDefinitions.FirstOrDefault()!.Width.Value;
|
||||
_config.RightPanelWidth = MainGrid.ColumnDefinitions.LastOrDefault()!.Width.Value;
|
||||
_config.WindowSize = new Size(Width, Height);
|
||||
_config.WindowLocation = new Point(Left, Top);
|
||||
_config.FullScreen = WindowState == WindowState.Maximized;
|
||||
var saveConfigFn = () => _configRepository.Save(_config);
|
||||
saveConfigFn.Debounce(TimeSpan.FromSeconds(5)).Invoke();
|
||||
}
|
||||
|
||||
private void ShowTimeAnnotations(TimeSpan time)
|
||||
{
|
||||
Dispatcher.Invoke(() => VideoSlider.Value = _mediaPlayer.Position * VideoSlider.Maximum);
|
||||
|
||||
Reference in New Issue
Block a user