Exemple #1
0
		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);
			};
		}
Exemple #2
0
		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);
		}
Exemple #3
0
		public DesignerCanvas(PlanDesignerViewModel planDesignerViewModel)
			: base(planDesignerViewModel)
		{
			var editItem = DesignerCanvasHelper.BuildMenuItem(
				"Редактировать",
				"BEdit",
				planDesignerViewModel.PlansViewModel.EditCommand
			);
			ContextMenu.Items.Add(editItem);
		}
Exemple #4
0
		public DesignerCanvas(PlanDesignerViewModel planDesignerViewModel)
			: base(planDesignerViewModel)
		{
			var editItem = DesignerCanvasHelper.BuildMenuItem(
				"Редактировать", 
				"pack://application:,,,/Controls;component/Images/BEdit.png", 
				planDesignerViewModel.PlansViewModel.EditCommand
			);
			ContextMenu.Items.Add(editItem);
		}
Exemple #5
0
        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);
        }