- Notifications
You must be signed in to change notification settings - Fork3
feat: add mocked tray app#10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
48 changes: 48 additions & 0 deletionsApp/App.csproj
This file contains hidden or 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> |
14 changes: 14 additions & 0 deletionsApp/App.xaml
This file contains hidden or 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> |
29 changes: 29 additions & 0 deletionsApp/App.xaml.cs
This file contains hidden or 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 addedApp/Assets/coder_icon_32_dark.ico
Binary file not shown.
Binary file addedApp/Assets/coder_icon_32_light.ico
Binary file not shown.
16 changes: 16 additions & 0 deletionsApp/HorizontalRule.xaml
This file contains hidden or 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> |
11 changes: 11 additions & 0 deletionsApp/HorizontalRule.xaml.cs
This file contains hidden or 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(); | ||
} | ||
} |
72 changes: 72 additions & 0 deletionsApp/TrayIcon.xaml
This file contains hidden or 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> |
45 changes: 45 additions & 0 deletionsApp/TrayIcon.xaml.cs
This file contains hidden or 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.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.