-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce79935
commit 3dd98ba
Showing
7 changed files
with
191 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!-- Copyright (c) Microsoft Corporation and Contributors. --> | ||
<!-- Licensed under the MIT License. --> | ||
|
||
<Page | ||
x:Class="Amethyst.Pages.Plugins" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:mvvm="using:Amethyst.MVVM" | ||
xmlns:controls="using:Amethyst.Controls" | ||
xmlns:util="using:Amethyst.Utils" | ||
xmlns:classes="using:Amethyst.Classes" | ||
Loaded="Page_Loaded" NavigationCacheMode="Required" | ||
mc:Ignorable="d" Background="Transparent"> | ||
|
||
<Grid Background="Transparent"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="450" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="15*" /> | ||
<ColumnDefinition Width="20" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0"> | ||
</Grid> | ||
|
||
<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="2" | ||
x:Name="DevicesMainContentScrollViewer" | ||
VerticalScrollBarVisibility="Visible" Padding="20,-20" Margin="-20,20,-20,20"> | ||
|
||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" | ||
x:Name="DevicesMainContentGridOuter" Margin="0,0,0,15"> | ||
|
||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" | ||
x:Name="DevicesMainContentGridInner"> | ||
</Grid> | ||
</Grid> | ||
</ScrollViewer> | ||
</Grid> | ||
</Grid> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright (c) Microsoft Corporation and Contributors. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading; | ||
using Amethyst.Utils; | ||
using System.Threading.Tasks; | ||
using Amethyst.Classes; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace Amethyst.Pages; | ||
|
||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class Plugins : Page, INotifyPropertyChanged | ||
{ | ||
private bool _pluginsPageLoadedOnce; | ||
|
||
public Plugins() | ||
{ | ||
InitializeComponent(); | ||
|
||
Logger.Info($"Constructing page: '{GetType().FullName}'..."); | ||
// TODO TeachingTips | ||
|
||
Logger.Info("Registering a detached binary semaphore " + | ||
$"reload handler for '{GetType().FullName}'..."); | ||
|
||
Task.Run(() => | ||
{ | ||
Shared.Events.ReloadPluginsPageEvent = | ||
new ManualResetEvent(false); | ||
while (true) | ||
{ | ||
// Wait for a reload signal (blocking) | ||
Shared.Events.ReloadPluginsPageEvent.WaitOne(); | ||
// Reload & restart the waiting loop | ||
if (_pluginsPageLoadedOnce && Interfacing.CurrentPageTag == "plugins") | ||
Shared.Main.DispatcherQueue.TryEnqueue(Page_LoadedHandler); | ||
// Reset the event | ||
Shared.Events.ReloadPluginsPageEvent.Reset(); | ||
} | ||
}); | ||
} | ||
|
||
// MVVM stuff | ||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
private void Page_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
Logger.Info($"Re/Loading page: '{GetType().FullName}'..."); | ||
Interfacing.CurrentAppState = "plugins"; | ||
|
||
// Execute the handler | ||
Page_LoadedHandler(); | ||
|
||
// Mark as loaded | ||
_pluginsPageLoadedOnce = true; | ||
} | ||
|
||
private void Page_LoadedHandler() | ||
{ | ||
OnPropertyChanged(); // Just everything | ||
} | ||
|
||
private void OnPropertyChanged(string propertyName = null) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
} |