Skip to content

Commit 307fbeb

Browse files
authored
Merge pull request #467 from trimble-oss/copilot/fix-code-scanning-alerts
Resolve 4 error-severity CodeQL findings blocking policy compliance
2 parents 08e5f92 + 05ddd61 commit 307fbeb

3 files changed

Lines changed: 45 additions & 29 deletions

File tree

Trimble.Modus.Components/Controls/DropDown/TMDropDown.xaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private void OnSelected(object sender, SelectedItemChangedEventArgs e)
201201
var newItem = e.SelectedItem;
202202
var newIndex = e.SelectedItemIndex;
203203

204-
// Always update (even if newItem is null that represents clearing)
204+
// Always update (even if newItem is null that represents clearing)
205205
SelectedItem = newItem;
206206
SelectedIndex = newIndex;
207207

@@ -332,10 +332,10 @@ private void UpdateListBorderHeight(IEnumerable items)
332332

333333
if (itemCount < 4)
334334
{
335-
desiredHeight = itemCount * 56;
336-
margin = new Thickness(0, ((itemCount - 1) * 56) + 4, 10, 0);
335+
desiredHeight = itemCount * 56.0;
336+
margin = new Thickness(0, ((itemCount - 1) * 56.0) + 4.0, 10, 0);
337337
#if WINDOWS
338-
margin = new Thickness(0, ((itemCount - 1) * 56) + 30, 10, 0);
338+
margin = new Thickness(0, ((itemCount - 1) * 56.0) + 30.0, 10, 0);
339339
#endif
340340
}
341341
}

Trimble.Modus.Components/Controls/TMSpinner/TMSpinner.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ private static void OnSpinnerSizeChanged(BindableObject bindable, object oldValu
103103
{
104104
if (bindable is TMSpinner tmSpinner)
105105
{
106-
Console.WriteLine("Spinner Size Changed", (Size)newValue);
107106
switch ((Size)newValue)
108107
{
109108
case Size.XSmall:
Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,42 @@
11
namespace Trimble.Modus.Components.Helpers;
2-
3-
public static class ResourcesDictionary
4-
{
5-
public static Color GetColor(string styleKey)
6-
{
7-
if (Application.Current.Resources.ContainsKey(styleKey))
8-
{
9-
return Application.Current.Resources[styleKey] as Color;
10-
}
11-
else
12-
{
13-
ResourceDictionary style = new Styles.LightThemeColors();
14-
if (Application.Current.RequestedTheme == AppTheme.Dark)
15-
{
16-
style = new Styles.DarkThemeColors();
17-
}
18-
if (style.ContainsKey(styleKey))
19-
{
20-
return style[styleKey] as Color;
21-
}
22-
}
23-
return Colors.Transparent;
24-
}
25-
}
2+
3+
public static class ResourcesDictionary
4+
{
5+
public static Color GetColor(string styleKey)
6+
{
7+
if (Application.Current?.Resources is ResourceDictionary resources &&
8+
resources.TryGetValue(styleKey, out var applicationResource) &&
9+
applicationResource is Color applicationColor)
10+
{
11+
return applicationColor;
12+
}
13+
14+
if (Application.Current?.Resources is ResourceDictionary appResources)
15+
{
16+
var preferredType = Application.Current.RequestedTheme == AppTheme.Dark
17+
? typeof(Styles.DarkThemeColors)
18+
: typeof(Styles.LightThemeColors);
19+
20+
foreach (var dictionary in appResources.MergedDictionaries)
21+
{
22+
if (dictionary.GetType() == preferredType &&
23+
dictionary.TryGetValue(styleKey, out var themeResource) &&
24+
themeResource is Color themeColor)
25+
{
26+
return themeColor;
27+
}
28+
}
29+
30+
foreach (var dictionary in appResources.MergedDictionaries)
31+
{
32+
if (dictionary.TryGetValue(styleKey, out var mergedResource) &&
33+
mergedResource is Color mergedColor)
34+
{
35+
return mergedColor;
36+
}
37+
}
38+
}
39+
40+
return Colors.Transparent;
41+
}
42+
}

0 commit comments

Comments
 (0)