Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/04/09 17:31:38 (15 years ago)
Author:
aleitner
Message:

Drag'n'Drop for changing group for client (#626)

Location:
trunk/sources/HeuristicLab.Hive.Server.Console/3.2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerManagementConsole.Designer.cs

    r1956 r2007  
    3333      this.jobToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    3434      this.groupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     35      this.projectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    3536      this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    3637      this.largeIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     
    8788      this.tcManagementConsole = new System.Windows.Forms.TabControl();
    8889      this.checkBox1 = new System.Windows.Forms.CheckBox();
    89       this.projectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    9090      this.menuStrip1.SuspendLayout();
    9191      this.plClientDetails.SuspendLayout();
     
    174174      this.groupToolStripMenuItem.Click += new System.EventHandler(this.groupToolStripMenuItem_Click);
    175175      //
     176      // projectToolStripMenuItem
     177      //
     178      this.projectToolStripMenuItem.Name = "projectToolStripMenuItem";
     179      this.projectToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P)));
     180      this.projectToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
     181      this.projectToolStripMenuItem.Text = "Project";
     182      this.projectToolStripMenuItem.Click += new System.EventHandler(this.projectToolStripMenuItem_Click);
     183      //
    176184      // viewToolStripMenuItem
    177185      //
     
    637645      this.tvClientControl.Size = new System.Drawing.Size(151, 357);
    638646      this.tvClientControl.TabIndex = 0;
     647      this.tvClientControl.DragLeave += new System.EventHandler(this.tvClientControl_DragLeave);
    639648      this.tvClientControl.MouseUp += new System.Windows.Forms.MouseEventHandler(this.tvClientControl_MouseUp);
    640649      this.tvClientControl.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.tvClientControl_NodeMouseClick);
     
    667676      this.lvClientControl.LargeImageList = this.ilLargeImgClient;
    668677      this.lvClientControl.Location = new System.Drawing.Point(0, 0);
    669       this.lvClientControl.MultiSelect = false;
    670678      this.lvClientControl.Name = "lvClientControl";
    671679      this.lvClientControl.Size = new System.Drawing.Size(299, 386);
     
    695703      this.checkBox1.Text = "checkBox1";
    696704      this.checkBox1.UseVisualStyleBackColor = true;
    697       //
    698       // projectToolStripMenuItem
    699       //
    700       this.projectToolStripMenuItem.Name = "projectToolStripMenuItem";
    701       this.projectToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P)));
    702       this.projectToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
    703       this.projectToolStripMenuItem.Text = "Project";
    704       this.projectToolStripMenuItem.Click += new System.EventHandler(this.projectToolStripMenuItem_Click);
    705705      //
    706706      // HiveServerManagementConsole
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerManagementConsole.cs

    r1956 r2007  
    5656    private ClientInfo currentClient = null;
    5757
    58     private TreeNode currentNode = null;
     58    private TreeNode currentGroupNode = null;
    5959    Guid parentgroup = Guid.Empty;
    6060    private ToolTip tt = new ToolTip();
     
    8080    }
    8181
     82    private TreeNode hoverNode; // node being hovered over during DnD
    8283    private void Init() {
    8384
     
    113114        IClientManager clientManager = ServiceLocator.GetClientManager();
    114115        if (tvClientControl.SelectedNode != null) {
    115           //  Delete Group
     116          Response resp = clientManager.DeleteClientGroup(((ClientGroup)tvClientControl.SelectedNode.Tag).Id);
     117          if (tvClientControl.SelectedNode == currentGroupNode) {
     118            currentGroupNode = null;
     119          }
     120          tvClientControl.Nodes.Remove(tvClientControl.SelectedNode);
     121          AddClients();
    116122        }
    117123      };
     124
     125      lvClientControl.ItemDrag += delegate(object sender, ItemDragEventArgs e) {
     126        List<string> itemIDs = new List<string>((sender as ListView).SelectedItems.Count);
     127        foreach (ListViewItem item in (sender as ListView).SelectedItems) {
     128          itemIDs.Add(item.Name);
     129        }
     130        (sender as ListView).DoDragDrop(itemIDs.ToArray(), DragDropEffects.Move);
     131      };
     132
     133      tvClientControl.DragEnter += delegate(object sender, DragEventArgs e) {
     134        e.Effect = DragDropEffects.Move;
     135      };
     136
     137      tvClientControl.DragOver += delegate(object sender, DragEventArgs e) {
     138        Point mouseLocation = tvClientControl.PointToClient(new Point(e.X, e.Y));
     139        TreeNode node = tvClientControl.GetNodeAt(mouseLocation);
     140        if (node != null && ((ClientGroup)node.Tag).Id != Guid.Empty) {
     141          e.Effect = DragDropEffects.Move;
     142          if (hoverNode == null) {
     143            node.BackColor = Color.LightBlue;
     144            node.ForeColor = Color.White;
     145            hoverNode = node;
     146          } else if (hoverNode != node) {
     147            hoverNode.BackColor = Color.White;
     148            hoverNode.ForeColor = Color.Black;
     149            node.BackColor = Color.LightBlue;
     150            node.ForeColor = Color.White;
     151            hoverNode = node;
     152          }
     153        } else {
     154          e.Effect = DragDropEffects.None;
     155        }
     156      };
     157
     158      tvClientControl.DragDrop += delegate(object sender, DragEventArgs e) {
     159        if (e.Data.GetDataPresent(typeof(string[]))) {
     160          Point dropLocation = (sender as TreeView).PointToClient(new Point(e.X, e.Y));
     161          TreeNode dropNode = (sender as TreeView).GetNodeAt(dropLocation);
     162          if (((ClientGroup)dropNode.Tag).Id != Guid.Empty) {
     163            List<ClientInfo> clients = new List<ClientInfo>();
     164            foreach (ListViewItem lvi in lvClientControl.SelectedItems) {
     165              clients.Add((ClientInfo)lvi.Tag);
     166            }
     167            ChangeGroup(clients, ((ClientGroup)dropNode.Tag).Id);
     168          }
     169          tvClientControl_DragLeave(null, EventArgs.Empty);
     170          AddClients();
     171        }
     172      };
     173    }
     174
     175    private void ChangeGroup(List<ClientInfo> clients, Guid clientgroupID) {
     176      IClientManager clientManager = ServiceLocator.GetClientManager();
     177      Guid groupId = ((ClientGroup)currentGroupNode.Tag).Id;
     178      foreach (ClientInfo client in clients) {
     179        if (groupId != Guid.Empty) {
     180          Response resp = clientManager.DeleteResourceFromGroup(groupId, client.Id);
     181        }
     182        clientManager.AddResourceToGroup(clientgroupID, client);
     183      }
    118184    }
    119185
     
    181247
    182248    }
    183    
     249
    184250    #endregion
    185251
     
    254320      }
    255321
    256       if (currentNode != null) {
     322      if (currentGroupNode != null) {
    257323        lvClientControl.Items.Clear();
    258324        lvClientControl.Groups.Clear();
    259         AddGroupsToListView(currentNode);
     325        AddGroupsToListView(currentGroupNode);
    260326      }
    261327      tvClientControl.ExpandAll();
     
    443509      }
    444510    }
    445    
     511
    446512
    447513    private void RefreshForm() {
     
    570636      lvClientControl.Items.Clear();
    571637      lvClientControl.Groups.Clear();
    572       currentNode = e.Node;
     638      currentGroupNode = e.Node;
    573639      AddGroupsToListView(e.Node);
    574640    }
     
    602668      tvClientControl.SelectedNode = hitTestInfo.Node;
    603669      if (e.Button != MouseButtons.Right) return;
    604         if (hitTestInfo.Node != null) {
    605           Resource selectedGroup = (Resource)tvClientControl.SelectedNode.Tag;
    606 
    607           if (selectedGroup != null) {
    608             contextMenuGroup.Items.Add(menuItemAddGroup);
    609             contextMenuGroup.Items.Add(menuItemDeleteGroup);
    610           }
    611         } else {
     670      if (hitTestInfo.Node != null) {
     671        Resource selectedGroup = (Resource)tvClientControl.SelectedNode.Tag;
     672
     673        if (selectedGroup != null) {
    612674          contextMenuGroup.Items.Add(menuItemAddGroup);
    613         }
    614         tvClientControl.ContextMenuStrip.Show(tvClientControl, new Point(e.X, e.Y));
     675          contextMenuGroup.Items.Add(menuItemDeleteGroup);
     676        }
     677      } else {
     678        contextMenuGroup.Items.Add(menuItemAddGroup);
     679      }
     680      tvClientControl.ContextMenuStrip.Show(tvClientControl, new Point(e.X, e.Y));
    615681    }
    616682
     
    636702        ClientGroup cg = new ClientGroup() { Name = name };
    637703        clientManager.AddClientGroup(cg);
    638         AddClients();
    639       }
     704      }
     705      AddClients();
    640706    }
    641707
     
    688754      smallIconsToolStripMenuItem.CheckState = CheckState.Unchecked;
    689755      listToolStripMenuItem.CheckState = CheckState.Checked;
     756    }
     757
     758    private void tvClientControl_DragLeave(object sender, EventArgs e) {
     759      foreach (TreeNode node in tvClientControl.Nodes) {
     760        node.BackColor = Color.White;
     761        node.ForeColor = Color.Black;
     762      }
    690763    }
    691764    #endregion
     
    798871    #endregion
    799872
     873
     874
    800875  }
    801876}
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerManagementConsole.resx

    r1956 r2007  
    398398</value>
    399399  </data>
     400  <metadata name="updaterWoker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     401    <value>388, 41</value>
     402  </metadata>
    400403  <metadata name="contextMenuJob.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    401404    <value>246, 40</value>
     
    452455</value>
    453456  </data>
    454   <metadata name="updaterWoker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    455     <value>388, 41</value>
    456   </metadata>
    457457</root>
Note: See TracChangeset for help on using the changeset viewer.