Beispiel #1
0
 public MainWindow()
 {
     this.UpdateLanguage();
     InitializeComponent();
     WindowPositionSettings.UseWith(this, "MainWindowPosition");
     ViewModel.View = this;
 }
Beispiel #2
0
 public EditIoDevice()
 {
     this.UpdateLanguage();
     InitializeComponent();
     WindowPositionSettings.UseWith(this, "EditIoDeviceWindowPosition");
     ViewModel.View = this;
     tbName.Focus();
     UpdateTypeEditorRowHeight();
     Closing += EditIoDeviceClosing;
 }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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());
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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));
        }
Beispiel #7
0
 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();
 }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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);
        }