Skip to content

Commit

Permalink
Refactor code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
AkazaRenn committed Nov 24, 2023
1 parent 927061f commit e1c7899
Show file tree
Hide file tree
Showing 47 changed files with 1,006 additions and 832 deletions.
6 changes: 3 additions & 3 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Application
x:Class="FruitLanguageSwitcher.App"
x:Class="FruitToolbox.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FruitLanguageSwitcher">
xmlns:local="using:FruitToolbox">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
<ResourceDictionary Source="Views/TrayIcon.xaml" />
<ResourceDictionary Source="Settings/TrayIcon.xaml" />
<ResourceDictionary Source="ms-appx:///WinUICommunity.Components/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
Expand Down
25 changes: 12 additions & 13 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FruitLanguageSwitcher.Core;

using FruitToolbox.LanguageSwitcher;
using H.NotifyIcon;

using Microsoft.Toolkit.Uwp.Notifications;
Expand All @@ -9,7 +8,7 @@
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace FruitLanguageSwitcher
namespace FruitToolbox
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
Expand All @@ -20,10 +19,10 @@ public sealed partial class App: Application

public static TaskbarIcon TrayIcon { get; private set; }

private static LanguageSwitcher Switcher;
private static Hotkey Hotkey;
private static Views.Settings SettingsWindow = null;
private static Views.Flyout NewLangFlyout;
private static LanguageSwitcher.Core Switcher;
private static Hotkey.Core Hotkey;
private static Settings.View SettingsWindow = null;
private static LanguageSwitcher.Flyout NewLangFlyout;

#endregion

Expand Down Expand Up @@ -58,7 +57,7 @@ private static void InitializeFlyout()
{
NewLangFlyout = new();

LanguageSwitcher.NewLanguageEvent += NewLangFlyout.UpdateText;
LanguageSwitcher.Core.NewLanguageEvent += NewLangFlyout.UpdateText;
NewLangFlyout.Activate();
}

Expand All @@ -79,16 +78,16 @@ private void InitializeTrayIcon()

private static void InitializeFunction()
{
Switcher = new LanguageSwitcher();
Hotkey = new Hotkey(Switcher.SwapCategoryNoReturn,
Switcher = new LanguageSwitcher.Core();
Hotkey = new(Switcher.SwapCategoryNoReturn,
Switcher.UpdateInputLanguageByKeyboard,
Switcher.OnRaltUp);
Settings.SettingsChangedEventHandler += Hotkey.SettingsUpdateHandler;
Settings.SettingsChangedEventHandler += Views.Flyout.SettingsUpdateHandler;
Settings.Core.SettingsChangedEventHandler += Hotkey.SettingsUpdateHandler;
Settings.Core.SettingsChangedEventHandler += LanguageSwitcher.Flyout.SettingsUpdateHandler;

if(!Switcher.Ready())
{
Settings.LanguageSwitcherEnabled = false;
Settings.Core.LanguageSwitcherEnabled = false;
new ToastContentBuilder()
.AddText("Unable to enable language switcher")
.AddText("Please make sure you have both keyboard languages and IME languages installed")
Expand Down
54 changes: 0 additions & 54 deletions Core/Hotkey.cs

This file was deleted.

75 changes: 0 additions & 75 deletions Core/LanguageSwitcher.cs

This file was deleted.

48 changes: 0 additions & 48 deletions Core/LanguageSwitcher/Language.h

This file was deleted.

44 changes: 0 additions & 44 deletions Core/LanguageSwitcher/LanguageSwitcher.h

This file was deleted.

5 changes: 4 additions & 1 deletion Core/LanguageSwitcher/LanguageSwitcher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<ProjectGuid>{8eabf3ad-23d8-49fd-88a8-13c7a0cacbd0}</ProjectGuid>
<RootNamespace>LanguageSwitcher</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.22000.0</WindowsTargetPlatformMinVersion>
<TargetFramework>net8.0</TargetFramework>
<ProjectName>Core</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
Expand Down Expand Up @@ -54,7 +57,7 @@
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
<CLRSupport>NetCore</CLRSupport>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
Loading

0 comments on commit e1c7899

Please sign in to comment.