[Mwinapi-commits] SF.net SVN: mwinapi:[96] trunk
Status: Beta
Brought to you by:
schierlm
From: <sch...@us...> - 2011-01-01 22:54:04
|
Revision: 96 http://mwinapi.svn.sourceforge.net/mwinapi/?rev=96&view=rev Author: schierlm Date: 2011-01-01 22:53:58 +0000 (Sat, 01 Jan 2011) Log Message: ----------- - add Highlight support for SystemAccessibleObject Modified Paths: -------------- trunk/ManagedWinapi/Properties/AssemblyInfo.cs trunk/ManagedWinapi/SystemAccessibleObject.cs trunk/Tools/AOExplorer/MainForm.cs trunk/Tools/AOExplorer/Properties/AssemblyInfo.cs trunk/Tools/WinternalExplorer/MainForm.cs trunk/Tools/WinternalExplorer/Properties/AssemblyInfo.cs Modified: trunk/ManagedWinapi/Properties/AssemblyInfo.cs =================================================================== --- trunk/ManagedWinapi/Properties/AssemblyInfo.cs 2010-11-18 17:12:00 UTC (rev 95) +++ trunk/ManagedWinapi/Properties/AssemblyInfo.cs 2011-01-01 22:53:58 UTC (rev 96) @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ManagedWinapi")] -[assembly: AssemblyCopyright("Copyright © 2005, 2006, 2007, 2008, 2009, 2010 Michael Schierl")] +[assembly: AssemblyCopyright("Copyright © 2005, 2006, 2007, 2008, 2009, 2010, 2011 Michael Schierl")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] Modified: trunk/ManagedWinapi/SystemAccessibleObject.cs =================================================================== --- trunk/ManagedWinapi/SystemAccessibleObject.cs 2010-11-18 17:12:00 UTC (rev 95) +++ trunk/ManagedWinapi/SystemAccessibleObject.cs 2011-01-01 22:53:58 UTC (rev 96) @@ -265,7 +265,14 @@ { get { - return iacc.get_accValue(childID); + try + { + return iacc.get_accValue(childID); + } + catch (COMException) + { + return null; + } } } @@ -276,7 +283,14 @@ { get { - return (int)iacc.get_accState(childID); + try + { + return (int)iacc.get_accState(childID); + } + catch (COMException) + { + return 0; + } } } @@ -462,6 +476,23 @@ } } + /// <summary> + /// Highlight the accessible object with a red border. + /// </summary> + public void Highlight() + { + Rectangle objectLocation = Location; + SystemWindow window = Window; + Rectangle windowLocation = window.Rectangle; + using (WindowDeviceContext windowDC = window.GetDeviceContext(false)) + { + using (Graphics g = windowDC.CreateGraphics()) + { + g.DrawRectangle(new Pen(Color.Red, 4), objectLocation.X - windowLocation.X, objectLocation.Y - windowLocation.Y, objectLocation.Width, objectLocation.Height); + } + } + } + #region Equals and HashCode /// @@ -489,22 +520,29 @@ { if (ia1.Equals(ia2)) return true; if (Marshal.GetIUnknownForObject(ia1) == Marshal.GetIUnknownForObject(ia2)) return true; - if (ia1.accChildCount != ia2.accChildCount) return false; - SystemAccessibleObject sa1 = new SystemAccessibleObject(ia1, 0); - SystemAccessibleObject sa2 = new SystemAccessibleObject(ia2, 0); - if (sa1.Window.HWnd != sa2.Window.HWnd) return false; - if (sa1.Location != sa2.Location) return false; - if (sa1.DefaultAction != sa2.DefaultAction) return false; - if (sa1.Description != sa2.Description) return false; - if (sa1.KeyboardShortcut != sa2.KeyboardShortcut) return false; - if (sa1.Name != sa2.Name) return false; - if (!sa1.Role.Equals(sa2.Role)) return false; - if (sa1.State != sa2.State) return false; - if (sa1.Value != sa2.Value) return false; - if (sa1.Visible != sa2.Visible) return false; - if (ia1.accParent == null && ia2.accParent == null) return true; - if (ia1.accParent == null || ia2.accParent == null) return false; - bool de = DeepEquals((IAccessible)ia1.accParent, (IAccessible)ia2.accParent); + try + { + if (ia1.accChildCount != ia2.accChildCount) return false; + SystemAccessibleObject sa1 = new SystemAccessibleObject(ia1, 0); + SystemAccessibleObject sa2 = new SystemAccessibleObject(ia2, 0); + if (sa1.Window.HWnd != sa2.Window.HWnd) return false; + if (sa1.Location != sa2.Location) return false; + if (sa1.DefaultAction != sa2.DefaultAction) return false; + if (sa1.Description != sa2.Description) return false; + if (sa1.KeyboardShortcut != sa2.KeyboardShortcut) return false; + if (sa1.Name != sa2.Name) return false; + if (!sa1.Role.Equals(sa2.Role)) return false; + if (sa1.State != sa2.State) return false; + if (sa1.Value != sa2.Value) return false; + if (sa1.Visible != sa2.Visible) return false; + if (ia1.accParent == null && ia2.accParent == null) return true; + if (ia1.accParent == null || ia2.accParent == null) return false; + } + catch (COMException) + { + return false; + } + bool de = DeepEquals((IAccessible)ia1.accParent, (IAccessible)ia2.accParent); return de; } Modified: trunk/Tools/AOExplorer/MainForm.cs =================================================================== --- trunk/Tools/AOExplorer/MainForm.cs 2010-11-18 17:12:00 UTC (rev 95) +++ trunk/Tools/AOExplorer/MainForm.cs 2011-01-01 22:53:58 UTC (rev 96) @@ -271,9 +271,21 @@ LoadAll(SystemAccessibleObject.Caret); } + private SystemAccessibleObject highlightedObject = null; + private void selCrosshair_CrosshairDragging(object sender, EventArgs e) { SystemAccessibleObject sao = SystemAccessibleObject.FromPoint(MousePosition.X, MousePosition.Y); + if (highlightedObject == null || !highlightedObject.Equals(sao)) + { + if (highlightedObject != null) + { + highlightedObject.Window.Refresh(); + highlightedObject = null; + } + sao.Highlight(); + highlightedObject = sao; + } LoadProperties(sao); tree.Enabled = false; } @@ -281,6 +293,11 @@ private void selCrosshair_CrosshairDragged(object sender, EventArgs e) { selCrosshair_CrosshairDragging(sender, e); + if (highlightedObject != null) + { + highlightedObject.Window.Refresh(); + highlightedObject = null; + } LoadTree(lastObject); tree.Enabled = true; Modified: trunk/Tools/AOExplorer/Properties/AssemblyInfo.cs =================================================================== --- trunk/Tools/AOExplorer/Properties/AssemblyInfo.cs 2010-11-18 17:12:00 UTC (rev 95) +++ trunk/Tools/AOExplorer/Properties/AssemblyInfo.cs 2011-01-01 22:53:58 UTC (rev 96) @@ -11,7 +11,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("AOExplorer")] -[assembly: AssemblyCopyright("Copyright © 2006, 2007 Michael Schierl")] +[assembly: AssemblyCopyright("Copyright © 2006, 2007, 2011 Michael Schierl")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] Modified: trunk/Tools/WinternalExplorer/MainForm.cs =================================================================== --- trunk/Tools/WinternalExplorer/MainForm.cs 2010-11-18 17:12:00 UTC (rev 95) +++ trunk/Tools/WinternalExplorer/MainForm.cs 2011-01-01 22:53:58 UTC (rev 96) @@ -200,11 +200,12 @@ this.Cursor = Cursors.WaitCursor; lastX = MousePosition.X; lastY = MousePosition.Y; - UpdateSelection(true); + UpdateSelection(true, false); if (highlightedWindow != null) { highlightedWindow.Refresh(); highlightedWindow = null; + highlightedAccessibleObject = null; } this.Cursor = null; } @@ -212,9 +213,10 @@ SelectableTreeNodeData lastNode = null; bool lastIncludeTree = false; - private void UpdateSelection(bool includeTree) + private void UpdateSelection(bool includeTree, bool highlightOnly) { SelectableTreeNodeData stnd = SelectFromPoint(lastX, lastY); + if (highlightOnly) return; if (!Visible) Visible = true; if (!stnd.Equals(lastNode) || includeTree != lastIncludeTree) { @@ -225,12 +227,29 @@ } SystemWindow highlightedWindow; + SystemAccessibleObject highlightedAccessibleObject; private SelectableTreeNodeData SelectFromPoint(int lastX, int lastY) { if (selAccObjs.Checked) { SystemAccessibleObject sao = SystemAccessibleObject.FromPoint(lastX, lastY); + if (sao != highlightedAccessibleObject) + { + if (highlightedWindow != null) + { + highlightedWindow.Refresh(); + highlightedWindow = null; + highlightedAccessibleObject = null; + } + SystemWindow sw = sao.Window; + if (sw.HWnd != this.Handle && !sw.IsDescendantOf(new SystemWindow(this.Handle))) + { + sao.Highlight(); + highlightedWindow = sw; + highlightedAccessibleObject = sao; + } + } return new AccessibilityData(this, sao); } else @@ -244,6 +263,7 @@ { highlightedWindow.Refresh(); highlightedWindow = null; + highlightedAccessibleObject = null; } if (sw.HWnd != this.Handle && !sw.IsDescendantOf(new SystemWindow(this.Handle))) { @@ -319,7 +339,7 @@ if (!found) { MessageBox.Show("Could not find window below " + curr.Text); - return null; + return curr; } } if (existingNodes[wd] != curr) throw new Exception(); @@ -336,13 +356,13 @@ Visible = false; crossHair.RestoreMouseCapture(); } - else if (!autoHide.Checked) + else { if (MousePosition.X != lastX || MousePosition.Y != lastY) { lastX = MousePosition.X; lastY = MousePosition.Y; - UpdateSelection(false); + UpdateSelection(false, autoHide.Checked); Update(); } } Modified: trunk/Tools/WinternalExplorer/Properties/AssemblyInfo.cs =================================================================== --- trunk/Tools/WinternalExplorer/Properties/AssemblyInfo.cs 2010-11-18 17:12:00 UTC (rev 95) +++ trunk/Tools/WinternalExplorer/Properties/AssemblyInfo.cs 2011-01-01 22:53:58 UTC (rev 96) @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("WinternalExplorer")] -[assembly: AssemblyCopyright("Copyright © 2007, 2008, 2010 Michael Schierl")] +[assembly: AssemblyCopyright("Copyright © 2007, 2008, 2010, 2011 Michael Schierl")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |