Beispiel #1
0
 private void windowList_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         windowControl.Show(windowList, e.Location);
         selected = windowList.HitTest(e.X, e.Y);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Handling double mouse click for changing MetaData info of the loaded data columns
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListView1_MouseDoubleClick(object sender, forms.MouseEventArgs e)
        {
            forms.ListViewHitTestInfo info = listView1.HitTest(X, Y);
            var row     = info.Item.Index;
            var col     = info.Item.SubItems.IndexOf(info.SubItem);
            var colType = listView1.Items[3].SubItems[col];

            li = info.Item;
            subItemSelected = col;
            //only first and second Row process the mouse input
            if (li == null || row > 3 || row < 1 || col < 1)
            {
                return;
            }

            forms.ComboBox combo = null;
            if (row == 1)
            {
                combo = cmbBox1;
            }
            else if (row == 2)
            {
                combo = cmbBox2;
            }
            else if (row == 3)
            {
                combo = cmbBox3;
            }
            else
            {
                combo = cmbBox1;
            }

            var subItm = li.SubItems[col];

            if (combo != null)
            {
                combo.Bounds = subItm.Bounds;
                combo.Show();
                combo.Text = subItm.Text;
                combo.SelectAll();
                combo.Focus();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Create a OlvListViewHitTestInfo
        /// </summary>
        /// <param name="hti"></param>
        public OlvListViewHitTestInfo(ListViewHitTestInfo hti) {
            this.item = (OLVListItem)hti.Item;
            this.subItem = (OLVListSubItem)hti.SubItem;
            this.location = hti.Location;

            switch (hti.Location) {
            case ListViewHitTestLocations.StateImage:
                this.HitTestLocation = HitTestLocation.CheckBox;
                break;
            case ListViewHitTestLocations.Image:
                this.HitTestLocation = HitTestLocation.Image;
                break;
            case ListViewHitTestLocations.Label:
                this.HitTestLocation = HitTestLocation.Text;
                break;
            default:
                this.HitTestLocation = HitTestLocation.Nothing;
                break;
            }
        }
Beispiel #4
0
        // Select the item at the mouse X/Y and store it, show control menus at that X/Y.
        private void zombieListView_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                selected = zombieListView.HitTest(e.X, e.Y);
                if (selected.Item != null)
                    if (selected.Item.ForeColor != Color.Gray)
                        clientControl.Show(zombieListView, e.Location);
                    else if (selected.Item.ForeColor == Color.Gray)
                        removeControl.Show(zombieListView, e.Location);
                    else
                    {

                    }
            }
        }
        private void CreateNormalMenu(Point ptInvoke, ListViewHitTestInfo hitTest, MouseEventArgs e)
        {
            hitTest.Item.Selected = true;

            #region Fields

            ShellItem item = (ShellItem)hitTest.Item.Tag;

            int offset = br.FileView.SelectedOrder.Contains(hitTest.Item) ? 0 : 1;
            IntPtr[] pidls = new IntPtr[br.FileView.SelectedOrder.Count + offset];

            if (offset == 1)
                pidls[0] = item.PIDLRel.Ptr;

            for (int i = offset; i < pidls.Length; i++)
            {
                pidls[i] = ((ShellItem)((ListViewItem)br.FileView.SelectedOrder[i - offset]).Tag).PIDLRel.Ptr;
            }

            IntPtr contextMenu = IntPtr.Zero,
                iContextMenuPtr = IntPtr.Zero,
                iContextMenuPtr2 = IntPtr.Zero,
                iContextMenuPtr3 = IntPtr.Zero;
            IShellFolder parentShellFolder =
                (item.ParentItem != null) ? item.ParentItem.ShellFolder : item.ShellFolder;

            #endregion

            #region Show / Invoke

            try
            {
                if (ContextMenuHelper.GetIContextMenu(parentShellFolder, pidls, out iContextMenuPtr, out iContextMenu))
                {
                    contextMenu = ShellAPI.CreatePopupMenu();
                    iContextMenu.QueryContextMenu(
                        contextMenu,
                        0,
                        ShellAPI.CMD_FIRST,
                        ShellAPI.CMD_LAST,
                        ShellAPI.CMF.EXPLORE |
                        ShellAPI.CMF.CANRENAME |
                        ((Control.ModifierKeys & Keys.Shift) != 0 ? ShellAPI.CMF.EXTENDEDVERBS : 0));

                    Marshal.QueryInterface(iContextMenuPtr, ref ShellAPI.IID_IContextMenu2, out iContextMenuPtr2);
                    Marshal.QueryInterface(iContextMenuPtr, ref ShellAPI.IID_IContextMenu3, out iContextMenuPtr3);

                    try
                    {
                        iContextMenu2 =
                            (IContextMenu2)Marshal.GetTypedObjectForIUnknown(iContextMenuPtr2, typeof(IContextMenu2));

                        iContextMenu3 =
                            (IContextMenu3)Marshal.GetTypedObjectForIUnknown(iContextMenuPtr3, typeof(IContextMenu3));
                    }
                    catch (Exception) { }

                    uint selected = ShellAPI.TrackPopupMenuEx(
                                        contextMenu,
                                        ShellAPI.TPM.RETURNCMD,
                                        ptInvoke.X,
                                        ptInvoke.Y,
                                        this.Handle,
                                        IntPtr.Zero);

                    br.OnContextMenuMouseHover(new ContextMenuMouseHoverEventArgs(string.Empty));

                    if (selected >= ShellAPI.CMD_FIRST)
                    {
                        string command = ContextMenuHelper.GetCommandString(iContextMenu, selected - ShellAPI.CMD_FIRST, true);

                        if (command == "Explore" && br.FolderView.SelectedNode != null)
                        {
                            if (!br.FolderView.SelectedNode.IsExpanded)
                                br.FolderView.SelectedNode.Expand();

                            br.FolderView.SelectedNode = br.FolderView.SelectedNode.Nodes[hitTest.Item.Text];
                        }
                        else if (command == "rename")
                        {
                            hitTest.Item.BeginEdit();
                        }
                        else
                        {
                            ContextMenuHelper.InvokeCommand(
                                iContextMenu,
                                selected - ShellAPI.CMD_FIRST,
                                ShellItem.GetRealPath(br.SelectedItem),
                                ptInvoke);
                        }
                    }
                }
            }
            #endregion
            catch (Exception) { }
            #region Finally
            finally
            {
                if (iContextMenu != null)
                {
                    Marshal.ReleaseComObject(iContextMenu);
                    iContextMenu = null;
                }

                if (iContextMenu2 != null)
                {
                    Marshal.ReleaseComObject(iContextMenu2);
                    iContextMenu2 = null;
                }

                if (iContextMenu3 != null)
                {
                    Marshal.ReleaseComObject(iContextMenu3);
                    iContextMenu3 = null;
                }

                if (contextMenu != null)
                    ShellAPI.DestroyMenu(contextMenu);

                if (iContextMenuPtr != IntPtr.Zero)
                    Marshal.Release(iContextMenuPtr);

                if (iContextMenuPtr2 != IntPtr.Zero)
                    Marshal.Release(iContextMenuPtr2);

                if (iContextMenuPtr3 != IntPtr.Zero)
                    Marshal.Release(iContextMenuPtr3);
            }
            #endregion
        }
Beispiel #6
0
 private void listView_sensitiveData_MouseMove(object sender, MouseEventArgs e)
 {
     pointedItem = listView_sensitiveData.GetItemAt(e.X, e.Y);
     pointedItemInfo = listView_sensitiveData.HitTest(e.X, e.Y);
 }
Beispiel #7
0
 private void listView_MouseUp(object sender, MouseEventArgs e)
 {
     m_lastHitTest = null;
     listView.Invalidate();
 }
Beispiel #8
0
 private void listView_MouseDown(object sender, MouseEventArgs e)
 {
     Point mousePos = listView.PointToClient(Control.MousePosition);
     m_lastHitTest = listView.HitTest(mousePos);
     listView.Invalidate();
 }
        private void taskListHit(ListViewHitTestInfo hit)
        {
            ListViewItem.ListViewSubItem subItem = hit.SubItem;

            if (hit.Item.Tag == null)
            {
                hit.Item.Tag = false;
            }

            //当点击的是任务的选择列时,弹出编辑任务信息弹窗
            if ((hit.Item.SubItems[0] == subItem || hit.Item.SubItems[6] == subItem) && !(bool)hit.Item.Tag)
            {
                hit.Item.Tag = true;
                editTask(hit.Item);
            }
            else {
                hit.Item.Tag = false;
            }
        }
Beispiel #10
0
        private void bugListHit(ListViewHitTestInfo hit)
        {
            ListViewItem.ListViewSubItem subItem = hit.SubItem;

            //任务已解决
            if (hit.Item.SubItems[3] == subItem)
            {
                BugInfo bug = queryBugById(hit.Item.SubItems[1].Text);
                bug.isDone = (bool)subItem.Tag;

                //绘制复选框
                drawCheckBox(bugList, subItem, (bool)subItem.Tag);
            }

            if (hit.Item.Tag == null)
            {
                hit.Item.Tag = false;
            }

            hit.Item.Tag = !(bool)hit.Item.Tag;

            hit.Item.Checked = (bool)hit.Item.Tag;
        }
Beispiel #11
0
 private void listView1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         loc = listView1.HitTest(e.Location);
         if (loc.Item != null)
         {
             if (loc.Item != null) contextMenuStrip1.Show(listView1, e.Location);
         }
     }
 }
Beispiel #12
0
        private void EditListViewItem(ListViewHitTestInfo item)
        {
            if (item == null || item.SubItem == null)
              {
            return;
              }

              TextBox tbxEdit = new TextBox();
              tbxEdit.Parent = listView1;
              tbxEdit.Tag = item;	// Store clicked item
              tbxEdit.Location = new Point(item.SubItem.Bounds.Location.X, item.SubItem.Bounds.Location.Y - 1);
              tbxEdit.AutoSize = false;
              tbxEdit.Height = item.Item.Bounds.Height + 1;
              tbxEdit.Width = item.SubItem.Bounds.Width + 1;
              tbxEdit.BorderStyle = BorderStyle.FixedSingle;
              tbxEdit.KeyDown += new KeyEventHandler(tbxEdit_KeyDown);
              tbxEdit.LostFocus += new EventHandler(tbxEdit_LostFocus);
              tbxEdit.Text = item.SubItem.Text;
              tbxEdit.CreateControl();
              tbxEdit.Focus();
        }
Beispiel #13
0
        void listView1_SA_edit_search_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            hitInfo = listView1_SA_edit_search.HitTest(e.X, e.Y);

            if (hitInfo.Item.SubItems.IndexOf(hitInfo.SubItem) != 1 & hitInfo.Item.SubItems.IndexOf(hitInfo.SubItem) != 2)
            {
                editBox.Bounds = hitInfo.SubItem.Bounds;
                editBox.Text = hitInfo.SubItem.Text;
                editBox.Focus();
                editBox.Show();
            }
        }
 /// <summary>
 /// Override the HitTest method, cause on Mono, this method throw an exception if the location
 /// is outside of the client area
 /// </summary>
 /// <param name="location">where you want to test</param>
 /// <returns>the hit test result</returns>
 public new ListViewHitTestInfo HitTest(Point location)
 {
     ListViewHitTestInfo result = null;
     try
     {
         result = base.HitTest(location);
     }
     catch
     {
         result = new ListViewHitTestInfo(null, null, ListViewHitTestLocations.None);
     }
     return result;
 }