Exemple #1
0
        public MainWindowViewModel()
        {
            _totalWorkItemsCount = 0;
            Items = new ObservableCollection <TabItemViewModel>();

            QueryProvider.Instance.Changed += (sender, e) =>
            {
                LoadTabControls();

                BackgroundRunner.Run(() => { Repository.Instance.Refresh(); });
            };

            Repository.Instance.AfterLoadWorkItems +=
                (sender, e) => { new AsyncRelayCommand(DataBind, null).Execute(null); };

            LoadTabControls();

            new AsyncRelayCommand(DataBind, null).Execute(null);
        }
Exemple #2
0
        protected override void OnStartup(StartupEventArgs args)
        {
            Dispatcher.UnhandledException += (sender, e) =>
            {
                //new Window1().Show();
                //var errorMessage = string.Format("An exception occurred: {0}",
                //    e.Exception.Message + Environment.NewLine + e.Exception.StackTrace);
                //MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                e.Handled = true;
                var window = new ExceptionMessageBox(e.Exception, "AN UNHANDLED EXCEPTION HAS OCCURED.");
                window.ShowDialog();
            };

            BackgroundRunner.Init();
            BackgroundRunner.Run(Repository.Instance.Refresh);
            BackgroundRunner.Run(Repository.Instance.LoadQueryHierarchy);

            base.OnStartup(args);
        }
Exemple #3
0
        private void TextBox_OnKeyDown(object sender, KeyEventArgs e)
        {
            var textBox = sender as TextBox;

            if (textBox != null)
            {
                if (e.Key == Key.Enter)
                {
                    int id;
                    if (!string.IsNullOrWhiteSpace(textBox.Text) && int.TryParse(textBox.Text, out id))
                    {
                        BackgroundRunner.Run(() => Repository.OpenWorkItem(id));
                    }
                    Visibility = Visibility.Collapsed;
                }

                if (e.Key == Key.Escape)
                {
                    Visibility = Visibility.Collapsed;
                }

                e.Handled = !IsNumberKey(e.Key) && !IsDelOrBackspaceOrTabKey(e.Key);
            }
        }