Skip to content

Commit 4912f48

Browse files
Replace resource constants with properties in System.Windows.Controls.Ribbon (#6834)
Contributes to #1
1 parent 51ba512 commit 4912f48

23 files changed

+70
-93
lines changed

eng/WpfArcadeSdk/tools/SystemResources.props

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@
1212

1313
<_GenerateResourcesCodeAsConstants>true</_GenerateResourcesCodeAsConstants>
1414

15+
<!--
16+
Projects that compile XAML must also check for AssemblyName because XAML compilation generates a temporary project with a different project name.
17+
We use AssemblyName because AssemblyName is copied from the main project to the generated project.
18+
-->
1519
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='UIAutomationClient'">false</_GenerateResourcesCodeAsConstants>
1620
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='UIAutomationClientSideProviders'">false</_GenerateResourcesCodeAsConstants>
1721
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='UIAutomationProvider'">false</_GenerateResourcesCodeAsConstants>
22+
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='System.Windows.Controls.Ribbon' or '$(AssemblyName)'=='System.Windows.Controls.Ribbon'">false</_GenerateResourcesCodeAsConstants>
1823
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='System.Xaml'">false</_GenerateResourcesCodeAsConstants>
1924
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='WindowsBase'">false</_GenerateResourcesCodeAsConstants>
2025
<_GenerateResourcesCodeAsConstants Condition="'$(MSBuildProjectName)'=='WindowsFormsIntegration'">false</_GenerateResourcesCodeAsConstants>
@@ -37,7 +42,7 @@
3742
<ClassName Condition="'$(AssemblyName)'=='UIAutomationProvider'">MS.Internal.Automation.SR</ClassName>
3843
<ClassName Condition="'$(AssemblyName)'=='UIAutomationTypes'">System.SR</ClassName>
3944
<ClassName Condition="'$(AssemblyName)'=='WindowsBase'">MS.Internal.WindowsBase.SR</ClassName>
40-
<ClassName Condition="'$(AssemblyName)'=='System.Windows.Controls.Ribbon'">Microsoft.Windows.Controls.SRID</ClassName>
45+
<ClassName Condition="'$(AssemblyName)'=='System.Windows.Controls.Ribbon'">Microsoft.Windows.Controls.SR</ClassName>
4146
<ClassName Condition="'$(AssemblyName)'=='System.Windows.Input.Manipulations'">System.SR</ClassName>
4247
<ClassName Condition="'$(AssemblyName)'=='ReachFramework'">System.Windows.Xps.SRID</ClassName>
4348
<ClassName Condition="'$(AssemblyName)'=='PresentationFramework'">System.Windows.SRID</ClassName>

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonComboBoxAutomationPeer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ protected override void SetFocusCore()
8888
{
8989
TextBox tb = owner.EditableTextBoxSite;
9090
if (tb == null || !tb.IsKeyboardFocused)
91-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.SetFocusFailed));
91+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.SetFocusFailed);
9292
}
9393
else
94-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.SetFocusFailed));
94+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.SetFocusFailed);
9595
}
9696
}
9797
else
9898
{
99-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.SetFocusFailed));
99+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.SetFocusFailed);
100100
}
101101
}
102102

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonMenuButtonAutomationPeer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void IExpandCollapseProvider.Collapse()
173173
RibbonMenuButton owner = OwningMenuButton;
174174
if (!owner.HasItems)
175175
{
176-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
176+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
177177
}
178178

179179
owner.IsDropDownOpen = false;
@@ -187,7 +187,7 @@ void IExpandCollapseProvider.Expand()
187187
RibbonMenuButton owner = OwningMenuButton;
188188
if (!owner.HasItems)
189189
{
190-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
190+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
191191
}
192192

193193
owner.IsDropDownOpen = true;
@@ -237,7 +237,7 @@ bool ITransformProvider.CanRotate
237237

238238
void ITransformProvider.Move(double x, double y)
239239
{
240-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
240+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
241241
}
242242

243243
void ITransformProvider.Resize(double width, double height)
@@ -246,17 +246,17 @@ void ITransformProvider.Resize(double width, double height)
246246
throw new ElementNotEnabledException();
247247

248248
if (!((ITransformProvider)this).CanResize || width <= 0 || height <= 0)
249-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
249+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
250250

251251
if (!OwningMenuButton.ResizePopupInternal(width, height))
252252
{
253-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.ResizeParametersNotValid));
253+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.ResizeParametersNotValid);
254254
}
255255
}
256256

257257
void ITransformProvider.Rotate(double degrees)
258258
{
259-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
259+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
260260
}
261261

262262
#endregion

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonMenuItemDataAutomationPeer.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void IExpandCollapseProvider.Expand()
142142
UIElement owner = GetWrapper();
143143
if (owner == null)
144144
{
145-
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
145+
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.VirtualizedElement);
146146
}
147147

148148
RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;
@@ -153,14 +153,14 @@ void IExpandCollapseProvider.Expand()
153153
if ((role != MenuItemRole.TopLevelHeader && role != MenuItemRole.SubmenuHeader)
154154
|| !menuItemOwner.HasItems)
155155
{
156-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
156+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
157157
}
158158

159159
menuItemOwner.IsSubmenuOpen = true;
160160
}
161161
else
162162
{
163-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
163+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
164164
}
165165
}
166166

@@ -173,7 +173,7 @@ void IExpandCollapseProvider.Collapse()
173173
UIElement owner = GetWrapper();
174174
if (owner == null)
175175
{
176-
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
176+
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.VirtualizedElement);
177177
}
178178

179179
RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;
@@ -184,14 +184,14 @@ void IExpandCollapseProvider.Collapse()
184184
if ((role != MenuItemRole.TopLevelHeader && role != MenuItemRole.SubmenuHeader)
185185
|| !menuItemOwner.HasItems)
186186
{
187-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
187+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
188188
}
189189

190190
menuItemOwner.IsSubmenuOpen = false;
191191
}
192192
else
193193
{
194-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
194+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
195195
}
196196
}
197197

@@ -203,7 +203,7 @@ ExpandCollapseState IExpandCollapseProvider.ExpandCollapseState
203203
UIElement owner = GetWrapper();
204204
if (owner == null)
205205
{
206-
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
206+
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.VirtualizedElement);
207207
}
208208

209209
ExpandCollapseState result = ExpandCollapseState.Collapsed;
@@ -224,7 +224,7 @@ ExpandCollapseState IExpandCollapseProvider.ExpandCollapseState
224224
}
225225
else
226226
{
227-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
227+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
228228
}
229229

230230
return result;
@@ -243,13 +243,13 @@ void IInvokeProvider.Invoke()
243243
UIElement owner = GetWrapper();
244244
if (owner == null)
245245
{
246-
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
246+
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.VirtualizedElement);
247247
}
248248

249249
RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;
250250
if (menuItemOwner == null)
251251
{
252-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
252+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
253253
}
254254

255255
menuItemOwner.ClickItemInternal();
@@ -267,13 +267,13 @@ void IToggleProvider.Toggle()
267267
UIElement owner = GetWrapper();
268268
if (owner == null)
269269
{
270-
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
270+
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.VirtualizedElement);
271271
}
272272

273273
RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;
274274
if (menuItemOwner == null || !menuItemOwner.IsCheckable)
275275
{
276-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
276+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
277277
}
278278

279279
menuItemOwner.IsChecked = !menuItemOwner.IsChecked;
@@ -287,13 +287,13 @@ ToggleState IToggleProvider.ToggleState
287287
UIElement owner = GetWrapper();
288288
if (owner == null)
289289
{
290-
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
290+
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.VirtualizedElement);
291291
}
292292

293293
RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;
294294
if (menuItemOwner == null)
295295
{
296-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
296+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
297297
}
298298

299299
return menuItemOwner.IsChecked ? ToggleState.On : ToggleState.Off;
@@ -330,7 +330,7 @@ bool ITransformProvider.CanRotate
330330

331331
void ITransformProvider.Move(double x, double y)
332332
{
333-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
333+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
334334
}
335335

336336
void ITransformProvider.Resize(double width, double height)
@@ -341,27 +341,27 @@ void ITransformProvider.Resize(double width, double height)
341341
UIElement owner = GetWrapper();
342342
if (owner == null)
343343
{
344-
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.VirtualizedElement));
344+
throw new ElementNotAvailableException(Microsoft.Windows.Controls.SR.VirtualizedElement);
345345
}
346346

347347
RibbonMenuItem menuItemOwner = owner as RibbonMenuItem;
348348
if (menuItemOwner == null)
349349
{
350-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
350+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
351351
}
352352

353353
if (!((ITransformProvider)this).CanResize || width <= 0 || height <= 0)
354-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
354+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
355355

356356
if (!menuItemOwner.ResizePopupInternal(width, height))
357357
{
358-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.ResizeParametersNotValid));
358+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.ResizeParametersNotValid);
359359
}
360360
}
361361

362362
void ITransformProvider.Rotate(double degrees)
363363
{
364-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
364+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
365365
}
366366

367367
#endregion

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonQuickAccessToolBarAutomationPeer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void Collapse()
109109
}
110110
else
111111
{
112-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
112+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
113113
}
114114
}
115115

@@ -121,7 +121,7 @@ public void Expand()
121121
}
122122
else
123123
{
124-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
124+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
125125
}
126126
}
127127

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonSplitButtonAutomationPeer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void IToggleProvider.Toggle()
7575

7676
if (!OwningSplitButton.IsCheckable)
7777
{
78-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
78+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
7979
}
8080

8181
if (OwningSplitButton.HeaderButton != null)
@@ -108,7 +108,7 @@ void IInvokeProvider.Invoke()
108108
// When IsCheckable is true, TogglePattern should be used
109109
if (OwningSplitButton.IsCheckable)
110110
{
111-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
111+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
112112
}
113113

114114
if (OwningSplitButton.HeaderButton != null)

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Automation/Peers/RibbonTabDataAutomationPeer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void ISelectionItemProvider.RemoveFromSelection()
150150
RibbonTab tab = GetWrapper() as RibbonTab;
151151
if (tab != null && tab.IsSelected)
152152
{
153-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
153+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
154154
}
155155
}
156156

@@ -165,7 +165,7 @@ void ISelectionItemProvider.AddToSelection()
165165
Selector parentSelector = (Selector)(ItemsControlAutomationPeer.Owner);
166166
if ((parentSelector == null) || (parentSelector.SelectedItem != null && parentSelector.SelectedItem != Item))
167167
{
168-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.UIA_OperationCannotBePerformed));
168+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.UIA_OperationCannotBePerformed);
169169
}
170170
}
171171

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/ActivatingKeyTipEventArgs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public double KeyTipHorizontalOffset
8686
{
8787
if (double.IsInfinity(value) || double.IsNaN(value))
8888
{
89-
throw new ArgumentException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.InvalidKeyTipOffset));
89+
throw new ArgumentException(Microsoft.Windows.Controls.SR.InvalidKeyTipOffset);
9090
}
9191
_horizontalOffset = value;
9292
}
@@ -105,7 +105,7 @@ public double KeyTipVerticalOffset
105105
{
106106
if (double.IsInfinity(value) || double.IsNaN(value))
107107
{
108-
throw new ArgumentException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.InvalidKeyTipOffset));
108+
throw new ArgumentException(Microsoft.Windows.Controls.SR.InvalidKeyTipOffset);
109109
}
110110
_verticalOffset = value;
111111
}

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/KeyTipService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ private void OnKeyTipExactMatch(DependencyObject exactMatchElement)
989989
!KeyTipService.GetIsKeyTipScope(newScope) &&
990990
newScope != _currentGlobalScope)
991991
{
992-
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.ElementNotKeyTipScope));
992+
throw new InvalidOperationException(Microsoft.Windows.Controls.SR.ElementNotKeyTipScope);
993993
}
994994
if (newScope == null &&
995995
KeyTipService.GetIsKeyTipScope(exactMatchElement))
@@ -1796,7 +1796,7 @@ internal static KeyTipService Current
17961796
private const int ShowKeyTipsWaitTime = 500;
17971797
private const int NonZeroDigitCount = 9;
17981798

1799-
private static String QatKeyTipCharacters = Microsoft.Windows.Controls.SR.Get(Microsoft.Windows.Controls.SRID.QATKeyTipCharacters);
1799+
private static String QatKeyTipCharacters = Microsoft.Windows.Controls.SR.QATKeyTipCharacters;
18001800

18011801
#endregion
18021802
}

0 commit comments

Comments
 (0)