コード例 #1
0
        public static void Go(PhoneApplicationPage fromPage, Category category)
        {
            SelectionHandler = new PageActionHandler<Category>();
            SelectionHandler.AfterSelected = delegate(Category item)
            {
                if ((item != null) && (item.Id != category.ParentCategoryId))
                {
                    if (category.ParentCategory != null)
                    {
                        category.ParentCategory.Childrens.Remove(category);
                    }

                    category.ParentCategory = item;
                    if (item.Childrens.Count(p => p.Name == category.Name) == 0)
                    {
                        // reset order.
                        category.Order = item.Childrens
                            .Select(p => (int)p.Order).ToList().Max(p => p) + 1;

                        item.Childrens.Add(category);
                    }

                    ((System.Collections.Generic.IEnumerable<AccountItem>)category.AccountItems).ForEach<AccountItem>(p =>
                    {
                        p.RaisePropertyChangd("NameInfo");
                    });
                    ViewModelLocator.CategoryViewModel.Update(category);
                }
            };
            fromPage.NavigateTo("/pages/CategoryManager/SelectParentCategoryPage.xaml?id={0}&currentName={1}&type={2}&childName={3}", new object[] { category.ParentCategoryId, category.ParentCategory == null ? "N/A" : category.ParentCategory.Name, category.CategoryType, category.Name });
        }
コード例 #2
0
        public CategoryInfoViewer()
        {
            string str;
            this.currentMonthName = string.Empty;
            this.lastMonthName = string.Empty;
            this.actionName = string.Empty;
            this.symbol = string.Empty;
            this.InitializeComponent();
            TiltEffect.SetIsTiltEnabled(this, true);
            Category category = new Category
            {
                Name = AppResources.Loading
            };
            base.Name = str = AppResources.Loading;
            category.ParentCategory = new Category(str);
            category.Order = 0;
            category.DefaultAmount = 0.0M;
            this.current = category;
            base.DataContext = this;

            int index = System.DateTime.Now.Month - 1;

            if (DateTime.Now.Month == 1)
            {
                index = 12;
            }

            this.currentMonthName = LocalizedStrings.CultureName.DateTimeFormat.GetAbbreviatedMonthName(System.DateTime.Now.Month);

            this.lastMonthName = LocalizedStrings.CultureName.DateTimeFormat.GetAbbreviatedMonthName(index);

            this.Loaded += CategoryInfoViewer_Loaded;
        }
コード例 #3
0
        private void AddCategory(Category parentCategory = null)
        {
            Category category = new Category();
            if (parentCategory != null)
            {
                category = parentCategory;
            }

            CategoryInfoEditor.Go(this, category, this.CategoryType, PageActionType.Add);
        }
コード例 #4
0
        private void AddCategory()
        {
            this.Current = new Category();
            this.Current.Id = System.Guid.NewGuid();
            this.Current.Name = this.CategoryName.Text;
            this.Current.CategoryType = this.CategoryClassType;
            this.Current.ParentCategory = this.ParentCategory ?? this.ParentCategory;
            this.Current.DefaultAmount = this.DefaultAmount.Text.ToDecimal();

            if (!this.Current.IsParent)
            {
                this.ParentCategory.Childrens.Add(this.Current);
            }

            this.CategoryVM.AddCategory(this.Current);
        }
コード例 #5
0
 public static void Go(PhoneApplicationPage fromPage, Category category)
 {
     SelectionHandler = new PageActionHandler<Category>();
     SelectionHandler.AfterSelected = delegate(Category item)
     {
         if ((item != null) && (item.Id != category.ParentCategoryId))
         {
             category.ParentCategory.Childrens.Remove(category);
             category.ParentCategory = item;
             if (!item.Childrens.Contains(category))
             {
                 item.Childrens.Add(category);
             }
             ((System.Collections.Generic.IEnumerable<AccountItem>)category.AccountItems).ForEach<AccountItem>(delegate(AccountItem p)
             {
                 p.RaisePropertyChangd("NameInfo");
             });
             ViewModelLocator.CategoryViewModel.Update(category);
         }
     };
     fromPage.NavigateTo("/pages/CategoryManager/SelectParentCategoryPage.xaml?id={0}&currentName={1}&type={2}&childName={3}", new object[] { category.ParentCategoryId, category.ParentCategory.Name, category.CategoryType, category.Name });
 }
コード例 #6
0
 public CategoryInfoViewer()
 {
     string str;
     this.currentMonthName = string.Empty;
     this.lastMonthName = string.Empty;
     this.actionName = string.Empty;
     this.symbol = string.Empty;
     this.InitializeComponent();
     TiltEffect.SetIsTiltEnabled(this, true);
     Category category = new Category
     {
         Name = AppResources.Loading
     };
     base.Name = str = AppResources.Loading;
     category.ParentCategory = new Category(str);
     category.Order = 0;
     category.DefaultAmount = 0.0M;
     this.current = category;
     base.DataContext = this;
     int index = System.DateTime.Now.Month - 1;
     this.currentMonthName = LocalizedStrings.CultureName.DateTimeFormat.MonthGenitiveNames[index].ToLowerInvariant();
     this.lastMonthName = LocalizedStrings.CultureName.DateTimeFormat.MonthGenitiveNames[index - 1].ToLowerInvariant();
 }
コード例 #7
0
 private PageActionHandler<Category> InitializeCategorySelectorDialogBox()
 {
     System.Action<Category> action = null;
     System.Func<Category> func = null;
     if (this.categorySelectorHandler == null)
     {
         this.categorySelectorHandler = new PageActionHandler<Category>();
         if (action == null)
         {
             action = delegate(Category item)
             {
                 if (item != null)
                 {
                     this.CategoryNameButton.DataContext = item.CategoryInfo;
                     this.tempCategory = item;
                     if (this.actionType == PageActionType.Add)
                     {
                         this.TotalMoneyBox.Text = item.DefaultAmountString;
                     }
                 }
             };
         }
         this.categorySelectorHandler.AfterSelected = action;
         if (func == null)
         {
             func = () => this.tempCategory;
         }
         this.categorySelectorHandler.GetSelected = func;
     }
     return this.categorySelectorHandler;
 }
コード例 #8
0
 private void favouriteCategorySelectorDialogBox_Closed(object sender, System.EventArgs e)
 {
     if (this.favouriteCategorySelectorDialogBox.SelectedItem != null)
     {
         this.tempCategory = this.favouriteCategorySelectorDialogBox.SelectedItem;
         this.CategoryNameButton.DataContext = this.favouriteCategorySelectorDialogBox.SelectedItem;
         this.TotalMoneyBox.Text = this.tempCategory.DefaultAmountString;
     }
 }
コード例 #9
0
 private void CategoryType_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     this.tempCategory = null;
     this.CategoryNameButton.DataContext = null;
     this.EnsureIsClaim();
 }
コード例 #10
0
        private void BindData(AccountItem item)
        {
            this.CategoryType.SelectedIndex = (item.Type == ItemType.Expense) ? 0 : 1;
            this.CategoryNameButton.DataContext = item.NameInfo;
            this.tempCategory = item.Category;
            if (item.Type == ItemType.Expense)
            {
                this.IsClaim.IsChecked = new bool?(item.IsClaim.GetValueOrDefault());
            }
            this.MoneyCurrency.Text = item.Account.CurrencyType.GetCurrentString();
            this.TotalMoneyBox.Text = item.Money.ToMoneyF2();
            object obj2 = this.AccountName.Items.FirstOrDefault<object>(p => ((Account)p).Id == item.Account.Id);
            this.AccountName.SelectedItem = obj2;
            this.CreateDate.Value = new System.DateTime?(item.CreateTime);

            this.CreateTime.Value = item.CreateTime;

            this.DescriptionTextBox.Text = item.Description;
        }
コード例 #11
0
        private void postSelectedItem(Category selectedItem)
        {
            if (this.SelectionMode)
            {
                if (SelectionModeHandler != null)
                {
                    SelectionModeHandler.OnSelected(selectedItem);
                }

                this.SafeGoBack();
            }
            else
            {
                CategoryInfoViewer.Go(selectedItem.Id, this);
            }
        }
コード例 #12
0
 public bool LoadEditingObject(System.Guid categoryId)
 {
     this.CategoryManagementPageTitle.Text = LocalizedStrings.GetCombinedText(AppResources.Edit, AppResources.CategoryInfo, false).ToUpperInvariant();
     this.Current = this.CategoryVM.GetDataFromDatabase(p => p.Id == categoryId).FirstOrDefault<Category>();
     if (this.Current == null)
     {
         this.AlertNotification(AppResources.TheRecordMissing);
         return false;
     }
     else
     {
         this.CategoryName.Text = this.Current.Name;
         this.DefaultAmount.Text = this.Current.DefaultAmountString;
         this.ParentCategory = this.Current.ParentCategory;
     }
     this.CategoryType.SelectedIndex = (int)this.CategoryClassType;
     this.CategoryType.IsEnabled = false;
     this.EnsureParentCategory();
     return true;
 }
コード例 #13
0
 public static void Go(PhoneApplicationPage fromPage, Category category, ItemType categoryType, PageActionType pageAction = PageActionType.Add)
 {
     System.Guid guid = (category == null) ? System.Guid.Empty : category.Id;
     fromPage.NavigateTo("/Pages/CategoryManager/CategoryInfoEditor.xaml?id={0}&pageAction={1}&CategoryClassType={2}", new object[] { guid, pageAction, categoryType });
 }
        private void togglePivot(Category category)
        {
            this.SelectorPagesPivot.SelectedIndex = 1;

            _firstItem = category;
            SecondCategoryPivot.Header = _firstItem.Name;
            if (GetSecondCategoryItems != null)
            {
                SecondCategoryItems.ItemsSource = (GetSecondCategoryItems(category)).OfType<Category>().ToList();
            }
        }
コード例 #15
0
        private void favouriteCategorySelectorDialogBox_Closed(object sender, System.EventArgs e)
        {
            if (this.favouriteCategorySelectorDialogBox.SelectedItem != null)
            {
                this.tempCategory = this.favouriteCategorySelectorDialogBox.SelectedItem;
                this.CategoryNameButton.DataContext = this.favouriteCategorySelectorDialogBox.SelectedItem;

                if (this.Current != null && this.Current.IsInstallmentsItem.GetValueOrDefault())
                {
                }
                else
                {
                    this.TotalMoneyBox.Text = this.tempCategory.DefaultAmountString;
                }
            }
        }
コード例 #16
0
        private void BindData(AccountItem item)
        {
            this.CategoryType.SelectedIndex = (item.Type == ItemType.Expense) ? 0 : 1;
            this.CategoryNameButton.DataContext = item.NameInfo;
            this.tempCategory = item.Category;
            this.oldAccount = item.Account;

            if (item.Type == ItemType.Expense)
            {
                this.IsClaim.IsChecked = new bool?(item.IsClaim.GetValueOrDefault());
            }

            this.MoneyCurrency.Text = item.Account.CurrencyType.GetCurrentString();
            this.TotalMoneyBox.Text = item.Money.ToMoneyF2();

            if (item.Account != null)
            {
                this.AccountName.SelectedItem = item.Account;
                this.PaymentByInstalmentsSettingPanel.Visibility = item.Account.IsCreditCard ? Visibility.Visible : System.Windows.Visibility.Collapsed;
            }

            this.CreateDate.Value = new System.DateTime?(item.CreateTime);

            this.CreateTime.Value = item.CreateTime;

            this.DescriptionTextBox.Text = item.Description;
        }
コード例 #17
0
 private void LoadAddingObject(System.Guid categoryId)
 {
     System.Func<Category, Boolean> resultSelector = null;
     this.CategoryManagementPageTitle.Text = LocalizedStrings.GetCombinedText(AppResources.Add, AppResources.Category, false).ToUpperInvariant();
     if (categoryId != System.Guid.Empty)
     {
         if (resultSelector == null)
         {
             resultSelector = p => p.Id == categoryId;
         }
         this.ParentCategory = this.CategoryVM.GetDataFromDatabase(resultSelector).FirstOrDefault<Category>();
     }
     if (this.ParentCategory != null)
     {
         this.CategoryManagementPageTitle.Text = LocalizedStrings.GetCombinedText(AppResources.Add, AppResources.SencondaryCategoryName, false).ToUpperInvariant();
     }
     this.EnsureParentCategory();
 }
コード例 #18
0
 private void loadStatisticsInfo(Category category)
 {
     if (!this.hasLoadStatisticsInfo)
     {
         this.BusyForWork(AppResources.NowLoadingFormatter.FormatWith(new object[] { AppResources.Statistics }));
         System.Threading.ThreadPool.QueueUserWorkItem(delegate(object o)
         {
             if (category == null)
             {
                 Dispatcher.BeginInvoke(() =>
                 {
                     this.AlertNotification(AppResources.TheRecordMissing, null);
                     this.SafeGoBack();
                 });
             }
             this.LoadStasticsInfo(category);
         });
     }
 }
コード例 #19
0
 public void LoadEditingObject(System.Guid categoryId)
 {
     this.CategoryManagementPageTitle.Text = LocalizedStrings.GetCombinedText(AppResources.Edit, AppResources.CategoryInfo, false).ToUpperInvariant();
     this.Current = this.CategoryVM.GetDataFromDatabase(p => p.Id == categoryId).FirstOrDefault<Category>();
     if (this.Current != null)
     {
         this.CategoryName.Text = this.Current.Name;
         this.DefaultAmount.Text = this.Current.DefaultAmountString;
         this.OrderValue.Text = this.Current.Order.GetValueOrDefault().ToString();
         this.ParentCategory = this.Current.ParentCategory;
     }
     this.CategoryType.SelectedIndex = (int)this.CategoryClassType;
     this.CategoryType.IsEnabled = false;
     this.EnsureParentCategory();
 }
コード例 #20
0
 public void AddOrRemoveFavouriteItem(PageActionType addOrRemove, Category category)
 {
     if (addOrRemove == PageActionType.Delete)
         this.Items.Remove(category);
     if (addOrRemove == PageActionType.Add)
         this.Items.Add(category);
 }
コード例 #21
0
        private void LoadStasticsInfo(Category category)
        {
            int count = 0;
            DetailsCondition dc = new DetailsCondition
            {
                SearchingScope = SearchingScope.CurrentMonth
            };


            decimal val = ViewModelLocator.CategoryViewModel.CountStatistic(category, dc, delegate(int p)
            {
                count = p;
            });


            AccountItem ai = new AccountItem
            {
                SecondInfo = this.currentMonthName,
                ThirdInfo = AppResources.StatisticsInfoFormatterForCategory.FormatWith(new object[] { count, string.Empty, "{0}{1}".FormatWith(new object[] { this.symbol, val.ToMoneyF2() }) })
            };
            count = 0;

            DetailsCondition condition2 = new DetailsCondition
            {
                SearchingScope = SearchingScope.LastMonth
            };

            val = ViewModelLocator.CategoryViewModel.CountStatistic(category, condition2, delegate(int p)
            {
                count = p;
            });
            AccountItem lastMonthai = new AccountItem
            {
                SecondInfo = this.lastMonthName,
                ThirdInfo = AppResources.StatisticsInfoFormatterForCategory.FormatWith(new object[] { count, string.Empty, "{0}{1}".FormatWith(new object[] { this.symbol, val.ToMoneyF2() }) })
            };
            base.Dispatcher.BeginInvoke(delegate
            {
                this.CurrentMonthStaticsInfoPanel.DataContext = ai;
                this.LastMonthStaticsInfoPanel.DataContext = lastMonthai;
                this.hasLoadStatisticsInfo = true;
                this.WorkDone();
            });

            BudgetItem budgetItem = new BudgetItem
            {
                AssociatedCategory = category,
                BudgetType = category.CategoryType
            };
            DetailsCondition detailsCondition = new DetailsCondition
            {
                SearchingScope = SearchingScope.CurrentMonth
            };
            decimal monthlyBudgetAmount = ViewModelLocator.BudgetProjectViewModel.GetBudgetAmountForCategory(budgetItem, detailsCondition);
            base.Dispatcher.BeginInvoke(delegate
            {
                this.BudgetBlock.Text = "{0}{1}".FormatWith(new object[] { this.symbol, monthlyBudgetAmount.ToMoneyF2() });
            });
        }
 private void TurnToSecond(Category SelectedItem)
 {
     togglePivot(SelectedItem.ParentCategory);
 }
        private void togglePivot(Category category)
        {
            SecondCategoryPivot.Visibility = System.Windows.Visibility.Visible;
            this.SelectorPagesPivot.SelectedIndex = 1;
            FirstCategoryPivot.Visibility = System.Windows.Visibility.Collapsed;

            _firstItem = category;
            SecondCategoryPivot.Header = _firstItem.Name;
            if (GetSecondCategoryItems != null)
                SecondCategoryItems.ItemsSource = (GetSecondCategoryItems(category)).OfType<Category>().ToList();
        }
コード例 #24
0
        private void AddCategory(Category parentCategory = null)
        {
            var category = new Category();
            if (parentCategory != null)
            {
                _parentCategoryCache = parentCategory;

                category = _parentCategoryCache;
                if (category.Childrens != null)
                {
                    category.Childrens.CollectionChanged += Childrens_CollectionChanged;
                }
            }

            CategoryInfoEditor.Go(this, category, this.CategoryType, PageActionType.Add);
        }