public string Configure(ReadOnlyBook book, string currentSettings)
        {
            var view = new FavoriteAccountsConfiguration();
            currentSettings = view.GetSettings(book, currentSettings);

            return currentSettings;
        }
        /// <summary>
        /// Shows the <see cref="FavoriteAccountsConfiguration"/> screen and waits for the user to make a selection.
        /// </summary>
        /// <param name="book">The book from which to read the list of accounts.</param>
        /// <param name="settings">The current settings of the "Favorite Accounts" widget.</param>
        /// <returns>The new settings for the "Favorite Accounts" widget.</returns>
        public string GetSettings(ReadOnlyBook book, string settings)
        {
            var config = FavoriteAccountsWidget.LoadSettings(settings);

            var newAccounts = from a in book.Accounts
                              let path = a.GetPath(config.PathSeperator)
                              let fave = (from ap in config.AccountPaths
                                          where string.Equals(ap, path, StringComparison.OrdinalIgnoreCase)
                                          select ap).Any()
                              select new AccountView
                              {
                                  Name = path,
                                  Favorite = fave,
                              };

            this.accountViewBindingSource.Clear();
            foreach (var a in newAccounts)
            {
                this.accountViewBindingSource.Add(a);
            }

            var result = this.ShowDialog();

            if (result == DialogResult.OK)
            {
                config.AccountPaths = (from AccountView a in this.accountViewBindingSource
                                       where a.Favorite
                                       select a.Name).ToList();
            }

            return JsonConvert.SerializeObject(config);
        }
Example #3
0
 public void SetAccount(Account account, ReadOnlyBook book)
 {
     this.book    = book;
     this.account = account;
     this.splitsView.SetAccount(account, book);
     this.transactionEditor.SetBook(book);
 }
Example #4
0
 public void SetAccount(Account account, ReadOnlyBook book)
 {
     this.book = book;
     this.account = account;
     this.splitsView.SetAccount(account, book);
     this.transactionEditor.SetBook(book);
 }
        public string Configure(ReadOnlyBook book, string currentSettings)
        {
            ////var view = new RecentExpensesConfiguration();
            ////currentSettings = view.GetSettings(book, currentSettings);

            return currentSettings;
        }
Example #6
0
 public void SetBook(ReadOnlyBook book)
 {
     this.SetSplit(null);
     this.book = book;
     this.accountComboBox.Items.Clear();
     if (this.book != null)
     {
         this.accountComboBox.Items.AddRange(this.book.Accounts.ToArray());
     }
 }
Example #7
0
 public void SetBook(ReadOnlyBook book)
 {
     this.SetSplit(null);
     this.book = book;
     this.accountComboBox.Items.Clear();
     if (this.book != null)
     {
         this.accountComboBox.Items.AddRange(this.book.Accounts.ToArray());
     }
 }
        public void Refresh(ReadOnlyBook book, EventProxy events)
        {
            if (this.control == null)
            {
                throw new InvalidOperationException();
            }

            this.events = events;

            this.PopulateControl(book);
        }
        public Control Create(ReadOnlyBook book, EventProxy events)
        {
            if (this.control != null)
            {
                throw new InvalidOperationException();
            }

            this.events = events;
            this.control = null; //new PiePlot();

            this.PopulateControl(book);

            return this.control;
        }
Example #10
0
 private void PopulateControl(ReadOnlyBook book)
 {
     ////var accounts = from a in book.Accounts
     ////               let path = Account.GetAccountPath(a, this.settings.PathSeperator)
     ////               where (from ap in this.settings.AccountPaths
     ////                      where string.Equals(ap, path, StringComparison.OrdinalIgnoreCase)
     ////                      select ap).Any()
     ////               orderby path
     ////               select a;
     ////
     ////foreach (var account in accounts)
     ////{
     ////    var balance = book.GetAccountSplits(account).Sum(s => s.Amount);
     ////}
 }
 public IWidget CreateInstance(ReadOnlyBook book, string settings)
 {
     return new FavoriteAccountsWidget(settings);
 }
        private void PopulateControl(ReadOnlyBook book)
        {
            var accounts = from a in book.Accounts
                           let path = a.GetPath(this.settings.PathSeperator)
                           where (from ap in this.settings.AccountPaths
                                  where string.Equals(ap, path, StringComparison.OrdinalIgnoreCase)
                                  select ap).Any()
                           orderby path
                           select a;

            var empty = true;

            foreach (var account in accounts)
            {
                empty = false;

                var balance = book.GetAccountSplits(account).Sum(s => s.Amount);

                ////var accountImage = new Image
                ////{
                ////    Height = 16,
                ////    Width = 16,
                ////    Source = new BitmapImage(new Uri("pack://application:,,,/SharpBooks;component/resources/Coinstack.png")),
                ////    Margin = new Thickness(5.0d, 0.0d, 2.0d, 0.0d),
                ////};

                ////var nameLabel = new Label
                ////{
                ////    Content = account.Name,
                ////    Margin = new Thickness(2.0d, 0.0d, 0.0d, 0.0d),
                ////};

                ////var amountLabel = new Label
                ////{
                ////    Content = account.Security.FormatValue(balance),
                ////    Margin = new Thickness(2.0d, 0.0d, 2.0d, 0.0d),
                ////    HorizontalContentAlignment = HorizontalAlignment.Right,
                ////    Foreground = balance >= 0 ? Brushes.Black : Brushes.Red,
                ////};
            }

            if (empty)
            {
                var emptyLabel = new Label
                {
                    Text = "You have not selected any favorite accounts.",
                    TextAlign = System.Drawing.ContentAlignment.MiddleCenter,
                };

                this.control.Controls.Add(emptyLabel);
            }
        }
 public IWidget CreateInstance(ReadOnlyBook book, string settings)
 {
     return new RecentExpensesWidget(settings);
 }