private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { var layout = _settings.GetValue <string>("Layout"); if (layout != null) { try { DockSite.LoadLayout(layout); } catch (Exception ex) { ex.LogError(); } } var strategyFile = _settings.GetValue <string>("StrategyFile"); if (!strategyFile.IsEmpty() && File.Exists(strategyFile)) { LoadStrategy(strategyFile); } //else //{ // new MessageBoxBuilder() // .Error() // .Text("Файл стратегии не найден.") // .Owner(this) // .Button(MessageBoxButton.OK) // .Show(); //} }
/// <summary> /// Load settings. /// </summary> /// <param name="storage">Settings storage.</param> public void Load(SettingsStorage storage) { ErrorsGrid.Load(storage.GetValue <SettingsStorage>("ErrorsGrid")); var layout = storage.GetValue <string>("Layout"); if (layout != null) { DockSite.LoadLayout(layout, true); } }
public override void Load(SettingsStorage storage) { _debuggerSettings = storage.GetValue <SettingsStorage>("DebuggerSettings"); SafeLoadDebuggerSettings(); var layout = storage.GetValue <string>("Layout"); if (layout != null) { DockSite.LoadLayout(layout, true); } }
void IPersistable.Load(SettingsStorage storage) { var diagramEditor = storage.GetValue <SettingsStorage>("DiagramEditor"); if (diagramEditor != null) { DiagramEditor.Load(diagramEditor); } var layout = storage.GetValue <string>("Layout"); if (layout != null) { DockSite.LoadLayout(layout, true); } }
public override void Load(SettingsStorage storage) { //_suspendChangedEvent = true; //Expression = storage.GetValue("Expression", Expression); DateFrom = storage.GetValue("DateFrom", DateFrom); DateTo = storage.GetValue("DateTo", DateTo); var marketDataSettings = storage.GetValue <string>("MarketDataSettings"); if (marketDataSettings != null) { var id = marketDataSettings.To <Guid>(); var settings = ConfigManager.GetService <MarketDataSettingsCache>().Settings.FirstOrDefault(s => s.Id == id); if (settings != null) { MarketDataSettings = settings; } } var chart = storage.GetValue <SettingsStorage>("ChartPanel"); if (chart != null) { ChartPanel.Load(chart); } var securityPicker = storage.GetValue <SettingsStorage>("SecurityPicker"); if (securityPicker != null) { SecurityPicker.Load(securityPicker); } var layout = storage.GetValue <string>("Layout"); if (layout != null) { DockSite.LoadLayout(layout); } //_suspendChangedEvent = false; }
void IPersistable.Load(SettingsStorage storage) { var layout = storage.GetValue <string>("Layout"); if (layout != null) { DockSite.LoadLayout(layout); } var parameters = storage.GetValue <IEnumerable <SettingsStorage> >("Parameters"); if (parameters != null) { _parameters.Clear(); _parameters.AddRange(parameters.Select(p => p.Load <ParameterInfo>())); } if (Strategy != null && Strategy.Strategy != null) { OnStrategyAssigned(Strategy.Strategy); } }
public override void Load(SettingsStorage storage) { var gridSettings = storage.GetValue <SettingsStorage>("SecurityPicker"); if (gridSettings != null) { SecurityPicker.Load(gridSettings); } var layout = storage.GetValue <string>("Layout"); if (layout != null) { DockSite.LoadLayout(layout); } _securityIds.SyncDo(list => { list.Clear(); list.AddRange(storage.GetValue("Securities", ArrayHelper <string> .EmptyArray)); }); }
public static void LoadUISettings(this SettingsStorage storage, DockSite dockSite, PairSet <Tuple <string, Type>, IContentWindow> contents) { var controlsSettings = storage.GetValue <SettingsStorage[]>("Content"); foreach (var ctrlSettings in controlsSettings) { try { var id = ctrlSettings.GetValue <string>("Id"); var ctrlType = ctrlSettings.GetValue <string>("Type").To <Type>(); var isToolWindow = ctrlSettings.GetValue <bool>("IsToolWindow"); var dockingWindowName = ctrlSettings.GetValue <string>("DockingWindowName"); var controlSettings = ctrlSettings.GetValue <SettingsStorage>("Settings"); var tagType = ctrlSettings.GetValue <string>("TagType").To <Type>(); var canClose = true; object tag = null; if (tagType == typeof(StrategyInfo)) { tag = ConfigManager.GetService <IStudioEntityRegistry>().Strategies.ReadById(id.To <long>()); if (tag == null) { continue; } } else if (tagType != null && tagType.IsSubclassOf(typeof(Strategy))) { var sessionStrategy = ConfigManager.GetService <IStudioEntityRegistry>().ReadSessionStrategyById(id.To <Guid>()); if (sessionStrategy != null) { tag = sessionStrategy.Strategy; } if (tag == null) { continue; } } else if (tagType == typeof(CompositionDiagramElement)) { tag = ConfigManager.GetService <CompositionRegistry>().DiagramElements.FirstOrDefault(c => c.TypeId == id.To <Guid>()); if (tag == null) { continue; } } else if (tagType == typeof(ExpressionIndexSecurity) || tagType == typeof(ContinuousSecurity)) { tag = ConfigManager.GetService <IStudioEntityRegistry>().Securities.ReadById(id); if (tag == null) { continue; } } var control = ctrlType.CreateInstance <IStudioControl>(); var info = tag as StrategyInfo; if (info != null) { control.DoIf <IStudioControl, StrategyInfoCodeContent>(c => { canClose = false; c.StrategyInfo = info; }); control.DoIf <IStudioControl, DiagramPanel>(c => { canClose = false; c.StrategyInfo = info; }); control.DoIf <IStudioControl, StrategyInfoContent>(c => c.StrategyInfo = info); ConfigManager .GetService <IStudioCommandService>() .Bind(control.GetKey(), (IStudioCommandScope)control); } var strategy = tag as StrategyContainer; if (strategy != null) { control.DoIf <IStudioControl, StrategyContent>(c => c.SetStrategy(strategy)); control.DoIf <IStudioControl, DiagramDebuggerPanel>(c => c.Strategy = strategy); control.DoIf <IStudioControl, OptimizatorContent>(c => c.SetStrategy(strategy)); } var composition = tag as CompositionDiagramElement; if (composition != null) { ((DiagramPanel)control).Composition = composition; } var security = tag as Security; if (security != null) { ((CompositeSecurityPanel)control).Security = security; } var window = isToolWindow ? (IContentWindow) new ContentToolWindow { Id = id, Tag = tag, Control = control, Name = dockingWindowName, CanClose = canClose } : new ContentDocumentWindow { Id = id, Tag = tag, Control = control, Name = dockingWindowName, CanClose = canClose }; if (isToolWindow) { dockSite.ToolWindows.Add((ToolWindow)window); } else { dockSite.DocumentWindows.Add((DocumentWindow)window); } ((DockingWindow)window).Activate(); if (controlSettings != null) { control.Load(controlSettings); } contents.Add(Tuple.Create(id, ctrlType), window); } catch (Exception e) { e.LogError(); } } var layout = storage.GetValue <string>("Layout"); if (layout != null) { try { dockSite.LoadLayout(layout); } catch (Exception ex) { ex.LogError(); } } var activeWindow = storage.GetValue <string>("ActiveWindow"); if (activeWindow != null) { var id = activeWindow.To <Guid>(); var window = dockSite .ToolWindows .OfType <DockingWindow>() .Concat(dockSite.DocumentWindows) .FirstOrDefault(w => w.UniqueId == id); if (window != null) { window.Activate(); } } }