private void SelectionManager(EO.Wpf.TreeViewItem treeViewItem, bool isRightClick = true)
        {
            Kernel.Domain.Role role;

            if (treeViewItem.Header.ToString() == defaultValue.name)
            {
                role = null;
                treeViewItem.Focus();
            }
            else
            {
                role = this.Root.GetChildByName(treeViewItem.Header.ToString()) as Domain.Role;
                if (!CtrlPressed)
                {
                    if (!isRightClick || (isRightClick && !selectedItems.ContainsKey(treeViewItem) && !selectedRoles.Keys.Contains(role)))
                    {
                        removeCTRLSelection();
                        selectedItems.Add(treeViewItem, null);
                        SetSelectedItem(treeViewItem);
                        selectedRoles.Add(role, selectedRoles.Count + 1);
                    }
                }
                else if (CtrlPressed && !selectedItems.ContainsKey(treeViewItem) && !selectedRoles.Keys.Contains(role))
                {
                    selectedItems.Add(treeViewItem, null);
                    selectedRoles.Add(role, selectedRoles.Count + 1);
                    SetSelectedItem(treeViewItem);
                }
            }
        }
 // changes the state of the tree item:
 // selects it if it has not been selected and
 // deselects it otherwise
 void ChangeSelectedState(EO.Wpf.TreeViewItem treeViewItem)
 {
     if (!selectedItems.ContainsKey(treeViewItem))
     {                                              // select
         treeViewItem.Background = SELECTION_COLOR; // change background and foreground colors
         treeViewItem.Foreground = Brushes.White;
         selectedItems.Add(treeViewItem, null);     // add the item to selected items
     }
     else
     { // deselect
         Deselect(treeViewItem);
     }
 }
        /// <summary>
        /// Vérifie si l'on va cliquer sur le noeud par défaut afin d'activer le mode
        /// édition.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnItemClick(object sender, MouseButtonEventArgs e)
        {
            Kernel.Domain.Role  r;
            EO.Wpf.TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject);

            if (treeViewItem != null)
            {
                SelectionManager(treeViewItem, false);
            }
            else
            {
                r = GetSelectedRole();
                tree.Focus();
            }
        }
 /// <summary>
 /// Cette methode permet la selection du noeud présent derrière la souris
 /// lorsque fait un click-droit.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
 {
     EO.Wpf.TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject);
     if (treeViewItem != null)
     {
         treeViewItem.Focus();
         SelectionManager(treeViewItem);
         e.Handled = true;
     }
     else
     {
         Kernel.Domain.Role r = GetSelectedRole();
         if (r != null)
         {
             r.IsSelected = false;
         }
         tree.Focus();
         removeCTRLSelection();
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="treeViewItem"></param>
        private void DoSelectedItemChanged(EO.Wpf.TreeViewItem treeViewItem)
        {
            Domain.Role selectedRole;
            if (treeViewItem == null)
            {
                removeCTRLSelection();
                return;
            }
            else
            {
                selectedRole = GetSelectedRole();
            }

            removeCTRLSelection();
            ChangeSelectedState(treeViewItem);
            if (selectedRole != null)
            {
                UpdateSelectionList(selectedRole);
            }
        }
        public void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            EO.Wpf.TreeViewItem treeViewItem = new EO.Wpf.TreeViewItem();
            if (e != null)
            {
                treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject);
            }
            else
            {
                treeViewItem = ((sender as EO.Wpf.TreeView).SelectedItem as EO.Wpf.TreeViewItem);
            }

            if (treeViewItem != null)
            {
                SelectionManager(treeViewItem, false);
            }
            else
            {
                removeCTRLSelection();
            }
        }
 private void OnItemDragOver(object sender, EO.Wpf.ItemDragOverEventArgs e)
 {
     EO.Wpf.TreeViewItem item = (EO.Wpf.TreeViewItem)e.TargetItemContainer1;
 }
 private void SetSelectedItem(EO.Wpf.TreeViewItem treeViewItem)
 {
     treeViewItem.Background = SELECTION_COLOR; // change background and foreground colors
     treeViewItem.Foreground = Brushes.White;
 }
 // deselects the tree item
 void Deselect(EO.Wpf.TreeViewItem treeViewItem)
 {
     treeViewItem.Background = Brushes.Transparent; // change background and foreground colors
     treeViewItem.Foreground = Brushes.Black;
     selectedItems.Remove(treeViewItem);            // remove the item from the selected items set
 }