private void OnLoadInBackground(object sender, DoWorkEventArgs e) { this.IsBusy = true; Objects.SuspendNotifications(); // Load Object Types; TypeViewModelLocator.GetTypeVM(); // Load Objects Load(null); }
private void ChangeType(object p) { // ToDo: Bad practice to call a view from the viewmodel. Fix using IOC var typeSelectionPopup = new TypeSelectionPopup(); TypeViewModel typeViewModel = TypeViewModelLocator.GetTypeVM(); // Close the type selection box typeViewModel.CloseTrigger = false; typeViewModel.TypeGroup = "ControlObject"; // Filter the type collection on the type group typeViewModel.FilterText = typeViewModel.TypeGroup; // To have one popup for all type groups (object, template, property etc) the popup is embedded in a dialog typeSelectionPopup.ShowDialog(); }
public void AddSibling() { { // Instanciate a new requirement RequirementModel requirementItem = new RequirementModel { ID = Guid.NewGuid(), Project_ID = Globals.Project_ID, ArticleNo = "xxx", ArticleHeader = "New Article", Version = "", IsChanged = false, IsNew = true, RequirementType_ID = TypeViewModelLocator.GetTypeVM().GetTypeGroupID("Requirement"), ChildRequirements = new TD.ObservableItemCollection <RequirementModel>() }; // If no item has been selected, put the object in the root of the tree if (SelectedItem == null) { requirementItem.Parent_ID = null;// Requirements.Add(requirementItem); } // If the selected item is in the root, put the new object in the root also else if (SelectedItem.Parent_ID == null) { requirementItem.Parent_ID = null; Requirements.Insert(Requirements.IndexOf(SelectedItem) + 1, requirementItem); } // Otherwise het the parent object and add the new object as a child else { RequirementModel parentItem = GetRequirement(SelectedItem.Parent_ID); requirementItem.Parent_ID = SelectedItem.Parent_ID; parentItem.ChildRequirements.Insert(parentItem.ChildRequirements.IndexOf(SelectedItem) + 1, requirementItem); } IsChanged = true; } }
public void AddSibling() { // Instanciate a new object ObjectModel objectItem = new ObjectModel { ID = Guid.NewGuid(), Project_ID = Globals.Project_ID, ObjectName = "New Object", Description = "New Object Description", IsChanged = false, IsNew = true, ObjectType_ID = TypeViewModelLocator.GetTypeVM().GetTypeGroupID("Object"), ChildObjects = new TD.ObservableItemCollection <ObjectModel>() }; // If no item has been selected, put the object in the root of the tree if (SelectedItem == null) { objectItem.Parent_ID = null; Objects.Add(objectItem); } // If the selected item is in the root, put the new object in the root also else if (SelectedItem.Parent_ID == null) { objectItem.Parent_ID = null; objectItem.ObjectType_ID = SelectedItem.ObjectType_ID; Objects.Insert(Objects.IndexOf(SelectedItem) + 1, objectItem); } // Otherwise get the parent object and add the new object as a child else { ObjectModel parentItem = GetObject(SelectedItem.Parent_ID); objectItem.Parent_ID = SelectedItem.Parent_ID; objectItem.ObjectType_ID = SelectedItem.ObjectType_ID; parentItem.ChildObjects.Insert(parentItem.ChildObjects.IndexOf(SelectedItem) + 1, objectItem); } IsChanged = true; OnFocusRequested("ObjectName"); }
public void AddChild() { RequirementModel requirementItem = new RequirementModel { ID = Guid.NewGuid(), Project_ID = Globals.Project_ID, ArticleNo = "xxx", ArticleHeader = "New Requirement", Version = "", IsChanged = false, IsNew = true, RequirementType_ID = TypeViewModelLocator.GetTypeVM().GetTypeGroupID("Requirement"), ChildRequirements = new TD.ObservableItemCollection <RequirementModel>() }; if (SelectedItem != null) { requirementItem.Parent_ID = SelectedItem.ID; SelectedItem.ChildRequirements.Add(requirementItem); } IsChanged = true; }
private void OnLoadInBackground(object sender, DoWorkEventArgs e) { ObjectRequirements.SuspendNotifications(); TypeViewModelLocator.GetTypeVM(); Load(); }
private void Dialog_Loaded(object sender, RoutedEventArgs e) { DataContext = TypeViewModelLocator.GetTypeVM(); }