Exemplo n.º 1
0
        private void OnPasteClick(object sender, RoutedEventArgs e)
        {
            Domain.Attribute parent = GetSelectedValue();
            if (parent == null || parent.IsDefault)
            {
                parent = this.Root;
            }
            List <Domain.Attribute> attributes = Kernel.Util.ClipbordUtil.GetAttributes();

            if (attributes != null && attributes.Count > 0)
            {
                foreach (Domain.Attribute attribute in attributes)
                {
                    attribute.name = GetNewAttributeName(attribute.name);
                    ForgetDefaultAttributes(parent);
                    attribute.SetParent(parent);
                    parent.AddChild(attribute);
                    parent.related = true;
                    AddDefaultAttributes(parent);
                    addToSource(attribute);
                }
                attributes.Clear();
                if (Changed != null)
                {
                    Changed();
                }
            }
        }
Exemplo n.º 2
0
        private void OnOutdentClick(object sender, RoutedEventArgs e)
        {
            List <Domain.Attribute> attributes = GetSelectedValues();

            if (attributes.Count == 0)
            {
                return;
            }
            attributes.BubbleSort();
            foreach (Domain.Attribute attribute in attributes)
            {
                Domain.Attribute parent = attribute.parent;
                if (parent == null)
                {
                    parent = this.Root;
                }
                Domain.Attribute grandParent = parent.parent;
                if (grandParent == null)
                {
                    return;
                }

                ForgetDefaultAttributes(grandParent);
                parent.ForgetChild(attribute);
                parent.related = parent.childrenListChangeHandler.Items.Count > 0;
                grandParent.AddChild(attribute);
                grandParent.related = true;
                parent.IsExpanded   = true;

                int row = Source.IndexOf(grandParent);
                if (row >= 0)
                {
                    Source.Remove(grandParent);
                    Source.Insert(row, grandParent);
                }
                else
                {
                    row = Source.Count;
                    Source.Remove(attribute);
                    if (row - 2 >= 0)
                    {
                        Source.Insert(row - 2, attribute);
                    }
                    else
                    {
                        Source.Add(attribute);
                    }
                }
                AddDefaultAttributes(grandParent);
            }
            treeList.RefreshData();
            treeList.SelectedItems = attributes;
            if (Changed != null)
            {
                Changed();
            }
        }
Exemplo n.º 3
0
        protected Domain.Attribute GetCopy(Domain.Attribute attribute)
        {
            Domain.Attribute copy = new Domain.Attribute();

            copy.name      = "Copy Of " + attribute.name;
            copy.IsDefault = false;
            copy.position  = attribute.position;
            copy.parent    = null;
            foreach (Domain.Attribute child in attribute.childrenListChangeHandler.Items)
            {
                Domain.Attribute childcopy = GetCopy(child);
                copy.AddChild(childcopy);
                childcopy.parent = null;
            }
            return(copy);
        }
Exemplo n.º 4
0
        private void OnIndentClick(object sender, RoutedEventArgs e)
        {
            List <Domain.Attribute> attributes = GetSelectedValues();

            if (attributes.Count == 0)
            {
                return;
            }
            attributes.BubbleSort();
            foreach (Domain.Attribute attribute in attributes)
            {
                Domain.Attribute parent = attribute.parent;
                if (parent == null)
                {
                    parent = this.Root;
                }
                int position             = attribute.GetPosition();
                Domain.Attribute brother = (Domain.Attribute)parent.GetChildByPosition(position - 1);
                if (brother == null)
                {
                    return;
                }
                ForgetDefaultAttributes(parent);
                parent.ForgetChild(attribute);
                brother.AddChild(attribute);
                brother.related    = true;
                brother.IsExpanded = true;

                int row = Source.IndexOf(brother);
                Source.Remove(brother);
                Source.Insert(row, brother);
                AddDefaultAttributes(parent);
            }
            treeList.RefreshData();
            treeList.SelectedItems = attributes;
            if (Changed != null)
            {
                Changed();
            }
        }
Exemplo n.º 5
0
        private void OnNewClick(object sender, RoutedEventArgs e)
        {
            Domain.Attribute parent = GetSelectedValue();
            if (IsUsedToGenerateUniverse(parent))
            {
                return;
            }
            Kernel.Domain.Attribute attribute = GetNewAttribute();
            if (parent == null)
            {
                parent = this.Root;
            }
            if (parent != null)
            {
                ForgetDefaultAttributes(parent);
                parent.AddChild(attribute);
                parent.related = true;
                AddDefaultAttributes(parent);

                int row = Source.Count;
                Source.Remove(attribute);
                if (row - 2 >= 0)
                {
                    Source.Insert(row - 2, attribute);
                }
                else
                {
                    Source.Add(attribute);
                }
                SetSelectedValue(attribute);

                if (Changed != null)
                {
                    Changed();
                }
            }
        }