コード例 #1
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;

            if (button != null)
            {
                var category = button.DataContext as Category;
                if (category != null)
                {
                    VibrationDeviceHelper.Vibrate(TimeSpan.FromMilliseconds(150));

                    var caption = AppResources.ContinueQuestion;
                    var message = string.Format(AppResources.DeleteCategoryMessage, category.Caption);

                    if (MessageBox.Show(message, caption, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                    {
                        if (this.ViewModel.Delete(category))
                        {
                            RaiseEventsManager.RaiseRefreshMainScreen();
                        }
                    }
                }
            }

            this.Focus();
        }
コード例 #2
0
        public MainPage()
        {
            this.InitializeComponent();
            this.BuildLocalizedApplicationBar();

            RaiseEventsManager.SetMainViewModel(this.ViewModel); // important!

            this.Loaded += this.MainPage_Loaded;
        }
コード例 #3
0
        private void Persist(object parameter)
        {
            using (var dataService = new DataService())
            {
                if (this.IsCredit)
                {
                    var credit = new Credit
                    {
                        Id            = this.Id,
                        Caption       = this.Caption,
                        Date          = this.Date,
                        Value         = this.Value.Value,
                        OverrideValue = this.OverrideValue,
                        IsMonthly     = this.IsMonthly,
                        IsDisabled    = this.IsDisabled
                    };

                    dataService.PersistCredit(credit);
                }

                if (this.IsDebit)
                {
                    var debit = new Debit
                    {
                        Id            = this.Id,
                        Caption       = this.Caption,
                        Date          = this.Date,
                        Value         = this.Value.Value,
                        OverrideValue = this.OverrideValue,
                        IsMonthly     = this.IsMonthly,
                        IsDisabled    = this.IsDisabled
                    };

                    if (this.SelectedCategory != null && this.SelectedCategory.Id > 0)
                    {
                        debit.IdCatgory = this.SelectedCategory.Id;
                    }

                    dataService.PersistDebit(debit);
                }
            }

            RaiseEventsManager.RaiseRefreshMainScreen();
        }
コード例 #4
0
        private void Purge_Click(object sender, RoutedEventArgs e)
        {
            string caption = AppResources.ContinueQuestion;
            string message = AppResources.PurgeMessage;

            VibrationDeviceHelper.Vibrate(TimeSpan.FromMilliseconds(500));

            if (MessageBox.Show(message, caption, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                this.ViewModel.Purge();

                RaiseEventsManager.RaiseRefreshMainScreen();

                if (base.NavigationService.CanGoBack)
                {
                    base.NavigationService.GoBack();
                }
            }
        }
コード例 #5
0
        private void Save(object parameter)
        {
            var category = new Category {
                Caption = this.Caption
            };

            using (var dataService = new DataService())
            {
                dataService.InsertCategory(category);
            }

            var updatedCategories = new List <Category>(this.Categories);

            updatedCategories.Insert(0, category);

            this.Categories = new ObservableCollection <Category>(updatedCategories);
            this.Caption    = null;

            RaiseEventsManager.RaiseRefreshMainScreen();
        }
コード例 #6
0
 // Code to execute when the application is activated (brought to foreground)
 // This code will not execute when the application is first launched
 private void Application_Activated(object sender, ActivatedEventArgs e)
 {
     RaiseEventsManager.RaiseRefreshMainScreen(withForceLoad: false);
 }