Beispiel #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;
                }
            }
        }
Beispiel #2
0
        private void ElementOrderViewModel_SelectedItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (!_selectionChanging)
            {
                _selectionChanging = true;
                //Console.Out.WriteLine($"Element View Model changed {e.Action}");

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

                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    var lvm = e.OldItems.Cast <ElementModelViewModel>().SelectMany(x => x.GetLeafEnumerator());
                    DrawingPanelViewModel.Deselect(lvm);
                }

                if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    var models = e.NewItems.Cast <ElementModelViewModel>().SelectMany(x => x.GetLeafEnumerator());
                    DrawingPanelViewModel.Select(models);
                }

                _selectionChanging = false;
            }
        }
Beispiel #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();
        }
Beispiel #4
0
 internal void ClearDirtyFlag()
 {
     IsDirty = false;
     ElementTreeViewModel.ClearIsDirty();
     DrawingPanelViewModel.ClearIsDirty();
 }
Beispiel #5
0
 private void ElementTreeViewModel_ModelsChanged(object sender, EventArgs e)
 {
     ElementOrderViewModel.RefreshElementLeafViewModels();
     DrawingPanelViewModel.RefreshLightViewModels();
 }