Ejemplo n.º 1
0
        /// <summary>
        /// Remove this OrgElementViewModel from the
        /// OrgTreeViewModel
        /// </summary>
        /// <param name="i"></param>
        void IDragable.Remove(object data)
        {
            //if moving within organization we don't want to
            //delete the data from the tree
            OrgElementViewModel org = data as OrgElementViewModel;

            if (org != null)
            {
                //if not a move within organization(moving outside of orgchart)
                if (!org.isMoveWithinOrganization)
                {
                    OrgChartManager.Instance().RemoveNode(this.ID);
                }
            }
            //refresh the view of parent's children
            if (parent != null)
            {
                parent.Children = parent.GetChildren();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Drop data into this OrgElementViewModel
        /// </summary>
        void IDropable.Drop(object data, int index)
        {
            //if moving within organization, reassign the children to the
            //level above first
            OrgElementViewModel org  = data as OrgElementViewModel;
            ElementViewModel    elem = data as ElementViewModel;

            if (org != null)
            {
                org.isMoveWithinOrganization = true;
                if (org.ID == this.ID) //if dragged and dropped yourself, don't need to do anything
                {
                    return;
                }
                OrgChartManager.Instance().Reassign(new Node {
                    Id = org.ID
                }, org.parent.ID);
                OrgChartManager.Instance().AddNode(new Node {
                    Id        = org.ID,
                    ParentId  = this.ID,
                    FirstName = org.FirstName,
                    LastName  = org.LastName
                },
                                                   this.ID);
            }
            else if (elem != null)
            {
                OrgChartManager.Instance().AddNode(new Node {
                    Id        = elem.ID,
                    ParentId  = this.ID,
                    FirstName = elem.FirstName,
                    LastName  = elem.LastName
                },
                                                   this.ID);
            }
            this.Children = this.GetChildren();  //refresh view
        }
Ejemplo n.º 3
0
 internal OrgElementViewModel(Node i, OrgElementViewModel parent = null)
     : base(i)
 {
     //assign reference to the parent OrgElementViewModel
     this.parent = parent;
 }