Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
deansheather merged 2 commits intomainfromdean/app-mock
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletionsApp/App.csproj
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Binary file not shown.
Binary file addedApp/Assets/coder_icon_32_light.ico
View file
Open in desktop
Binary file not shown.
16 changes: 16 additions & 0 deletionsApp/HorizontalRule.xaml
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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;
}
}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp