private void OnAutoTypeFormShown(object sender, EventArgs e) { AutoTypeCtxForm f = sender as AutoTypeCtxForm; ListView lv = Tools.GetControl("m_lvItems", f) as ListView; PluginDebug.AddInfo("Auto-Type entry selection window shown", 0); if ((lv != null) && (lv.Items.Count == 0) && !Program.Config.Integration.AutoTypeAlwaysShowSelDialog) { PluginDebug.AddInfo("Auto-Type Entry Selection window closed", 0, "Reason: No entries to display"); f.Close(); return; } if ((lv != null) && (lv.Items.Count == 1) && !Program.Config.Integration.AutoTypeAlwaysShowSelDialog) { lv.Items[0].Selected = true; try { MethodInfo miPIS = f.GetType().GetMethod("ProcessItemSelection", BindingFlags.NonPublic | BindingFlags.Instance); miPIS.Invoke(f, null); PluginDebug.AddInfo("Auto-Type Entry Selection window closed", 0, "Reason: Only one entry to be shown"); } catch (Exception ex) { PluginDebug.AddError("Auto-Type Entry Selection window NOT closed", 0, "Reason: Could not process entry", "Details: " + ex.Message); } return; } }
private void OnAutoTypeFormShown(object sender, EventArgs e) { ListView lv = Tools.GetControl("m_lvItems", m_AT) as ListView; PluginDebug.AddInfo("Auto-Type entry selection window shown", 0); if ((lv != null) && (lv.Items.Count == 0) && !KeePass.Program.Config.Integration.AutoTypeAlwaysShowSelDialog) { PluginDebug.AddInfo("Auto-Type Entry Selection window closed", 0, "Reason: No entries to display"); m_AT.Close(); return; } if ((lv != null) && (lv.Items.Count == 1) && !KeePass.Program.Config.Integration.AutoTypeAlwaysShowSelDialog) { lv.Items[0].Selected = true; System.Reflection.MethodInfo miPIS = m_AT.GetType().GetMethod("ProcessItemSelection", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); try { miPIS.Invoke(m_AT, null); PluginDebug.AddInfo("Auto-Type Entry Selection window closed", 0, "Reason: Only one entry to be shown"); } catch (Exception ex) { PluginDebug.AddError("Auto-Type Entry Selection window NOT closed", 0, "Reason: Could not process entry", "Details: " + ex.Message); } return; } if (!Config.AddDBColumn && !Config.ColumnsSortable && !Config.SpecialColumns) { return; } try { if (Config.ColumnsSortable) { lv.HeaderStyle = ColumnHeaderStyle.Clickable; //Recreate groups to ensure the first group is shown correct in case KeeTheme is installed List <ListViewGroup> lvg = new List <ListViewGroup>(); foreach (ListViewGroup g in lv.Groups) { lvg.Add(g); } lv.Groups.Clear(); foreach (ListViewGroup g in lvg) { lv.Groups.Add(g); } lv.ColumnClick += SortColumns; Button bTools = (Button)Tools.GetControl("m_btnTools", m_AT); if (bTools != null) { CheckBox cbShowGroups = new CheckBox(); cbShowGroups.Name = "cbAAT_ShowGroups"; cbShowGroups.Checked = Config.ColumnsRememberSorting && Config.ColumnsSortGrouping; cbShowGroups.Text = PluginTranslate.AATFormShowGroups; cbShowGroups.AutoSize = true; m_AT.Controls.Add(cbShowGroups); bTools.Parent.Controls.Add(cbShowGroups); cbShowGroups.Top = bTools.Bottom - cbShowGroups.Height; cbShowGroups.Left = bTools.Left + bTools.Width + 5; cbShowGroups.CheckedChanged += AutoTypeForm_ShowGroups_CheckedChanged; } int s = (int)Config.ColumnsSortColumn; if (Config.ColumnsRememberSorting && (s != 0) && (Math.Abs(s) <= lv.Columns.Count)) { SortColumns(lv, new ColumnClickEventArgs(Math.Abs(s) - 1)); if (((s > 0) && (m_SortOrder != SortOrder.Ascending)) || ((s < 0) && (m_SortOrder != SortOrder.Descending))) { SortColumns(lv, new ColumnClickEventArgs(Math.Abs(s) - 1)); } } } if (Config.SpecialColumns && !KeePassLib.Native.NativeLib.IsUnix()) { lv.MouseClick += CellClick; lv.ColumnWidthChanged += HandleColumns; HandleColumns(lv, null); } if (Config.AddDBColumn) { List <AutoTypeCtx> lEntries = (List <AutoTypeCtx>)Tools.GetField("m_lCtxs", m_AT); string db1 = lEntries[0].Database.IOConnectionInfo.Path; foreach (AutoTypeCtx entry in lEntries) { if (entry.Database.IOConnectionInfo.Path != db1) { m_DBColumnVisible = true; if (!Config.SpecialColumns) { lv.ColumnWidthChanged += HandleColumns; } HandleColumns(lv, null); Button btnTools = (Button)Tools.GetField("m_btnTools", m_AT); btnTools.Click += OnColumnMenuOpening; break; } } } } catch (Exception) { } }