Setting v2: added power preview settings (#1702)

* added power preview settings

* Added link to module oververview

* create settings file if one is not found

* removed run oon start up speficic callback

* Update src/core/Microsoft.PowerToys.Settings.UI.Lib/ModuleSettings.cs

Co-Authored-By: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>

* fixed merge conflicts

Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>
This commit is contained in:
Lavius Motileng 2020-03-30 02:02:25 -07:00
parent a84be2ba60
commit f1951d0d5f
14 changed files with 423 additions and 132 deletions

View File

@ -191,7 +191,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.PowerToys.Settings.UI.Lib", "src\core\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj", "{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Settings.UI.Lib", "src\core\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj", "{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class Contributor
{
public string Name { get; set; }
public string Link { get; set; }
}
}

View File

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
/// <summary>
/// This class models the settings for the PowerPreview class.
/// Eaxmple JSON:
/// {
/// "name": "File Explorer Preview",
/// "properties": {
/// "IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL": { "value": true },
/// "PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID": { "value": true }
/// },
/// "version": "1.0"
/// }
/// </summary>
public class PowerPreviewSettings
{
public string name { get; set; }
public Properties properties { get; set; }
public string version { get; set; }
public PowerPreviewSettings()
{
this.properties = new Properties();
this.version = "1";
this.name = "_unset_";
}
public PowerPreviewSettings(string ptName)
{
this.properties = new Properties();
this.version = "1";
this.name = ptName;
}
public override string ToString()
{
return "{\"" + this.name + "\":" + JsonSerializer.Serialize(this) + "}";
}
}
public class Property
{
public bool value { get; set; }
public override string ToString()
{
return JsonSerializer.Serialize(this);
}
}
public class Properties
{
public Property IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL { get; set; }
public Property PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID { get; set; }
public Properties()
{
this.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL = new Property();
this.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID = new Property();
}
public override string ToString()
{
return JsonSerializer.Serialize(this);
}
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
/// <summary>
/// PowerToys runner expects a json text that contains one of the following attributes: refresh, general and powertoys.
/// The one for general settings is placed in the General settings model. This class represents the json text that starts with the "powertoys" attribute.
/// this will tell the runner that we are sending settings for a powertoy module and not for general settings.
/// </summary>
/// <typeparam name="M">M stands for the Model of PT Module Settings to be sent.</typeparam>
public class SndModuleSettings<M>
{
public M powertoys { get; set; }
public SndModuleSettings(M ptModuleSettings)
{
this.powertoys = ptModuleSettings;
}
public override string ToString()
{
return "{\"powertoys\":" + this.powertoys.ToString() + "}";
}
}
}

View File

@ -7,10 +7,8 @@
xmlns:Controls="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls"
xmlns:xaml="clr-namespace:Microsoft.Toolkit.Wpf.UI.XamlHost;assembly=Microsoft.Toolkit.Wpf.UI.XamlHost"
mc:Ignorable="d"
Title="PowerToys Settings" Height="800" Width="800">
<Grid >
<!--<xaml:WindowsXamlHost InitialTypeName="Microsoft.PowerToys.Settings.UI.Controls.DummyUserControl" ChildChanged="WindowsXamlHost_ChildChanged" />-->
Title="PowerToys Settings" Height="800" Width="1000">
<Grid>
<xaml:WindowsXamlHost InitialTypeName="Microsoft.PowerToys.Settings.UI.Views.ShellPage" ChildChanged="WindowsXamlHost_ChildChanged" />
</Grid>
</Window>

View File

@ -25,30 +25,12 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
if (shellPage != null)
{
shellPage.SetRestartElevatedCallback(delegate(string msg)
// send IPC Message
shellPage.SetDefaultSndMessageCallback(delegate (string msg)
{
MessageBox.Show(
msg,
"Restart Elevated",
MessageBoxButton.OK);
Program.ipcmanager.SendMessage(msg);
int milliseconds = 2000;
Thread.Sleep(milliseconds);
System.Windows.Application.Current.Shutdown();
});
shellPage.SetRunOnStartUpCallback(delegate (string msg)
{
MessageBox.Show(
msg,
"Run On Start Up",
MessageBoxButton.OK);
Program.ipcmanager.SendMessage(msg);
});
}
}

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@ -144,6 +144,9 @@
<Compile Include="Views\PowerLauncherPage.xaml.cs">
<DependentUpon>PowerLauncherPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PowerPreviewPage.xaml.cs">
<DependentUpon>PowerPreviewPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PowerRenamePage.xaml.cs">
<DependentUpon>PowerRenamePage.xaml</DependentUpon>
</Compile>
@ -223,6 +226,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\PowerPreviewPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\PowerRenamePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
@ -145,4 +145,8 @@
<value>Shortcut Guide</value>
<comment>Navigation view item name for Shortcut Guide</comment>
</data>
<data name="Shell_PowerPreview.Content" xml:space="preserve">
<value>File Explorer Preview</value>
<comment>File Explorer Preview Settings</comment>
</data>
</root>

View File

@ -1,4 +1,4 @@
// <copyright file="GeneralPage.xaml.cs" company="Microsoft Corp">
// <copyright file="GeneralPage.xaml.cs" company="Microsoft Corp">
// Copyright (c) Microsoft Corp. All rights reserved.
// </copyright>
@ -35,14 +35,32 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// <inheritdoc/>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
//GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
base.OnNavigatedTo(e);
// load and apply theme settings
// this.ReLoadTheme(settings.theme);
GeneralSettings settings = null;
try
{
// get settings file if they exist.
settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
// load and apply theme settings
this.ReLoadTheme(settings.theme);
// load run on start up ui settings value and update the ui state.
//this.ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
// load run on start-up settings value and update the ui state.
this.ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
}
catch (Exception exp)
{
// create settings file if one is not found.
settings = new GeneralSettings();
SettingsUtils.SaveSettings<GeneralSettings>(settings, string.Empty);
// load and apply theme settings
this.ReLoadTheme(settings.theme);
// load run on start up ui settings value and update the ui state.
this.ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
}
ShellPage.ShellHandler.HideContributorsList();
ShellPage.ShellHandler.HideFeatureDetails();
}
/// <summary>
@ -90,9 +108,9 @@ namespace Microsoft.PowerToys.Settings.UI.Views
SettingsUtils.SaveSettings<GeneralSettings>(settings, string.Empty);
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
if (ShellPage.Run_OnStartUp_Callback != null)
if (ShellPage.Default_SndMSG_Callback != null)
{
ShellPage.Run_OnStartUp_Callback(outsettings.ToString());
ShellPage.Default_SndMSG_Callback(outsettings.ToString());
}
}
}
@ -103,9 +121,9 @@ namespace Microsoft.PowerToys.Settings.UI.Views
settings.run_elevated = true;
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
if (ShellPage.Restart_Elevated_Callback != null)
if (ShellPage.Default_SndMSG_Callback != null)
{
ShellPage.Restart_Elevated_Callback(outsettings.ToString());
ShellPage.Default_SndMSG_Callback(outsettings.ToString());
}
}
@ -121,7 +139,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
// update and save settings to file.
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
settings.theme = themeName;
SettingsUtils.SaveSettings<GeneralSettings>(settings,string.Empty);
SettingsUtils.SaveSettings<GeneralSettings>(settings, string.Empty);
}
}
}

View File

@ -0,0 +1,27 @@
<Page
x:Class="Microsoft.PowerToys.Settings.UI.Views.PowerPreviewPage"
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"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<StackPanel Orientation="Vertical">
<TextBlock Text="These settings allow you to manage your Windows File Explorer Addons."
TextWrapping="Wrap"/>
<ToggleSwitch Header="Svg Preview Handler"
x:Name="ToggleSwitch_Preview_SVG"
Margin="{StaticResource SmallTopMargin}"
Toggled="ToggleSwitch_Preview_SVG_Toggled" />
<ToggleSwitch Header="Markdown Preview Handler"
x:Name="ToggleSwitch_Preview_MD"
Margin="{StaticResource SmallTopMargin}"
Toggled="ToggleSwitch_Preview_MD_Toggled" />
</StackPanel>
</Grid>
</Page>

View File

@ -0,0 +1,99 @@
using Microsoft.PowerToys.Settings.UI.Lib;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.ServiceModel.Channels;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace Microsoft.PowerToys.Settings.UI.Views
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class PowerPreviewPage : Page
{
private const string POWERTOY_NAME = "File Explorer Preview";
public PowerPreviewPage()
{
this.InitializeComponent();
}
/// <inheritdoc/>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
PowerPreviewSettings settings;
try
{
base.OnNavigatedTo(e);
settings = SettingsUtils.GetSettings<PowerPreviewSettings>(POWERTOY_NAME);
ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value;
ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value;
}
catch(Exception exp)
{
settings = new PowerPreviewSettings(POWERTOY_NAME);
SettingsUtils.SaveSettings<PowerPreviewSettings>(settings, POWERTOY_NAME);
ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value;
ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value;
}
ShellPage.ShellHandler.ShowFeatureDetails();
ShellPage.ShellHandler.SetFeatureDetails(
"https://github.com/microsoft/PowerToys/tree/master/src/modules/previewpane",
"https://github.com/microsoft/PowerToys/issues");
ShellPage.ShellHandler.HideContributorsList();
}
private void ToggleSwitch_Preview_SVG_Toggled(object sender, RoutedEventArgs e)
{
ToggleSwitch swt = sender as ToggleSwitch;
if (swt != null)
{
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(POWERTOY_NAME);
settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value = swt.IsOn;
SndModuleSettings<PowerPreviewSettings> moduleSettings = new SndModuleSettings<PowerPreviewSettings>(settings);
if (ShellPage.Default_SndMSG_Callback != null)
{
ShellPage.Default_SndMSG_Callback(moduleSettings.ToString());
}
}
}
private void ToggleSwitch_Preview_MD_Toggled(object sender, RoutedEventArgs e)
{
ToggleSwitch swt = sender as ToggleSwitch;
if (swt != null)
{
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(POWERTOY_NAME);
settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value = swt.IsOn;
SndModuleSettings<PowerPreviewSettings> moduleSettings = new SndModuleSettings<PowerPreviewSettings>(settings);
if (ShellPage.Default_SndMSG_Callback != null)
{
ShellPage.Default_SndMSG_Callback(moduleSettings.ToString());
}
}
}
}
}

View File

@ -1,4 +1,4 @@
<UserControl
<UserControl
x:Class="Microsoft.PowerToys.Settings.UI.Views.ShellPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -41,8 +41,8 @@
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<winui:NavigationView
<winui:NavigationView
x:Name="navigationView"
IsBackButtonVisible="Collapsed"
IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}"
@ -62,96 +62,106 @@
</winui:NavigationView.PaneHeader> -->
<winui:NavigationView.MenuItems>
<!--
<winui:NavigationView.MenuItems>
<!--
TODO WTS: Change the symbols for each item as appropriate for your app
More on Segoe UI Symbol icons: https://docs.microsoft.com/windows/uwp/style/segoe-ui-symbol-font
Or to use an IconElement instead of a Symbol see https://github.com/Microsoft/WindowsTemplateStudio/blob/master/docs/projectTypes/navigationpane.md
Edit String/en-US/Resources.resw: Add a menu item title for each page
-->
<winui:NavigationViewItem x:Uid="Shell_General" helpers:NavHelper.NavigateTo="views:GeneralPage">
<winui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE713;"/>
</winui:NavigationViewItem.Icon>
</winui:NavigationViewItem>
<winui:NavigationViewItem x:Uid="Shell_General" helpers:NavHelper.NavigateTo="views:GeneralPage">
<winui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE713;"/>
</winui:NavigationViewItem.Icon>
</winui:NavigationViewItem>
<!-- TO DO: Update icon -->
<winui:NavigationViewItem x:Uid="Shell_PowerRename" helpers:NavHelper.NavigateTo="views:PowerRenamePage">
<winui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE8AC;"/>
</winui:NavigationViewItem.Icon>
</winui:NavigationViewItem>
<!-- TO DO: Update icon -->
<winui:NavigationViewItem x:Uid="Shell_PowerRename" helpers:NavHelper.NavigateTo="views:PowerRenamePage">
<winui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE8AC;"/>
</winui:NavigationViewItem.Icon>
</winui:NavigationViewItem>
<!-- TO DO: Update icon -->
<winui:NavigationViewItem x:Uid="Shell_ShortcutGuide" helpers:NavHelper.NavigateTo="views:ShortcutGuidePage">
<winui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xEDA7;"/>
</winui:NavigationViewItem.Icon>
</winui:NavigationViewItem>
<!-- TO DO: Update icon -->
<winui:NavigationViewItem x:Uid="Shell_ShortcutGuide" helpers:NavHelper.NavigateTo="views:ShortcutGuidePage">
<winui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xEDA7;"/>
</winui:NavigationViewItem.Icon>
</winui:NavigationViewItem>
<!-- TO DO: Update icon -->
<winui:NavigationViewItem x:Uid="Shell_PowerLauncher" helpers:NavHelper.NavigateTo="views:PowerLauncherPage">
<winui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE8A7;"/>
</winui:NavigationViewItem.Icon>
</winui:NavigationViewItem>
</winui:NavigationView.MenuItems>
<i:Interaction.Behaviors>
<behaviors:NavigationViewHeaderBehavior
<!-- TO DO: Update icon -->
<winui:NavigationViewItem x:Uid="Shell_PowerLauncher" helpers:NavHelper.NavigateTo="views:PowerLauncherPage">
<winui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE8A7;"/>
</winui:NavigationViewItem.Icon>
</winui:NavigationViewItem>
<winui:NavigationViewItem x:Uid="Shell_PowerPreview" helpers:NavHelper.NavigateTo="views:PowerPreviewPage" >
<winui:NavigationViewItem.Icon>
<PathIcon Data="M608 128q45 0 77 9t58 24 46 31 40 31 44 23 55 10h992q27 0 50 10t40 27 28 41 10 50v384h-128V384H928q-31 0-54 9t-44 24-41 31-45 31-58 23-78 10H128v1152h128v128H0V256q0-27 10-50t27-40 41-28 50-10h480zm0 256q24 0 42-4t33-13 29-20 32-27q-17-15-31-26t-30-20-33-13-42-5H128v128h480zm1440 512v1152H384V896h1664zm-128 128H512v896h1408v-896zm-128 256h-384v-128h384v128zm-128 256h-256v-128h256v128zm0 256h-256v-128h256v128zm-384 0H640v-640h640v640zm-128-512H768v384h384v-384z" ></PathIcon>
</winui:NavigationViewItem.Icon>
</winui:NavigationViewItem>
</winui:NavigationView.MenuItems>
<i:Interaction.Behaviors>
<behaviors:NavigationViewHeaderBehavior
DefaultHeader="{x:Bind ViewModel.Selected.Content, Mode=OneWay}">
<behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
<DataTemplate>
<!-- TODO: Style clean up-->
<Grid Margin="0, 24, 0, 6">
<TextBlock
<behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
<DataTemplate>
<!-- TODO: Style clean up-->
<Grid Margin="0, 24, 0, 6">
<TextBlock
Text="{Binding}"
FontWeight="Bold"
Style="{ThemeResource TitleTextBlockStyle}"
Margin="{StaticResource SmallLeftRightMargin}" />
</Grid>
</DataTemplate>
</behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
</behaviors:NavigationViewHeaderBehavior>
<ic:EventTriggerBehavior EventName="ItemInvoked">
<ic:InvokeCommandAction Command="{x:Bind ViewModel.ItemInvokedCommand}" />
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>
<ScrollViewer Grid.Column="0">
<Grid RowSpacing="32"
</Grid>
</DataTemplate>
</behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
</behaviors:NavigationViewHeaderBehavior>
<ic:EventTriggerBehavior EventName="ItemInvoked">
<ic:InvokeCommandAction Command="{x:Bind ViewModel.ItemInvokedCommand}" />
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>
<ScrollViewer Grid.Column="0">
<Grid RowSpacing="32"
Margin="{StaticResource MediumLeftRightBottomMargin}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Frame x:Name="shellFrame" />
<Frame x:Name="shellFrame" />
<StackPanel x:Name="SidePanel"
<StackPanel x:Name="SidePanel"
Orientation="Vertical"
HorizontalAlignment="Left"
Width="240"
Grid.Column="1">
<TextBlock Text="About this feature"
<TextBlock x:Name="Feature_Details_Title"
Text="About this feature"
Style="{StaticResource SettingsGroupTitleStyle}"
Margin="{StaticResource XSmallBottomMargin}"/>
<HyperlinkButton Content="Module overview"/>
<HyperlinkButton Content="Give feedback"/>
<ListView x:Name="Feature_Details">
<HyperlinkButton x:Name="Module_Overview_LinkButton"
Content="Module overview"/>
<HyperlinkButton x:Name="Module_Feedback_LinkButton"
Content="Give feedback"/>
</ListView>
<TextBlock Text="Contributors"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<TextBlock x:Name="Contributors_List_Title"
Text="Contributors"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>
</StackPanel>
</Grid>
</ScrollViewer>
</winui:NavigationView>
<ListView x:Name="Contributors_List" />
</StackPanel>
</Grid>
</ScrollViewer>
</winui:NavigationView>
</Grid>
</UserControl>

View File

@ -5,10 +5,13 @@
namespace Microsoft.PowerToys.Settings.UI.Views
{
using System;
using System.Collections.Generic;
using Microsoft.PowerToys.Settings.UI.Activation;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.Services;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
/// <summary>
@ -30,19 +33,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// <summary>
/// A shell handler to be used to update contents of the shell dynamically from page within the frame.
/// </summary>
public static Microsoft.UI.Xaml.Controls.NavigationView ShellHandler = null;
/// <summary>
/// IPC callback function for restart elevated.
/// </summary>
public static IPCMessageCallback Restart_Elevated_Callback = null;
public static ShellPage ShellHandler = null;
/// <summary>
/// IPC callback function for run on start up.
/// </summary>
public static IPCMessageCallback Run_OnStartUp_Callback = null;
public static IPCMessageCallback Default_SndMSG_Callback = null;
/// <summary>
/// Initializes a new instance of the <see cref="ShellPage"/> class.
@ -53,27 +49,61 @@ namespace Microsoft.PowerToys.Settings.UI.Views
this.InitializeComponent();
this.DataContext = this.ViewModel;
ShellHandler = this.navigationView;
ShellHandler = this;
this.ViewModel.Initialize(this.shellFrame, this.navigationView, this.KeyboardAccelerators);
this.shellFrame.Navigate(typeof(GeneralPage));
}
/// <summary>
/// Restart elevated callback function initialization.
/// </summary>
/// <param name="implmentation">delegate function implementation.</param>
public void SetRestartElevatedCallback(IPCMessageCallback implmentation)
{
Restart_Elevated_Callback = implmentation;
}
/// <summary>
/// Run on start up callback function elevated initialization.
/// </summary>
/// <param name="implmentation">delegate function implementation.</param>
public void SetRunOnStartUpCallback(IPCMessageCallback implmentation)
public void SetDefaultSndMessageCallback(IPCMessageCallback implmentation)
{
Run_OnStartUp_Callback = implmentation;
Default_SndMSG_Callback = implmentation;
}
public void HideFeatureDetails()
{
this.Feature_Details_Title.Visibility = Visibility.Collapsed;
this.Feature_Details.Visibility = Visibility.Collapsed;
}
public void ShowFeatureDetails()
{
this.Feature_Details_Title.Visibility = Visibility.Visible;
this.Feature_Details.Visibility = Visibility.Visible;
}
public void SetFeatureDetails(string moduleOverviewLink,string reportBugLink)
{
this.Module_Overview_LinkButton.NavigateUri = new Uri(moduleOverviewLink);
this.Module_Feedback_LinkButton.NavigateUri = new Uri(reportBugLink);
}
public void HideContributorsList()
{
this.Contributors_List_Title.Visibility = Visibility.Collapsed;
this.Contributors_List.Visibility = Visibility.Collapsed;
}
public void ShowContributorsList()
{
this.Contributors_List_Title.Visibility = Visibility.Visible;
this.Contributors_List.Visibility = Visibility.Visible;
}
public void PopulateContributorsList(List<Contributor> contributors)
{
this.Contributors_List.Items.Clear();
foreach (Contributor contributor in contributors)
{
HyperlinkButton link = new HyperlinkButton();
link.Content = contributor.Name;
link.NavigateUri = new Uri(contributor.Link);
this.Contributors_List.Items.Add(link);
}
}
}
}

View File

@ -10,9 +10,12 @@ namespace Test
{
static void Main(string[] args)
{
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
OutGoingGeneralSettings outSettings = new OutGoingGeneralSettings(settings);
Console.WriteLine(outSettings.ToString());
PowerPreviewSettings pvst = new PowerPreviewSettings();
pvst.name = "File Explorer";
SndModuleSettings<PowerPreviewSettings> snd = new SndModuleSettings<PowerPreviewSettings>(pvst);
Console.WriteLine(snd.ToString());
}
}
}