public PlansViewModel() { ServiceFactory.Events.GetEvent<NavigateToPlanElementEvent>().Subscribe(OnNavigate); ServiceFactory.Events.GetEvent<ShowElementEvent>().Subscribe(OnShowElement); ServiceFactory.Events.GetEvent<FindElementEvent>().Subscribe(OnFindElementEvent); ServiceFactory.Events.GetEvent<RegisterPlanPresenterEvent<Plan>>().Subscribe(OnRegisterPlanPresenter); ServiceFactory.Events.GetEvent<SelectPlanEvent>().Subscribe(OnSelectPlan); _initialized = false; PlanPresenters = new List<IPlanPresenter<Plan>>(); PlanTreeViewModel = new PlanTreeViewModel(this); PlanDesignerViewModel = new PlanDesignerViewModel(this); PlanTreeViewModel.SelectedPlanChanged += SelectedPlanChanged; var isNotFirstTime = RegistrySettingsHelper.GetBool("Monitor.Plans.IsNotFirstTime"); var planNavigationWidth = RegistrySettingsHelper.GetDouble("Monitor.Plans.SplitterDistance"); if (!isNotFirstTime && planNavigationWidth == 0) { planNavigationWidth = 100; } PlanNavigationWidth = new GridLength(planNavigationWidth, GridUnitType.Pixel); ApplicationService.ShuttingDown += () => { RegistrySettingsHelper.SetDouble("Monitor.Plans.SplitterDistance", PlanNavigationWidth.Value); RegistrySettingsHelper.SetBool("Monitor.Plans.IsNotFirstTime", true); }; }
public PlansViewModel(List<IPlanPresenter<Plan, XStateClass>> planPresenters, LayoutPartPlansProperties properties) { _properties = properties ?? new LayoutPartPlansProperties { Type = LayoutPartPlansType.All }; PlanPresenters = planPresenters; ServiceFactory.Events.GetEvent<NavigateToPlanElementEvent>().Subscribe(OnNavigate); ServiceFactory.Events.GetEvent<ShowElementEvent>().Subscribe(OnShowElement); ServiceFactory.Events.GetEvent<FindElementEvent>().Subscribe(OnFindElementEvent); ServiceFactory.Events.GetEvent<SelectPlanEvent>().Subscribe(OnSelectPlan); ServiceFactory.Events.GetEvent<ChangePlanPropertiesEvent>().Unsubscribe(OnChangePlanProperties); ServiceFactory.Events.GetEvent<ChangePlanPropertiesEvent>().Subscribe(OnChangePlanProperties); ServiceFactory.Events.GetEvent<ControlPlanEvent>().Unsubscribe(OnControlPlan); ServiceFactory.Events.GetEvent<ControlPlanEvent>().Subscribe(OnControlPlan); _initialized = false; if (_properties.Type != LayoutPartPlansType.Single) { PlanTreeViewModel = new PlanTreeViewModel(this, _properties.Type == LayoutPartPlansType.Selected ? _properties.Plans : null, _properties.Type == LayoutPartPlansType.All); PlanTreeViewModel.SelectedPlanChanged += SelectedPlanChanged; var planNavigationWidth = RegistrySettingsHelper.GetDouble("Monitor.Plans.SplitterDistance"); if (planNavigationWidth == 0) planNavigationWidth = 100; PlanNavigationWidth = new GridLength(planNavigationWidth, GridUnitType.Pixel); ApplicationService.ShuttingDown += () => { RegistrySettingsHelper.SetDouble("Monitor.Plans.SplitterDistance", PlanNavigationWidth.Value); }; } else PlanNavigationWidth = GridLength.Auto; PlanDesignerViewModel = new PlanDesignerViewModel(this, properties); }
public DesignerCanvas(PlanDesignerViewModel planDesignerViewModel) : base(planDesignerViewModel) { var editItem = DesignerCanvasHelper.BuildMenuItem( "Редактировать", "BEdit", planDesignerViewModel.PlansViewModel.EditCommand ); ContextMenu.Items.Add(editItem); }
public DesignerCanvas(PlanDesignerViewModel planDesignerViewModel) : base(planDesignerViewModel) { var editItem = DesignerCanvasHelper.BuildMenuItem( "Редактировать", "pack://application:,,,/Controls;component/Images/BEdit.png", planDesignerViewModel.PlansViewModel.EditCommand ); ContextMenu.Items.Add(editItem); }
public PlansViewModel() { ServiceFactory.Events.GetEvent<ShowElementEvent>().Subscribe(OnShowElement); ServiceFactory.Events.GetEvent<FindElementEvent>().Subscribe(OnShowElementDevice); AddCommand = new RelayCommand(OnAdd); AddSubPlanCommand = new RelayCommand(OnAddSubPlan, CanAddEditRemove); RemoveCommand = new RelayCommand(OnRemove, CanAddEditRemove); EditCommand = new RelayCommand(OnEdit, CanAddEditRemove); AddSubPlanCommand = new RelayCommand(OnAddSubPlan, CanAddEditRemove); DesignerCanvas = new DesignerCanvas(); DesignerCanvas.Toolbox = new ToolboxViewModel(this); PlanDesignerViewModel = new PlanDesignerViewModel(); PlanDesignerViewModel.DesignerCanvas = DesignerCanvas; InitializeCopyPaste(); InitializeHistory(); ElementsViewModel = new ElementsViewModel(DesignerCanvas); PlansTreeViewModel = new PlansTreeViewModel(this); CreatePages(); _planExtensions = new List<Infrustructure.Plans.IPlanExtension<Plan>>(); Menu = new PlansMenuViewModel(this); }