Exemple #1
0
        private void contactList_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (draggingContact != null)
            {
                Point p = new Point(e.X, e.Y);
                p = contactList.PointToClient(p);

                TreeNode node = contactList.GetNodeAt(p.X, p.Y);

                if (node != null && node.Parent == null)
                {
                    ContactGroup group = node.Tag as ContactGroup;

                    if (draggingFromGroup != group)
                    {
                        if (draggingFromGroup != null)
                        {
                            draggingFromGroup.Remove(draggingContact);
                        }
                        if (group != null)
                        {
                            group.Add(draggingContact);
                        }
                    }

                    //node.Expand ();
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Custom Menu popup
        /// </summary>
        private void cmCustom_Popup(object sender, System.EventArgs e)
        {
            // Select the node first
            tCat.SelectedNode = tCat.GetNodeAt(tCat.PointToClient(Control.MousePosition));
            TreeNode node = tCat.SelectedNode;

            cmCustomCat.Enabled  = false;
            cmCustomItem.Enabled = false;
            cmCustomDel.Enabled  = false;

            if (node == null)
            {
                return;
            }

            cmCustomCat.Enabled = true;

            if (node.Parent != null)
            {
                if (tCat.Nodes.IndexOf(node.Parent) == 0)
                {
                    cmCustomItem.Enabled = true;
                    cmCustomDel.Enabled  = true;
                }
            }
        }
Exemple #3
0
 private new void MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         tvAsm.SelectedNode = tvAsm.GetNodeAt(e.X, e.Y);
     }
 }
Exemple #4
0
        private void treeView1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            NodeInfo curInfo;

            switch (e.Button)
            {
            case MouseButtons.Left:
                SelectedNode = treeView1.GetNodeAt(e.X, e.Y);
                break;

            case MouseButtons.Right:
                SelectedNode = treeView1.GetNodeAt(e.X, e.Y);
                if (SelectedNode != null)
                {
                    if (SelectedNode.Tag != null)
                    {
                        curInfo = (NodeInfo)SelectedNode.Tag;
                        if (curInfo.ContextMenu != null)
                        {
                            curInfo.ContextMenu.Show(treeView1, new Point(e.X + 10, e.Y));
                        }
                    }
                }
                break;

            default:
                break;
            }
        }
Exemple #5
0
        private void treeView1_DragEnter(object sender, DragEventArgs e)
        {
            Point    targetPoint = _tree.PointToClient(new Point(e.X, e.Y));
            TreeNode targetNode  = _tree.GetNodeAt(targetPoint);

            e.Effect = DragDropEffects.All;
        }
Exemple #6
0
        /// <summary>
        /// Event handler which is fired when the user selects to invite a member via the right-click context menu on the main tree.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItem8_Click(object sender, System.EventArgs e)
        {
            string memId = null;

            //get selected member via the mouse point
            memId = memberTree.GetNodeAt(mousePoint.X, mousePoint.Y).Text;
            ConversationMonitor cm = getFocusedConversationMonitor();

            if (cm != null)
            {
                cm.sendInvite(memId);                   //send invite if conversation monitor already exists
            }
            else                                        //notify user that a conversation must be in place
            {
                MessageBox.Show("You do not have any active conversations. You must start a conversation before inviting members.", "No conversation available", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
            }
//			else					//otherwise create a new conversation monitor
//			{
//				cm = new ConversationMonitor(this,ref facade);
//				currentConversations.Add(cm);
//				cm.Closing+=new CancelEventHandler(cm_Closing);
//				cm.Activated+=new EventHandler(cm_Activated);
//				cm.Show();
//				cm.sendInvite(memId);
//			}
        }
 private void OnListMouseUp(Object sender, MouseEventArgs e)
 {
     EditCandidateNode = null;
     if (e.Button == MouseButtons.Right)
     {
         EditCandidateNode = (TreeNode)TvList.GetNodeAt(e.X, e.Y);
     }
 }
Exemple #8
0
 /// <summary>
 /// Mouse down: do drag and drop
 /// </summary>
 private void tDeco_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         m_DragPoint = new Point(e.X, e.Y);
     }
     else if (e.Button == MouseButtons.Right)
     {
         tDeco.SelectedNode = tDeco.GetNodeAt(e.X, e.Y);
     }
 }
Exemple #9
0
        private void tvToolBox_Click(object sender, EventArgs e)
        {
            TreeNode tn = tvToolBox.GetNodeAt(this.PointToClient(MousePosition));

            if (tn.IsExpanded == true)
            {
                tn.Collapse();
            }
            else
            {
                tn.Expand();
            }
        }
        private void treeView1_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
        {
            // Retrieve the client coordinates of the mouse position.
            Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));

            // Select the node at the mouse position.
            treeView1.SelectedNode = treeView1.GetNodeAt(targetPoint);
            treeView1.Select();

            //Determine DragDrop Effects
            if ((e.KeyState & 4) == 4)             //Shift
            {
                e.Effect = DragDropEffects.Move;
            }
            else
            {
                if ((e.KeyState & 8) == 8)                 //Ctrl
                {
                    e.Effect = DragDropEffects.Copy;
                }
                else
                {
                    if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move)                     //Move by default;
                    {
                        e.Effect = DragDropEffects.Move;
                    }
                }
            }
        }
Exemple #11
0
 private void tvwCondition_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         tvwCondition.SelectedNode = tvwCondition.GetNodeAt(e.X, e.Y);
     }
 }
Exemple #12
0
 private void tvModel_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         tvModel_BeforeSelect(sender, new TreeViewCancelEventArgs(tvModel.GetNodeAt(e.X, e.Y), false, TreeViewAction.ByMouse));
     }
 }
Exemple #13
0
        private void treeView1_DoubleClick(object sender, System.EventArgs e)
        {
            Point    point1 = this.treeView1.PointToClient(Button.MousePosition);
            TreeNode node   = treeView1.GetNodeAt(point1);

            if (node != null)
            {
                if (node.Nodes.Count == 0)
                {
                    XmlElement element = node.Tag as XmlElement;
                    foreach (XmlNode xmlnode in element.ChildNodes)
                    {
                        if (xmlnode is ItopVector.Core.Figure.Symbol)
                        {
                            XmlElement element2 = xmlnode as XmlElement;
                            string     strid    = element2.GetAttribute("id");
                            if (strid == string.Empty)
                            {
                                strid = "未命名";
                            }
                            TreeNode node2 = new TreeNode(strid);
                            node2.Tag = element2;
                            node.Nodes.Add(node2);
                        }
                    }
                }
            }
        }
Exemple #14
0
        /// <summary>
        /// This method handles the <see cref="TreeView.DragDrop"/> event for a <see cref="TreeViewControl"/>.
        /// </summary>
        /// <param name="treeViewControl">The <see cref="TreeViewControl"/> to handle the <see cref="TreeView.DragDrop"/> event for.</param>
        /// <param name="treeView">The <see cref="TreeView"/> of the <see cref="TreeViewControl"/>.</param>
        /// <param name="e">The arguments of the <see cref="TreeView.DragDrop"/> event.</param>
        /// <param name="getTreeNodeInfoForData">A function for obtaining the <see cref="TreeNodeInfo"/> object corresponding to a provided data object.</param>
        public void HandleDragDrop(TreeViewControl treeViewControl, FormsTreeView treeView, DragEventArgs e, Func <object, TreeNodeInfo> getTreeNodeInfoForData)
        {
            RemovePlaceHolder(treeView);

            Point    point       = treeView.PointToClient(new Point(e.X, e.Y));
            TreeNode nodeOver    = treeView.GetNodeAt(point);
            TreeNode draggedNode = GetDraggedNodeData(e);

            if (nodeOver == null)
            {
                return;
            }

            SetDropAtLocation(e, draggedNode, nodeOver);

            TreeNodeInfo treeNodeInfo     = getTreeNodeInfoForData(nodeDropTarget.Tag);
            TreeNode     formerParentNode = draggedNode.Parent;

            // Move the tree node
            formerParentNode.Nodes.Remove(draggedNode);
            nodeDropTarget.Nodes.Insert(dropAtLocation, draggedNode);

            // Ensure the dragged node is visible afterwards
            draggedNode.EnsureVisible();

            // Restore any lost selection
            treeView.SelectedNode = draggedNode;

            treeNodeInfo.OnDrop?.Invoke(draggedNode.Tag, draggedNode.Parent.Tag, formerParentNode.Tag, dropAtLocation, treeViewControl);
        }
Exemple #15
0
        private void treeView1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            m_bStartedDragging = false;
            this.mouseDownLoc  = new EPoint(e.X, e.Y);
            XmlNode xmlNode = null;

            try
            {
                TreeNode node = treeView1.GetNodeAt(e.X, e.Y);
                if (node != null)
                {
                    xmlNode = (XmlNode)node.Tag;
                }
            }
            catch
            {
                return;
            }

            if (xmlNode == null)
            {
                return;
            }

            this.xmlNodeMouseDownOn = xmlNode;
            if (XmlNodeMouseDown != null)
            {
                XmlNodeMouseDown(this, xmlNode);
            }
        }
Exemple #16
0
        private void logTree_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                TreeNode clickedNode = logTree.GetNodeAt(new Point(e.X, e.Y));
                if (clickedNode != null)
                {
                    // store the right-clicked node (this sucks!!)
                    _rightClickedNode = clickedNode;

                    bool isMachineNode = (clickedNode.Parent == null);
                    connectToComputerMenuItem.Visible = isMachineNode;
                    openLogFileMenuItem.Visible       = true;
                    treeContextMenuSeparator1.Visible = !isMachineNode;
                    clearEventsMenuItem.Visible       = !isMachineNode;
                    refreshEntriesMenuItem.Visible    = !isMachineNode;
                    treeContextMenuSeparator2.Visible = !isMachineNode;
                    logPropertiesMenuItem.Visible     = !isMachineNode;
                    treeContextMenuSeparator3.Visible = true;
                    helpMenuItem.Visible = true;
                    treeContextMenu.Show(logTree, logTree.PointToClient(TreeView.MousePosition));
                }
                else
                {
                    foreach (MenuItem menuItem in treeContextMenu.MenuItems)
                    {
                        menuItem.Visible = false;
                    }
                }
            }
        }
Exemple #17
0
        private void mnuTree_Popup(object sender, System.EventArgs e)
        {
            // Get the node where the mouse is right now
            TreeNode node = tvwItems.GetNodeAt(tvwItems.PointToClient(Control.MousePosition));

            if (node == null)
            {
                return;
            }

            // Set this node as our selected node
            tvwItems.SelectedNode = node;
            if (node.Parent == null)
            {
                EnableSendUi(false, false);
                return;
            }

            if ((node.Nodes.Count == 0) && (node.Parent != offlineNode))
            {
                EnableSendUi(true, node.Nodes.Count == 0);
            }
            else
            {
                EnableSendUi(false, node.Nodes.Count == 0);
            }
        }
        private void deviceTree_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            TreeNode node = deviceTree.GetNodeAt(e.X, e.Y);

            if (node == null)
            {
                return;
            }
            deviceTree.SelectedNode = node;
            object infoObject = node.Tag;

            if (infoObject == null)
            {
                device           = null;
                okButton.Enabled = false;
                return;
            }
            if (infoObject.GetType() == typeof(UPnPDevice))
            {
                device           = (UPnPDevice)infoObject;
                okButton.Enabled = true;
            }
            else
            {
                device           = null;
                okButton.Enabled = false;
            }
        }
        /// <summary>
        /// Вычисляет место для вставки узла при перетаскивании
        /// </summary>
        /// <param name="tv">Дерево</param>
        /// <param name="x">Экранные координаты курсора</param>
        /// <param name="y">Экранные координаты курсора</param>
        /// <param name="NewParent">Узел, являющийся новым родителем</param>
        /// <param name="NewPos">Позиция среди подузлов этого родителя</param>
        public static void GetPositionToInsert(TreeView tv, TreeViewAdapter tva, int x, int y, out TreeNode NewParent, out int NewPos)
        {
            Point pt = tv.PointToClient(new Point(x, y));
            TreeNode DestinationNode = tv.GetNodeAt(pt);
            if (DestinationNode == null)
            {
                NewParent = null;
                NewPos = tv.Nodes.Count;
                return;
            }
            int kind;
            PointOfInterest pti = tva.GetPointByNode(DestinationNode);
            bool NestingAllowed = pti != null;
            int border = DestinationNode.Bounds.Height / 4;

            if (pt.Y <= (DestinationNode.Bounds.Top + border))
                kind = -1;  //верхняя четверть - перед узлом
            else if (pt.Y >= (DestinationNode.Bounds.Bottom - border))
            {
                if (!DestinationNode.IsExpanded)
                    kind = 1;   //нижняя четверть неразвернутого узла - после узла
                else
                    kind = 0;   //нижняя четверть развернутого узла - внутрь
            }
            else
                kind = 0;       //Иначе - внутрь

            if (kind == 0 && ! NestingAllowed)
                if (pt.Y <= (DestinationNode.Bounds.Top + 2*border))
                    kind = -1;  //если внутрь нельзя и верхняя половина - перед узлом
                else
                    kind = 1;   //Внутрь нельзя и нижняя половина - после узла

            if (kind == -1)
            {
                //Перед узлом
                NewParent = DestinationNode.Parent;
                if (NewParent == null)
                    NewPos = tv.Nodes.IndexOf(DestinationNode);
                else
                    NewPos = DestinationNode.Parent.Nodes.IndexOf(DestinationNode);
            }
            else if (kind == 1)
            {
                //После узла
                NewParent = DestinationNode.Parent;
                if (NewParent == null)
                    NewPos = tv.Nodes.IndexOf(DestinationNode) + 1;
                else
                    NewPos = DestinationNode.Parent.Nodes.IndexOf(DestinationNode) + 1;
            }
            else
            {
                //Внутрь узла
                NewParent = DestinationNode;
                NewPos = DestinationNode.Nodes.Count;
            }

        }
Exemple #20
0
 private void treeView_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         System.Windows.Forms.TreeView tv = (System.Windows.Forms.TreeView)sender;
         tv.SelectedNode = tv.GetNodeAt(e.Location);
     }
 }
Exemple #21
0
 private void tvwModel_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     tvwModel.SelectedNode = tvwModel.GetNodeAt(e.X, e.Y);
     if (e.Button == MouseButtons.Right)
     {
         PopUps pu = new PopUps(ref sc, ref this.tvwModel, ref this.ctxMenu, e);
     }
 }
Exemple #22
0
// <snippet1>
        private void treeView1_MouseDown(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
            // Remove the TreeNode under the mouse cursor
            // if the right mouse button was clicked.
            case MouseButtons.Right:
                treeView1.GetNodeAt(e.X, e.Y).Remove();
                break;

            // Toggle the TreeNode under the mouse cursor
            // if the middle mouse button (mouse wheel) was clicked.
            case MouseButtons.Middle:
                treeView1.GetNodeAt(e.X, e.Y).Toggle();
                break;
            }
        }
Exemple #23
0
        private void tImg_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            tImg.SelectedNode = tImg.GetNodeAt(e.X, e.Y);

            if (tImg.SelectedNode == null)
            {
                return;
            }

            if (e.Button == MouseButtons.Left && e.Clicks == 1)
            {
                m_DragStart = new Point(e.X, e.Y);
            }
            else if (e.Clicks == 2)
            {
                (tImg.SelectedNode.Tag as ImageInfo).Open();
            }
        }
Exemple #24
0
        // Second pass
        private void TreeDragOver(object sender, DragEventArgs e)
        {
            //Stop this from happening when over a node that
            //is not allowed to be dropped on
            TreeNode node = tvPics.GetNodeAt(tvPics.PointToClient
                                                 (new Point(e.X, e.Y)));

            if (node.Tag == null)
            {
                tvPics.Focus(); //Probelem with this is that it fires an event
                tvPics.SelectedNode = node;
                e.Effect            = DragDropEffects.All;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
Exemple #25
0
        /// <summary>
        /// Ensures that tree nodes are selected by right-click also.
        /// </summary>
        private void Tree_MouseDown(object sender, MouseEventArgs e)
        {
            TreeNode treeNode = Tree.GetNodeAt(e.X, e.Y);

            // Optimized to allow automatic conversion to VB.NET
            if (e.Button.Equals(MouseButtons.Right) && treeNode != null)
            {
                Tree.SelectedNode = treeNode;
            }
        }
        /// <summary>
        /// Updates the state of context menus based on the current selection.
        /// </summary>
        private void BrowseTV_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // ignore left button actions.
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            // selects the item that was right clicked on.
            TreeNode clickedNode = BrowseTV.GetNodeAt(e.X, e.Y);

            // no item clicked on - do nothing.
            if (clickedNode == null)
            {
                return;
            }

            // force selection to clicked node.
            BrowseTV.SelectedNode = clickedNode;

            // disable everything.
            PickMI.Enabled            = false;
            EditFiltersMI.Enabled     = false;
            RefreshMI.Enabled         = false;
            SetLoginMI.Enabled        = false;
            ConnectMI.Enabled         = false;
            DisconnectMI.Enabled      = false;
            ViewComplexTypeMI.Enabled = false;

            if (clickedNode == m_localNetwork || IsHostNode(clickedNode))
            {
                RefreshMI.Enabled  = true;
                SetLoginMI.Enabled = true;
                return;
            }

            if (IsServerNode(clickedNode))
            {
                PickMI.Enabled        = true;
                ConnectMI.Enabled     = !((TsCDaServer)clickedNode.Tag).IsConnected;
                DisconnectMI.Enabled  = ((TsCDaServer)clickedNode.Tag).IsConnected;
                EditFiltersMI.Enabled = true;
                RefreshMI.Enabled     = true;
                return;
            }

            if (IsBrowseElementNode(clickedNode))
            {
                PickMI.Enabled            = true;
                EditFiltersMI.Enabled     = true;
                RefreshMI.Enabled         = true;
                ViewComplexTypeMI.Enabled = (TsCCpxComplexTypeCache.GetComplexItem((TsCDaBrowseElement)clickedNode.Tag) != null);
                return;
            }
        }
        private void tvEquations_DoubleClick(object sender, System.EventArgs e)
        {
            try
            {
                FunctionNode FunctionNode = tvEquations.GetNodeAt(tvEquations.PointToClient(Cursor.Position)) as FunctionNode;

                _currentItem = null;

                if (FunctionNode != null)
                {
                    _currentItem             = (FunctionParameters)FunctionNode.Item;
                    tvEquations.SelectedNode = FunctionNode;
                    ItemAction(_currentItem, "Edit");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Can't get node tag. Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #28
0
 private void treeView1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if ((e.Button & MouseButtons.Left) == MouseButtons.Left && bMouseDown)
     {
         bMouseDown = false;
         //start drag group for re-grouping
         System.Drawing.Point pt = new System.Drawing.Point(e.X, e.Y);
         TableNode            nd = (TableNode)treeView1.GetNodeAt(pt);
         if (nd != null)
         {
             treeView1.SelectedNode = nd;
             dragData         = new clsDragTableData();
             dragData.objNode = nd;
             System.Windows.Forms.DragDropEffects ret = treeView1.DoDragDrop(dragData, System.Windows.Forms.DragDropEffects.All);
             if (ret == System.Windows.Forms.DragDropEffects.Move)
             {
             }
         }
     }
 }
        private void TVwPacketDetails_Click(object sender, System.EventArgs e)
        {
            TreeNode mNode;

            mNode = TVwPacketDetails.GetNodeAt(MouseX, MouseY);
            if (mNode == null)
            {
                return;
            }

            Function.HighlightText(RtxPacketData, mNode, ref StatusBar);
        }
Exemple #30
0
        private void treeView1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ListViewItem)))
            {
                ListViewItem item = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
                Point        pt   = new Point(e.X, e.Y);
                pt = this.PointToClient(pt);
//				treeView1.Select();
                TreeNode node = treeView1.GetNodeAt(pt);
                if (node == null)
                {
                    MessageBox.Show(this, "Not Found!");
                    return;
                }
                hbm.Department dep  = DepartmentData.GetDepartmentFromName(node.Text);
                hbm._User      user = UserData.GetUserFromUserID(item.Text);
                UserData.MoveToDep(user, dep);
                listView1.Items.Remove(item);
                MessageBox.Show(this, item.Text + dep.DepartmentName);
            }
        }
Exemple #31
0
        /// <summary>
        /// This method handles the <see cref="TreeView.DragOver"/> event for a <see cref="TreeViewControl"/>.
        /// </summary>
        /// <param name="treeView">The <see cref="TreeView"/> of the <see cref="TreeViewControl"/>.</param>
        /// <param name="e">The arguments of the <see cref="TreeView.DragOver"/> event.</param>
        /// <param name="getTreeNodeInfoForData">A function for obtaining the <see cref="TreeNodeInfo"/> object corresponding to a provided data object.</param>
        public void HandleDragOver(FormsTreeView treeView, DragEventArgs e, Func <object, TreeNodeInfo> getTreeNodeInfoForData)
        {
            if (lastDragOverPoint.X == e.X && lastDragOverPoint.Y == e.Y)
            {
                return;
            }

            lastDragOverPoint = new Point(e.X, e.Y);

            Point    point       = treeView.PointToClient(lastDragOverPoint);
            TreeNode nodeOver    = treeView.GetNodeAt(point);
            TreeNode draggedNode = GetDraggedNodeData(e);

            if (draggedNode == null || nodeOver == null || nodeOver == draggedNode || IsDropTargetChildOfDraggedNode(nodeOver, draggedNode))
            {
                RemovePlaceHolder(treeView);
                e.Effect = DragDropEffects.None;
                return;
            }

            ScrollIntoView(point, nodeOver, treeView);

            PlaceholderLocation placeholderLocation = GetPlaceHoldersLocation(treeView, draggedNode, nodeOver, getTreeNodeInfoForData);

            if (nodeDropTarget == null)
            {
                return;
            }

            TreeNodeInfo treeNodeInfo = getTreeNodeInfoForData(nodeDropTarget.Tag);
            bool         canDrop      = treeNodeInfo.CanDrop != null && treeNodeInfo.CanDrop(draggedNode.Tag, nodeDropTarget.Tag);

            e.Effect = canDrop ? DragDropEffects.Move : DragDropEffects.None;

            if (placeholderLocation == PlaceholderLocation.None)
            {
                RemovePlaceHolder(treeView);
                e.Effect = DragDropEffects.None;

                return;
            }

            if (canDrop)
            {
                CreatePlaceholder(treeView, nodeOver, placeholderLocation);
            }
            else
            {
                RemovePlaceHolder(treeView);

                e.Effect = DragDropEffects.None;
            }
        }
Exemple #32
0
 private void InitTreeView()
 {
     objTreeView = new TreeView();
     objTreeView.ShowLines = true;
     objTreeView.ShowNodeToolTips = true;
     objTreeView.ShowPlusMinus = true;
     objTreeView.ShowRootLines = true;
     objTreeView.ImageList = imgList;
     objTreeView.Dock = DockStyle.Fill;
     objTreeView.AllowDrop = true;
     objTreeView.DragDrop += new DragEventHandler(FileDragAndDropHandler.OnDragDrop);
     objTreeView.DragEnter += new DragEventHandler(FileDragAndDropHandler.OnDragEnter);
     objTreeView.MouseDown += delegate(object sender, MouseEventArgs e)
     {
         if (e.Button == MouseButtons.Right)
         {
             objTreeView.SelectedNode = objTreeView.GetNodeAt(e.X, e.Y);
         }
     };
     objTreeView.AfterSelect += new TreeViewEventHandler(OnAfterSelect);
     objTreeView.AfterExpand += new TreeViewEventHandler(OnAfterExpand);
 }
        private void TreeViewDragOver(TreeView treeView, DragEventArgs e)
        {
            if (insideTreeViewDragOver)
                return;

            insideTreeViewDragOver = true;

            try
            {
                Point pt = treeView.PointToClient(new Point(e.X, e.Y));

                int x = pt.X;
                int y = pt.Y;
                string data = "";
                bool doHilite = false;

                NodeBase overNode = (NodeBase)treeView.GetNodeAt(new Point(x, y));

                if (e.Data.GetDataPresent(typeof(string)))
                {
                    data = (string)e.Data.GetData(typeof(string));
                }

                if (data == null)
                    data = "";

                if (data.Length > 0)
                {
                    string header;
                    XmlNode payload = ParseDragData(data, out header);
                    if (header == "aspect")
                    {
                        if (overNode != null)
                        {
                            if (overNode is TypeNode)
                            {
                                doHilite = true;
                            }
                        }
                    }
                    if (header == "pointcut" || header == "interceptor")
                    {
                        if (overNode != null)
                        {
                            if (overNode is TypeNode)
                            {
                                doHilite = true;
                            }
                            if (overNode is MethodNode)
                            {
                                if (((MethodNode) overNode).CanBeProxied())
                                    doHilite = true;
                            }
                        }
                    }
                }

                if (doHilite)
                {
                    e.Effect = DragDropEffects.Copy;
                    TurnOnTreeDragHilite(overNode);
                }
                else
                    TurnOffTreeDragHilite();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                insideTreeViewDragOver = false;
            }
        }
Exemple #34
0
        public static TreeNode getTreeNodeAtDroppedOverPoint(TreeView tvTreeView, int iDroppedX, int iDroppedY)
        {
            Point pPointToString = tvTreeView.PointToScreen(tvTreeView.Location);

            int iAdjustedX = tvTreeView.Left + iDroppedX - pPointToString.X;
            int iAdjustedY = tvTreeView.Top + iDroppedY - pPointToString.Y;

            //PublicDI.log.info("x:{0} y:{1}   - {2}, {3}", x, y, tvCurrentFilters.Left, tvCurrentFilters.Top);
            return tvTreeView.GetNodeAt(iAdjustedX, iAdjustedY);
        }
        private void TreeViewDragDrop(TreeView treeView, System.Windows.Forms.DragEventArgs e)
        {
            Point pt = treeView.PointToClient(new Point(e.X, e.Y));

            int x = pt.X;
            int y = pt.Y;
            string data = "";

            ObjectTreeNode overNode = (ObjectTreeNode) treeView.GetNodeAt(new Point(x, y));

            if (e.Data.GetDataPresent(typeof(string)))
            {
                data = (string) e.Data.GetData(typeof(string));
            }

            if (data == null)
                data = "";

            if (data.Length > 0)
            {
                string header ;
                XmlNode payload = ParseDragData(data, out header);
                if (header == "object")
                {
                    object dropObject = GetDropObject(payload);
                    if (overNode != null)
                    {
                        if (overNode.PropertyMap != null)
                        {
                            if (dropObject != null)
                            {
                                IClassMap dropClassMap = Context.DomainMap.MustGetClassMap(dropObject.GetType() );
                                if (dropClassMap.IsSubClassOrThisClass(overNode.PropertyMap.GetReferencedClassMap()))
                                {
                                    if (overNode.PropertyMap.IsCollection)
                                    {
                                        IList list = (IList) Context.ObjectManager.GetPropertyValue(overNode.Obj,  overNode.PropertyMap.Name);
                                        list.Add(dropObject);
                                        Context.ObjectManager.SetPropertyValue(overNode.Obj,  overNode.PropertyMap.Name, list);
                                    }
                                    else
                                    {
                                        overNode.Obj.GetType().GetProperty(overNode.PropertyMap.Name).SetValue(overNode.Obj, dropObject, null);
                                    }
                                    RefreshAll();
                                }
                            }
                        }
                    }
                    else
                    {
                        if (dropObject != null)
                        {
                            OpenObject(dropObject);
                        }
                    }
                }
            }

            TurnOffTreeDragHilite();
        }
        private void TreeViewDragOver(TreeView treeView, System.Windows.Forms.DragEventArgs e)
        {
            if (insideTreeViewDragOver)
                return;

            insideTreeViewDragOver = true;

            try
            {
                Point pt = treeView.PointToClient(new Point(e.X, e.Y));

                int x = pt.X;
                int y = pt.Y;
                string data = "";
                bool doHilite = false;

                ObjectTreeNode overNode = (ObjectTreeNode) treeView.GetNodeAt(new Point(x, y));

                if (e.Data.GetDataPresent(typeof(string)))
                {
                    data = (string) e.Data.GetData(typeof(string));
                }

                if (data == null)
                    data = "";

                if (data.Length > 0)
                {
                    string header;
                    XmlNode payload = ParseDragData(data, out header);
                    if (header == "object")
                    {
                        if (overNode != null)
                        {
                            if (overNode.PropertyMap != null)
                            {
                                object dropObject = GetDropObject(payload);
                                IClassMap dropClassMap = Context.DomainMap.MustGetClassMap(dropObject.GetType() );
                                if (dropClassMap.IsSubClassOrThisClass(overNode.PropertyMap.GetReferencedClassMap()))
                                {
                                    doHilite = true ;
                                }
                            }
                        }
                    }
                }

                if (doHilite)
                {
                    e.Effect = DragDropEffects.Copy;
                    TurnOnTreeDragHilite(overNode);
                }
                else
                    TurnOffTreeDragHilite();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                insideTreeViewDragOver = false;
            }
        }
 public Smarttree(TreeView tView)
 {
     this.tViewCut = tView;
     root = tViewCut.GetNodeAt(0, 0);
 }
        private void TreeViewMouseUp(TreeView treeView, MouseEventArgs e)
        {
            TreeNode onNode = treeView.GetNodeAt(new Point(e.X, e.Y));

            if (onNode != null)
            {
                if (treeView.SelectedNode != onNode)
                    treeView.SelectedNode = onNode;

                if (e.Button == MouseButtons.Right)
                {
                    NodeBase nodeBase = onNode as NodeBase;
                    selected = nodeBase.Object;

                    if (onNode is AspectNode)
                        aspectContextMenuStrip.Show(treeView, new Point(e.X, e.Y));

                    if (onNode is AspectTargetNode)
                        aspectTargetContextMenuStrip.Show(treeView, new Point(e.X, e.Y));

                    if (onNode is MixinNode)
                        mixinContextMenuStrip.Show(treeView, new Point(e.X, e.Y));

                    if (onNode is PointcutNode)
                        pointcutContextMenuStrip.Show(treeView, new Point(e.X, e.Y));

                    if (onNode is PointcutTargetNode)
                        pointcutTargetContextMenuStrip.Show(treeView, new Point(e.X, e.Y));

                    if (onNode is InterceptorNode)
                        interceptorContextMenuStrip.Show(treeView, new Point(e.X, e.Y));

                    if (onNode is AssemblyNode)
                        assemblyContextMenuStrip.Show(treeView, new Point(e.X, e.Y));

                }
            }
            else
            {
                selected = null;
            }
        }
Exemple #39
0
        private void Drop(TreeView treeView, DragEventArgs e)
        {
            FileBrowser fileBrowser = ((FileBrowser)(((KryptonGroupBox)(((Panel)treeView.Parent).Parent)).Parent));

            TreeNode newNode;

            if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false))
            {
                Point pt = treeView.PointToClient(new Point(e.X, e.Y));
                TreeNode destinationNode = treeView.GetNodeAt(pt);
                newNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
                _PreviousNodeName = newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0];

                _SourcePath = newNode.FullPath;

                if (destinationNode.ImageIndex == 2)
                {
                    if (destinationNode.Parent.FullPath == newNode.Parent.FullPath)
                        _TargetPath = _SourcePath;
                    else if (File.Exists(destinationNode.Parent.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + ".xml"))
                        _TargetPath = destinationNode.Parent.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + "-COPY.xml";
                    else _TargetPath = destinationNode.Parent.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + ".xml";
                }

                else
                {
                    if (File.Exists(destinationNode.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + ".xml"))
                        _TargetPath = destinationNode.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + "-COPY.xml";
                    else _TargetPath = destinationNode.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + ".xml";
                }

                if (_TargetPath != _SourcePath)
                {
                    try
                    {
                        if (treeView.SelectedNode.ImageIndex == 2)
                        {
                            File.Move(_SourcePath, _TargetPath);

                            // Check if config in db exists, else add config
                            try
                            {
                                AnalyticsWebService.AnalyticsSoapClient session = new AnalyticsWebService.AnalyticsSoapClient();
                                int idConfig = session.Get_histo_id_config(_SourcePath);
                                if (idConfig == 0)
                                    session.Add_histo_config(_PreviousNodeName.Replace(".xml", ""), _SourcePath);
                                session.Close();
                            }
                            catch { }

                            // Update Config path in database
                            try
                            {
                                AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                                service.Update_histo_config_path(_SourcePath, _TargetPath);
                                service.Close();
                            }
                            catch { }
                        }
                        else if (treeView.SelectedNode.ImageIndex == 1)
                            Directory.Move(_SourcePath, _TargetPath.Replace(".xml", ""));
                    }
                    catch (Exception ex) { Console.WriteLine(ex); }
                }
            }

            fileBrowser.EditToolStripMenuItem.Enabled = false;
            EditToolStripButton.Enabled = false;
            fileBrowser.PopulateTreeView();
        }
        private void TreeViewMouseUp(TreeView treeView, System.Windows.Forms.MouseEventArgs e)
        {
            TreeNode onNode = treeView.GetNodeAt(new Point(e.X, e.Y));

            if (onNode != null)
            {
                if (treeView.SelectedNode != onNode)
                {
                    treeView.SelectedNode = onNode;
                }
            }

            if (e.Button == MouseButtons.Right)
            {
                contextMenuObjects.Clear() ;
                if (treeView.SelectedNode != null)
                {
                    contextMenuObjects.Add(treeView.SelectedNode);
                    ShowContextMenu(treeView, e.X, e.Y);
                }
            }
        }
        private void TreeViewDragDrop(TreeView treeView, DragEventArgs e)
        {
            Point pt = treeView.PointToClient(new Point(e.X, e.Y));

            int x = pt.X;
            int y = pt.Y;
            string data = "";

            NodeBase overNode = (NodeBase)treeView.GetNodeAt(new Point(x, y));

            if (e.Data.GetDataPresent(typeof(string)))
            {
                data = (string)e.Data.GetData(typeof(string));
            }

            if (data == null)
                data = "";

            if (data.Length > 0)
            {
                string header;
                XmlNode payload = ParseDragData(data, out header);
                if (header == "aspect")
                {
                    PresentationAspect dropAspect = GetDropAspect(payload);
                    if (overNode != null)
                    {
                        if (overNode is TypeNode)
                        {
                            if (dropAspect != null)
                            {
                                dropAspect.AddTypeTarget(((TypeNode)overNode).Type);
                                RefreshAll();
                            }
                        }
                    }
                }
                if (header == "pointcut")
                {
                    PresentationPointcut dropPointcut = GetDropPointcut(payload);
                    if (overNode != null)
                    {
                        if (overNode is TypeNode)
                        {
                            if (dropPointcut != null)
                            {
                                dropPointcut.AddTypeTarget(((TypeNode)overNode).Type);
                                RefreshAll();
                            }
                        }
                        if (overNode is MethodNode)
                        {
                            if (dropPointcut != null)
                            {
                                MethodNode methodNode = overNode as MethodNode;
                                if (methodNode.CanBeProxied())
                                {
                                    dropPointcut.AddMethodTarget(methodNode.MethodBase, methodNode.Type);
                                    RefreshAll();
                                }
                            }
                        }
                    }
                }
                if (header == "interceptor")
                {
                    PresentationInterceptor dropInterceptor = GetDropInterceptor(payload);
                    if (overNode != null)
                    {
                        if (overNode is TypeNode)
                        {
                            if (dropInterceptor != null)
                            {
                                dropInterceptor.AddTypeTarget(((TypeNode)overNode).Type);
                                RefreshAll();
                            }
                        }
                        if (overNode is MethodNode)
                        {
                            if (dropInterceptor != null)
                            {
                                MethodNode methodNode = overNode as MethodNode;
                                if (methodNode.CanBeProxied())
                                {
                                    dropInterceptor.AddMethodTarget(methodNode.MethodBase, methodNode.Type);
                                    RefreshAll();
                                }
                            }
                        }
                    }
                }
            }

            TurnOffTreeDragHilite();
        }
		private void favList_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
		{
			focusedTreeView = e.Node.TreeView;
			if (e.Button == MouseButtons.Right)
			{
				focusedTreeView.SelectedNode = focusedTreeView.GetNodeAt(e.X, e.Y);
				contextMenuStrip2.Show(focusedTreeView, e.Location);
			}
		}
Exemple #43
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Open a context menu at the right position on a tree view.
        /// </summary>
        /// <param name="tree">The tree view.</param>
        /// <param name="contextMenu">The context menu to display.</param>
        /// <param name="evt">The mouse event.</param>
        /// <param name="mousePoint">The position of the mouse.</param>
        //////////////////////////////////////////////////////////////////////////
        public static void ShowContext(TreeView treeView, ContextMenuStrip contextMenu, MouseEventArgs evt, Point mousePoint)
        {
            // Retrieve the node under the mouse
            treeView.SelectedNode = treeView.GetNodeAt(evt.X, evt.Y);

            if (treeView.SelectedNode != null)
            {
                // Show context menu at correct position
                contextMenu.Show(mousePoint);
            }
        }
 /// <summary>
 /// Возвращает номер курсора, который нужно показать в данной точке
 /// </summary>
 /// <param name="tv">TreeView, надо которым перемещается узел</param>
 /// <param name="node">Перемещаемый узел</param>
 /// <param name="x">Координаты курсора</param>
 /// <param name="y">Координаты курсора</param>
 /// <returns>-1 - обычный курсор, перемещать в эту точку нельзя
 /// 0 - курсор, указывающий на добавление нового уровня
 /// 1 - курсор, указывающий на добавление узла на том же уровне</returns>
 public static int GetCursorKind(TreeView tv, TreeViewAdapter tva, TreeNode node, int x, int y)
 {
     TreeNode Dst;
     int pos;
     CursorHelper.GetPositionToInsert(tv, tva, x, y, out Dst, out pos);
     if (!CursorHelper.NestingAllowed(node, Dst)// нельзя перемещать узел в своего же потомка
         || (Dst == node.Parent && (node.Index == pos || node.Index == pos - 1))// не надо двигать, если положение и так совпадет
         )
         return -1;
     if (Dst != null && Dst == tv.GetNodeAt(tv.PointToClient(new Point(x, y))))
         return 0;
     else
         return 1;
 }