-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29d485b
commit 6ecbc3f
Showing
27 changed files
with
1,057 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework> | ||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion> | ||
<RootNamespace>Coder.Desktop.App</RootNamespace> | ||
<ApplicationManifest>app.manifest</ApplicationManifest> | ||
<Platforms>x86;x64;ARM64</Platforms> | ||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers> | ||
<UseWinUI>true</UseWinUI> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Manifest Include="$(ApplicationManifest)"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/> | ||
<PackageReference Include="DependencyPropertyGenerator" Version="1.5.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="H.NotifyIcon.WinUI" Version="2.2.0"/> | ||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742"/> | ||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.250108002"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Page Update="TrayIcon.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Page Update="HorizontalRule.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
</ItemGroup> | ||
|
||
<!-- Publish Properties --> | ||
<PropertyGroup> | ||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun> | ||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun> | ||
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed> | ||
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<Application | ||
x:Class="Coder.Desktop.App.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.UI.Xaml; | ||
|
||
namespace Coder.Desktop.App; | ||
|
||
public partial class App : Application | ||
{ | ||
private TrayWindow? TrayWindow; | ||
|
||
public App() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private bool HandleClosedEvents { get; } = true; | ||
|
||
protected override void OnLaunched(LaunchActivatedEventArgs args) | ||
{ | ||
TrayWindow = new TrayWindow(); | ||
TrayWindow.Closed += (sender, args) => | ||
{ | ||
// TODO: wire up HandleClosedEvents properly | ||
if (HandleClosedEvents) | ||
{ | ||
args.Handled = true; | ||
TrayWindow.AppWindow.Hide(); | ||
} | ||
}; | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<UserControl | ||
x:Class="Coder.Desktop.App.HorizontalRule" | ||
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"> | ||
|
||
<Border | ||
Background="{ThemeResource DefaultTextForegroundThemeBrush}" | ||
Opacity="0.3" | ||
Height="1" | ||
HorizontalAlignment="Stretch" /> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace Coder.Desktop.App; | ||
|
||
public sealed partial class HorizontalRule : UserControl | ||
{ | ||
public HorizontalRule() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<UserControl | ||
x:Class="Coder.Desktop.App.TrayIcon" | ||
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" | ||
xmlns:tb="using:H.NotifyIcon" | ||
mc:Ignorable="d"> | ||
|
||
<UserControl.Resources> | ||
<!-- Icons are used from .cs --> | ||
<!-- ReSharper disable Xaml.RedundantResource --> | ||
<BitmapImage x:Key="IconLightTheme" UriSource="ms-appx:///Assets/coder_icon_32_dark.ico" /> | ||
<BitmapImage x:Key="IconDarkTheme" UriSource="ms-appx:///Assets/coder_icon_32_light.ico" /> | ||
<!-- ReSharper restore Xaml.RedundantResource --> | ||
</UserControl.Resources> | ||
|
||
<tb:TaskbarIcon | ||
x:Name="TaskbarIcon" | ||
Visibility="Visible" | ||
ToolTipText="Coder" | ||
ContextMenuMode="SecondWindow" | ||
LeftClickCommand="{x:Bind OpenCommand}" | ||
NoLeftClickDelay="True"> | ||
|
||
<tb:TaskbarIcon.ContextFlyout> | ||
<MenuFlyout> | ||
<MenuFlyoutItem> | ||
<MenuFlyoutItem.Command> | ||
<XamlUICommand | ||
Label="Show Window" | ||
Description="Show Window" | ||
Command="{x:Bind OpenCommand}"> | ||
|
||
<XamlUICommand.IconSource> | ||
<SymbolIconSource Symbol="OpenPane" /> | ||
</XamlUICommand.IconSource> | ||
<XamlUICommand.KeyboardAccelerators> | ||
<KeyboardAccelerator | ||
Key="S" | ||
Modifiers="Control" /> | ||
</XamlUICommand.KeyboardAccelerators> | ||
</XamlUICommand> | ||
</MenuFlyoutItem.Command> | ||
</MenuFlyoutItem> | ||
|
||
<MenuFlyoutSeparator /> | ||
|
||
<MenuFlyoutItem> | ||
<MenuFlyoutItem.Command> | ||
<XamlUICommand | ||
Label="Exit" | ||
Description="Exit" | ||
Command="{x:Bind ExitCommand}"> | ||
|
||
<XamlUICommand.IconSource> | ||
<SymbolIconSource Symbol="ClosePane" /> | ||
</XamlUICommand.IconSource> | ||
<XamlUICommand.KeyboardAccelerators> | ||
<KeyboardAccelerator | ||
Key="E" | ||
Modifiers="Control" /> | ||
</XamlUICommand.KeyboardAccelerators> | ||
</XamlUICommand> | ||
</MenuFlyoutItem.Command> | ||
</MenuFlyoutItem> | ||
</MenuFlyout> | ||
</tb:TaskbarIcon.ContextFlyout> | ||
</tb:TaskbarIcon> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Diagnostics; | ||
using System.Windows.Input; | ||
using Windows.UI.ViewManagement; | ||
using DependencyPropertyGenerator; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Media.Imaging; | ||
|
||
namespace Coder.Desktop.App; | ||
|
||
[DependencyProperty<ICommand>("OpenCommand")] | ||
[DependencyProperty<ICommand>("ExitCommand")] | ||
public sealed partial class TrayIcon : UserControl | ||
{ | ||
private readonly UISettings _uiSettings = new(); | ||
|
||
public TrayIcon() | ||
{ | ||
InitializeComponent(); | ||
_uiSettings.ColorValuesChanged += OnColorValuesChanged; | ||
UpdateTrayIconBasedOnTheme(); | ||
} | ||
|
||
private void OnColorValuesChanged(UISettings sender, object args) | ||
{ | ||
DispatcherQueue.TryEnqueue(UpdateTrayIconBasedOnTheme); | ||
} | ||
|
||
private void UpdateTrayIconBasedOnTheme() | ||
{ | ||
var currentTheme = Application.Current.RequestedTheme; | ||
Debug.WriteLine("Theme update requested, found theme: " + currentTheme); | ||
|
||
switch (currentTheme) | ||
{ | ||
case ApplicationTheme.Dark: | ||
TaskbarIcon.IconSource = (BitmapImage)Resources["IconDarkTheme"]; | ||
break; | ||
case ApplicationTheme.Light: | ||
default: | ||
TaskbarIcon.IconSource = (BitmapImage)Resources["IconLightTheme"]; | ||
break; | ||
} | ||
} | ||
} |
Oops, something went wrong.