mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
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:
parent
a84be2ba60
commit
f1951d0d5f
@ -191,7 +191,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
.editorconfig = .editorconfig
|
.editorconfig = .editorconfig
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
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
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
12
src/core/Microsoft.PowerToys.Settings.UI.Lib/Contributor.cs
Normal file
12
src/core/Microsoft.PowerToys.Settings.UI.Lib/Contributor.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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() + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,10 +7,8 @@
|
|||||||
xmlns:Controls="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls"
|
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"
|
xmlns:xaml="clr-namespace:Microsoft.Toolkit.Wpf.UI.XamlHost;assembly=Microsoft.Toolkit.Wpf.UI.XamlHost"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="PowerToys Settings" Height="800" Width="800">
|
Title="PowerToys Settings" Height="800" Width="1000">
|
||||||
|
<Grid>
|
||||||
<Grid >
|
|
||||||
<!--<xaml:WindowsXamlHost InitialTypeName="Microsoft.PowerToys.Settings.UI.Controls.DummyUserControl" ChildChanged="WindowsXamlHost_ChildChanged" />-->
|
|
||||||
<xaml:WindowsXamlHost InitialTypeName="Microsoft.PowerToys.Settings.UI.Views.ShellPage" ChildChanged="WindowsXamlHost_ChildChanged" />
|
<xaml:WindowsXamlHost InitialTypeName="Microsoft.PowerToys.Settings.UI.Views.ShellPage" ChildChanged="WindowsXamlHost_ChildChanged" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -25,30 +25,12 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
|
|||||||
|
|
||||||
if (shellPage != null)
|
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);
|
Program.ipcmanager.SendMessage(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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">
|
<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')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
@ -144,6 +144,9 @@
|
|||||||
<Compile Include="Views\PowerLauncherPage.xaml.cs">
|
<Compile Include="Views\PowerLauncherPage.xaml.cs">
|
||||||
<DependentUpon>PowerLauncherPage.xaml</DependentUpon>
|
<DependentUpon>PowerLauncherPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\PowerPreviewPage.xaml.cs">
|
||||||
|
<DependentUpon>PowerPreviewPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\PowerRenamePage.xaml.cs">
|
<Compile Include="Views\PowerRenamePage.xaml.cs">
|
||||||
<DependentUpon>PowerRenamePage.xaml</DependentUpon>
|
<DependentUpon>PowerRenamePage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -223,6 +226,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\PowerPreviewPage.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\PowerRenamePage.xaml">
|
<Page Include="Views\PowerRenamePage.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
@ -145,4 +145,8 @@
|
|||||||
<value>Shortcut Guide</value>
|
<value>Shortcut Guide</value>
|
||||||
<comment>Navigation view item name for Shortcut Guide</comment>
|
<comment>Navigation view item name for Shortcut Guide</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Shell_PowerPreview.Content" xml:space="preserve">
|
||||||
|
<value>File Explorer Preview</value>
|
||||||
|
<comment>File Explorer Preview Settings</comment>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -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 (c) Microsoft Corp. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
@ -35,14 +35,32 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
//GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
|
||||||
base.OnNavigatedTo(e);
|
base.OnNavigatedTo(e);
|
||||||
|
GeneralSettings settings = null;
|
||||||
// load and apply theme settings
|
try
|
||||||
// this.ReLoadTheme(settings.theme);
|
{
|
||||||
|
// 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.
|
// load run on start-up settings value and update the ui state.
|
||||||
//this.ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
|
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>
|
/// <summary>
|
||||||
@ -90,9 +108,9 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
SettingsUtils.SaveSettings<GeneralSettings>(settings, string.Empty);
|
SettingsUtils.SaveSettings<GeneralSettings>(settings, string.Empty);
|
||||||
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
|
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;
|
settings.run_elevated = true;
|
||||||
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
|
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.
|
// update and save settings to file.
|
||||||
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
||||||
settings.theme = themeName;
|
settings.theme = themeName;
|
||||||
SettingsUtils.SaveSettings<GeneralSettings>(settings,string.Empty);
|
SettingsUtils.SaveSettings<GeneralSettings>(settings, string.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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>
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<UserControl
|
<UserControl
|
||||||
x:Class="Microsoft.PowerToys.Settings.UI.Views.ShellPage"
|
x:Class="Microsoft.PowerToys.Settings.UI.Views.ShellPage"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
@ -41,8 +41,8 @@
|
|||||||
</VisualState>
|
</VisualState>
|
||||||
</VisualStateGroup>
|
</VisualStateGroup>
|
||||||
</VisualStateManager.VisualStateGroups>
|
</VisualStateManager.VisualStateGroups>
|
||||||
|
|
||||||
<winui:NavigationView
|
<winui:NavigationView
|
||||||
x:Name="navigationView"
|
x:Name="navigationView"
|
||||||
IsBackButtonVisible="Collapsed"
|
IsBackButtonVisible="Collapsed"
|
||||||
IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}"
|
IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}"
|
||||||
@ -62,96 +62,106 @@
|
|||||||
|
|
||||||
|
|
||||||
</winui:NavigationView.PaneHeader> -->
|
</winui:NavigationView.PaneHeader> -->
|
||||||
<winui:NavigationView.MenuItems>
|
<winui:NavigationView.MenuItems>
|
||||||
<!--
|
<!--
|
||||||
TODO WTS: Change the symbols for each item as appropriate for your app
|
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
|
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
|
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
|
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 x:Uid="Shell_General" helpers:NavHelper.NavigateTo="views:GeneralPage">
|
||||||
<winui:NavigationViewItem.Icon>
|
<winui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</winui:NavigationViewItem.Icon>
|
</winui:NavigationViewItem.Icon>
|
||||||
</winui:NavigationViewItem>
|
</winui:NavigationViewItem>
|
||||||
|
|
||||||
<!-- TO DO: Update icon -->
|
<!-- TO DO: Update icon -->
|
||||||
<winui:NavigationViewItem x:Uid="Shell_PowerRename" helpers:NavHelper.NavigateTo="views:PowerRenamePage">
|
<winui:NavigationViewItem x:Uid="Shell_PowerRename" helpers:NavHelper.NavigateTo="views:PowerRenamePage">
|
||||||
<winui:NavigationViewItem.Icon>
|
<winui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</winui:NavigationViewItem.Icon>
|
</winui:NavigationViewItem.Icon>
|
||||||
</winui:NavigationViewItem>
|
</winui:NavigationViewItem>
|
||||||
|
|
||||||
<!-- TO DO: Update icon -->
|
<!-- TO DO: Update icon -->
|
||||||
<winui:NavigationViewItem x:Uid="Shell_ShortcutGuide" helpers:NavHelper.NavigateTo="views:ShortcutGuidePage">
|
<winui:NavigationViewItem x:Uid="Shell_ShortcutGuide" helpers:NavHelper.NavigateTo="views:ShortcutGuidePage">
|
||||||
<winui:NavigationViewItem.Icon>
|
<winui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</winui:NavigationViewItem.Icon>
|
</winui:NavigationViewItem.Icon>
|
||||||
</winui:NavigationViewItem>
|
</winui:NavigationViewItem>
|
||||||
|
|
||||||
<!-- TO DO: Update icon -->
|
<!-- TO DO: Update icon -->
|
||||||
<winui:NavigationViewItem x:Uid="Shell_PowerLauncher" helpers:NavHelper.NavigateTo="views:PowerLauncherPage">
|
<winui:NavigationViewItem x:Uid="Shell_PowerLauncher" helpers:NavHelper.NavigateTo="views:PowerLauncherPage">
|
||||||
<winui:NavigationViewItem.Icon>
|
<winui:NavigationViewItem.Icon>
|
||||||
<FontIcon Glyph=""/>
|
<FontIcon Glyph=""/>
|
||||||
</winui:NavigationViewItem.Icon>
|
</winui:NavigationViewItem.Icon>
|
||||||
</winui:NavigationViewItem>
|
</winui:NavigationViewItem>
|
||||||
</winui:NavigationView.MenuItems>
|
|
||||||
<i:Interaction.Behaviors>
|
<winui:NavigationViewItem x:Uid="Shell_PowerPreview" helpers:NavHelper.NavigateTo="views:PowerPreviewPage" >
|
||||||
<behaviors:NavigationViewHeaderBehavior
|
<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}">
|
DefaultHeader="{x:Bind ViewModel.Selected.Content, Mode=OneWay}">
|
||||||
<behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
|
<behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<!-- TODO: Style clean up-->
|
<!-- TODO: Style clean up-->
|
||||||
<Grid Margin="0, 24, 0, 6">
|
<Grid Margin="0, 24, 0, 6">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding}"
|
Text="{Binding}"
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
Style="{ThemeResource TitleTextBlockStyle}"
|
Style="{ThemeResource TitleTextBlockStyle}"
|
||||||
Margin="{StaticResource SmallLeftRightMargin}" />
|
Margin="{StaticResource SmallLeftRightMargin}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
|
</behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
|
||||||
</behaviors:NavigationViewHeaderBehavior>
|
</behaviors:NavigationViewHeaderBehavior>
|
||||||
<ic:EventTriggerBehavior EventName="ItemInvoked">
|
<ic:EventTriggerBehavior EventName="ItemInvoked">
|
||||||
<ic:InvokeCommandAction Command="{x:Bind ViewModel.ItemInvokedCommand}" />
|
<ic:InvokeCommandAction Command="{x:Bind ViewModel.ItemInvokedCommand}" />
|
||||||
</ic:EventTriggerBehavior>
|
</ic:EventTriggerBehavior>
|
||||||
</i:Interaction.Behaviors>
|
</i:Interaction.Behaviors>
|
||||||
<ScrollViewer Grid.Column="0">
|
<ScrollViewer Grid.Column="0">
|
||||||
<Grid RowSpacing="32"
|
<Grid RowSpacing="32"
|
||||||
Margin="{StaticResource MediumLeftRightBottomMargin}">
|
Margin="{StaticResource MediumLeftRightBottomMargin}">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Frame x:Name="shellFrame" />
|
<Frame x:Name="shellFrame" />
|
||||||
|
|
||||||
<StackPanel x:Name="SidePanel"
|
<StackPanel x:Name="SidePanel"
|
||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Width="240"
|
Width="240"
|
||||||
Grid.Column="1">
|
Grid.Column="1">
|
||||||
|
|
||||||
<TextBlock Text="About this feature"
|
<TextBlock x:Name="Feature_Details_Title"
|
||||||
|
Text="About this feature"
|
||||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||||
|
|
||||||
<HyperlinkButton Content="Module overview"/>
|
<ListView x:Name="Feature_Details">
|
||||||
<HyperlinkButton Content="Give feedback"/>
|
<HyperlinkButton x:Name="Module_Overview_LinkButton"
|
||||||
|
Content="Module overview"/>
|
||||||
|
<HyperlinkButton x:Name="Module_Feedback_LinkButton"
|
||||||
|
Content="Give feedback"/>
|
||||||
|
</ListView>
|
||||||
|
|
||||||
<TextBlock Text="Contributors"
|
<TextBlock x:Name="Contributors_List_Title"
|
||||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
Text="Contributors"
|
||||||
|
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||||
|
|
||||||
<HyperlinkButton Content="Contributor name"/>
|
<ListView x:Name="Contributors_List" />
|
||||||
<HyperlinkButton Content="Contributor name"/>
|
</StackPanel>
|
||||||
<HyperlinkButton Content="Contributor name"/>
|
</Grid>
|
||||||
</StackPanel>
|
</ScrollViewer>
|
||||||
</Grid>
|
</winui:NavigationView>
|
||||||
</ScrollViewer>
|
|
||||||
</winui:NavigationView>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@ -5,10 +5,13 @@
|
|||||||
namespace Microsoft.PowerToys.Settings.UI.Views
|
namespace Microsoft.PowerToys.Settings.UI.Views
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Microsoft.PowerToys.Settings.UI.Activation;
|
using Microsoft.PowerToys.Settings.UI.Activation;
|
||||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||||
|
using Microsoft.PowerToys.Settings.UI.Lib;
|
||||||
using Microsoft.PowerToys.Settings.UI.Services;
|
using Microsoft.PowerToys.Settings.UI.Services;
|
||||||
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -30,19 +33,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A shell handler to be used to update contents of the shell dynamically from page within the frame.
|
/// A shell handler to be used to update contents of the shell dynamically from page within the frame.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Microsoft.UI.Xaml.Controls.NavigationView ShellHandler = null;
|
public static ShellPage ShellHandler = null;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// IPC callback function for restart elevated.
|
|
||||||
/// </summary>
|
|
||||||
public static IPCMessageCallback Restart_Elevated_Callback = null;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IPC callback function for run on start up.
|
/// IPC callback function for run on start up.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IPCMessageCallback Run_OnStartUp_Callback = null;
|
public static IPCMessageCallback Default_SndMSG_Callback = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ShellPage"/> class.
|
/// Initializes a new instance of the <see cref="ShellPage"/> class.
|
||||||
@ -53,27 +49,61 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
|
|
||||||
this.DataContext = this.ViewModel;
|
this.DataContext = this.ViewModel;
|
||||||
ShellHandler = this.navigationView;
|
ShellHandler = this;
|
||||||
this.ViewModel.Initialize(this.shellFrame, this.navigationView, this.KeyboardAccelerators);
|
this.ViewModel.Initialize(this.shellFrame, this.navigationView, this.KeyboardAccelerators);
|
||||||
this.shellFrame.Navigate(typeof(GeneralPage));
|
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>
|
/// <summary>
|
||||||
/// Run on start up callback function elevated initialization.
|
/// Run on start up callback function elevated initialization.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="implmentation">delegate function implementation.</param>
|
/// <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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,12 @@ namespace Test
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
PowerPreviewSettings pvst = new PowerPreviewSettings();
|
||||||
OutGoingGeneralSettings outSettings = new OutGoingGeneralSettings(settings);
|
pvst.name = "File Explorer";
|
||||||
Console.WriteLine(outSettings.ToString());
|
|
||||||
|
SndModuleSettings<PowerPreviewSettings> snd = new SndModuleSettings<PowerPreviewSettings>(pvst);
|
||||||
|
|
||||||
|
Console.WriteLine(snd.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user