void IPersistable.Save(SettingsStorage settings) { var ps = new PairSet <Tuple <string, Type>, IContentWindow>(); foreach (var control in _controls) { ps.Add(Tuple.Create(control.Id, control.Control.GetType()), control); } settings.SaveUISettings(DockSite, ps); if (EmulationService != null) { settings.SetValue("EmulationService", EmulationService.Save()); } }
void IPersistable.Load(SettingsStorage settings) { _suspendChangedEvent = true; RemoveControls(); settings.LoadUISettings(DockSite, new PairSet <Tuple <string, Type>, IContentWindow>()); var emulationService = settings.GetValue <SettingsStorage>("EmulationService"); if (emulationService != null && EmulationService != null) { EmulationService.Load(emulationService); } _suspendChangedEvent = false; }
public OptimizatorContent() { InitializeComponent(); ParametersGrid.ItemsSource = _parameters; var isInitialization = false; var cmdSvc = ConfigManager.GetService <IStudioCommandService>(); cmdSvc.Register <StartStrategyCommand>(this, true, cmd => { var error = Strategy.CheckCanStart(false); if (error != null) { new MessageBoxBuilder() .Owner(this) .Caption(LocalizedStrings.Str3577) .Text(error) .Warning() .Show(); return; } try { _parameters.ForEach(p => p.Check()); } catch (Exception excp) { new MessageBoxBuilder() .Owner(this) .Caption(LocalizedStrings.Str3577) .Text(excp.Message) .Warning() .Show(); return; } isInitialization = true; _strategies.Clear(); ResultsPanel.Clear(); Task.Factory.StartNew(() => { EmulationService.Strategies = CreateStrategies().ToEx(GetIterationCount()); EmulationService.StartEmulation(); isInitialization = false; }); }, cmd => EmulationService != null && EmulationService.CanStart && !isInitialization); cmdSvc.Register <StopStrategyCommand>(this, true, cmd => EmulationService.StopEmulation(), cmd => EmulationService != null && EmulationService.CanStop); ResultsPanel.AddContextMenuItem(new Separator()); ResultsPanel.AddContextMenuItem(new MenuItem { Header = LocalizedStrings.Str3578, Command = OpenStrategyCommand, CommandTarget = this }); ResultsPanel.AddContextMenuItem(new MenuItem { Header = LocalizedStrings.Str3579, Command = SetParametersCommand, CommandTarget = this }); }