private void initializeWindows() { var aboutWindowViewModel = new AboutWindowViewModel( updateService: new UpdateService(Toggl.IsUpdateCheckDisabled(), Toggl.UpdatesPath), versionText: $"Version {Program.Version()} {Utils.Bitness()}"); this.childWindows = new Window[] { this.editPopup = new EditViewPopup(), new AboutWindow(aboutWindowViewModel), new FeedbackWindow(), new PreferencesWindow(), }; this.idleNotificationWindow = new IdleNotificationWindow(); this.editPopup.EditView.SetTimer(this.timerEntryListView.Timer); this.timerEntryListView.Timer.RunningTimeEntrySecondPulse += this.updateTaskbarTooltip; this.timerEntryListView.Timer.StartStopClick += (sender, args) => this.closeEditPopup(true); this.timerEntryListView.Entries.SetEditPopup(this.editPopup); this.timerEntryListView.Entries.CloseEditPopup += (sender, args) => this.closeEditPopup(true); this.editPopup.IsVisibleChanged += this.editPopupVisibleChanged; this.editPopup.SizeChanged += (sender, args) => this.updateEntriesListWidth(); this.idleNotificationWindow.AddedIdleTimeAsNewEntry += (o, e) => this.ShowOnTop(); this.miniTimer = new MiniTimerWindow(this); this.IsVisibleChanged += this.ownChildWindows; }
private void initializeWindows() { var aboutWindowViewModel = new AboutWindowViewModel( updateService: Toggl.UpdateService, versionText: $"Version {Program.Version()} {Utils.Bitness()}"); this.childWindows = new Window[] { this.editPopup = new EditViewPopup(), new AboutWindow(aboutWindowViewModel), new FeedbackWindow(), new PreferencesWindow(), }; this.idleNotificationWindow = new IdleNotificationWindow(); this.editPopup.EditView.SetTimer(this.timerEntryListView.Timer); this.timerEntryListView.Timer.ViewModel.WhenValueChanged(x => x.DurationText).Subscribe(x => updateTaskbarTooltip(this, x)); this.timerEntryListView.Timer.StartStopButtonClicked += () => closeEditPopup(true); this.timerEntryListView.Entries.SetEditPopup(this.editPopup); this.timerEntryListView.Entries.CloseEditPopup += (sender, args) => this.closeEditPopup(true); this.editPopup.IsVisibleChanged += this.editPopupVisibleChanged; this.editPopup.SizeChanged += (sender, args) => this.updateEntriesListWidth(); this.idleNotificationWindow.AddedIdleTimeAsNewEntry += (o, e) => this.ShowOnTop(); this.miniTimer = new MiniTimerWindow(this); this.IsVisibleChanged += this.ownChildWindows; }
private void initializeWindows() { this.childWindows = new Window[] { this.editPopup = new EditViewPopup(), new AboutWindow(), new FeedbackWindow(), new PreferencesWindow(), }; this.idleNotificationWindow = new IdleNotificationWindow(); this.editPopup.EditView.SetTimer(this.timerEntryListView.Timer); this.timerEntryListView.Timer.RunningTimeEntrySecondPulse += this.updateTaskbarTooltip; this.timerEntryListView.Timer.StartStopClick += (sender, args) => this.closeEditPopup(true); this.timerEntryListView.Entries.SetEditPopup(this.editPopup); this.timerEntryListView.Entries.CloseEditPopup += (sender, args) => this.closeEditPopup(true); this.editPopup.IsVisibleChanged += this.editPopupVisibleChanged; this.editPopup.SizeChanged += (sender, args) => this.updateEntriesListWidth(); this.idleNotificationWindow.AddedIdleTimeAsNewEntry += (o, e) => this.ShowOnTop(); this.miniTimer = new MiniTimerWindow(this); this.IsVisibleChanged += this.ownChildWindows; }
public static void LoadWindowLocation(Window mainWindow, EditViewPopup editPopup, MiniTimerWindow miniTimer) { if (editPopup != null) { editPopup.Width = Toggl.GetEditViewWidth(); } if (Toggl.GetWindowMaximized()) { mainWindow.WindowState = WindowState.Maximized; } else if (Toggl.GetWindowMinimized()) { mainWindow.WindowState = WindowState.Minimized; } long x = 0, y = 0, h = 0, w = 0; if (Toggl.WindowSettings(ref x, ref y, ref h, ref w) && ValidateWindowSettings(x, y, h, w)) { mainWindow.Left = x; mainWindow.Top = y; mainWindow.Width = w; mainWindow.Height = h; Toggl.Debug("Retrieved window location and size ({0}x{1} by {2}x{3})", x, y, w, h); } else { mainWindow.Width = 330; mainWindow.Height = 510; Toggl.Debug("Failed to retrieve window location and size. Setting the default size."); } // First try to shift the window onto the bounding box of visible screens if (ShiftWindowOntoVisibleArea(mainWindow)) { Toggl.Debug("Shifted main window onto visible area"); } // Then handle the case where the window is in the bounding box but not on any of the screens if (!VisibleOnAnyScreen(mainWindow)) { var location = Screen.PrimaryScreen.WorkingArea.Location; mainWindow.Left = location.X; mainWindow.Top = location.Y; Toggl.Debug("Force moved window to primary screen"); } if (miniTimer != null) { x = Toggl.GetMiniTimerX(); y = Toggl.GetMiniTimerY(); w = Toggl.GetMiniTimerW(); miniTimer.Left = x; miniTimer.Top = y; miniTimer.Width = w; Toggl.Debug("Retrieved mini timer location ({0}x{1} by {2})", x, y, w); CheckMinitimerVisibility(miniTimer); } }
public static void LoadWindowLocation(Window mainWindow, EditViewPopup editPopup, MiniTimerWindow miniTimer) { if (editPopup != null) { editPopup.Width = Toggl.GetEditViewWidth(); } if (Toggl.GetWindowMaximized()) { mainWindow.WindowState = WindowState.Maximized; } else if (Toggl.GetWindowMinimized()) { mainWindow.WindowState = WindowState.Minimized; } long x = 0, y = 0, h = 0, w = 0; if (Toggl.WindowSettings(ref x, ref y, ref h, ref w)) { mainWindow.Left = x; mainWindow.Top = y; mainWindow.Width = w; mainWindow.Height = h; Toggl.Debug("Retrieved window location and size ({0}x{1} by {2}x{3})", x, y, w, h); } else { Toggl.Debug("Failed to retrieve window location and size"); } if (!visibleOnAnyScreen(mainWindow)) { var location = Screen.PrimaryScreen.WorkingArea.Location; mainWindow.Left = location.X; mainWindow.Top = location.Y; Toggl.Debug("Force moved window to primary screen"); } if (miniTimer != null) { x = Toggl.GetMiniTimerX(); y = Toggl.GetMiniTimerY(); w = Toggl.GetMiniTimerW(); miniTimer.Left = x; miniTimer.Top = y; miniTimer.Width = w; Toggl.Debug("Retrieved mini timer location ({0}x{1} by {2})", x, y, w); if (!visibleOnAnyScreen(miniTimer)) { var location = Screen.PrimaryScreen.WorkingArea.Location; miniTimer.Left = location.X; miniTimer.Top = location.Y; Toggl.Debug("Force moved mini timer to primary screen"); } } }
public static void SaveWindowLocation(Window mainWindow, EditViewPopup edit, MiniTimerWindow miniTimer) { long x, y, w, h; if (mainWindow.WindowState == WindowState.Minimized) { var rb = mainWindow.RestoreBounds; x = (long)rb.X; y = (long)rb.Y; w = (long)rb.Width; h = (long)rb.Height; } else { x = (long)mainWindow.Left; y = (long)mainWindow.Top; w = (long)mainWindow.Width; h = (long)mainWindow.Height; } var success = ValidateWindowSettings(x, y, h, w) && Toggl.SetWindowSettings(x, y, h, w); Toggl.Debug(success ? "Saved window location and size ({0}x{1} by {2}x{3})" : "Failed to save window location and size ({0}x{1} by {2}x{3})", x, y, w, h); var state = mainWindow.WindowState; Toggl.SetWindowMaximized(state == WindowState.Maximized); Toggl.SetWindowMinimized(state == WindowState.Minimized); if (edit != null) { Toggl.SetEditViewWidth((long)edit.Width); } if (miniTimer != null) { x = (long)miniTimer.Left; y = (long)miniTimer.Top; w = (long)miniTimer.Width; Toggl.SetMiniTimerX(x); Toggl.SetMiniTimerY(y); Toggl.SetMiniTimerW(w); Toggl.Debug("Saved mini timer location ({0}x{1} by {2})", x, y, w); } }
public void SetEditPopup(EditViewPopup editPopup) { this.editPopup = editPopup; }
private void initializeWindows() { this.childWindows = new Window[]{ this.editPopup = new EditViewPopup(), this.aboutWindow = new AboutWindow(), this.feedbackWindow = new FeedbackWindow(), new PreferencesWindow(), }; this.idleNotificationWindow = new IdleNotificationWindow(); this.editPopup.EditView.SetTimer(this.timerEntryListView.Timer); this.timerEntryListView.Timer.RunningTimeEntrySecondPulse += this.updateTaskbarTooltip; this.timerEntryListView.Timer.StartStopClick += (sender, args) => this.closeEditPopup(true); this.timerEntryListView.Entries.SetEditPopup(this.editPopup); this.timerEntryListView.Entries.CloseEditPopup += (sender, args) => this.closeEditPopup(true); this.editPopup.IsVisibleChanged += this.editPopupVisibleChanged; this.editPopup.SizeChanged += (sender, args) => this.updateEntriesListWidth(); this.idleNotificationWindow.AddedIdleTimeAsNewEntry += (o, e) => this.ShowOnTop(); this.IsVisibleChanged += this.ownChildWindows; }