Inheritance: System.EventArgs
コード例 #1
0
        private void OnOpenUrl(object sender, DynamicMenuEventArgs e)
        {
            if (e == null)
            {
                Debug.Assert(false); return;
            }

            OpenWithItem it = (e.Tag as OpenWithItem);

            if (it == null)
            {
                Debug.Assert(false); return;
            }

            PwEntry[] v = Program.MainForm.GetSelectedEntries();
            if (v == null)
            {
                Debug.Assert(false); return;
            }

            foreach (PwEntry pe in v)
            {
                string strUrl = pe.Strings.ReadSafe(PwDefs.UrlField);
                if (string.IsNullOrEmpty(strUrl))
                {
                    continue;
                }

                WinUtil.OpenUrlWithApp(strUrl, pe, it.FilePath);
            }
        }
コード例 #2
0
        private void OnOpenUrl(object sender, DynamicMenuEventArgs e)
        {
            if (e == null)
            {
                Debug.Assert(false); return;
            }

            OpenWithItem it = (e.Tag as OpenWithItem);

            if (it == null)
            {
                Debug.Assert(false); return;
            }

            string strApp = it.FilePath;

            PwEntry[] v = Program.MainForm.GetSelectedEntries();
            if (v == null)
            {
                Debug.Assert(false); return;
            }

            foreach (PwEntry pe in v)
            {
                // Get the entry's URL, avoid URL override
                string strUrl = pe.Strings.ReadSafe(PwDefs.UrlField);
                if (string.IsNullOrEmpty(strUrl))
                {
                    continue;
                }

                if (it.FilePathType == OwFilePathType.Executable)
                {
                    WinUtil.OpenUrlWithApp(strUrl, pe, strApp);
                }
                else if (it.FilePathType == OwFilePathType.ShellExpand)
                {
                    string str = strApp.Replace(PlhTargetUri,
                                                SprEncoding.EncodeForCommandLine(strUrl));
                    WinUtil.OpenUrl(str, pe, false);
                }
                else
                {
                    Debug.Assert(false);
                }
            }
        }
コード例 #3
0
        private void OnMenuClick(object sender, EventArgs e)
        {
            ToolStripItem tsi = (sender as ToolStripItem);

            Debug.Assert(tsi != null); if (tsi == null)
            {
                return;
            }

            string strText = tsi.Text;

            Debug.Assert(strText != null); if (strText == null)
            {
                return;
            }

            DynamicMenuEventArgs args = new DynamicMenuEventArgs(strText, tsi.Tag);

            if (this.MenuClick != null)
            {
                this.MenuClick(sender, args);
            }
        }
コード例 #4
0
        private void OnProfilesDynamicMenuClick(object sender, DynamicMenuEventArgs e)
        {
            PwProfile pwp = null;
            if (e.ItemName == DeriveFromPrevious) {
                pwp = PwProfile.DeriveFromPassword(new ProtectedString(true, current_password_field.ToUtf8()));
            }
            else {
                foreach (PwProfile pwgo in Program.Config.PasswordGenerator.UserProfiles) {
                    if (pwgo.Name == e.ItemName) {
                        pwp = pwgo;
                        break;
                    }
                }
            }

            if (pwp != null) {
                ProtectedString psNew;

                PwGenerator.Generate(out psNew, pwp, null, m_host.PwGeneratorPool);
                current_password_field.SetPassword(psNew.ReadUtf8());
                current_password_confirm_field.SetPassword(psNew.ReadUtf8());

            }
            else { Debug.Assert(false); }
        }
コード例 #5
0
        private void OnEntryBinaryView(object sender, DynamicMenuEventArgs e)
        {
            PwEntry pe = GetSelectedEntry(false);
            if(pe == null) { Debug.Assert(false); return; }

            ProtectedBinary pbData = pe.Binaries.Get(e.ItemName);
            if(pbData == null) { Debug.Assert(false); return; }

            DataViewerForm dvf = new DataViewerForm();
            dvf.InitEx(e.ItemName, pbData.ReadData());

            dvf.ShowDialog();
        }
コード例 #6
0
        private void OnOpenUrl(object sender, DynamicMenuEventArgs e)
        {
            if(e == null) { Debug.Assert(false); return; }

            OpenWithItem it = (e.Tag as OpenWithItem);
            if(it == null) { Debug.Assert(false); return; }

            PwEntry[] v = Program.MainForm.GetSelectedEntries();
            if(v == null) { Debug.Assert(false); return; }

            foreach(PwEntry pe in v)
            {
                string strUrl = pe.Strings.ReadSafe(PwDefs.UrlField);
                if(string.IsNullOrEmpty(strUrl)) continue;

                WinUtil.OpenUrlWithApp(strUrl, pe, it.FilePath);
            }
        }
コード例 #7
0
		private void OnEntryMoveToGroup(object sender, DynamicMenuEventArgs e)
		{
			PwGroup pgTo = (e.Tag as PwGroup);
			if(pgTo == null) { Debug.Assert(false); return; }

			m_pgActiveAtDragStart = GetSelectedGroup();
			MoveOrCopySelectedEntries(pgTo, DragDropEffects.Move);
		}
コード例 #8
0
		private void OnAddEntryTag(object sender, DynamicMenuEventArgs e)
		{
			string strTag = (e.Tag as string);
			if(strTag == null) { Debug.Assert(false); return; }

			if(strTag.Length == 0)
			{
				SingleLineEditForm dlg = new SingleLineEditForm();
				dlg.InitEx(KPRes.TagNew, KPRes.TagAddNew, KPRes.Name + ":",
					Properties.Resources.B48x48_KMag, string.Empty, null);

				if(UIUtil.ShowDialogNotValue(dlg, DialogResult.OK)) return;
				strTag = dlg.ResultString;
				UIUtil.DestroyForm(dlg);
			}

			if(!string.IsNullOrEmpty(strTag))
				AddOrRemoveTagsToFromSelectedEntries(strTag, true);
		}
コード例 #9
0
		private void OnEntryBinaryOpen(object sender, DynamicMenuEventArgs e)
		{
			if(e == null) { Debug.Assert(false); return; }

			EntryBinaryDataContext ctx = (e.Tag as EntryBinaryDataContext);
			if(ctx == null) { Debug.Assert(false); return; }

			PwEntry pe = ctx.Entry;
			if(pe == null) { Debug.Assert(false); return; }
			Debug.Assert(object.ReferenceEquals(pe, GetSelectedEntry(false)));

			if(string.IsNullOrEmpty(ctx.Name)) { Debug.Assert(false); return; }
			ProtectedBinary pb = pe.Binaries.Get(ctx.Name);
			if(pb == null) { Debug.Assert(false); return; }

			ProtectedBinary pbMod = BinaryDataUtil.Open(ctx.Name, pb, ctx.Options);
			if(pbMod != null)
			{
				pe.Binaries.Set(ctx.Name, pbMod);
				pe.Touch(true, false);

				RefreshEntriesList();
				UpdateUIState(true);
			}
		}
コード例 #10
0
ファイル: MainForm_Functions.cs プロジェクト: elitak/keepass
        private void OnCopyCustomString(object sender, DynamicMenuEventArgs e)
        {
            PwEntry pe = GetSelectedEntry(false);
            if(pe == null) return;

            if(ClipboardUtil.CopyAndMinimize(pe.Strings.GetSafe(e.ItemName), true,
                this, pe, m_docMgr.ActiveDatabase))
                StartClipboardCountdown();
        }
コード例 #11
0
ファイル: MainForm_Functions.cs プロジェクト: elitak/keepass
 private void ExecuteBinaryEditView(string strBinName, ProtectedBinary pb)
 {
     BinaryDataClass bdc = BinaryDataClassifier.Classify(strBinName,
         pb.ReadData());
     DynamicMenuEventArgs args = new DynamicMenuEventArgs(strBinName,
         DataEditorForm.SupportsDataType(bdc) ?
         new EditableBinaryAttachment(strBinName) : null);
     OnEntryBinaryView(null, args);
 }
コード例 #12
0
        void m_dynCustomStrings_MenuClick(object sender, DynamicMenuEventArgs e)
        {
            PwEntry pe = m_host.MainWindow.GetSelectedEntry(false);
            if (pe == null) return;

            if (ClipboardUtil.CopyAndMinimize(pe.Strings.ReadSafe((string)e.Tag), true, m_host.MainWindow, pe, m_host.Database))
                m_host.MainWindow.StartClipboardCountdown();
        }
コード例 #13
0
ファイル: PwEntryForm.cs プロジェクト: amiryal/keepass2
        private void OnProfilesDynamicMenuClick(object sender, DynamicMenuEventArgs e)
        {
            PwProfile pwp = null;
            if(e.ItemName == DeriveFromPrevious)
            {
                byte[] pbCur = m_secPassword.ToUtf8();
                ProtectedString psCur = new ProtectedString(true, pbCur);
                Array.Clear(pbCur, 0, pbCur.Length);
                pwp = PwProfile.DeriveFromPassword(psCur);
            }
            else
            {
                foreach(PwProfile pwgo in Program.Config.PasswordGenerator.UserProfiles)
                {
                    if(pwgo.Name == e.ItemName)
                    {
                        pwp = pwgo;
                        break;
                    }
                }
            }

            if(pwp != null)
            {
                ProtectedString psNew = new ProtectedString(true);
                PwGenerator.Generate(psNew, pwp, null, Program.PwGeneratorPool);
                byte[] pbNew = psNew.ReadUtf8();
                m_secPassword.SetPassword(pbNew);
                m_secRepeat.SetPassword(pbNew);
                Array.Clear(pbNew, 0, pbNew.Length);
            }
            else { Debug.Assert(false); }
        }
コード例 #14
0
		public void OnShowQRCode(object sender, DynamicMenuEventArgs e)
		{
			var key = e.Tag as string;
			if (key == null)
			{
				return;
			}

			var pe = host.MainWindow.GetSelectedEntry(true);
			if (pe == null)
			{
				return;
			}

			var context = new SprContext(pe, host.Database, SprCompileFlags.All);
			var value = SprEngine.Compile(pe.Strings.GetSafe(key).ReadString(), context);

			try
			{
				var data = new QRCodeGenerator().CreateQrCode(value, QRCodeGenerator.ECCLevel.L);
				if (data != null)
				{
					var form = new ShowQRCodeForm(
						host,
						data.GetBitmap(10, Color.Black, Color.White),
						SprEngine.Compile(pe.Strings.GetSafe(PwDefs.TitleField).ReadString(), context),
						TryTranslateKey(key)
					);
					form.ShowDialog();
				}
			}
			catch
			{
				MessageBox.Show("The data can't be displayed as a QR Code.");
			}
		}
コード例 #15
0
		private void ExecuteBinaryOpen(PwEntry pe, string strBinName)
		{
			EntryBinaryDataContext ctx = new EntryBinaryDataContext();
			ctx.Entry = pe;
			ctx.Name = strBinName;

			DynamicMenuEventArgs args = new DynamicMenuEventArgs(strBinName, ctx);
			OnEntryBinaryOpen(null, args);
		}
コード例 #16
0
		private void OnCopyCustomString(object sender, DynamicMenuEventArgs e)
		{
			string strKey = (e.Tag as string);
			if(strKey == null) { Debug.Assert(false); return; }

			PwEntry pe = GetSelectedEntry(false);
			if(pe == null) { Debug.Assert(false); return; }

			if(ClipboardUtil.CopyAndMinimize(pe.Strings.GetSafe(strKey), true,
				this, pe, m_docMgr.ActiveDatabase))
				StartClipboardCountdown();
		}
コード例 #17
0
ファイル: MainForm_Functions.cs プロジェクト: elitak/keepass
        private void OnEntryBinaryView(object sender, DynamicMenuEventArgs e)
        {
            PwEntry pe = GetSelectedEntry(false);
            if(pe == null) { Debug.Assert(false); return; }

            EditableBinaryAttachment eba = (e.Tag as EditableBinaryAttachment);

            ProtectedBinary pbData = pe.Binaries.Get((eba != null) ? eba.Name :
                e.ItemName);
            if(pbData == null) { Debug.Assert(false); return; }

            if(eba == null) // Not editable
            {
                DataViewerForm dvf = new DataViewerForm();
                dvf.InitEx(e.ItemName, pbData.ReadData());
                UIUtil.ShowDialogAndDestroy(dvf);
            }
            else
            {
                DataEditorForm def = new DataEditorForm();
                def.InitEx(eba.Name, pbData.ReadData());
                def.ShowDialog();

                if(def.EditedBinaryData != null) // User changed the data
                {
                    pe.Binaries.Set(eba.Name, new ProtectedBinary(false,
                        def.EditedBinaryData));
                    pe.Touch(true, false);

                    RefreshEntriesList();
                    UpdateUIState(true);
                }
                UIUtil.DestroyForm(def);
            }
        }
コード例 #18
0
		private void OnShowEntriesByTag(object sender, DynamicMenuEventArgs e)
		{
			if(e == null) { Debug.Assert(false); return; }
			ShowEntriesByTag(e.Tag as string);
		}
コード例 #19
0
ファイル: MainForm_Functions.cs プロジェクト: elitak/keepass
        private void OnShowEntriesByTag(object sender, DynamicMenuEventArgs e)
        {
            string strTag = (e.Tag as string);
            if(strTag == null) { Debug.Assert(false); return; }
            if(strTag.Length == 0) return; // No assert

            PwDatabase pd = m_docMgr.ActiveDatabase;
            if((pd == null) || !pd.IsOpen) { Debug.Assert(false); return; }

            PwObjectList<PwEntry> vEntries = new PwObjectList<PwEntry>();
            pd.RootGroup.FindEntriesByTag(strTag, vEntries, true);

            PwGroup pgResults = new PwGroup(true, true);
            pgResults.IsVirtual = true;
            foreach(PwEntry pe in vEntries) pgResults.AddEntry(pe, false);

            UpdateUI(false, null, false, null, true, pgResults, false);
        }
コード例 #20
0
		private void OnRemoveEntryTag(object sender, DynamicMenuEventArgs e)
		{
			string strTag = (e.Tag as string);
			if(strTag == null) { Debug.Assert(false); return; }
			if(strTag.Length == 0) return;

			AddOrRemoveTagsToFromSelectedEntries(strTag, false);
		}
コード例 #21
0
ファイル: PwEntryForm.cs プロジェクト: rdealexb/keepass
        private void OnDynBinOpen(object sender, DynamicMenuEventArgs e)
        {
            if(e == null) { Debug.Assert(false); return; }

            BinaryDataOpenOptions opt = (e.Tag as BinaryDataOpenOptions);
            if(opt == null) { Debug.Assert(false); return; }

            OpenSelBin(opt);
        }
コード例 #22
0
ファイル: DynamicMenu.cs プロジェクト: haro-freezd/KeePass
        private void OnMenuClick(object sender, EventArgs e)
        {
            ToolStripItem tsi = (sender as ToolStripItem);
            Debug.Assert(tsi != null); if(tsi == null) return;

            string strText = tsi.Text;
            Debug.Assert(strText != null); if(strText == null) return;

            DynamicMenuEventArgs args = new DynamicMenuEventArgs(strText, tsi.Tag);
            if(this.MenuClick != null) this.MenuClick(sender, args);
        }
コード例 #23
0
ファイル: PwEntryForm.cs プロジェクト: rdealexb/keepass
        private void OnProfilesDynamicMenuClick(object sender, DynamicMenuEventArgs e)
        {
            string strProfile = (e.Tag as string);
            if(strProfile == null) { Debug.Assert(false); return; }

            PwProfile pwp = null;
            if(strProfile == DeriveFromPrevious)
            {
                byte[] pbCur = m_icgPassword.GetPasswordUtf8();
                ProtectedString psCur = new ProtectedString(true, pbCur);
                MemUtil.ZeroByteArray(pbCur);
                pwp = PwProfile.DeriveFromPassword(psCur);
            }
            else if(strProfile == AutoGenProfile)
                pwp = Program.Config.PasswordGenerator.AutoGeneratedPasswordsProfile;
            else
            {
                foreach(PwProfile pwgo in PwGeneratorUtil.GetAllProfiles(false))
                {
                    if(pwgo.Name == strProfile)
                    {
                        pwp = pwgo;
                        break;
                    }
                }
            }

            if(pwp != null)
            {
                ProtectedString psNew;
                PwGenerator.Generate(out psNew, pwp, null, Program.PwGeneratorPool);
                byte[] pbNew = psNew.ReadUtf8();
                m_icgPassword.SetPassword(pbNew, true);
                MemUtil.ZeroByteArray(pbNew);
            }
            else { Debug.Assert(false); }
        }
コード例 #24
0
ファイル: OpenWithMenu.cs プロジェクト: riking/go-keepass2
		private void OnOpenUrl(object sender, DynamicMenuEventArgs e)
		{
			if(e == null) { Debug.Assert(false); return; }

			OpenWithItem it = (e.Tag as OpenWithItem);
			if(it == null) { Debug.Assert(false); return; }

			string strApp = it.FilePath;

			PwEntry[] v = Program.MainForm.GetSelectedEntries();
			if(v == null) { Debug.Assert(false); return; }

			foreach(PwEntry pe in v)
			{
				string strUrl = pe.Strings.ReadSafe(PwDefs.UrlField);
				if(string.IsNullOrEmpty(strUrl)) continue;

				if(it.FilePathType == OwFilePathType.Executable)
					WinUtil.OpenUrlWithApp(strUrl, pe, strApp);
				else if(it.FilePathType == OwFilePathType.ShellExpand)
				{
					string str = strApp.Replace(PlhTargetUri, strUrl);
					WinUtil.OpenUrl(str, pe, false);
				}
				else { Debug.Assert(false); }
			}
		}
コード例 #25
0
        private void OnCopyCustomString(object sender, DynamicMenuEventArgs e)
        {
            PwEntry pe = GetSelectedEntry(false);
            if(pe == null) return;

            ClipboardUtil.CopyAndMinimize(pe.Strings.ReadSafe(e.ItemName), true,
                Program.Config.MainWindow.MinimizeAfterClipboardCopy ?
                this : null, pe, m_docMgr.ActiveDatabase);
            StartClipboardCountdown();
        }