예제 #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;
                }
            }
        }
예제 #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;
            }
        }
예제 #3
0
        /// <summary>
        /// Method to invoke when the Delete command is executed.
        /// </summary>
        private void Delete()
        {
            //PropModelServices.Instance().RemoveElementModels(ElementTreeViewModel.SelectedItems.Select(x => x.ElementModel));
            var itemsToDelete = ElementTreeViewModel.SelectedItems.ToList();

            ElementTreeViewModel.SelectedItems.Clear();
            itemsToDelete.ForEach(x => x.RemoveFromParent());
            DrawingPanelViewModel.DeselectAll();
            DrawingPanelViewModel.RefreshLightViewModels();
            ElementOrderViewModel.RefreshElementLeafViewModels();
        }
예제 #4
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);
     }
 }
예제 #5
0
 private void ElementTreeViewModel_ModelsChanged(object sender, EventArgs e)
 {
     ElementOrderViewModel.RefreshElementLeafViewModels();
     DrawingPanelViewModel.RefreshLightViewModels();
 }