Ejemplo n.º 1
0
        /// <summary>
        /// Disposes what needs be when the window is closed.
        /// </summary>
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            SrsEntryViewModel vm = ((SrsEntryViewModel)DataContext);

            vm.FinishedEditing -= OnFinishedEditing;
            vm.Dispose();

            NavigationActor.Instance.ActiveWindow = NavigationActor.Instance.MainWindow;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Since a <see cref="GalaSoft.MvvmLight.Command.RelayCommand"/> does not accept keyboard shortcuts,
        /// we have to manually invoke the commands on a keyboard event.
        /// </summary>
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            /*
             * - CTRL+Enter -> SubmitCommand
             * - CTRL+Delete -> DeleteCommand
             * - CTRL+R -> DateToNowCommand
             * - CTRL+N -> DateToNeverCommand
             * - CTRL+E -> ToggleDateEditCommand
             */

            KeyboardDevice keyboardDevice = e.KeyboardDevice;

            if (keyboardDevice.IsKeyDown(Key.LeftCtrl) || keyboardDevice.IsKeyDown(Key.RightCtrl))
            {
                SrsEntryViewModel viewModel = ((SrsEntryViewModel)DataContext);
                switch (e.Key)
                {
                case Key.Enter:
                    viewModel.SubmitCommand.Execute(null);
                    e.Handled = true;
                    break;

                case Key.Delete:
                    viewModel.DeleteCommand.Execute(null);
                    e.Handled = true;
                    break;

                case Key.R:
                    viewModel.DateToNowCommand.Execute(null);
                    e.Handled = true;
                    break;

                case Key.N:
                    viewModel.DateToNeverCommand.Execute(null);
                    e.Handled = true;
                    break;

                case Key.E:
                    viewModel.ToggleDateEditCommand.Execute(null);
                    if (viewModel.IsEditingDate)
                    {
                        ReviewDatePicker.Focus();
                    }
                    e.Handled = true;
                    break;

                case Key.S:
                    viewModel.ToggleSuspendCommand.Execute(null);
                    e.Handled = true;
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes the ViewModel.
        /// </summary>
        private void InitializeViewModel(SrsEntry entity)
        {
            SrsEntryViewModel vm;

            if (entity == null)
            {
                vm = new SrsEntryViewModel();
            }
            else
            {
                vm = new SrsEntryViewModel(entity);
            }

            vm.FinishedEditing += OnFinishedEditing;
            DataContext         = vm;
        }