1 /* 2 KeePass Password Safe - The Open-Source Password Manager 3 Copyright (C) 2003-2021 Dominik Reichl <dominik.reichl@t-online.de> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 using System; 21 using System.Collections.Generic; 22 using System.ComponentModel; 23 using System.Diagnostics; 24 using System.Drawing; 25 using System.Text; 26 using System.Windows.Forms; 27 28 using KeePass.App; 29 using KeePass.Ecas; 30 using KeePass.Resources; 31 using KeePass.UI; 32 33 using KeePassLib; 34 using KeePassLib.Utility; 35 36 namespace KeePass.Forms 37 { 38 public partial class EcasActionForm : Form 39 { 40 private EcasAction m_actionInOut = null; 41 private EcasAction m_action = null; // Working copy 42 43 private bool m_bBlockTypeSelectionHandler = false; 44 InitEx(EcasAction e)45 public void InitEx(EcasAction e) 46 { 47 m_actionInOut = e; 48 m_action = e.CloneDeep(); 49 } 50 EcasActionForm()51 public EcasActionForm() 52 { 53 InitializeComponent(); 54 GlobalWindowManager.InitializeForm(this); 55 } 56 OnFormLoad(object sender, EventArgs e)57 private void OnFormLoad(object sender, EventArgs e) 58 { 59 GlobalWindowManager.AddWindow(this); 60 61 this.Text = KPRes.Action; 62 this.Icon = AppIcons.Default; 63 64 Debug.Assert(!m_lblParamHint.AutoSize); // For RTL support 65 m_lblParamHint.Text = KPRes.ParamDescHelp; 66 67 foreach(EcasActionProvider ap in Program.EcasPool.ActionProviders) 68 { 69 foreach(EcasActionType t in ap.Actions) 70 m_cmbActions.Items.Add(t.Name); 71 } 72 73 UpdateDataEx(m_action, false, EcasTypeDxMode.Selection); 74 } 75 OnFormClosed(object sender, FormClosedEventArgs e)76 private void OnFormClosed(object sender, FormClosedEventArgs e) 77 { 78 GlobalWindowManager.RemoveWindow(this); 79 } 80 UpdateDataEx(EcasAction a, bool bGuiToInternal, EcasTypeDxMode dxType)81 private bool UpdateDataEx(EcasAction a, bool bGuiToInternal, 82 EcasTypeDxMode dxType) 83 { 84 m_bBlockTypeSelectionHandler = true; 85 bool bResult = EcasUtil.UpdateDialog(EcasObjectType.Action, m_cmbActions, 86 m_dgvParams, a, bGuiToInternal, dxType); 87 m_bBlockTypeSelectionHandler = false; 88 return bResult; 89 } 90 OnBtnOK(object sender, EventArgs e)91 private void OnBtnOK(object sender, EventArgs e) 92 { 93 if(!UpdateDataEx(m_actionInOut, true, EcasTypeDxMode.Selection)) 94 this.DialogResult = DialogResult.None; 95 } 96 OnBtnCancel(object sender, EventArgs e)97 private void OnBtnCancel(object sender, EventArgs e) 98 { 99 } 100 OnActionsSelectedIndexChanged(object sender, EventArgs e)101 private void OnActionsSelectedIndexChanged(object sender, EventArgs e) 102 { 103 if(m_bBlockTypeSelectionHandler) return; 104 105 UpdateDataEx(m_action, true, EcasTypeDxMode.ParamsTag); 106 UpdateDataEx(m_action, false, EcasTypeDxMode.None); 107 } 108 OnBtnHelp(object sender, EventArgs e)109 private void OnBtnHelp(object sender, EventArgs e) 110 { 111 AppHelp.ShowHelp(AppDefs.HelpTopics.Triggers, AppDefs.HelpTopics.TriggersActions); 112 } 113 } 114 } 115