示例#1
0
 public void DragDropSelectedCrowdMember(Crowd targetCrowd)
 {
     this.LockTreeUpdate(true);
     if (this.SelectedCharacterCrowdMember != null) // dragged a Character
     {
         // avoid linking or cloning of default and combat effect crowds
         if (this.SelectedCharacterCrowdMember.Name != DEFAULT_CHARACTER_NAME && this.SelectedCharacterCrowdMember.Name != COMBAT_EFFECTS_CHARACTER_NAME)
         {
             if (this.SelectedCrowdMember.Name == targetCrowd.Name)
             {
                 // It is in the same crowd, so clone
                 this.CrowdClipboard.CopyToClipboard(this.SelectedCharacterCrowdMember);
                 CrowdMember pastedMember = this.CrowdClipboard.PasteFromClipboard(targetCrowd);
                 OnEditNeeded(pastedMember, new CustomEventArgs <string>()
                 {
                     Value = "EditAfterDragDrop"
                 });
             }
             else
             {
                 // different crowd, so link
                 if (!targetCrowd.ContainsMember(SelectedCharacterCrowdMember))
                 {
                     this.CrowdClipboard.LinkToClipboard(this.SelectedCharacterCrowdMember);
                     this.CrowdClipboard.PasteFromClipboard(targetCrowd);
                 }
             }
         }
     }
     else // dragged a Crowd
     {
         // link/clone the crowd but don't create circular reference
         if (this.SelectedCrowdMember != null && targetCrowd.Name != this.SelectedCrowdMember.Name)
         {
             bool canLinkCrowd = false;
             if (SelectedCrowdMember.Members != null && !targetCrowd.IsCrowdNestedWithinContainerCrowd(SelectedCrowdMember))
             {
                 canLinkCrowd = true;
             }
             else
             {
                 canLinkCrowd = true;
             }
             if (canLinkCrowd)
             {
                 if (!targetCrowd.ContainsMember(this.SelectedCrowdMember))
                 {
                     // Link
                     this.CrowdClipboard.LinkToClipboard(this.SelectedCrowdMember);
                     this.CrowdClipboard.PasteFromClipboard(targetCrowd);
                 }
                 else
                 {
                     // Clone
                     this.CrowdClipboard.CopyToClipboard(this.SelectedCrowdMember);
                     CrowdMember pastedMember = this.CrowdClipboard.PasteFromClipboard(targetCrowd);
                     OnEditNeeded(pastedMember, new CustomEventArgs <string>()
                     {
                         Value = "EditAfterDragDrop"
                     });
                 }
             }
         }
     }
     if (targetCrowd != null)
     {
         OnExpansionUpdateNeeded(targetCrowd, new CustomEventArgs <ExpansionUpdateEvent> {
             Value = ExpansionUpdateEvent.DragDrop
         });
     }
     this.LockTreeUpdate(false);
 }