/// <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; } } }
/// <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(); }
private void ElementTreeViewModel_ModelsChanged(object sender, EventArgs e) { ElementOrderViewModel.RefreshElementLeafViewModels(); DrawingPanelViewModel.RefreshLightViewModels(); }