private void OnOutdentClick(object sender, RoutedEventArgs e) { List <Domain.AttributeValue> attributeValues = GetSelectedValues(); if (attributeValues.Count == 0) { return; } attributeValues.BubbleSort(); foreach (Domain.AttributeValue attributeValue in attributeValues) { Domain.AttributeValue parent = attributeValue.parent; if (parent == null) { parent = this.Root; } Domain.AttributeValue grandParent = parent.parent; if (grandParent == null) { return; } ForgetDefaultAttributeValues(grandParent); parent.ForgetChild(attributeValue); grandParent.AddChild(attributeValue); parent.IsExpanded = true; int row = Source.IndexOf(grandParent); if (row >= 0) { Source.Remove(grandParent); Source.Insert(row, grandParent); } else { row = Source.Count; Source.Remove(attributeValue); if (row - 2 >= 0) { Source.Insert(row - 2, attributeValue); } else { Source.Add(attributeValue); } } AddDefaultAttributeValues(grandParent); } treeList.SelectedItems = attributeValues; if (Changed != null) { Changed(); } }
private void OnDeleteClick(object sender, RoutedEventArgs e) { List <Domain.AttributeValue> attributeValues = GetSelectedValues(); if (attributeValues.Count == 0) { return; } String message = "Do you want to delete AttributeValue: '" + attributeValues[0] + "' ?"; if (attributeValues.Count > 1) { message = "Do you want to delete the " + attributeValues.Count + " selected attributeValues ?"; } MessageBoxResult result = Kernel.Util.MessageDisplayer.DisplayYesNoQuestion("Delete AttributeValue", message); if (result == MessageBoxResult.Yes) { foreach (Domain.AttributeValue attributeValue in attributeValues) { if (IsUsedToGenerateUniverse(attributeValue)) { return; } Domain.AttributeValue parent = attributeValue.parent; ForgetDefaultAttributeValues(parent); if (attributeValue.oid.HasValue) { parent.RemoveChild(attributeValue); } else { parent.ForgetChild(attributeValue); } AddDefaultAttributeValues(parent); removeFromSource(attributeValue); } if (Changed != null) { Changed(); } } }
private void OnIndentClick(object sender, RoutedEventArgs e) { List <Domain.AttributeValue> attributeValues = GetSelectedValues(); if (attributeValues.Count == 0) { return; } attributeValues.BubbleSort(); foreach (Domain.AttributeValue attributeValue in attributeValues) { Domain.AttributeValue parent = attributeValue.parent; if (parent == null) { parent = this.Root; } int position = attributeValue.GetPosition(); Domain.AttributeValue brother = (Domain.AttributeValue)parent.GetChildByPosition(position - 1); if (brother == null) { return; } ForgetDefaultAttributeValues(parent); parent.ForgetChild(attributeValue); brother.AddChild(attributeValue); brother.IsExpanded = true; int row = Source.IndexOf(brother); Source.Remove(brother); Source.Insert(row, brother); AddDefaultAttributeValues(parent); } treeList.SelectedItems = attributeValues; if (Changed != null) { Changed(); } }