-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Showing
24 changed files
with
276 additions
and
82 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
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
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
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 |
---|---|---|
@@ -1,13 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage | ||
x:Class="H.NotifyIcon.Apps.Maui.MainPage" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:tb="https://notifyicon.com/" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:skia="clr-namespace:SkiaSharp.Views.Maui.Controls;assembly=SkiaSharp.Views.Maui.Controls" | ||
x:Class="H.NotifyIcon.Apps.Maui.MainPage" | ||
> | ||
|
||
<ScrollView> | ||
<skia:SKCanvasView x:Name="CanvasView" /> | ||
</ScrollView> | ||
<Grid> | ||
<tb:TaskbarIcon | ||
IconSource="red.ico" | ||
x:Name="TrayIcon" | ||
/> | ||
</Grid> | ||
<!-- <ScrollView> --> | ||
<!-- <skia:SKCanvasView x:Name="CanvasView" /> --> | ||
<!-- </ScrollView> --> | ||
|
||
</ContentPage> |
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 |
---|---|---|
@@ -1,49 +1,46 @@ | ||
using SkiaSharp; | ||
using SkiaSharp.Views.Maui; | ||
|
||
namespace H.NotifyIcon.Apps.Maui; | ||
namespace H.NotifyIcon.Apps.Maui; | ||
|
||
public partial class MainPage | ||
{ | ||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
|
||
CanvasView.PaintSurface += CanvasViewOnPaintSurface; | ||
//CanvasView.PaintSurface += CanvasViewOnPaintSurface; | ||
} | ||
|
||
private static void CanvasViewOnPaintSurface(object? sender, SKPaintSurfaceEventArgs args) | ||
{ | ||
SKImageInfo info = args.Info; | ||
SKSurface surface = args.Surface; | ||
SKCanvas canvas = surface.Canvas; | ||
|
||
canvas.Clear(); | ||
|
||
using var backgroundBrush = new SKPaint(); | ||
backgroundBrush.Style = SKPaintStyle.Stroke; | ||
backgroundBrush.Color = SKColors.Black; | ||
backgroundBrush.StrokeWidth = 24; | ||
backgroundBrush.StrokeCap = SKStrokeCap.Round; | ||
|
||
using var foregroundBrush = new SKPaint(); | ||
foregroundBrush.Style = SKPaintStyle.Stroke; | ||
foregroundBrush.Color = SKColors.White; | ||
foregroundBrush.StrokeWidth = 1; | ||
foregroundBrush.StrokeCap = SKStrokeCap.Round; | ||
foregroundBrush.TextSize = 48; | ||
|
||
canvas.DrawBitmap(SkiaSharpIconGenerator.Generate( | ||
backgroundBrush: backgroundBrush, | ||
foregroundBrush: foregroundBrush, | ||
text: "H", | ||
font: new SKFont(SKTypeface.Default, size: 48F), | ||
pen: new SKPaint | ||
{ | ||
Style = SKPaintStyle.Stroke, | ||
StrokeWidth = 5, | ||
Color = SKColors.Aqua, | ||
}), info.Rect); | ||
} | ||
// | ||
// private static void CanvasViewOnPaintSurface(object? sender, SKPaintSurfaceEventArgs args) | ||
// { | ||
// SKImageInfo info = args.Info; | ||
// SKSurface surface = args.Surface; | ||
// SKCanvas canvas = surface.Canvas; | ||
// | ||
// canvas.Clear(); | ||
// | ||
// using var backgroundBrush = new SKPaint(); | ||
// backgroundBrush.Style = SKPaintStyle.Stroke; | ||
// backgroundBrush.Color = SKColors.Black; | ||
// backgroundBrush.StrokeWidth = 24; | ||
// backgroundBrush.StrokeCap = SKStrokeCap.Round; | ||
// | ||
// using var foregroundBrush = new SKPaint(); | ||
// foregroundBrush.Style = SKPaintStyle.Stroke; | ||
// foregroundBrush.Color = SKColors.White; | ||
// foregroundBrush.StrokeWidth = 1; | ||
// foregroundBrush.StrokeCap = SKStrokeCap.Round; | ||
// foregroundBrush.TextSize = 48; | ||
// | ||
// canvas.DrawBitmap(SkiaSharpIconGenerator.Generate( | ||
// backgroundBrush: backgroundBrush, | ||
// foregroundBrush: foregroundBrush, | ||
// text: "H", | ||
// font: new SKFont(SKTypeface.Default, size: 48F), | ||
// pen: new SKPaint | ||
// { | ||
// Style = SKPaintStyle.Stroke, | ||
// StrokeWidth = 5, | ||
// Color = SKColors.Aqua, | ||
// }), info.Rect); | ||
// } | ||
} | ||
|
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
18 changes: 7 additions & 11 deletions
18
src/apps/H.NotifyIcon.Apps.Maui/Platforms/MacCatalyst/Program.cs
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 |
---|---|---|
@@ -1,15 +1,11 @@ | ||
using ObjCRuntime; | ||
using H.NotifyIcon.Apps.Maui; | ||
using UIKit; | ||
|
||
namespace H.NotifyIcon.Apps.Maui; | ||
|
||
public class Program | ||
#if DEBUG | ||
if (System.Diagnostics.Debugger.IsAttached) | ||
{ | ||
// This is the main entry point of the application. | ||
static void Main(string[] args) | ||
{ | ||
// if you want to use a different Application Delegate class from "AppDelegate" | ||
// you can specify it here. | ||
UIApplication.Main(args, null, typeof(AppDelegate)); | ||
} | ||
Thread.Sleep(TimeSpan.FromSeconds(5)); | ||
} | ||
#endif | ||
|
||
UIApplication.Main(args, null, typeof(AppDelegate)); |
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 |
---|---|---|
@@ -1,15 +1,11 @@ | ||
using ObjCRuntime; | ||
using H.NotifyIcon.Apps.Maui; | ||
using UIKit; | ||
|
||
namespace H.NotifyIcon.Apps.Maui; | ||
|
||
public class Program | ||
#if DEBUG | ||
if (System.Diagnostics.Debugger.IsAttached) | ||
{ | ||
// This is the main entry point of the application. | ||
static void Main(string[] args) | ||
{ | ||
// if you want to use a different Application Delegate class from "AppDelegate" | ||
// you can specify it here. | ||
UIApplication.Main(args, null, typeof(AppDelegate)); | ||
} | ||
Thread.Sleep(TimeSpan.FromSeconds(5)); | ||
} | ||
#endif | ||
|
||
UIApplication.Main(args, null, typeof(AppDelegate)); |
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
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> | ||
<TargetFrameworks>net7.0;net7.0-windows10.0.19041.0</TargetFrameworks> | ||
<UseMaui>true</UseMaui> | ||
<DefineConstants>$(DefineConstants);HAS_PLATFORM_CODE;HAS_MAUI</DefineConstants> | ||
<NoWarn>$(NoWarn);CA1031;CS8002;CS0108;CA1501</NoWarn> | ||
<EnableWindowsTargeting>true</EnableWindowsTargeting> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Label="NuGet"> | ||
<Description>This is an implementation of a NotifyIcon (aka system tray icon or taskbar icon) for the MAUI platform. | ||
It does not just rely on the Windows Forms NotifyIcon component, | ||
but is a purely independent control which leverages several features of the WinUI framework in order to display rich tooltips, | ||
popups, context menus, and balloon messages. It can be used directly in code or embedded in any XAML file. | ||
</Description> | ||
<PackageTags>notifyicon;maui;tray</PackageTags> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Label="AssemblyInfo"> | ||
<AssemblyAttribute Include="Microsoft.Maui.Controls.XmlnsPrefix"> | ||
<_Parameter1>https://notifyicon.com/</_Parameter1> | ||
<_Parameter2>tb</_Parameter2> | ||
</AssemblyAttribute> | ||
<AssemblyAttribute Include="Microsoft.Maui.Controls.XmlnsDefinition"> | ||
<_Parameter1>https://notifyicon.com/</_Parameter1> | ||
<_Parameter2>H.NotifyIcon</_Parameter2> | ||
</AssemblyAttribute> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="DependencyPropertyGenerator"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="EventGenerator.Generator"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageVersion Remove="Microsoft.WindowsAppSDK" /> | ||
<PackageVersion Remove="Microsoft.Windows.SDK.BuildTools" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\H.NotifyIcon\H.NotifyIcon.csproj" /> | ||
</ItemGroup> | ||
|
||
</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,18 @@ | ||
namespace H.NotifyIcon; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[CLSCompliant(false)] | ||
public static class MauiAppBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="builder"></param> | ||
/// <returns></returns> | ||
public static MauiAppBuilder UseNotifyIcon(this MauiAppBuilder builder) | ||
{ | ||
return builder; | ||
} | ||
} |
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
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
Oops, something went wrong.