Make it work - WIP

This commit is contained in:
Stefan Markovic 2021-11-06 18:03:16 +01:00
parent 79bd4031be
commit 9ad691a282
10 changed files with 65 additions and 36 deletions

View file

@ -71,9 +71,17 @@ namespace Microsoft.PowerToys.Settings.UI.Library
{
try
{
long seconds = long.Parse(LastCheckedDate, CultureInfo.CurrentCulture);
var date = DateTimeOffset.FromUnixTimeSeconds(seconds).UtcDateTime;
return date.ToLocalTime().ToString(CultureInfo.CurrentCulture);
// TODO(stefan) revert this
if (LastCheckedDate != null)
{
long seconds = long.Parse(LastCheckedDate, CultureInfo.CurrentCulture);
var date = DateTimeOffset.FromUnixTimeSeconds(seconds).UtcDateTime;
return date.ToLocalTime().ToString(CultureInfo.CurrentCulture);
}
else
{
return DateTime.UtcNow.ToString(CultureInfo.CurrentCulture);
}
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception)

View file

@ -90,7 +90,7 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Controls
this.Unloaded += ShortcutControl_Unloaded;
hook = new HotkeySettingsControlHook(Hotkey_KeyDown, Hotkey_KeyUp, Hotkey_IsActive, FilterAccessibleKeyboardEvents);
ResourceLoader resourceLoader = ResourceLoader.GetForCurrentView();
ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse();
// We create the Dialog in C# because doing it in XAML is giving WinUI/XAML Island bugs when using dark theme.
shortcutDialog = new ContentDialog

View file

@ -22,9 +22,9 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Converters
string targetValue = string.Empty;
switch (value)
{
case 0: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Fit_Fill_ThirdPersonSingular"); break;
case 1: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Fit_Fit_ThirdPersonSingular"); break;
case 2: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Fit_Stretch_ThirdPersonSingular"); break;
case 0: targetValue = ResourceLoader.GetForViewIndependentUse().GetString("ImageResizer_Fit_Fill_ThirdPersonSingular"); break;
case 1: targetValue = ResourceLoader.GetForViewIndependentUse().GetString("ImageResizer_Fit_Fit_ThirdPersonSingular"); break;
case 2: targetValue = ResourceLoader.GetForViewIndependentUse().GetString("ImageResizer_Fit_Stretch_ThirdPersonSingular"); break;
}
if (toLower)

View file

@ -22,10 +22,10 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Converters
string targetValue = string.Empty;
switch (value)
{
case 0: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Unit_Centimeter"); break;
case 1: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Unit_Inch"); break;
case 2: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Unit_Percent"); break;
case 3: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Unit_Pixel"); break;
case 0: targetValue = ResourceLoader.GetForViewIndependentUse().GetString("ImageResizer_Unit_Centimeter"); break;
case 1: targetValue = ResourceLoader.GetForViewIndependentUse().GetString("ImageResizer_Unit_Inch"); break;
case 2: targetValue = ResourceLoader.GetForViewIndependentUse().GetString("ImageResizer_Unit_Percent"); break;
case 3: targetValue = ResourceLoader.GetForViewIndependentUse().GetString("ImageResizer_Unit_Pixel"); break;
}
if (toLower)

View file

@ -27,10 +27,5 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3
{
this.InitializeComponent();
}
private void myButton_Click(object sender, RoutedEventArgs e)
{
// myButton.Content = "Clicked";
}
}
}

View file

@ -283,10 +283,12 @@
<value>Remap a key</value>
<comment>Keyboard Manager remap keyboard button content</comment>
</data>
<!--
<data name="KeyboardManager_RemapKeyboardButton_Accessible.AutomationProperties.Name" xml:space="preserve">
<value>Remap a key</value>
<comment>Keyboard Manager remap keyboard button content</comment>
</data>
-->
<data name="KeyboardManager_Keys.Header" xml:space="preserve">
<value>Keys</value>
<comment>Keyboard Manager remap keyboard header</comment>
@ -295,10 +297,12 @@
<value>Remap a shortcut</value>
<comment>Keyboard Manager remap shortcuts button</comment>
</data>
<!--
<data name="KeyboardManager_RemapShortcutsButton_Accessible.AutomationProperties.Name" xml:space="preserve">
<value>Remap a shortcut</value>
<comment>Keyboard Manager remap shortcuts button</comment>
</data>
-->
<data name="KeyboardManager_Shortcuts.Header" xml:space="preserve">
<value>Shortcuts</value>
<comment>Keyboard Manager remap keyboard header</comment>
@ -309,12 +313,14 @@
<data name="Shortcut.Header" xml:space="preserve">
<value>Shortcut</value>
</data>
<!--
<data name="RemapKeysList.AutomationProperties.Name" xml:space="preserve">
<value>Current Key Remappings</value>
</data>
<data name="RemapShortcutsList.AutomationProperties.Name" xml:space="preserve">
<value>Current Shortcut Remappings</value>
</data>
-->
<data name="KeyboardManager_RemappedKeysListItem.AutomationProperties.Name" xml:space="preserve">
<value>Key Remapping</value>
<comment>key as in keyboard key</comment>
@ -478,10 +484,12 @@
<value>Launch layout editor</value>
<comment>launches the FancyZones layout editor application</comment>
</data>
<!--
<data name="FancyZones_LaunchEditorButton_Accessible.AutomationProperties.Name" xml:space="preserve">
<value>Launch layout editor</value>
<comment>launches the FancyZones layout editor application</comment>
</data>
-->
<data name="FancyZones_LaunchEditorButtonControl.Description" xml:space="preserve">
<value>Set and manage your layouts</value>
<comment>launches the FancyZones layout editor application</comment>
@ -715,9 +723,11 @@
<value>Enable Image Resizer</value>
<comment>do not loc the Product name. Do you want this feature on / off</comment>
</data>
<!--
<data name="ImagesSizesListView.AutomationProperties.Name" xml:space="preserve">
<value>Image Size</value>
</data>
-->
<data name="ImageResizer_Configurations.AutomationProperties.Name" xml:space="preserve">
<value>Configurations</value>
</data>
@ -736,10 +746,12 @@
<data name="ImageResizer_Size.Header" xml:space="preserve">
<value>Unit</value>
</data>
<!--
<data name="RemoveButton.AutomationProperties.Name" xml:space="preserve">
<value>Remove</value>
<comment>Removes a user defined setting group for Image Resizer</comment>
</data>
-->
<data name="ImageResizer_Image.AutomationProperties.Name" xml:space="preserve">
<value>Image Resizer</value>
</data>
@ -912,9 +924,11 @@
<data name="General_VersionLastChecked.Text" xml:space="preserve">
<value>Last checked: </value>
</data>
<!--
<data name="General_Version.AutomationProperties.Name" xml:space="preserve">
<value>Version</value>
</data>
-->
<data name="Admin_mode.Header" xml:space="preserve">
<value>Administrator mode</value>
</data>
@ -1012,9 +1026,11 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
<data name="ImageResizer_FilenameFormatPlaceholder.PlaceholderText" xml:space="preserve">
<value>Example: %1 (%2)</value>
</data>
<!--
<data name="ImageResizer_FilenameParameters.AutomationProperties.Name" xml:space="preserve">
<value>Filename parameters</value>
</data>
-->
<data name="Radio_Theme_Dark.Content" xml:space="preserve">
<value>Dark</value>
<comment>Dark refers to color, not weight</comment>
@ -1118,12 +1134,14 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
<value>Small</value>
<comment>The size of the image</comment>
</data>
<!--
<data name="FancyZones_MoveWindowBasedOnRelativePosition_Accessible.AutomationProperties.Name" xml:space="preserve">
<value>Windows key + Up, down, left or right arrow key to move windows based on relative position</value>
</data>
<data name="FancyZones_MoveWindowLeftRightBasedOnZoneIndex_Accessible.AutomationProperties.Name" xml:space="preserve">
<value>Windows key + Left or right arrow keys to move windows based on zone index</value>
</data>
-->
<data name="FancyZones_MoveWindowBasedOnRelativePosition_Description.Text" xml:space="preserve">
<value>Windows key +    or </value>
<comment>Do not loc the icons (hex numbers)</comment>
@ -1175,9 +1193,11 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
<data name="PowerLauncher_IncludeInGlobalResultDescription.Text" xml:space="preserve">
<value>Show results on queries without direct activation command</value>
</data>
<!--
<data name="PowerLauncher_EnablePluginToggle.AutomationProperties.Name" xml:space="preserve">
<value>Enable plugin</value>
</data>
-->
<data name="Run_AdditionalOptions.Text" xml:space="preserve">
<value>Additional options</value>
</data>
@ -1534,9 +1554,11 @@ From there, simply click on a Markdown file, PDF file or SVG icon in the File Ex
<data name="ImageResizer_Unit_Pixel" xml:space="preserve">
<value>Pixels</value>
</data>
<!--
<data name="EditButton.AutomationProperties.Name" xml:space="preserve">
<value>Edit</value>
</data>
-->
<data name="No" xml:space="preserve">
<value>No</value>
<comment>Label of a cancel button</comment>
@ -1557,12 +1579,14 @@ From there, simply click on a Markdown file, PDF file or SVG icon in the File Ex
<data name="ExcludedApps.Header" xml:space="preserve">
<value>Excluded apps</value>
</data>
<!--
<data name="Enable_ColorFormat.AutomationProperties.Name" xml:space="preserve">
<value>Enable colorformat</value>
</data>
<data name="More_Options_Button.AutomationProperties.Name" xml:space="preserve">
<value>More options</value>
</data>
-->
<data name="More_Options_ButtonTooltip.Text" xml:space="preserve">
<value>More options</value>
</data>
@ -1645,9 +1669,11 @@ From there, simply click on a Markdown file, PDF file or SVG icon in the File Ex
<data name="PowerLauncher_SearchList.PlaceholderText" xml:space="preserve">
<value>Search this list</value>
</data>
<!--
<data name="PowerLauncher_SearchList.AutomationProperties.Name" xml:space="preserve">
<value>Search this list</value>
</data>
-->
<data name="Awake.SecondaryLinksHeader" xml:space="preserve">
<value>Attribution</value>
</data>

View file

@ -23,8 +23,7 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
{
InitializeComponent();
var settingsUtils = new SettingsUtils();
//TODO(stefan)
//var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
var resourceLoader = ResourceLoader.GetForViewIndependentUse();
Func<string, string> loader = (string name) =>
{
//return resourceLoader.GetString(name);
@ -42,7 +41,7 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
if (deleteRowButton != null)
{
ImageSize x = (ImageSize)deleteRowButton.DataContext;
ResourceLoader resourceLoader = ResourceLoader.GetForCurrentView();
ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse();
ContentDialog dialog = new ContentDialog();
dialog.XamlRoot = RootPage.XamlRoot;
@ -73,7 +72,7 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
{
try
{
ViewModel.AddRow(ResourceLoader.GetForCurrentView().GetString("ImageResizer_DefaultSize_NewSizePrefix"));
ViewModel.AddRow(ResourceLoader.GetForViewIndependentUse().GetString("ImageResizer_DefaultSize_NewSizePrefix"));
}
catch (Exception ex)
{
@ -87,8 +86,8 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
if (ViewModel.IsListViewFocusRequested)
{
// Set focus to the last item in the ListView
int size = ImagesSizesListView.Items.Count;
((ListViewItem)ImagesSizesListView.ContainerFromIndex(size - 1)).Focus(FocusState.Programmatic);
//int size = ImagesSizesListView.Items.Count;
//((ListViewItem)ImagesSizesListView.ContainerFromIndex(size - 1)).Focus(FocusState.Programmatic);
// Reset the focus requested flag
ViewModel.IsListViewFocusRequested = false;

View file

@ -23,14 +23,15 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
{
private const string PowerToyName = "Keyboard Manager";
private readonly CoreDispatcher dispatcher;
// TODO(stefan) bring this back
//private readonly CoreDispatcher dispatcher;
private readonly IFileSystemWatcher watcher;
public KeyboardManagerViewModel ViewModel { get; }
public KeyboardManagerPage()
{
dispatcher = Window.Current.Dispatcher;
//dispatcher = Window.Current.Dispatcher;
var settingsUtils = new SettingsUtils();
ViewModel = new KeyboardManagerViewModel(settingsUtils, SettingsRepository<GeneralSettings>.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, FilterRemapKeysList);
@ -50,18 +51,18 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
// Todo: Handle duplicate events either by somehow suppress them or re-read the configuration everytime since we will be updating the UI only if something is changed.
if (ViewModel.LoadProfile())
{
await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
/*await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
ViewModel.NotifyFileChanged();
});
});*/
}
}
private static void CombineRemappings(List<KeysDataModel> remapKeysList, uint leftKey, uint rightKey, uint combinedKey)
{
// Using InvariantCulture for keys as they are internally represented as numerical values
KeysDataModel firstRemap = remapKeysList.Find(x => uint.Parse(x.OriginalKeys, CultureInfo.InvariantCulture) == leftKey);
KeysDataModel secondRemap = remapKeysList.Find(x => uint.Parse(x.OriginalKeys, CultureInfo.InvariantCulture) == rightKey);
KeysDataModel firstRemap = remapKeysList?.Find(x => uint.Parse(x.OriginalKeys, CultureInfo.InvariantCulture) == leftKey);
KeysDataModel secondRemap = remapKeysList?.Find(x => uint.Parse(x.OriginalKeys, CultureInfo.InvariantCulture) == rightKey);
if (firstRemap != null && secondRemap != null)
{
if (firstRemap.NewRemapKeys == secondRemap.NewRemapKeys)

View file

@ -9,6 +9,7 @@ using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
using Microsoft.UI.Xaml.Controls;
using Windows.ApplicationModel.Resources;
// TODO(stefan)
using WindowsUI = Windows.UI;
@ -52,8 +53,7 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
}
});
// TODO(stefan)
/* var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
var loader = ResourceLoader.GetForViewIndependentUse();
searchResultPreferencesOptions = new ObservableCollection<Tuple<string, string>>();
searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_AlphabeticalOrder"), "alphabetical_order"));
@ -64,7 +64,7 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ApplicationName"), "application_name"));
searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_StringInApplication"), "string_in_application"));
searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ExecutableName"), "executable_name"));
*/ }
}
private void OpenColorsSettings_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{

View file

@ -14,6 +14,7 @@ using Microsoft.UI.Xaml.Controls;
// TODO(stefan)
using WSL = Windows.System.Launcher;
using Windows.ApplicationModel.Resources;
namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
{
@ -186,14 +187,13 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
if (AutomationPeer.ListenerExists(AutomationEvents.MenuOpened))
{
// TODO(stefan)
/* var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
var loader = ResourceLoader.GetForViewIndependentUse();
peer.RaiseNotificationEvent(
AutomationNotificationKind.ActionCompleted,
AutomationNotificationProcessing.ImportantMostRecent,
loader.GetString("Shell_NavigationMenu_Announce_Open"),
"navigationMenuPaneOpened");
*/ }
}
}
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Params are required for event handler signature requirements.")]
@ -214,13 +214,13 @@ namespace Microsoft.PowerToys.Settings.UI.WinUI3.Views
if (AutomationPeer.ListenerExists(AutomationEvents.MenuClosed))
{
// TODO(stefan)
/* var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
var loader = ResourceLoader.GetForViewIndependentUse();
peer.RaiseNotificationEvent(
AutomationNotificationKind.ActionCompleted,
AutomationNotificationProcessing.ImportantMostRecent,
loader.GetString("Shell_NavigationMenu_Announce_Collapse"),
"navigationMenuPaneClosed");
*/}
}
}
private void OOBEItem_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)