2021-10-22 13:30:18 +01:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
2024-08-15 17:29:25 +02:00
|
|
|
|
using System;
|
2024-10-17 05:14:57 -04:00
|
|
|
|
|
2024-08-15 17:29:25 +02:00
|
|
|
|
using ManagedCommon;
|
2023-01-31 00:00:11 +01:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Helpers;
|
2021-10-22 13:30:18 +01:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library;
|
2022-10-26 14:02:31 +01:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
2022-04-19 22:00:28 +02:00
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
2021-10-22 13:30:18 +01:00
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Views
|
|
|
|
|
|
{
|
2023-01-31 00:00:11 +01:00
|
|
|
|
public sealed partial class MouseUtilsPage : Page, IRefreshablePage
|
2021-10-22 13:30:18 +01:00
|
|
|
|
{
|
|
|
|
|
|
private MouseUtilsViewModel ViewModel { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public MouseUtilsPage()
|
|
|
|
|
|
{
|
2021-11-23 10:19:26 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// By mistake, the first release of Find My Mouse was saving settings in two places at the same time.
|
|
|
|
|
|
// Delete the wrong path for Find My Mouse settings.
|
|
|
|
|
|
var tempSettingsUtils = new SettingsUtils();
|
|
|
|
|
|
if (tempSettingsUtils.SettingsExists("Find My Mouse"))
|
|
|
|
|
|
{
|
|
|
|
|
|
var settingsFilePath = tempSettingsUtils.GetSettingsFilePath("Find My Mouse");
|
|
|
|
|
|
System.IO.File.Delete(settingsFilePath);
|
|
|
|
|
|
tempSettingsUtils.DeleteSettings("Find My Mouse");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (System.Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-10-22 13:30:18 +01:00
|
|
|
|
var settingsUtils = new SettingsUtils();
|
2022-01-24 13:29:16 +00:00
|
|
|
|
ViewModel = new MouseUtilsViewModel(
|
|
|
|
|
|
settingsUtils,
|
|
|
|
|
|
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),
|
|
|
|
|
|
SettingsRepository<FindMyMouseSettings>.GetInstance(settingsUtils),
|
|
|
|
|
|
SettingsRepository<MouseHighlighterSettings>.GetInstance(settingsUtils),
|
2023-02-24 13:30:30 +00:00
|
|
|
|
SettingsRepository<MouseJumpSettings>.GetInstance(settingsUtils),
|
2022-01-26 14:01:24 +00:00
|
|
|
|
SettingsRepository<MousePointerCrosshairsSettings>.GetInstance(settingsUtils),
|
2022-01-24 13:29:16 +00:00
|
|
|
|
ShellPage.SendDefaultIPCMessage);
|
|
|
|
|
|
|
2021-10-22 13:30:18 +01:00
|
|
|
|
DataContext = ViewModel;
|
|
|
|
|
|
InitializeComponent();
|
2024-11-26 15:37:59 +00:00
|
|
|
|
|
|
|
|
|
|
this.MouseUtils_MouseJump_Panel.ViewModel = ViewModel;
|
2025-08-20 09:31:52 +08:00
|
|
|
|
|
|
|
|
|
|
Loaded += (s, e) => ViewModel.OnPageLoaded();
|
2021-10-22 13:30:18 +01:00
|
|
|
|
}
|
2023-01-31 00:00:11 +01:00
|
|
|
|
|
|
|
|
|
|
public void RefreshEnabledState()
|
|
|
|
|
|
{
|
|
|
|
|
|
ViewModel.RefreshEnabledState();
|
|
|
|
|
|
}
|
2024-08-15 17:29:25 +02:00
|
|
|
|
|
|
|
|
|
|
private void OpenAnimationsSettings_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
StartProcessHelper.Start(StartProcessHelper.AnimationsSettings);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.LogError("Error while trying to open the animations settings", ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-10-22 13:30:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|