private void UpdateViewPortWhenTeamVisualChange(OrgTeamViewModel team, bool isLayoutSynchronous)
 {
     Point oldPosition = team.Position;
     this.LayoutOrgChart(false, isLayoutSynchronous);
     this.diagram.UpdateViewportRespectingShape(oldPosition, team.Position);
 }
 private void ExpandItemDelayed(OrgTeamViewModel teamToExpand)
 {
     bool shouldExpand = this.teamToExpand != teamToExpand;
     if (shouldExpand)
     {
         this.teamToExpand = teamToExpand;
         this.actionDelayer.Execute(new Action(() =>
         {
             this.teamToExpand.AreMembersVisible = true;
         }), this.expandDelayInterval);
     }
 }
 private void FindAndRemoveRecursive(OrgTeamViewModel parent, OrgTeamViewModel toDelete)
 {
     foreach (var item in parent.Children)
     {
         if (item == toDelete)
         {
             parent.Children.Remove(item);
             parent.DeleteTeamCommand.InvalidateCanExecute();
             return;
         }
         this.FindAndRemoveRecursive(item as OrgTeamViewModel, toDelete);
     }
 }
		private void DiagramBringIntoView(OrgTeamViewModel node)
		{
			var shape = this.diagram.ContainerGenerator.ContainerFromItem(node) as RadDiagramShape;
			if (shape != null)
			{
				this.diagram.BringIntoView(shape, 1, true);
			}
		}
 internal void FindAndRemove(OrgTeamViewModel team)
 {
     if (team == this.HierarchicalDataSource[0])
     {
         this.HierarchicalDataSource.Clear();
     }
     else
     {
         this.FindAndRemoveRecursive(this.HierarchicalDataSource[0], team);
     }
 }
		private OrgTeamViewModel CreateNode(XElement element, OrgTeamViewModel parentNode)
		{
			OrgTeamViewModel orgTeam = new OrgTeamViewModel()
			{
				Name = element.Attribute("Name").Value,
			};
#if WPF
            orgTeam.Branch = (Branch)Enum.Parse(typeof(Branch), element.Attribute("Branch").Value);
#else
            orgTeam.Branch = (Branch)Enum.Parse(typeof(Branch), element.Attribute("Branch").Value, false);
#endif
            orgTeam.TeamMembers.AddRange(this.GetTeamMembers(element, orgTeam));
            orgTeam.Path = parentNode == null ? orgTeam.Name : parentNode.Path + "|" + orgTeam.Name;		
            orgTeam.PropertyChanged += this.OnNodePropertyChanged;
            orgTeam.IsExpandedChanged += this.OnNodeIsExpandedChanged;
            orgTeam.MembersVisibilityChanged += this.OrgTeamMembersVisibilityChanged;
            return orgTeam;
		}
		private ObservableCollection<HierarchicalNodeViewModel> GetSubNodes(XContainer element, OrgTeamViewModel parent)
		{
			var nodes = new ObservableCollection<HierarchicalNodeViewModel>();
			foreach (var subElement in element.Elements("Node"))
			{
				OrgTeamViewModel node = this.CreateNode(subElement, parent);
				node.Children.AddRange(this.GetSubNodes(subElement, node));
				nodes.Add(node);
			}
			return nodes;
		}
 private ObservableCollection<OrgTeamMemberViewModel> GetTeamMembers(XContainer element, OrgTeamViewModel team)
 {
     var members = new ObservableCollection<OrgTeamMemberViewModel>();
     foreach (var xmlNodeMember in element.Elements("NodeMember"))
     {
         OrgTeamMemberViewModel member = new OrgTeamMemberViewModel();
         member.Team = team;
         member.Name = xmlNodeMember.Attribute("Name").Value;
         member.ImagePath = string.Format("../../Images/Diagrams/OrgChart/{0}.png", member.Name); 
         member.Position = xmlNodeMember.Attribute("Position").Value;
         members.Add(member);
     }
     return members;
 }
 internal void OpenDropMembersDialog(OrgTeamViewModel team, OrgTeamMemberViewModel member)
 {
     DropDialogViewModel dropModel = new DropDialogViewModel()
     {
         Header = string.Format("Drop in {0} team", team.Name),
         DropMessage = string.Format("Are you sure you want to drop {0} in {1} team?", member.Name, team.Name)
     };
     DropDialog dialog = new DropDialog();
     dialog.DataContext =  dropModel;
     dropModel.OkCommand = new DelegateCommand(x =>
         {
             member.Team.TeamMembers.Remove(member);
             member.Team = team;
             team.TeamMembers.Add(member);
             if (this.TeamMembersVisibilityChanged != null)
             {
                 TeamExpandCollapseChangeEventArgs args = new TeamExpandCollapseChangeEventArgs(team);
                 this.TeamMembersVisibilityChanged(this, args);
             }
             dialog.Close();
         });
     dropModel.CancelCommand = new DelegateCommand(x => dialog.Close());
     dialog.ShowDialog();
 }