/// <inheritdoc/> public string Configure(IReadOnlyBook book, string currentSettings) { ////var view = new RecentExpensesConfiguration(); ////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(IReadOnlyBook 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)); }
/// <inheritdoc/> public string Configure(IReadOnlyBook book, string currentSettings) { var view = new FavoriteAccountsConfiguration(); currentSettings = view.GetSettings(book, currentSettings); return(currentSettings); }
/// <inheritdoc/> public void Refresh(IReadOnlyBook book, EventProxy events) { if (this.control == null) { throw new InvalidOperationException(); } this.events = events; this.PopulateControl(book); }
private void PopulateControl(IReadOnlyBook 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); } }
/// <inheritdoc/> public Control Create(IReadOnlyBook book, EventProxy events) { if (this.control != null) { throw new InvalidOperationException(); } this.events = events; this.control = null; //new PiePlot(); this.PopulateControl(book); return this.control; }
/// <inheritdoc/> public Control Create(IReadOnlyBook book, EventProxy events) { if (this.control != null) { throw new InvalidOperationException(); } this.events = events; this.control = new FlowLayoutPanel(); this.PopulateControl(book); return(this.control); }
private void PopulateControl(IReadOnlyBook 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 void SetConfiguration(IReadOnlyBook book, string settings) { this.settings = LoadSettings(settings); }