public MainWindow() { InitializeComponent(); _app = (App)Application.Current; var fileValidator = new FileValidator(); var errorHandler = new ErrorHandlerView(); var librarySelector = new LibrarySelector(fileValidator, errorHandler, Dispatcher, _app.EventAggregator); _vm = new MainVm(new LibraryLocationDialog(), librarySelector, errorHandler, fileValidator, _app.AppSettings, _app.EventAggregator); DataContext = _vm; Instance = this; var positionData = _app.AppSettings.WindowPositions == null ? null : _app.AppSettings.WindowPositions .FirstOrDefault(w => w.WindowId == "MainWindow"); _windowPositionSettings = new WindowPositionSettings(positionData, 0.7); _windowPositionSettings.AttachWindow(this); if (positionData == null) { _windowPositionSettings.PositionData.WindowId = "MainWindow"; if (_app.AppSettings.WindowPositions == null) { _app.AppSettings.WindowPositions = new List <WindowPositionData>(); } _app.AppSettings.WindowPositions.Add(_windowPositionSettings.PositionData); } _app.MainWindow = this; }
public MainWindow() { this.UpdateLanguage(); InitializeComponent(); WindowPositionSettings.UseWith(this, "MainWindowPosition"); ViewModel.View = this; }
public EditIoDevice() { this.UpdateLanguage(); InitializeComponent(); WindowPositionSettings.UseWith(this, "EditIoDeviceWindowPosition"); ViewModel.View = this; tbName.Focus(); UpdateTypeEditorRowHeight(); Closing += EditIoDeviceClosing; }
public void SetsNotMaximizedOnClosingMinimizedState() { var windowStub = new Mock <IWindow>(); var settingsMock = new Mock <ISettings>(); WindowPositionSettings.UseWith(windowStub.Object, settingsMock.Object); windowStub.Setup(w => w.WindowState).Returns(WindowState.Minimized); windowStub.Raise(w => w.Closing += null, new CancelEventArgs()); settingsMock.Verify(settings => settings.SetBoolean(MaximizedKey, false)); }
public void ReloadsAndSavesSettingsOnClosing() { var windowStub = new Mock <IWindow>(); var settingsMock = new Mock <ISettings>(); WindowPositionSettings.UseWith(windowStub.Object, settingsMock.Object); windowStub.Raise(w => w.Closing += null, new CancelEventArgs()); settingsMock.Verify(settings => settings.Reload()); settingsMock.Verify(settings => settings.Save()); }
public void UseWithSetsNormalWhenNotMinimized() { var windowMock = new Mock <IWindow>(); var settignsStub = new Mock <ISettings>(); settignsStub.Setup(settings => settings.GetDouble(HeightKey)).Returns(Height); settignsStub.Setup(settings => settings.GetDouble(WidthKey)).Returns(Width); settignsStub.Setup(settings => settings.GetDouble(TopKey)).Returns(Top); settignsStub.Setup(settings => settings.GetDouble(LeftKey)).Returns(Left); settignsStub.Setup(settings => settings.GetBoolean(MaximizedKey)).Returns(false); WindowPositionSettings.UseWith(windowMock.Object, settignsStub.Object); windowMock.VerifySet(window => window.WindowState = WindowState.Normal); }
public void SetsBoundsOnClosing() { var windowStub = new Mock <IWindow>(); var settingsMock = new Mock <ISettings>(); WindowPositionSettings.UseWith(windowStub.Object, settingsMock.Object); windowStub.Setup(w => w.RestoreBounds).Returns(new Rect(Left, Top, Width, Height)); windowStub.Raise(w => w.Closing += null, new CancelEventArgs()); settingsMock.Verify(settings => settings.SetDouble(LeftKey, Left)); settingsMock.Verify(settings => settings.SetDouble(TopKey, Top)); settingsMock.Verify(settings => settings.SetDouble(WidthKey, Width)); settingsMock.Verify(settings => settings.SetDouble(HeightKey, Height)); }
public MainWindow() { this.UpdateLanguage(); InitializeComponent(); ViewModel.View = this; ViewModel.PropertyChanged += ViewModelPropertyChanged; ViewModel.Reporter.PropertyChanged += ReporterPropertyChanged; Loaded += MainWindowLoaded; Closed += MainWindowClosed; StateChanged += MainWindowStateChanged; WindowPositionSettings.UseWith(this, "MainWindowPosition"); LoadWindowSettings(); }
public void LoadSettings() { //Resolve to get the last used theme from the settings _container.Resolve <ThemeSettings>(); WindowPositionSettings position = _container.Resolve <IWindowPositionSettings>() as WindowPositionSettings; //Set the position of the window based on previous session values, delayed loaded in WiderBootstrpper if (_container.Resolve <IShell>() is IShell view) { view.Top = position.Top; view.Left = position.Left; view.Width = position.Width; view.Height = position.Height; } }
private void OnClosing(object sender, CancelEventArgs e) { WindowPositionSettings.Current[nameof(MainWindow)] = new WindowPosition { Top = Top, Left = Left, Height = Height, Width = Width, WindowState = WindowState }; WindowPositionSettings.Save(); ViewModel.OnClosing(); }
public void UseWithSetsValuesWhenValuesPresent() { var windowMock = new Mock <IWindow>(); var settignsStub = new Mock <ISettings>(); settignsStub.Setup(settings => settings.GetDouble(HeightKey)).Returns(Height); settignsStub.Setup(settings => settings.GetDouble(WidthKey)).Returns(Width); settignsStub.Setup(settings => settings.GetDouble(TopKey)).Returns(Top); settignsStub.Setup(settings => settings.GetDouble(LeftKey)).Returns(Left); settignsStub.Setup(settings => settings.GetBoolean(MaximizedKey)).Returns(true); WindowPositionSettings.UseWith(windowMock.Object, settignsStub.Object); windowMock.VerifySet(window => window.WindowStartupLocation = WindowStartupLocation.Manual); windowMock.VerifySet(window => window.Height = Height); windowMock.VerifySet(window => window.Width = Width); windowMock.VerifySet(window => window.Top = Top); windowMock.VerifySet(window => window.Left = Left); windowMock.VerifySet(window => window.WindowState = WindowState.Maximized); }
private static void UseWithDoesNotSetValuesWhenAnythingNotPresetAndSetsOtherwise( double?height, double?width, double?top, double?left, bool?maximized, bool shouldSet) { var windowMock = new Mock <IWindow>(); var settignsStub = new Mock <ISettings>(); settignsStub.Setup(settings => settings.GetDouble(HeightKey)).Returns(height); settignsStub.Setup(settings => settings.GetDouble(WidthKey)).Returns(width); settignsStub.Setup(settings => settings.GetDouble(TopKey)).Returns(top); settignsStub.Setup(settings => settings.GetDouble(LeftKey)).Returns(left); settignsStub.Setup(settings => settings.GetBoolean(MaximizedKey)).Returns(maximized); WindowPositionSettings.UseWith(windowMock.Object, settignsStub.Object); var times = shouldSet ? Times.Once() : Times.Never(); windowMock.VerifySet(window => window.WindowStartupLocation = WindowStartupLocation.Manual, times); windowMock.VerifySet(window => window.Height = It.Is <Double>(h => h == height), times); windowMock.VerifySet(window => window.Width = It.Is <Double>(w => w == width), times); windowMock.VerifySet(window => window.Top = It.Is <Double>(t => t == top), times); windowMock.VerifySet(window => window.Left = It.Is <Double>(l => l == left), times); windowMock.VerifySet(window => window.WindowState = It.IsAny <WindowState>(), times); }
private void LoadSettings() { ShellView view; ShellViewMetro metroView; //Resolve to get the last used theme from the settings _container.Resolve <ThemeSettings>(); IShell shell = _container.Resolve <IShell>(); WindowPositionSettings position = _container.Resolve <IWindowPositionSettings>() as WindowPositionSettings; //Set the position of the window based on previous session values based on metro or regular if (WideBootstrapper.IsMetro == true) { metroView = shell as ShellViewMetro; if (metroView != null) { metroView.Top = position.Top; metroView.Left = position.Left; metroView.Width = position.Width; metroView.Height = position.Height; metroView.WindowState = position.State; } } else { view = shell as ShellView; if (view != null) { view.Top = position.Top; view.Left = position.Left; view.Width = position.Width; view.Height = position.Height; view.WindowState = position.State; } } }
public WindowPositionSettingsBuilder(WindowPositionSettings settings) { this.settings = settings; }