/// <summary> /// /// </summary> /// <param name="propertyItem"></param> /// <param name="S88Type"></param> public void SetPropertyType(PropertyModel propertyItem, string propertyType) { propertyItem.PropertyType_ID = GetPropertyType_ID(propertyType); }
/// <summary> /// Method triggered by the TreeListViewDragDropBehavior Class. Takes care of moving on item in the tree, which can be from /// any level to any level /// </summary> /// <param name="destination"></param> public void MoveSelection(TreeListViewRow destination) // Collection<PropertyModel> selectedItems, PropertyModel destination ) { if (destination != null) { PropertyModel destinationItem = (destination.DataContext) as PropertyModel; try { // Setup a private collection with the selected items only. This is because the SelectedItems that are part of the view model collection // will change as soon as we start removing and adding objects TD.ObservableItemCollection <PropertyModel> selectedItems = new TD.ObservableItemCollection <PropertyModel>(); foreach (PropertyModel item in SelectedItems) { selectedItems.Add(item); } foreach (PropertyModel item in selectedItems) { // find the original parent of the object that's moved PropertyModel parentSourceItem = GetProperty(item.Parent_ID); // If the parent is in the root level if (parentSourceItem == null) { // Remove the item in the root level Properties.Remove(item); } else { // Otherwise remove the item from the child collection parentSourceItem.ChildProperties.Remove(item); } TreeListViewDropPosition relativeDropPosition = (TreeListViewDropPosition)destination.GetValue(RadTreeListView.DropPositionProperty); destination.UpdateLayout(); // If put on top of destination if (relativeDropPosition == TreeListViewDropPosition.Inside) { // the Parent_ID of the item will become the ID of the destination item.Parent_ID = destinationItem.ID; destinationItem.ChildProperties.Add(item); } // If put before or after the destination else { // if the desitination is in the root collection if (destinationItem.Parent_ID == null) { // The parent_ID of the item will also be null item.Parent_ID = null; Properties.Insert(Properties.IndexOf(destinationItem), item); } else { // otherwise the Parent_ID of the item will be the same as that of the destination item item.Parent_ID = destinationItem.Parent_ID; // find the Parent of the destination item parentSourceItem = GetProperty(destinationItem.Parent_ID); // Insert the item before or after the destination item in the ChildObject collection of the parent of the destination if (relativeDropPosition == TreeListViewDropPosition.Before) { parentSourceItem.ChildProperties.Insert(parentSourceItem.ChildProperties.IndexOf(destinationItem), item); } else { parentSourceItem.ChildProperties.Insert(parentSourceItem.ChildProperties.IndexOf(destinationItem) + 1, item); } } } } } catch (Exception ex) { RadWindow.Alert(ex.Message); } } //try //{ // // Setup a private collection with the selected items only. This is because the SelectedItems that are part of the view model collection // // will change as soon as we start removing and adding objects // TD.ObservableItemCollection<PropertyModel> selectedItems = new TD.ObservableItemCollection<PropertyModel>(); // foreach (PropertyModel item in SelectedItems) // { // selectedItems.Add(item); // } // foreach (PropertyModel item in selectedItems) // { // // find the original parent of the object that's moved // PropertyModel parentSourceItem = GetProperty(item.Parent_ID); // // If the parent is in the root level // if (parentSourceItem == null) // // Remove the item in the root level // Properties.Remove(item); // else // // Otherwise remove the item from the child collection // parentSourceItem.ChildProperties.Remove(item); // if (destination != null) // { // TreeListViewDropPosition relativeDropPosition = (TreeListViewDropPosition)destination.GetValue(RadTreeListView.DropPositionProperty); // PropertyModel destinationItem = (destination.DataContext) as PropertyModel; // // If put on top of destination // if (relativeDropPosition == TreeListViewDropPosition.Inside) // { // // the Parent_ID of the item will become the ID of the destination // item.Parent_ID = destinationItem.ID; // destinationItem.ChildProperties.Add(item); // } // // If put before or after the destination // else // { // // if the desitination is in the root collection // if (destinationItem.Parent_ID == null) // { // // The parent_ID of the item will also be null // item.Parent_ID = null; // Properties.Insert(Properties.IndexOf(destinationItem), item); // } // else // { // // otherwise the Parent_ID of the item will be the same as that of the destination item // item.Parent_ID = destinationItem.Parent_ID; // // find the Parent of the destination item // parentSourceItem = GetProperty(destinationItem.Parent_ID); // // Insert the item above the destination item in the ChildObject collection of the parent of the destination // if (relativeDropPosition == TreeListViewDropPosition.Before) // parentSourceItem.ChildProperties.Insert(parentSourceItem.ChildProperties.IndexOf(destinationItem), item); // else // parentSourceItem.ChildProperties.Insert(parentSourceItem.ChildProperties.IndexOf(destinationItem) + 1, item); // } // } // } // else // destination is null, i.e. below the tree // { // item.Parent_ID = null; // Properties.Add(item); // } // } //} //catch (Exception ex) //{ // RadWindow.Alert(ex.Message); //} }