Esempio n. 1
0
        private void mFieldsGrid_CellRightClick(object sender, CellRightClickEventArgs e)
        {
            var rowObject = (FieldsListView.RowObject)e.Model;

            if (rowObject == null || rowObject.IsInsertionRow)
            {
                mURLDropDown.Visible              = false;
                mCopyCommand.Enabled              = false;
                mEditFieldCommand.Enabled         = false;
                mProtectFieldCommand.Enabled      = false;
                mPasswordGeneratorCommand.Enabled = false;
                mDeleteFieldCommand.Enabled       = false;
                mAddNewCommand.Enabled            = Entry != null;

                mProtectFieldCommand.Checked = false;
                mCopyCommand.Text            = String.Format(Properties.Resources.CopyCommand, Properties.Resources.Field);
            }
            else
            {
                var url = e.Item.SubItems.Count == 2 ? e.Item.GetSubItem(1).Url : null;
                mLastContextMenuUrl               = url;
                mURLDropDown.Visible              = url != null;
                mCopyCommand.Enabled              = true;
                mEditFieldCommand.Enabled         = true;
                mProtectFieldCommand.Enabled      = true;
                mPasswordGeneratorCommand.Enabled = true;
                mDeleteFieldCommand.Enabled       = true;
                mAddNewCommand.Enabled            = true;

                mProtectFieldCommand.Checked = rowObject.Value.IsProtected;
                mCopyCommand.Text            = String.Format(Properties.Resources.CopyCommand, rowObject.DisplayName);
            }
            e.MenuStrip = mFieldGridContextMenu;
            mFieldGridContextMenuTarget = mFieldsGrid;
        }
 public void EndDrag(object dragObject, System.Windows.Forms.DragDropEffects effect)
 {
     if (mFieldListView != null)
     {
         mFieldListView.IsDragging = false;
         mFieldListView.Cursor     = Cursors.Default;
         mFieldListView            = null;
     }
 }
            public string GetDisplayValue(FieldsListView listView)
            {
                if (Value == null)
                {
                    return(null);
                }

                if (!RevealValue && HideValue)
                {
                    return(PwDefs.HiddenPassword);
                }
                else
                {
                    return(listView.GetDisplayValue(Value, RevealValue));
                }
            }
            public object StartDrag(ObjectListView olv, System.Windows.Forms.MouseButtons button, OLVListItem item)
            {
                if (button == MouseButtons.Left)
                {
                    string dragText = null;
                    if (!KeePass.App.AppPolicy.Current.DragDrop)
                    {
                        dragText = KeePass.App.AppPolicy.RequiredPolicyMessage(KeePass.App.AppPolicyId.DragDrop);
                    }
                    else
                    {
                        var rowObject      = item.RowObject as RowObject;
                        var fieldsListView = olv as FieldsListView;
                        if (rowObject != null && fieldsListView != null)
                        {
                            dragText = fieldsListView.GetDragValue(rowObject);
                        }
                    }

                    if (!String.IsNullOrEmpty(dragText))
                    {
                        mFieldListView = olv as FieldsListView;
                        if (mFieldListView != null)
                        {
                            mFieldListView.IsDragging = true;
                        }

                        var dataObject = new DataObject();
                        dataObject.SetText(dragText);

                        return(dataObject);
                    }
                }

                return(null);
            }