public override void Save(SettingsStorage storage) { storage.SetValue("GridSettings", TradesGrid.Save()); storage.SetValue("Securities", _securityIds.ToArray()); storage.SetValue("AlertSettings", AlertBtn.Save()); storage.SetValue("VolumeFilter", VolumeFilter.Value); }
/// <summary> /// Here we launch the custom tag editor in a popup /// </summary> private void TradesGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e) { if ((string)e.Column.Header == "Tags") { //make sure the popup isn't too big, otherwise items can be hidden in small resolutions TagPickerPopup.Height = Math.Min(600, TradesGrid.ActualHeight - 100); //Fill it TagPickerPopupListBox.ItemsSource = Context .Tags .OrderBy(x => x.Name) .ToList() .Select( x => new CheckListItem <Tag>(x)) .ToList(); var trade = (Trade)TradesGrid.SelectedItem; if (trade.Tags != null) { foreach (CheckListItem <Tag> item in TagPickerPopupListBox.Items) { item.IsChecked = trade.Tags.Contains(item.Item); } } //and open it at the right position TagPickerPopup.PlacementTarget = TradesGrid.GetCell(e.Row.GetIndex(), e.Column.DisplayIndex); TagPickerPopup.IsOpen = true; } }
/// <summary> /// Here we launch the custom tag editor in a popup /// </summary> private void TradesGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e) { if ((string)e.Column.Header == "Tags") { //Fill it TagPickerPopupListBox.ItemsSource = Context .Tags .OrderBy(x => x.Name) .ToList() .Select( x => new CheckListItem <Tag>(x)) .ToList(); var trade = (Trade)TradesGrid.SelectedItem; if (trade.Tags != null) { foreach (CheckListItem <Tag> item in TagPickerPopupListBox.Items) { item.IsChecked = trade.Tags.Contains(item.Item); } } //and open it at the right position TagPickerPopup.PlacementTarget = TradesGrid.GetCell(e.Row.GetIndex(), e.Column.DisplayIndex); TagPickerPopup.IsOpen = true; } }
public override void Load(SettingsStorage storage) { TradesGrid.Load(storage.GetValue <SettingsStorage>("GridSettings")); _securityIds.SyncDo(list => { list.Clear(); list.AddRange(storage.GetValue("Securities", ArrayHelper.Empty <string>())); }); var alertSettings = storage.GetValue <SettingsStorage>("AlertSettings"); if (alertSettings != null) { AlertBtn.Load(alertSettings); } VolumeFilter.Value = storage.GetValue <decimal?>("VolumeFilter"); }
public MainWindow(DataContainer data, IAppSettings settings, DbContextFactory contextFactory, IDataSourcer dataSourcer) { ///////////////////////////////////////////////////////// InitializeComponent(); ///////////////////////////////////////////////////////// Settings = settings; ContextFactory = contextFactory; DataSourcer = dataSourcer; ViewModel = new MainViewModel(ContextFactory, DataSourcer, DialogCoordinator.Instance, Settings, data); this.DataContext = ViewModel; PopulateStatementMenus(); //Restore column ordering, widths, and sorting LoadDataGridLayouts(); //A hack to force the heavy stuff to load, //providing snappier navigation at the expense of longer startup time #if !DEBUG TradesGrid.Measure(new Size(500, 500)); OrdersGrid.Measure(new Size(500, 500)); CashTransactionsGrid.Measure(new Size(500, 500)); //todo: remove this stuff? #endif //hiding the tab headers Style s = new Style(); s.Setters.Add(new Setter(VisibilityProperty, Visibility.Collapsed)); MainTabCtl.ItemContainerStyle = s; //close the slash screen //App.Splash.LoadComplete(); this.Show(); ShowChangelog(); }
public MainWindow() { //make sure we have a database connection and stuff, otherwise show the dialog to set db settings try { DBUtils.CheckDBConnection(); } catch { App.Splash.LoadComplete(); var dbDetailsWindow = new DBPicker(); dbDetailsWindow.ShowDialog(); } //initialize logging InitializeLogging(); //Log unhandled exceptions AppDomain.CurrentDomain.UnhandledException += AppDomain_CurrentDomain_UnhandledException; //set the connection string DBUtils.SetConnectionString(); Context = new DBContext(); //create db if it doesn't exist Context.Database.Initialize(false); //check for any currencies, seed the db with initial values if nothing is found if (!Context.Currencies.Any()) { Seed.DoSeed(); } //check for empty account fields if (Context.EquitySummaries.Any(x => x.AccountID == null)) { App.Splash.LoadComplete(); var accountMigrationWindow = new AccountMigrationWindow(); accountMigrationWindow.ShowDialog(); } var qdmsSource = new ExternalDataSources.QDMS(); Datasourcer = new DataSourcer(Context, qdmsSource); TradesRepository = new TradesRepository(Context, Datasourcer); IDialogService dialogService = new DialogService(this); ViewModel = new MainViewModel(Context, Datasourcer, dialogService); ///////////////////////////////////////////////////////// InitializeComponent(); ///////////////////////////////////////////////////////// DataContext = ViewModel; //Create the load statement menus using the loaded plugins PopulateStatementMenus(); //Restore column ordering, widths, and sorting LoadDataGridLayouts(); //A hack to force the heavy stuff to load, //providing snappier navigation at the expense of longer startup time #if !DEBUG ViewModel.TradesPageViewModel.Refresh(); TradesGrid.Measure(new Size(500, 500)); ViewModel.OrdersPageViewModel.Refresh(); OrdersGrid.Measure(new Size(500, 500)); ViewModel.CashTransactionsPageViewModel.Refresh(); CashTransactionsGrid.Measure(new Size(500, 500)); #endif //hiding the tab headers Style s = new Style(); s.Setters.Add(new Setter(VisibilityProperty, Visibility.Collapsed)); MainTabCtl.ItemContainerStyle = s; //load the open positions page data ViewModel.RefreshCurrentPage(); //close the slash screen App.Splash.LoadComplete(); ShowChangelog(); }
public override void Load(SettingsStorage settings) { TradesGrid.Load(settings.GetValue <SettingsStorage>("TradesGrid")); }
public override void Save(SettingsStorage settings) { settings.SetValue("TradesGrid", TradesGrid.Save()); }