Ejemplo n.º 1
0
        /// <summary>
        /// Method to invoke when the AddLight command is executed.
        /// </summary>
        private void AddLight(Point p)
        {
            var target = ElementTreeViewModel.SelectedItem;

            var model = PropModelServices.Instance().AddLight(target?.ElementModel, p);

            if (model == null)
            {
                return;
            }

            DrawingPanelViewModel.RefreshLightViewModels();
            ElementOrderViewModel.RefreshElementLeafViewModels();

            if (model == target?.ElementModel)
            {
                ElementTreeViewModel.SelectModels(new[] { target });
            }
            else
            {
                var vms       = ElementModelLookUpService.Instance.GetModels(model.Id);
                var viewModel = vms.First();
                var parent    = viewModel.ParentViewModel as ElementModelViewModel;
                if (parent != null)
                {
                    ElementTreeViewModel.SelectModels(new[] { parent });
                    parent.IsExpanded = true;
                }
            }
        }
Ejemplo n.º 2
0
        private void DrawingViewModel_SelectedItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (!_selectionChanging)
            {
                _selectionChanging = true;

                //Console.Out.WriteLine($"Drawing View Model changed {e.Action}");

                if (e.Action == NotifyCollectionChangedAction.Reset)
                {
                    ElementTreeViewModel.DeselectAll();
                    ElementOrderViewModel.DeselectAll();
                }

                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    if (e.OldItems != null)
                    {
                        var parents = e.OldItems.Cast <LightViewModel>().SelectMany(l => ElementModelLookUpService.Instance.GetModels(l.Light.ParentModelId));
                        ElementTreeViewModel.DeselectModels(parents);
                    }
                }

                if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    var parents = e.NewItems.Cast <LightViewModel>().SelectMany(l => ElementModelLookUpService.Instance.GetModels(l.Light.ParentModelId));
                    ElementTreeViewModel.SelectModels(parents);
                }
                _selectionChanging = false;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Called when the SelectedTabIndex property has changed.
 /// </summary>
 private void OnSelectedTabIndexChanged()
 {
     if (SelectedTabIndex == 0)
     {
         //var selectedModelIds = ElementTreeViewModel.SelectedItems.Select(e => e.ElementModel.Id).Distinct();
         ElementTreeViewModel.DeselectAll();
         //ElementOrderViewModel.Select(selectedModelIds);
     }
     else if (SelectedTabIndex == 1)
     {
         //var selectedModelIds = ElementOrderViewModel.SelectedItems.Select(e => e.ElementModel.Id).Distinct();
         ElementOrderViewModel.DeselectAll();
         //ElementTreeViewModel.Select(selectedModelIds);
     }
 }
Ejemplo n.º 4
0
        public DrawingPanelViewModel(ElementTreeViewModel elementTreeViewModel)
        {
            _elementTreeViewModel = elementTreeViewModel;
            _elementModelMap      = new Dictionary <Guid, List <LightViewModel> >();
            LightNodes            = new ObservableCollection <LightViewModel>();

            TransformCommand = new RelayCommand <Transform>(Transform);

            AlignTopsCommand              = new RelayCommand(AlignTops, CanExecuteAlignmentMethod);
            AlignBottomsCommand           = new RelayCommand(AlignBottoms, CanExecuteAlignmentMethod);
            AlignLeftCommand              = new RelayCommand(AlignLeft, CanExecuteAlignmentMethod);
            AlignRightCommand             = new RelayCommand(AlignRight, CanExecuteAlignmentMethod);
            DistributeHorizontallyCommand = new RelayCommand(DistributeHorizontally, CanExecuteAlignmentMethod);
            DistributeVerticallyCommand   = new RelayCommand(DistributeVertically, CanExecuteAlignmentMethod);

            DeleteSelectedLightsCommand = new RelayCommand(DeleteSelectedLights);
            Configuration = ConfigurationService.Instance().Config;
            SelectedItems = new FastObservableCollection <LightViewModel>();
            SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;
            IsDrawing = true;
            Prop      = elementTreeViewModel.Prop;
        }
Ejemplo n.º 5
0
 internal void ClearDirtyFlag()
 {
     IsDirty = false;
     ElementTreeViewModel.ClearIsDirty();
     DrawingPanelViewModel.ClearIsDirty();
 }