A timer window.
Inheritance: INotifyPropertyChanged, IRestorableWindow
        /// <summary>
        /// Initializes a new instance of the <see cref="ThemeManagerWindow"/> class.
        /// </summary>
        /// <param name="timerWindow">The <see cref="TimerWindow"/> to edit the theme for.</param>
        public ThemeManagerWindow(TimerWindow timerWindow)
        {
            this.InitializeComponent();
            this.BindThemesComboBox();

            this.TimerWindow = timerWindow;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Shows an existing <see cref="Timer"/> in a new <see cref="TimerWindow"/>.
        /// </summary>
        /// <param name="savedTimer">An existing <see cref="Timer"/>.</param>
        private void ShowSavedTimerInNewWindow(Timer savedTimer)
        {
            TimerWindow newTimerWindow = new TimerWindow();

            if (savedTimer.Options.WindowSize != null)
            {
                newTimerWindow.Restore(savedTimer.Options.WindowSize);
            }
            else
            {
                newTimerWindow.RestoreFromWindow(this.timerWindow);
            }

            newTimerWindow.Show(savedTimer);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Invoked when a recent <see cref="TimerStart"/> <see cref="MenuItem"/> is clicked.
        /// </summary>
        /// <param name="sender">The <see cref="MenuItem"/> where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private void RecentInputMenuItemClick(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;
            TimerStart timerStart = (TimerStart)menuItem.Tag;

            TimerWindow window;
            if (this.timerWindow.Timer.State == TimerState.Stopped || this.timerWindow.Timer.State == TimerState.Expired)
            {
                window = this.timerWindow;
            }
            else
            {
                window = new TimerWindow();
                window.Options.Set(this.timerWindow.Options);
                window.RestoreFromWindow(this.timerWindow);
            }

            window.Show(timerStart);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Invoked when the "New timer" <see cref="MenuItem"/> is clicked.
 /// </summary>
 /// <param name="sender">The <see cref="MenuItem"/> where the event handler is attached.</param>
 /// <param name="e">The event data.</param>
 private void NewTimerMenuItemClick(object sender, RoutedEventArgs e)
 {
     TimerWindow window = new TimerWindow();
     window.RestoreFromWindow(this.timerWindow);
     window.Show();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Binds the <see cref="ContextMenu"/> to a <see cref="TimerWindow"/>.
        /// </summary>
        /// <param name="window">A <see cref="TimerWindow"/>.</param>
        public void Bind(TimerWindow window)
        {
            // Validate parameters
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            // Validate state
            if (this.timerWindow != null)
            {
                throw new InvalidOperationException();
            }

            // Initialize members
            this.timerWindow = window;

            this.timerWindow.ContextMenuOpening += this.WindowContextMenuOpening;
            this.timerWindow.ContextMenuClosing += this.WindowContextMenuClosing;
            this.timerWindow.ContextMenu = this;

            this.dispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal, this.Dispatcher);
            this.dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
            this.dispatcherTimer.Tick += this.DispatcherTimerTick;

            this.selectableColorMenuItems = new List<MenuItem>();
            this.selectableSoundMenuItems = new List<MenuItem>();

            // Build the menu
            this.BuildMenu();
        }
        /// <summary>
        /// Sets the <see cref="TimerWindow"/> that will be updated when a theme is selected in this window.
        /// </summary>
        /// <param name="newTimerWindow">The <see cref="TimerWindow"/> to set.</param>
        /// <returns><c>true</c> if the <see cref="TimerWindow"/> was set, or <c>false</c> if the user canceled the
        /// change because there were unsaved changes to the selected theme.</returns>
        public bool SetTimerWindow(TimerWindow newTimerWindow)
        {
            if (!this.PromptToSaveIfRequired())
            {
                return false;
            }

            this.TimerWindow = newTimerWindow;
            return true;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Shows windows for all saved timers.
        /// </summary>
        /// <param name="arguments">Parsed command-line arguments.</param>
        private static void ShowSavedTimerWindows(CommandLineArguments arguments)
        {
            foreach (Timer savedTimer in TimerManager.Instance.ResumableTimers)
            {
                TimerWindow window = new TimerWindow();

                if (savedTimer.Options.WindowSize != null)
                {
                    window.Restore(savedTimer.Options.WindowSize, RestoreOptions.AllowMinimized);
                }
                else
                {
                    window.Restore(arguments.GetWindowSize(), RestoreOptions.AllowMinimized);
                }

                window.Show(savedTimer);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Shows a new timer window. The window will run the <see cref="TimerStart"/> specified in the <see
        /// cref="CommandLineArguments"/>, or it will display in input mode if there is no <see cref="TimerStart"/>.
        /// </summary>
        /// <param name="arguments">Parsed command-line arguments.</param>
        private static void ShowNewTimerWindow(CommandLineArguments arguments)
        {
            TimerWindow window = new TimerWindow(arguments.TimerStart);
            window.Options.Set(arguments.GetTimerOptions());
            window.Restore(arguments.GetWindowSize(), RestoreOptions.AllowMinimized);
            window.Show();

            if (window.WindowState != WindowState.Minimized)
            {
                window.BringToFrontAndActivate();
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Binds the <see cref="InterfaceScaler"/> to a <see cref="TimerWindow"/>.
        /// </summary>
        /// <param name="window">A <see cref="TimerWindow"/>.</param>
        public void Bind(TimerWindow window)
        {
            // Validate parameters
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            // Validate state
            if (this.timerWindow != null)
            {
                throw new InvalidOperationException();
            }

            // Initialize members
            this.timerWindow = window;

            this.innerGrid = this.timerWindow.InnerGrid;
            this.controlsPanel = this.timerWindow.ControlsPanel;
            this.timerTextBox = this.timerWindow.TimerTextBox;
            this.titleTextBox = this.timerWindow.TitleTextBox;
            this.innerNotificationBorder = this.timerWindow.InnerNotificationBorder;
            this.buttons = new[]
            {
                this.timerWindow.StartButton,
                this.timerWindow.PauseButton,
                this.timerWindow.ResumeButton,
                this.timerWindow.StopButton,
                this.timerWindow.ResetButton,
                this.timerWindow.CloseButton,
                this.timerWindow.CancelButton
            };
            this.timeExpiredLabel = this.timerWindow.TimeExpiredLabel;

            // Hook up events
            this.timerWindow.Loaded += (s, e) => this.Scale();
            this.timerWindow.SizeChanged += (s, e) => this.Scale();
            this.timerWindow.PropertyChanged += (s, e) => this.Scale();
            this.timerTextBox.TextChanged += (s, e) => this.Scale();
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Invoked when the "New timer" <see cref="MenuItem"/> is clicked.
 /// </summary>
 /// <param name="sender">The <see cref="MenuItem"/> where the event handler is attached.</param>
 /// <param name="e">The event data.</param>
 private void NewTimerMenuItemClick(object sender, EventArgs e)
 {
     TimerWindow window = new TimerWindow();
     window.RestoreFromSibling();
     window.Show();
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Returns a new instance of the <see cref="TimerWindow"/> class for the parsed command-line arguments.
 /// </summary>
 /// <param name="arguments">Parsed command-line arguments.</param>
 /// <returns>A <see cref="TimerWindow"/>.</returns>
 private static TimerWindow GetTimerWindowFromArguments(CommandLineArguments arguments)
 {
     TimerWindow window = new TimerWindow(arguments.TimerStart);
     window.Options.Set(arguments.GetTimerOptions());
     window.Restore(arguments.GetWindowSize(), RestoreOptions.AllowMinimized);
     return window;
 }