private void OnPasteClick(object sender, RoutedEventArgs e) { Domain.AttributeValue parent = GetSelectedValue(); if (parent == null || parent.IsDefault) { parent = this.Root; } List <Domain.AttributeValue> attributeValues = Kernel.Util.ClipbordUtil.GetAttributeValues(); if (attributeValues != null && attributeValues.Count > 0) { foreach (Domain.AttributeValue attributeValue in attributeValues) { attributeValue.name = GetNewAttributeValueName(attributeValue.name); ForgetDefaultAttributeValues(parent); attributeValue.SetParent(parent); parent.AddChild(attributeValue); AddDefaultAttributeValues(parent); addToSource(attributeValue); } if (Changed != null) { Changed(); } } }
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(); } }
protected Domain.AttributeValue GetCopy(Domain.AttributeValue attributeValue) { Domain.AttributeValue copy = new Domain.AttributeValue(); copy.name = "Copy Of " + attributeValue.name; copy.IsDefault = false; copy.position = attributeValue.position; copy.parent = null; foreach (Domain.AttributeValue child in attributeValue.childrenListChangeHandler.Items) { Domain.AttributeValue childcopy = GetCopy(child); copy.AddChild(childcopy); childcopy.parent = null; } return(copy); }
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(); } }
private void OnNewClick(object sender, RoutedEventArgs e) { Domain.AttributeValue parent = GetSelectedValue(); if (IsUsedToGenerateUniverse(parent)) { return; } Kernel.Domain.AttributeValue attributeValue = GetNewAttributeValue(); if (parent == null) { parent = this.Root; } if (parent != null) { ForgetDefaultAttributeValues(parent); parent.AddChild(attributeValue); AddDefaultAttributeValues(parent); int row = Source.Count; Source.Remove(attributeValue); if (row - 2 >= 0) { Source.Insert(row - 2, attributeValue); } else { Source.Add(attributeValue); } SetSelectedValue(attributeValue); if (Changed != null) { Changed(); } } }