|
Line 0
Link Here
|
|
|
1 |
// Permission is hereby granted, free of charge, to any person obtaining |
| 2 |
// a copy of this software and associated documentation files (the |
| 3 |
// "Software"), to deal in the Software without restriction, including |
| 4 |
// without limitation the rights to use, copy, modify, merge, publish, |
| 5 |
// distribute, sublicense, and/or sell copies of the Software, and to |
| 6 |
// permit persons to whom the Software is furnished to do so, subject to |
| 7 |
// the following conditions: |
| 8 |
// |
| 9 |
// The above copyright notice and this permission notice shall be |
| 10 |
// included in all copies or substantial portions of the Software. |
| 11 |
// |
| 12 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 13 |
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 14 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 15 |
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 16 |
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 17 |
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 18 |
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 19 |
// |
| 20 |
// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) |
| 21 |
// |
| 22 |
// Authors: |
| 23 |
// Neville Gao <nevillegao@gmail.com> |
| 24 |
// |
| 25 |
|
| 26 |
using System; |
| 27 |
using System.Windows.Automation; |
| 28 |
using System.Windows.Automation.Provider; |
| 29 |
using SWF = System.Windows.Forms; |
| 30 |
using Mono.UIAutomation.Winforms; |
| 31 |
using Mono.UIAutomation.Winforms.Events; |
| 32 |
using Mono.UIAutomation.Winforms.Events.StatusBar; |
| 33 |
|
| 34 |
namespace Mono.UIAutomation.Winforms.Behaviors.StatusBar |
| 35 |
{ |
| 36 |
internal class StatusBarPanelGridItemProviderBehavior : ProviderBehavior, IGridItemProvider |
| 37 |
{ |
| 38 |
#region Constructor |
| 39 |
|
| 40 |
public StatusBarPanelGridItemProviderBehavior (StatusBarProvider.StatusBarPanelProvider provider, |
| 41 |
SWF.StatusBarPanel statusBarPanel) |
| 42 |
: base (provider) |
| 43 |
{ |
| 44 |
this.statusBarPanel = statusBarPanel; |
| 45 |
} |
| 46 |
|
| 47 |
#endregion |
| 48 |
|
| 49 |
#region IProviderBehavior Interface |
| 50 |
|
| 51 |
public override AutomationPattern ProviderPattern { |
| 52 |
get { return GridItemPatternIdentifiers.Pattern; } |
| 53 |
} |
| 54 |
|
| 55 |
public override void Connect (SWF.Control control) |
| 56 |
{ |
| 57 |
// NOTE: Row Property NEVER changes. |
| 58 |
// NOTE: RowSpan Property NEVER changes. |
| 59 |
// NOTE: ColumnSpan Property NEVER changes. |
| 60 |
// NOTE: ContainingGrid Property NEVER changes. |
| 61 |
Provider.SetEvent (ProviderEventType.GridItemPatternColumnProperty, |
| 62 |
new StatusBarPanelGridItemPatternColumnEvent (Provider)); |
| 63 |
} |
| 64 |
|
| 65 |
public override void Disconnect (SWF.Control control) |
| 66 |
{ |
| 67 |
Provider.SetEvent (ProviderEventType.GridItemPatternRowProperty, |
| 68 |
null); |
| 69 |
Provider.SetEvent (ProviderEventType.GridItemPatternColumnProperty, |
| 70 |
null); |
| 71 |
Provider.SetEvent (ProviderEventType.GridItemPatternRowSpanProperty, |
| 72 |
null); |
| 73 |
Provider.SetEvent (ProviderEventType.GridItemPatternColumnProperty, |
| 74 |
null); |
| 75 |
Provider.SetEvent (ProviderEventType.GridItemPatternContainingGridProperty, |
| 76 |
null); |
| 77 |
} |
| 78 |
|
| 79 |
public override object GetPropertyValue (int propertyId) |
| 80 |
{ |
| 81 |
if (propertyId == GridItemPatternIdentifiers.RowProperty.Id) |
| 82 |
return Row; |
| 83 |
else if (propertyId == GridItemPatternIdentifiers.ColumnProperty.Id) |
| 84 |
return Column; |
| 85 |
else if (propertyId == GridItemPatternIdentifiers.RowSpanProperty.Id) |
| 86 |
return RowSpan; |
| 87 |
else if (propertyId == GridItemPatternIdentifiers.ColumnSpanProperty.Id) |
| 88 |
return ColumnSpan; |
| 89 |
else if (propertyId == GridItemPatternIdentifiers.ContainingGridProperty.Id) |
| 90 |
return ContainingGrid; |
| 91 |
else |
| 92 |
return base.GetPropertyValue (propertyId); |
| 93 |
} |
| 94 |
|
| 95 |
#endregion |
| 96 |
|
| 97 |
#region IGridItemProvider Members |
| 98 |
|
| 99 |
public int Row { |
| 100 |
get { return 0; } |
| 101 |
} |
| 102 |
|
| 103 |
public int Column { |
| 104 |
get { return statusBarPanel.Parent.Panels.IndexOf (statusBarPanel); } |
| 105 |
} |
| 106 |
|
| 107 |
public int RowSpan { |
| 108 |
get { return 1; } |
| 109 |
} |
| 110 |
|
| 111 |
public int ColumnSpan { |
| 112 |
get { return 1; } |
| 113 |
} |
| 114 |
|
| 115 |
public IRawElementProviderSimple ContainingGrid { |
| 116 |
get { return ProviderFactory.GetProvider (statusBarPanel.Parent); } |
| 117 |
} |
| 118 |
|
| 119 |
#endregion |
| 120 |
|
| 121 |
#region Private Fields |
| 122 |
|
| 123 |
private SWF.StatusBarPanel statusBarPanel; |
| 124 |
|
| 125 |
#endregion |
| 126 |
} |
| 127 |
} |