private void SetCustomMembers(TreeNodeCustomStaff s, CustomGroup c)
        {
            INWindow inWindow = this.dataService.INWindow as INWindow;

            if (inWindow.Employee.FirstTreeView.Items.Count > 0)
            {
                foreach (TreeViewItem item in (System.Collections.IEnumerable)inWindow.Employee.FirstTreeView.Items)
                {
                    CustomGroupTreeViewItem cust = item as CustomGroupTreeViewItem;
                    if (cust != null && cust.Tag != null)
                    {
                        if (c.GroupID == cust.Tag.ToString())
                        {
                            foreach (TreeNodeCustomStaff i in (System.Collections.IEnumerable)cust.Items)
                            {
                                if (i.Staff.Uid != s.Staff.Uid)
                                {
                                    i.IsBigHead = false;
                                    i.ShowSmallHead();
                                }
                            }
                        }
                        else
                        {
                            foreach (TreeNodeCustomStaff i in (System.Collections.IEnumerable)cust.Items)
                            {
                                i.IsBigHead = false;
                                i.ShowSmallHead();
                            }
                        }
                    }
                }
            }
        }
 public TreeNodeCustomStaff(Staff staff)
 {
     this.InitializeComponent();
     this.staff  = staff;
     this.status = staff.Status;
     this.UpdateInfo();
     this.AddEventListenerHandler();
     base.PreviewMouseRightButtonDown += delegate(object s, MouseButtonEventArgs e)
     {
         TreeNodeCustomStaff.mouse_event(this.MOUSEEVENTF_LEFTDOWN, (int)e.GetPosition(this).X, (int)e.GetPosition(this).Y, 0, 0);
     };
 }
 public void UpdateStaff(Staff staff)
 {
     foreach (TreeViewItem item in (System.Collections.IEnumerable) this.FirstTreeView.Items)
     {
         CustomGroupTreeViewItem customGroupTreeViewItem = item as CustomGroupTreeViewItem;
         if (customGroupTreeViewItem != null)
         {
             foreach (object cItem in (System.Collections.IEnumerable)item.Items)
             {
                 TreeNodeCustomStaff treeNodeCustomStaff = cItem as TreeNodeCustomStaff;
                 if (treeNodeCustomStaff != null)
                 {
                     treeNodeCustomStaff.UpdateInfo();
                 }
             }
         }
     }
 }
        private void CustomGroupTreeViewItem_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            TreeNodeCustomStaff node = e.Source as TreeNodeCustomStaff;

            if (node != null)
            {
                node.Focus();
                e.Handled = true;
            }
            else
            {
                CustomGroupTreeViewItem customGroupTreeViewItem = sender as CustomGroupTreeViewItem;
                if (customGroupTreeViewItem != null)
                {
                    customGroupTreeViewItem.Focus();
                    e.Handled = true;
                }
            }
        }
 private void Sort(System.Collections.Generic.List <Staff> staffs, string groupId)
 {
     foreach (TreeViewItem item in (System.Collections.IEnumerable) this.FirstTreeView.Items)
     {
         if (item is CustomGroupTreeViewItem)
         {
             if (item.DataContext is CustomGroup)
             {
                 if ((item.DataContext as CustomGroup).GroupID == groupId)
                 {
                     item.Items.Clear();
                     if (staffs.Count > 0)
                     {
                         IOrderedEnumerable <Staff> v =
                             from t in staffs
                             orderby t.Status == UserStatus.Offline, t.Status == UserStatus.Hide, t.Status == UserStatus.Out, t.Status == UserStatus.DoNotDisturb, t.Status == UserStatus.Busy, t.Status == UserStatus.Meeting, t.Status == UserStatus.Away, t.Status == UserStatus.Online
                         select t;
                         foreach (Staff staff in v)
                         {
                             TreeNodeCustomStaff node = new TreeNodeCustomStaff(staff);
                             node.SessionService = this.sessionService;
                             node.DataService    = this.dataService;
                             node.ContextMenu    = new ContextMenu();
                             MenuItem menuItem = new MenuItem();
                             menuItem.Header      = "将联系人从该组移除";
                             menuItem.Tag         = groupId;
                             menuItem.DataContext = node.Staff;
                             node.ContextMenu.Items.Add(menuItem);
                             menuItem.Click += new RoutedEventHandler(this.menuItem_Click);
                             item.Items.Add(node);
                         }
                         staffs.Clear();
                     }
                     break;
                 }
             }
         }
     }
 }
 private void SetCustomMembers(TreeNodeCustomStaff s, CustomGroup c)
 {
     INWindow inWindow = this.dataService.INWindow as INWindow;
     if (inWindow.Employee.FirstTreeView.Items.Count > 0)
     {
         foreach (TreeViewItem item in (System.Collections.IEnumerable)inWindow.Employee.FirstTreeView.Items)
         {
             CustomGroupTreeViewItem cust = item as CustomGroupTreeViewItem;
             if (cust != null && cust.Tag != null)
             {
                 if (c.GroupID == cust.Tag.ToString())
                 {
                     foreach (TreeNodeCustomStaff i in (System.Collections.IEnumerable)cust.Items)
                     {
                         if (i.Staff.Uid != s.Staff.Uid)
                         {
                             i.IsBigHead = false;
                             i.ShowSmallHead();
                         }
                     }
                 }
                 else
                 {
                     foreach (TreeNodeCustomStaff i in (System.Collections.IEnumerable)cust.Items)
                     {
                         i.IsBigHead = false;
                         i.ShowSmallHead();
                     }
                 }
             }
         }
     }
 }
 private void Sort(System.Collections.Generic.List<Staff> staffs, string groupId)
 {
     foreach (TreeViewItem item in (System.Collections.IEnumerable)this.FirstTreeView.Items)
     {
         if (item is CustomGroupTreeViewItem)
         {
             if (item.DataContext is CustomGroup)
             {
                 if ((item.DataContext as CustomGroup).GroupID == groupId)
                 {
                     item.Items.Clear();
                     if (staffs.Count > 0)
                     {
                         IOrderedEnumerable<Staff> v =
                             from t in staffs
                             orderby t.Status == UserStatus.Offline, t.Status == UserStatus.Hide, t.Status == UserStatus.Out, t.Status == UserStatus.DoNotDisturb, t.Status == UserStatus.Busy, t.Status == UserStatus.Meeting, t.Status == UserStatus.Away, t.Status == UserStatus.Online
                             select t;
                         foreach (Staff staff in v)
                         {
                             TreeNodeCustomStaff node = new TreeNodeCustomStaff(staff);
                             node.SessionService = this.sessionService;
                             node.DataService = this.dataService;
                             node.ContextMenu = new ContextMenu();
                             MenuItem menuItem = new MenuItem();
                             menuItem.Header = "将联系人从该组移除";
                             menuItem.Tag = groupId;
                             menuItem.DataContext = node.Staff;
                             node.ContextMenu.Items.Add(menuItem);
                             menuItem.Click += new RoutedEventHandler(this.menuItem_Click);
                             item.Items.Add(node);
                         }
                         staffs.Clear();
                     }
                     break;
                 }
             }
         }
     }
 }
 private void AddChildren(IDKin.IM.Core.CustomGroup group, CustomGroupTreeViewItem item)
 {
     try
     {
         if (group != null && group.Members != null && group.Members.Count != 0)
         {
             IOrderedEnumerable<IDKin.IM.Core.Staff> v =
                 from t in @group.Members
                 orderby t.Status == UserStatus.Offline, t.Status == UserStatus.Hide, t.Status == UserStatus.Out, t.Status == UserStatus.DoNotDisturb, t.Status == UserStatus.Busy, t.Status == UserStatus.Meeting, t.Status == UserStatus.Away, t.Status == UserStatus.Online
                 select t;
             foreach (IDKin.IM.Core.Staff staff in v)
             {
                 TreeNodeCustomStaff node = new TreeNodeCustomStaff(staff);
                 node.SessionService = this.sessionService;
                 node.DataService = this.dataService;
                 node.ContextMenu = this.GetContextMenuForStaff(node);
                 item.Items.Add(node);
             }
         }
     }
     catch (System.Exception ex)
     {
         System.Console.WriteLine(ex.ToString());
     }
 }
 private ContextMenu GetContextMenuForStaff(TreeNodeCustomStaff treeitem)
 {
     ContextMenu cMenu = new ContextMenu();
     MenuItem item = new MenuItem();
     item.Header = "将联系人从该组移除";
     cMenu.Items.Add(item);
     item.Click += delegate(object s, RoutedEventArgs e)
     {
         CustomGroupTreeViewItem t = treeitem.Parent as CustomGroupTreeViewItem;
         if (t != null)
         {
             IDKin.IM.Core.CustomGroup c = t.DataContext as IDKin.IM.Core.CustomGroup;
             if (this.dataModel.CustomeGroupName.ContainsKey(c.GroupID))
             {
                 CustomGroupManagerWindowViewModel vmodel = CustomGroupManagerWindowViewModel.GetInstance();
                 this.dataModel.CustomeGroupName[c.GroupID].Members.Remove(treeitem.Staff);
                 vmodel.DeleteMemberToCustomGroup((int)this.sessionService.Uid, c.GroupID, this.GetMembers(this.dataModel.CustomeGroupName[c.GroupID]));
                 t.Items.Remove(treeitem);
             }
         }
     };
     return cMenu;
 }