Beispiel #1
0
        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);
            }
        }