58
60
base.OnMouseHover(e);
63
/* protected override void OnKeyUp(KeyEventArgs e)
66
UnfocusGroupInSingleMode();
68
private void UnfocusGroupInSingleMode()
72
if(!WinUtil.IsAtLeastWindowsVista) return;
73
if(KeePassLib.Native.NativeLib.IsUnix()) return;
74
if(!this.ShowGroups) return;
75
if(this.MultiSelect) return;
77
const uint m = (NativeMethods.LVGS_FOCUSED | NativeMethods.LVGS_SELECTED);
79
uint uGroups = (uint)this.Groups.Count;
80
for(uint u = 0; u < uGroups; ++u)
83
if(NativeMethods.GetGroupStateByIndex(this, u, m,
86
NativeMethods.SetGroupState(this, iGroupID, m,
87
NativeMethods.LVGS_SELECTED);
92
catch(Exception) { Debug.Assert(false); }
95
protected override void OnKeyDown(KeyEventArgs e)
97
try { if(SkipGroupHeaderIfRequired(e)) return; }
98
catch(Exception) { Debug.Assert(false); }
103
private bool SkipGroupHeaderIfRequired(KeyEventArgs e)
105
if(!this.ShowGroups) return false;
106
if(this.MultiSelect) return false;
108
ListViewItem lvi = this.FocusedItem;
111
ListViewGroup g = lvi.Group;
112
ListViewItem lviChangeTo = null;
114
if((e.KeyCode == Keys.Up) && IsFirstLastItemInGroup(g, lvi, true))
115
lviChangeTo = (GetNextLvi(g, true) ?? lvi); // '??' for top item
116
else if((e.KeyCode == Keys.Down) && IsFirstLastItemInGroup(g, lvi, false))
117
lviChangeTo = (GetNextLvi(g, false) ?? lvi); // '??' for bottom item
119
if(lviChangeTo != null)
121
foreach(ListViewItem lviEnum in this.Items)
122
lviEnum.Selected = false;
124
lviChangeTo.Selected = true;
125
lviChangeTo.Focused = true;
126
EnsureVisible(lviChangeTo.Index);
136
private static bool IsFirstLastItemInGroup(ListViewGroup g,
137
ListViewItem lvi, bool bFirst)
139
if(g == null) { Debug.Assert(false); return false; }
141
ListViewItemCollection c = g.Items;
142
if(c.Count == 0) { Debug.Assert(false); return false; }
144
return (bFirst ? (c[0] == lvi) : (c[c.Count - 1] == lvi));
147
private ListViewItem GetNextLvi(ListViewGroup gBaseExcl, bool bUp)
149
if(gBaseExcl == null) { Debug.Assert(false); return null; }
151
int i = this.Groups.IndexOf(gBaseExcl);
152
if(i < 0) { Debug.Assert(false); return null; }
159
ListViewGroup g = this.Groups[i];
160
if(g.Items.Count > 0) return g.Items[g.Items.Count - 1];
168
int nGroups = this.Groups.Count;
171
ListViewGroup g = this.Groups[i];
172
if(g.Items.Count > 0) return g.Items[0];