예제 #1
0
        /// <summary>
        /// Cette méthode permet de désactiver un menuItem dans le cas
        /// où l'opération associée à ce menuItem n'est pas possible pour
        /// le noeud courant.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnContextMenuOpening(ContextMenuEventArgs e)
        {
            Kernel.Domain.Measure selectedItem = GetSelectedMeasure();
            if (selectedItem != null && selectedItem != defaultValue)
            {
                int lastPosition = -1;
                if (selectedItem.GetParent() != this.Root)
                {
                    lastPosition = selectedItem.parent.GetItems().Count;
                }
                else
                {
                    lastPosition = defaultValue.GetPosition();
                }

                this.newMenuItem.IsEnabled      = this.Root != null;
                this.cutMenuItem.IsEnabled      = this.Root != null && selectedItem != null && selectedItem.parent != null;
                this.copyMenuItem.IsEnabled     = this.Root != null && selectedItem != null && selectedItem.parent != null;
                this.pasteMenuItem.IsEnabled    = this.Root != null && selectedItem != null && !Kernel.Util.ClipbordUtil.IsClipBoardEmpty();
                this.deleteMenuItem.IsEnabled   = this.Root != null && selectedItem != null && selectedItem.parent != null;
                this.moveUpMenuItem.IsEnabled   = this.Root != null && selectedItem != null && selectedItem.GetPosition() > 0 && selectedItem.parent != null;
                this.moveDownMenuItem.IsEnabled = this.Root != null && selectedItem != null && selectedItem.parent != null && !((selectedItem.GetPosition() + 1) == lastPosition);
                this.indentMenuItem.IsEnabled   = this.Root != null && selectedItem != null && selectedItem.GetPosition() > 0 && selectedItem.parent != null;
                this.outdentMenuItem.IsEnabled  = this.Root != null && selectedItem != null && selectedItem.parent != null && selectedItem.GetParent() != Root;
            }
        }
예제 #2
0
 /// <summary>
 /// Supprime un noeud et ses fils.
 /// </summary>
 /// <param name="model">Le noeud à supprimer</param>
 public void DeleteNode(Kernel.Domain.Measure item)
 {
     if (item != null && item.parent != null)
     {
         MessageBoxResult result = Kernel.Util.MessageDisplayer.DisplayYesNoQuestion("Delete Measure", "Do you want to delete measure : " + item.name + "?");
         if (result == MessageBoxResult.Yes)
         {
             int index = item.GetPosition();
             item.GetParent().RemoveChild(item);
             if (Changed != null)
             {
                 Changed();
             }
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Transforme un noeud en sous-noeud
 /// </summary>
 /// <param name="model">le noeud à édenté</param>
 public void IndentNode(Kernel.Domain.Measure item)
 {
     if (item.parent != null)
     {
         int position           = item.GetPosition();
         IHierarchyObject child = item.parent.GetChildByPosition(position - 1);
         if (child != null)
         {
             item.parent.ForgetChild(item);
             child.AddChild(item);
             if (Changed != null)
             {
                 Changed();
             }
             SetSelectedMeasure(item);
         }
     }
 }