public IList <Control> DeleteSelected() { IList <Control> result = new List <Control>(); foreach (Control control in ControlList) { if (control.IsSelected) { result.Add(control); } else { if (control is LineControl) { LineControl line = control as LineControl; //if (line.Source.IsSelected || line.Target.IsSelected) // result.Add(control); } } } foreach (Control control in result) { ControlList.Remove(control); } return(result); }
public void Remove(BaseWidget control) { m_widgets.Remove(control); }
public StrategyContent() { InitializeComponent(); _controls = new ControlList(); _controls.Loaded += () => { //чтобы команда привязки стратегии отработала корректно, //ее необходимо вызвать когда проинициализированы все Scope //для контролов, что будет только после их загрузки. if (Strategy != null) { RaiseBindStrategy(); //RaiseSelectStrategy(); } ChildsLoaded.SafeInvoke(); if (!_needRaiseChangedOnLoaded) { return; } //первая загрузка шаблона происходит до открытия вкладки //поэтому после того как она будет открыта необходимо сохранить настройки _needRaiseChangedOnLoaded = false; RaiseChangedCommand(); }; _controls.SizeChanged += RaiseChangedCommand; DockSite.WindowClosing += (sender, args) => { //окна могут открываться и закрываться в момент загрузки разметки if (!_suspendChangedEvent) { ((IStudioControl)args.Window.Content).Dispose(); } var contentWindow = args.Window as IContentWindow; if (contentWindow != null) { _controls.Remove(contentWindow); } RaiseChangedCommand(); }; DockSite.WindowOpened += (sender, args) => { var contentWindow = args.Window as IContentWindow; if (contentWindow != null) { _controls.Add(contentWindow); } RaiseChangedCommand(); }; DockSite.WindowStateChanged += (sender, args) => RaiseChangedCommand(); DockSite.WindowDragged += (sender, args) => RaiseChangedCommand(); var cmdSvc = ConfigManager.GetService <IStudioCommandService>(); cmdSvc.Register <ControlChangedCommand>(this, false, cmd => RaiseChangedCommand()); cmdSvc.Register <OpenWindowCommand>(this, true, cmd => OpenControl(cmd.Id, cmd.CtrlType, null, ctrl => { })); cmdSvc.Register <OpenMarketDepthCommand>(this, true, cmd => OpenControl(cmd.Security.Id, typeof(ScalpingMarketDepthControl), cmd.Security, ctrl => { ((ScalpingMarketDepthControl)ctrl).Settings.Security = cmd.Security; })); cmdSvc.Register <AddLogListenerCommand>(this, false, cmd => _logManager.Listeners.Add(cmd.Listener)); cmdSvc.Register <RemoveLogListenerCommand>(this, false, cmd => _logManager.Listeners.Remove(cmd.Listener)); cmdSvc.Register <RequestBindSource>(this, true, cmd => RaiseBindStrategy(cmd.Control)); cmdSvc.Register <LoadLayoutCommand>(this, true, cmd => LoadTemplate(cmd.Layout, true)); cmdSvc.Register <SaveLayoutCommand>(this, true, cmd => cmd.Layout = this.Save().SaveSettingsStorage()); cmdSvc.Register <StartStrategyCommand>(this, true, cmd => { if (EmulationService != null) { var error = Strategy.CheckCanStart(false); if (error != null) { new MessageBoxBuilder() .Owner(this) .Caption(LocalizedStrings.Str3598) .Text(error) .Warning() .Show(); return; } EmulationService.StartEmulation(); } else { new StartStrategyCommand(cmd.Strategy).Process(this); } }); cmdSvc.Register <StopStrategyCommand>(this, true, cmd => { if (EmulationService != null) { EmulationService.StopEmulation(); } else { new StopStrategyCommand(cmd.Strategy).Process(this); } }); }
public void Remove(BaseButton control) { ControlList.Remove(control); }