Skip to content

Commit ea949d6

Browse files
Merge branch 'master' into feature/design-tools
2 parents 1cace8c + e0a5d28 commit ea949d6

File tree

12 files changed

+133
-111
lines changed

12 files changed

+133
-111
lines changed

Microsoft.Toolkit.Uwp.SampleApp/Controls/XamlCodeEditor.xaml.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public sealed partial class XamlCodeEditor : UserControl
2121
public static readonly DependencyProperty TextProperty =
2222
DependencyProperty.Register(nameof(Text), typeof(string), typeof(XamlCodeEditor), new PropertyMetadata(string.Empty));
2323

24+
private ThemeListener _themeListener = new ThemeListener();
25+
2426
public XamlCodeEditor()
2527
{
2628
this.InitializeComponent();
@@ -40,7 +42,7 @@ public async void ReportError(XamlExceptionRange error)
4042
// Highlight Error Line
4143
XamlCodeRenderer.Decorations.Add(new IModelDeltaDecoration(
4244
range,
43-
new IModelDecorationOptions() { IsWholeLine = true, ClassName = _errorStyle, HoverMessage = new string[] { error.Message }.ToMarkdownString() }));
45+
new IModelDecorationOptions() { IsWholeLine = true, ClassName = ErrorStyle, HoverMessage = new string[] { error.Message }.ToMarkdownString() }));
4446

4547
// Show Glyph Icon
4648
XamlCodeRenderer.Decorations.Add(new IModelDeltaDecoration(
@@ -121,10 +123,12 @@ public string Text
121123

122124
public DateTime TimeSampleEditedLast { get; private set; } = DateTime.MinValue;
123125

124-
private CssLineStyle _errorStyle = new CssLineStyle()
126+
private CssLineStyle ErrorStyle
125127
{
126-
BackgroundColor = new SolidColorBrush(Color.FromArgb(0x00, 0xFF, 0xD6, 0xD6))
127-
};
128+
get => _themeListener.CurrentTheme.Equals(ApplicationTheme.Light) ?
129+
new CssLineStyle() { BackgroundColor = new SolidColorBrush(Color.FromArgb(0x00, 0xFF, 0xD6, 0xD6)) } :
130+
new CssLineStyle() { BackgroundColor = new SolidColorBrush(Color.FromArgb(0x00, 0x66, 0x00, 0x00)) };
131+
}
128132

129133
private CssGlyphStyle _errorIconStyle = new CssGlyphStyle()
130134
{

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/DispatcherQueueHelper/DispatcherQueueHelperPage.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.Threading.Tasks;
6-
using Microsoft.Toolkit.Uwp.Helpers;
6+
using Microsoft.Toolkit.Uwp.Extensions;
77
using Windows.System;
88
using Windows.UI.Xaml;
9-
using Microsoft.Toolkit.Uwp.Extensions;
109

1110
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
1211
{

Microsoft.Toolkit.Uwp.SampleApp/Shell.SamplePicker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Linq;
88
using System.Numerics;
99
using System.Threading.Tasks;
10+
using Microsoft.Toolkit.Uwp.Extensions;
1011
using Microsoft.Toolkit.Uwp.Helpers;
1112
using Microsoft.Toolkit.Uwp.SampleApp.Pages;
1213
using Microsoft.Toolkit.Uwp.UI.Animations;
@@ -147,7 +148,7 @@ private void NavView_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
147148
ShowSamplePicker(category.Samples, true);
148149

149150
// Then Focus on Picker
150-
DispatcherHelper.ExecuteOnUIThreadAsync(() => SamplePickerGridView.Focus(FocusState.Keyboard));
151+
dispatcherQueue.EnqueueAsync(() => SamplePickerGridView.Focus(FocusState.Keyboard));
151152
}
152153
}
153154
else if (args.IsSettingsInvoked)

Microsoft.Toolkit.Uwp.SampleApp/Shell.Search.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.Linq;
6+
using Microsoft.Toolkit.Uwp.Extensions;
67
using Microsoft.Toolkit.Uwp.Helpers;
78
using Microsoft.Toolkit.Uwp.UI.Extensions;
89
using Windows.UI.Xaml;
@@ -76,7 +77,7 @@ private void SearchBox_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEve
7677
if (e.Key == Windows.System.VirtualKey.Down && SamplePickerGrid.Visibility == Windows.UI.Xaml.Visibility.Visible)
7778
{
7879
// If we try and navigate down out of the textbox (and there's search results), go to the search results.
79-
DispatcherHelper.ExecuteOnUIThreadAsync(() => SamplePickerGridView.Focus(FocusState.Keyboard));
80+
dispatcherQueue.EnqueueAsync(() => SamplePickerGridView.Focus(FocusState.Keyboard));
8081
}
8182
}
8283

Microsoft.Toolkit.Uwp.SampleApp/Shell.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Microsoft.Toolkit.Uwp.SampleApp.Pages;
88
using Microsoft.Toolkit.Uwp.UI.Extensions;
99
using Windows.System;
10-
using Windows.UI.Xaml;
1110
using Windows.UI.Xaml.Controls;
1211
using Windows.UI.Xaml.Media.Animation;
1312
using Windows.UI.Xaml.Navigation;
@@ -16,6 +15,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
1615
{
1716
public sealed partial class Shell
1817
{
18+
private readonly DispatcherQueue dispatcherQueue = DispatcherQueue.GetForCurrentThread();
19+
1920
public static Shell Current { get; private set; }
2021

2122
public Shell()

Microsoft.Toolkit.Uwp.UI.Animations/Expressions/ExpressionFunctions.cs

Lines changed: 74 additions & 74 deletions
Large diffs are not rendered by default.

Microsoft.Toolkit.Uwp.UI.Animations/Expressions/ExpressionNodes/ExpressionNode.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,15 @@ private string ToExpressionStringInternal()
502502
ret = $"({Children[0].ToExpressionStringInternal()} {GetOperationString()} {Children[1].ToExpressionStringInternal()})";
503503
break;
504504

505+
case OperationType.UnaryOperator:
506+
if (Children.Count != 1)
507+
{
508+
throw new Exception("Can't have an unary operator that doesn't have exactly one params");
509+
}
510+
511+
ret = $"( {GetOperationString()} {Children[0].ToExpressionStringInternal()} )";
512+
break;
513+
505514
case OperationType.Constant:
506515
if (Children.Count == 0)
507516
{

Microsoft.Toolkit.Uwp.UI.Animations/Expressions/OperationType.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ internal enum OperationType
1515
Function,
1616

1717
/// <summary>
18-
/// The operator
18+
/// The operator (takes two operands)
1919
/// </summary>
2020
Operator,
2121

22+
/// <summary>
23+
/// The operator that only takes one operand
24+
/// </summary>
25+
UnaryOperator,
26+
2227
/// <summary>
2328
/// The constant
2429
/// </summary>

Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationExtensions.Light.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Collections.Generic;
77
using Microsoft.Graphics.Canvas;
88
using Microsoft.Graphics.Canvas.Effects;
9-
using Microsoft.Toolkit.Uwp.Helpers;
9+
using Microsoft.Toolkit.Uwp.Extensions;
1010
using Windows.UI;
1111
using Windows.UI.Composition;
1212
using Windows.UI.Composition.Effects;
@@ -102,7 +102,7 @@ public static AnimationSet Light(
102102
var task = new AnimationTask();
103103
task.AnimationSet = animationSet;
104104

105-
task.Task = DispatcherHelper.ExecuteOnUIThreadAsync(
105+
task.Task = visual.DispatcherQueue.EnqueueAsync(
106106
() =>
107107
{
108108
const string sceneName = "PointLightScene";
@@ -184,7 +184,7 @@ public static AnimationSet Light(
184184
}
185185

186186
pointLights[visual] = pointLight;
187-
}, Windows.UI.Core.CoreDispatcherPriority.Normal);
187+
});
188188

189189
animationSet.AddAnimationThroughTask(task);
190190
return animationSet;

Microsoft.Toolkit.Uwp.UI/Extensions/ScrollViewer/ScrollViewerExtensions.MiddleClickScrolling.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ private static void Scroll(object state)
162162
offsetX = offsetX > _maxSpeed ? _maxSpeed : offsetX;
163163
offsetY = offsetY > _maxSpeed ? _maxSpeed : offsetY;
164164

165-
RunInUIThread(dispatcherQueue, () =>
166-
{
167-
_scrollViewer?.ChangeView(_scrollViewer.HorizontalOffset + offsetX, _scrollViewer.VerticalOffset + offsetY, null, true);
168-
});
165+
dispatcherQueue.EnqueueAsync(() => _scrollViewer?.ChangeView(_scrollViewer.HorizontalOffset + offsetX, _scrollViewer.VerticalOffset + offsetY, null, true));
169166
}
170167
}
171168

@@ -326,10 +323,7 @@ private static void SetCursorType(DispatcherQueue dispatcherQueue, double offset
326323

327324
if (_oldCursorID != cursorID)
328325
{
329-
RunInUIThread(dispatcherQueue, () =>
330-
{
331-
Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Custom, cursorID);
332-
});
326+
dispatcherQueue.EnqueueAsync(() => Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Custom, cursorID));
333327

334328
_oldCursorID = cursorID;
335329
}
@@ -366,10 +360,5 @@ private static bool IsCursorResourceAvailable()
366360

367361
return isCursorAvailable;
368362
}
369-
370-
private static async void RunInUIThread(DispatcherQueue dispatcherQueue, Action action)
371-
{
372-
await dispatcherQueue.EnqueueAsync(action, DispatcherQueuePriority.Normal);
373-
}
374363
}
375364
}

0 commit comments

Comments
 (0)