Inheritance: KeePass.Util.CancellableOperationEventArgs
コード例 #1
0
		private void PerformDefaultAction(object sender, EventArgs e, PwEntry pe,
			int colID)
		{
			Debug.Assert(pe != null); if(pe == null) return;

			if(this.DefaultEntryAction != null)
			{
				CancelEntryEventArgs args = new CancelEntryEventArgs(pe, colID);
				this.DefaultEntryAction(sender, args);
				if(args.Cancel) return;
			}

			bool bCnt = false;

			AceColumn col = GetAceColumn(colID);
			AceColumnType colType = col.Type;
			switch(colType)
			{
				case AceColumnType.Title:
					if(PwDefs.IsTanEntry(pe)) OnEntryCopyPassword(sender, e);
					else OnEntryEdit(sender, e);
					break;
				case AceColumnType.UserName:
					OnEntryCopyUserName(sender, e);
					break;
				case AceColumnType.Password:
					OnEntryCopyPassword(sender, e);
					break;
				case AceColumnType.Url:
					PerformDefaultUrlAction(null, false);
					break;
				case AceColumnType.Notes:
					bCnt = ClipboardUtil.CopyAndMinimize(pe.Strings.GetSafe(
						PwDefs.NotesField), true, this, pe, m_docMgr.ActiveDatabase);
					break;
				case AceColumnType.CreationTime:
					bCnt = ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString(
						pe.CreationTime), true, this, pe, null);
					break;
				case AceColumnType.LastModificationTime:
					bCnt = ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString(
						pe.LastModificationTime), true, this, pe, null);
					break;
				case AceColumnType.LastAccessTime:
					bCnt = ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString(
						pe.LastAccessTime), true, this, pe, null);
					break;
				case AceColumnType.ExpiryTime:
					if(pe.Expires)
						bCnt = ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString(
							pe.ExpiryTime), true, this, pe, null);
					else
						bCnt = ClipboardUtil.CopyAndMinimize(m_strNeverExpiresText,
							true, this, pe, null);
					break;
				case AceColumnType.Attachment:
				case AceColumnType.AttachmentCount:
					PerformDefaultAttachmentAction();
					break;
				case AceColumnType.Uuid:
					bCnt = ClipboardUtil.CopyAndMinimize(pe.Uuid.ToHexString(),
						true, this, pe, null);
					break;
				case AceColumnType.CustomString:
					bCnt = ClipboardUtil.CopyAndMinimize(pe.Strings.ReadSafe(
						col.CustomName), true, this, pe, m_docMgr.ActiveDatabase);
					break;
				case AceColumnType.PluginExt:
					if(Program.ColumnProviderPool.SupportsCellAction(col.CustomName))
						Program.ColumnProviderPool.PerformCellAction(col.CustomName, pe);
					else
						bCnt = ClipboardUtil.CopyAndMinimize(
							Program.ColumnProviderPool.GetCellData(col.CustomName, pe),
							true, this, pe, m_docMgr.ActiveDatabase);
					break;
				case AceColumnType.OverrideUrl:
					bCnt = ClipboardUtil.CopyAndMinimize(pe.OverrideUrl,
						true, this, pe, null);
					break;
				case AceColumnType.Tags:
					bCnt = ClipboardUtil.CopyAndMinimize(StrUtil.TagsToString(pe.Tags, true),
						true, this, pe, null);
					break;
				case AceColumnType.ExpiryTimeDateOnly:
					if(pe.Expires)
						bCnt = ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayStringDateOnly(
							pe.ExpiryTime), true, this, pe, null);
					else
						bCnt = ClipboardUtil.CopyAndMinimize(m_strNeverExpiresText,
							true, this, pe, null);
					break;
				case AceColumnType.Size:
					bCnt = ClipboardUtil.CopyAndMinimize(StrUtil.FormatDataSizeKB(
						pe.GetSize()), true, this, pe, null);
					break;
				case AceColumnType.HistoryCount:
					EditSelectedEntry(true);
					break;
				default:
					Debug.Assert(false);
					break;
			}

			if(bCnt) StartClipboardCountdown();
		}
コード例 #2
0
        private void PerformDefaultAction(object sender, EventArgs e, PwEntry pe, AppDefs.ColumnId colID)
        {
            Debug.Assert(pe != null); if(pe == null) return;

            if(this.DefaultEntryAction != null)
            {
                CancelEntryEventArgs args = new CancelEntryEventArgs(pe, colID);
                this.DefaultEntryAction(sender, args);
                if(args.Cancel) return;
            }

            bool bMinimize = Program.Config.MainWindow.MinimizeAfterClipboardCopy;
            Form frmMin = (bMinimize ? this : null);

            switch(colID)
            {
                case AppDefs.ColumnId.Title:
                    if(PwDefs.IsTanEntry(pe))
                        OnEntryCopyPassword(sender, e);
                    else
                        OnEntryEdit(sender, e);
                    break;
                case AppDefs.ColumnId.UserName:
                    OnEntryCopyUserName(sender, e);
                    break;
                case AppDefs.ColumnId.Password:
                    OnEntryCopyPassword(sender, e);
                    break;
                case AppDefs.ColumnId.Url:
                    OnEntryOpenUrl(sender, e);
                    break;
                case AppDefs.ColumnId.Notes:
                    ClipboardUtil.CopyAndMinimize(pe.Strings.ReadSafe(PwDefs.NotesField),
                        true, frmMin, pe, m_docMgr.ActiveDatabase);
                    StartClipboardCountdown();
                    break;
                case AppDefs.ColumnId.CreationTime:
                    ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString(pe.CreationTime),
                        true, frmMin, null, null);
                    StartClipboardCountdown();
                    break;
                case AppDefs.ColumnId.LastAccessTime:
                    ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString(pe.LastAccessTime),
                        true, frmMin, null, null);
                    StartClipboardCountdown();
                    break;
                case AppDefs.ColumnId.LastModificationTime:
                    ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString(pe.LastModificationTime),
                        true, frmMin, null, null);
                    StartClipboardCountdown();
                    break;
                case AppDefs.ColumnId.ExpiryTime:
                    if(pe.Expires)
                        ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString(pe.ExpiryTime),
                            true, frmMin, null, null);
                    else
                        ClipboardUtil.CopyAndMinimize(KPRes.NeverExpires,
                            true, frmMin, null, null);
                    StartClipboardCountdown();
                    break;
                case AppDefs.ColumnId.Attachment:
                    break;
                case AppDefs.ColumnId.Uuid:
                    ClipboardUtil.CopyAndMinimize(pe.Uuid.ToHexString(),
                        true, frmMin, null, null);
                    StartClipboardCountdown();
                    break;
                default:
                    Debug.Assert(false);
                    break;
            }
        }