Skip to content

Commit

Permalink
Adding MicaController RuntimeProfiler recording (#6694)
Browse files Browse the repository at this point in the history
* Adding MicaController RuntimeProfiler recording

* PR feedback: moving garbage collection button to TestFrame.
  • Loading branch information
RBrid authored Feb 11, 2022
1 parent 9aedb00 commit e5fa75c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 14 deletions.
29 changes: 22 additions & 7 deletions dev/CommonStyles/TestUI/CalendarViewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,25 @@ private void SetDensityColors(CalendarViewDayItem dayItem)
{
if (hasDensityBars.IsChecked.Value)
{
bool isToday = dayItem.Date.Date.Equals(DateTime.Now.Date);
Calendar calendar = new Calendar();
calendar.SetDateTime(dayItem.Date);

DateTime today = DateTime.Now.Date;
bool isToday = calendar.Day == today.Day && calendar.Month == today.Month && calendar.Year == today.Year;

if (dayItem.Date.Day % 6 == 0 || isToday)
if (calendar.Day % 6 == 0 || isToday)
{
List<Color> densityColors = new List<Color>();

densityColors.Add(Colors.Green);
densityColors.Add(Colors.Green);

if (dayItem.Date.Day % 4 == 0 || isToday)
if (calendar.Day % 4 == 0 || isToday)
{
densityColors.Add(Colors.Blue);
densityColors.Add(Colors.Blue);
}
if (dayItem.Date.Day % 9 == 0 || isToday)
if (calendar.Day % 9 == 0 || isToday)
{
densityColors.Add(Colors.Orange);
}
Expand All @@ -113,9 +117,20 @@ private void SetDensityColors(CalendarViewDayItem dayItem)

private void SetBlackout(CalendarViewDayItem dayItem)
{
dayItem.IsBlackout =
(isSundayBlackedOut.IsChecked.Value && dayItem.Date.DayOfWeek == System.DayOfWeek.Sunday) ||
(isTodayBlackedOut.IsChecked.Value && dayItem.Date.Date.Equals(DateTime.Now.Date));
Calendar calendar = new Calendar();

calendar.SetDateTime(dayItem.Date);

bool isBlackout = isSundayBlackedOut.IsChecked.Value && calendar.DayOfWeek == Windows.Globalization.DayOfWeek.Sunday;

if (!isBlackout && isTodayBlackedOut.IsChecked.Value)
{
Calendar calendarToday = new Calendar();
calendarToday.SetToNow();
isBlackout = calendar.Day == calendarToday.Day && calendar.Month == calendarToday.Month && calendar.Year == calendarToday.Year;
}

dayItem.IsBlackout = isBlackout;
}

private void SelectionMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down
6 changes: 6 additions & 0 deletions dev/Materials/Backdrop/MicaController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
#include "common.h"

#include "MicaController.h"
#include "RuntimeProfiler.h"
#include "SystemBackdropBrushFactory.h"

#include "MicaController.g.cpp"

MicaController::MicaController()
{
__RP_Marker_ClassById(RuntimeProfiler::ProfId_MicaController);
}

MicaController::~MicaController()
{
if (auto target = m_target.get())
Expand Down
2 changes: 1 addition & 1 deletion dev/Materials/Backdrop/MicaController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

struct MicaController : winrt::implementation::MicaControllerT<MicaController>, SystemBackdropComponentInternal::ISystemBackdropController
{
MicaController() = default;
MicaController();
~MicaController();

bool SetTarget(winrt::Windows::UI::Xaml::Window const& xamlWindow);
Expand Down
3 changes: 2 additions & 1 deletion dev/Telemetry/RuntimeProfiler.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.


Expand Down Expand Up @@ -57,6 +57,7 @@ namespace RuntimeProfiler
ProfId_AnimatedIcon,
ProfId_InfoBadge,
ProfId_WebView2,
ProfId_MicaController,
ProfId_Size // ProfId_Size is the last always.
} ProfilerClassId;

Expand Down
1 change: 0 additions & 1 deletion test/MUXControlsTestApp/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
</ScrollViewer>
<StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Center">
<CheckBox x:Name="LongAnimationsDisabled" AutomationProperties.AutomationId="LongAnimationsDisabled" Content="Long Animations Disabled" Checked="LongAnimationsDisabled_Checked" Unchecked="LongAnimationsDisabled_Unchecked" Margin="10,0,0,0"/>

<ComboBox
x:Name="LanguageChooser"
Header="Languages"
Expand Down
11 changes: 8 additions & 3 deletions test/TestAppUtils/TestFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ private void TestFrame_Navigated(object sender, Windows.UI.Xaml.Navigation.Navig
_currentPageTextBlock.Text = (e.Parameter is string ? e.Parameter as string : "");
}

GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GarbageCollection_Click(null, null);
}

protected override void OnApplyTemplate()
Expand Down Expand Up @@ -183,6 +181,13 @@ private void ToggleThemeButton_Click(object sender,RoutedEventArgs e)
contentAsFrameworkElement.RequestedTheme = (contentAsFrameworkElement.RequestedTheme == ElementTheme.Light) ? ElementTheme.Dark : ElementTheme.Light;
}

private void GarbageCollection_Click(object sender, RoutedEventArgs e)
{
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}

private void GoFullScreenInvokeButton_Click(object sender, RoutedEventArgs e)
{
var icon = _goFullScreenInvokerButton.Content as SymbolIcon;
Expand Down
8 changes: 7 additions & 1 deletion test/TestAppUtils/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@
AutomationProperties.AutomationId="__EnableRTL"
IsTabStop="False"
Content="Enable RTL"/>

<Button x:Name="GarbageCollection"
VerticalAlignment="Stretch" Margin="0,0,4,0"
Style="{ThemeResource AccentButtonStyle}"
IsTabStop="False"
Content="Garbage Collection"
Click="GarbageCollection_Click"/>

<TextBlock x:Name="CurrentPageTextBlock" AutomationProperties.AutomationId="__CurrentPage" FontSize="18" VerticalAlignment="Center" Margin="10,0,0,0"/>
</StackPanel>

Expand Down

0 comments on commit e5fa75c

Please sign in to comment.