예제 #1
0
		public PlansViewModel()
		{
			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);
			AddFolderCommand = new RelayCommand(OnAddFolder);
			AddSubFolderCommand = new RelayCommand(OnAddSubFolder, CanAddEditRemove);

			LayerGroupService.Instance.RegisterGroup(Helper.SubPlanAlias, "Ссылки на планы");
			ServiceFactory.Events.GetEvent<DesignerItemFactoryEvent>().Subscribe((e) =>
			{
				if (e.Element is ElementSubPlan)
				{
					e.DesignerItem = new DesignerItemSubPlan(e.Element);
					e.DesignerItem.IconSource = "/Controls;component/Images/CMap.png";
				}
			});

			PlanDesignerViewModel = new PlanDesignerViewModel(this);
			PlanDesignerViewModel.IsCollapsedChanged += new EventHandler(PlanDesignerViewModel_IsCollapsedChanged);
			OnPropertyChanged(() => PlanDesignerViewModel);
			PlanDesignerViewModel.DesignerCanvas.ZoomChanged();
			ElementsViewModel = new ElementsViewModel(PlanDesignerViewModel.DesignerCanvas);

			InitializeCopyPaste();
			PlansTreeViewModel = new PlansTreeViewModel(this);
			CreatePages();
			_planExtensions = new List<Infrustructure.Plans.IPlanExtension<Plan>>();
			Menu = new PlansMenuViewModel(this);
			_splitterDistance = RegistrySettingsHelper.GetDouble("Administrator.Plans.SplitterDistance");
			if (_splitterDistance == 0)
				_splitterDistance = 300;
			_emptyGridColumn = new GridLength(0, GridUnitType.Pixel);
			Width1 = new GridLength(1, GridUnitType.Star);
			Width2 = GridLength.Auto;
			Width3 = new GridLength(_splitterDistance, GridUnitType.Pixel);
			var layerDistance = RegistrySettingsHelper.GetDouble("Administrator.Plans.LayerDistance");
			LayersHeight = new GridLength(layerDistance == 0 ? 500 : layerDistance, GridUnitType.Pixel);
			ApplicationService.ShuttingDown += () =>
			{
				RegistrySettingsHelper.SetDouble("Administrator.Plans.SplitterDistance", Width3 == _emptyGridColumn ? _splitterDistance : Width3.Value);
				RegistrySettingsHelper.SetDouble("Administrator.Plans.LayerDistance", LayersHeight.Value);
			};
		}
예제 #2
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);
        }