Skip to content

Commit

Permalink
release: 1.5.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7c13 committed Jan 7, 2024
1 parent f099d45 commit b41084c
Show file tree
Hide file tree
Showing 112 changed files with 1,042 additions and 546 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2024 Jackie (Jiaqi) Liu
Copyright (c) 2019-2024 Jackie (Jiaqi) Liu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -115,7 +115,7 @@ TL;DR: You might notice that I work for Microsoft but Notepads is my personal pr
* Localization Contributors:
* [fr-FR][French (France)]: [François Rousselet](https://github.com/frousselet), [François-Joseph du Fou](https://github.com/FJduFou), [Armand Delessert](https://github.com/ArmandDelessert)
* [es-ES][Spanish (Spain)]: [Jose Pinilla](https://github.com/joseppinilla)
* [zh-CN][Chinese (S)]: [lindexi](https://github.com/lindexi), [walterlv](https://github.com/walterlv), [Jackie Liu](https://github.com/0x7c13)
* [zh-CN][Chinese (S)]: [lindexi](https://github.com/lindexi), [walterlv](https://github.com/walterlv), [0x7c13](https://github.com/0x7c13)
* [hu-HU][Hungarian (Hungary)]: [Csányi István](https://github.com/AmionSky), [Kristóf Kékesi](https://github.com/KristofKekesi)
* [tr-TR][Turkish (Turkey)]: [Mert Can Demir](https://github.com/validatedev), [Emirhakan Tanhan](https://github.com/EmirhakanTanhan)
* [ja-JP][Japanese (Japan)]: [Mamoru Satoh](https://github.com/pnp0a03)
Expand Down
2 changes: 1 addition & 1 deletion src/Notepads.Controls/Properties/AssemblyInfo.cs
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Notepads.Controls")]
[assembly: AssemblyCopyright("Copyright © 2020-2024 Jackie (Jiaqi) Liu")]
[assembly: AssemblyCopyright("Copyright © 2019-2024 Jackie (Jiaqi) Liu")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/App.xaml.cs
@@ -1,4 +1,9 @@
namespace Notepads
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads
{
using System;
using System.Collections.Generic;
Expand Down
88 changes: 46 additions & 42 deletions src/Notepads/Brushes/HostBackdropAcrylicBrush.cs
@@ -1,4 +1,9 @@
namespace Notepads.Brushes
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Brushes
{
using System;
using System.Collections.Generic;
Expand All @@ -21,12 +26,12 @@
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using Microsoft.Graphics.Canvas.UI.Composition;
using Notepads.Controls.Helpers;
using Controls.Helpers;

public sealed class HostBackdropAcrylicBrush : XamlCompositionBrushBase, IDisposable
{
public static readonly DependencyProperty TintOpacityProperty = DependencyProperty.Register(
"TintOpacity",
private static readonly DependencyProperty TintOpacityProperty = DependencyProperty.Register(
nameof(TintOpacity),
typeof(float),
typeof(HostBackdropAcrylicBrush),
new PropertyMetadata(0.0f, OnTintOpacityChanged)
Expand All @@ -38,29 +43,29 @@ public float TintOpacity
set => SetValue(TintOpacityProperty, value);
}

private static void OnTintOpacityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
private static void OnTintOpacityChanged(DependencyObject dependencyObject,
DependencyPropertyChangedEventArgs args)
{
if (d is HostBackdropAcrylicBrush brush)
if (!(dependencyObject is HostBackdropAcrylicBrush brush)) return;

if (brush.CompositionBrush is CompositionEffectBrush)
{
if (brush.CompositionBrush is CompositionEffectBrush)
{
TintOpacityToArithmeticCompositeEffectSourceAmount((float)e.NewValue,
_acrylicTintOpacityMinThreshold,
out var source1Amount,
out var source2Amount);
brush.CompositionBrush?.Properties.InsertScalar("LuminosityBlender.Source1Amount", source1Amount);
brush.CompositionBrush?.Properties.InsertScalar("LuminosityBlender.Source2Amount", source2Amount);
}
else if (brush.CompositionBrush is CompositionColorBrush)
{
// Do nothing since we are falling back to CompositionColorBrush here
// TintOpacity only applies to the CompositionEffectBrush we created
}
TintOpacityToArithmeticCompositeEffectSourceAmount((float)args.NewValue,
_acrylicTintOpacityMinThreshold,
out var source1Amount,
out var source2Amount);
brush.CompositionBrush?.Properties.InsertScalar("LuminosityBlender.Source1Amount", source1Amount);
brush.CompositionBrush?.Properties.InsertScalar("LuminosityBlender.Source2Amount", source2Amount);
}
else if (brush.CompositionBrush is CompositionColorBrush)
{
// Do nothing since we are falling back to CompositionColorBrush here
// TintOpacity only applies to the CompositionEffectBrush we created
}
}

public static readonly DependencyProperty LuminosityColorProperty = DependencyProperty.Register(
"LuminosityColor",
private static readonly DependencyProperty LuminosityColorProperty = DependencyProperty.Register(
nameof(LuminosityColor),
typeof(Color),
typeof(HostBackdropAcrylicBrush),
new PropertyMetadata(Colors.Transparent, OnLuminosityColorChanged)
Expand All @@ -72,30 +77,31 @@ public Color LuminosityColor
set => SetValue(LuminosityColorProperty, value);
}

private static void OnLuminosityColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
private static void OnLuminosityColorChanged(DependencyObject dependencyObject,
DependencyPropertyChangedEventArgs args)
{
if (d is HostBackdropAcrylicBrush brush)
if (!(dependencyObject is HostBackdropAcrylicBrush brush)) return;

switch (brush.CompositionBrush)
{
if (brush.CompositionBrush is CompositionEffectBrush)
{
if (brush.CompositionBrush?.Properties.TryGetColor("LuminosityColor.Color", out var currentColor) == CompositionGetValueStatus.Succeeded)
case CompositionEffectBrush _
when brush.CompositionBrush?.Properties.TryGetColor("LuminosityColor.Color", out var currentColor)
== CompositionGetValueStatus.Succeeded:
{
var easing = Window.Current.Compositor.CreateLinearEasingFunction();
var animation = Window.Current.Compositor.CreateColorKeyFrameAnimation();
animation.InsertKeyFrame(0.0f, currentColor);
animation.InsertKeyFrame(1.0f, (Color)e.NewValue, easing);
animation.InsertKeyFrame(1.0f, (Color)args.NewValue, easing);
animation.Duration = TimeSpan.FromMilliseconds(167);
brush.CompositionBrush.StartAnimation("LuminosityColor.Color", animation);
break;
}
else
{
brush.CompositionBrush?.Properties.InsertColor("LuminosityColor.Color", (Color)e.NewValue);
}
}
else if (brush.CompositionBrush is CompositionColorBrush colorBrush)
{
colorBrush.Color = (Color)e.NewValue;
}
case CompositionEffectBrush _:
brush.CompositionBrush?.Properties.InsertColor("LuminosityColor.Color", (Color)args.NewValue);
break;
case CompositionColorBrush colorBrush:
colorBrush.Color = (Color)args.NewValue;
break;
}
}

Expand Down Expand Up @@ -136,7 +142,7 @@ private async Task BuildInternalAsync()
}
else
{
CompositionBrush = await BuildHostBackdropAcrylicBrushAsync();
CompositionBrush = await BuildHostBackdropAcrylicBrushInternalAsync();
}

// Register energy saver event
Expand All @@ -147,12 +153,10 @@ private async Task BuildInternalAsync()
UISettings.AdvancedEffectsEnabledChanged -= OnAdvancedEffectsEnabledChanged;
UISettings.AdvancedEffectsEnabledChanged += OnAdvancedEffectsEnabledChanged;
}
catch (Exception ex)
catch (Exception)
{
// Fallback to color brush if unable to create HostBackdropAcrylicBrush
CompositionBrush = Window.Current.Compositor.CreateColorBrush(LuminosityColor);
Analytics.TrackEvent("FailedToBuildAcrylicBrush",
new Dictionary<string, string> { { "Exception", ex.ToString() } });
}
finally
{
Expand Down Expand Up @@ -191,7 +195,7 @@ protected override async void OnDisconnected()
base.OnDisconnected();
}

public async Task<CompositionBrush> BuildHostBackdropAcrylicBrushAsync()
private async Task<CompositionBrush> BuildHostBackdropAcrylicBrushInternalAsync()
{
int stage = 0;

Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Commands/CommandHandlerResult.cs
@@ -1,4 +1,9 @@
namespace Notepads.Commands
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Commands
{
public class CommandHandlerResult
{
Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Commands/ICommandHandler.cs
@@ -1,4 +1,9 @@
namespace Notepads.Commands
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Commands
{
public interface ICommandHandler<in T>
{
Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Commands/IKeyboardCommand.cs
@@ -1,4 +1,9 @@
namespace Notepads.Commands
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Commands
{
using Windows.System;

Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Commands/IMouseCommand.cs
@@ -1,4 +1,9 @@
namespace Notepads.Commands
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Commands
{
public interface IMouseCommand<in T>
{
Expand Down
9 changes: 7 additions & 2 deletions src/Notepads/Commands/KeyboardCommand.cs
@@ -1,10 +1,15 @@
namespace Notepads.Commands
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Commands
{
using System;
using System.Collections.Generic;
using Windows.System;

public class KeyboardCommand<T> : IKeyboardCommand<T>
public sealed class KeyboardCommand<T> : IKeyboardCommand<T>
{
private static readonly TimeSpan ConsecutiveHitsInterval = TimeSpan.FromMilliseconds(500);

Expand Down
9 changes: 7 additions & 2 deletions src/Notepads/Commands/KeyboardCommandHandler.cs
@@ -1,12 +1,17 @@
namespace Notepads.Commands
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Commands
{
using System.Collections.Generic;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;

public class KeyboardCommandHandler : ICommandHandler<KeyRoutedEventArgs>
public sealed class KeyboardCommandHandler : ICommandHandler<KeyRoutedEventArgs>
{
public readonly ICollection<IKeyboardCommand<KeyRoutedEventArgs>> Commands;

Expand Down
9 changes: 7 additions & 2 deletions src/Notepads/Commands/MouseCommand.cs
@@ -1,8 +1,13 @@
namespace Notepads.Commands
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Commands
{
using System;

public class MouseCommand<T> : IMouseCommand<T>
public sealed class MouseCommand<T> : IMouseCommand<T>
{
private readonly bool _ctrl;
private readonly bool _alt;
Expand Down
9 changes: 7 additions & 2 deletions src/Notepads/Commands/MouseCommandHandler.cs
@@ -1,12 +1,17 @@
namespace Notepads.Commands
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Commands
{
using System.Collections.Generic;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;

public class MouseCommandHandler : ICommandHandler<PointerRoutedEventArgs>
public sealed class MouseCommandHandler : ICommandHandler<PointerRoutedEventArgs>
{
public readonly ICollection<IMouseCommand<PointerRoutedEventArgs>> Commands;

Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Controls/Dialog/AppCloseSaveReminderDialog.cs
@@ -1,4 +1,9 @@
namespace Notepads.Controls.Dialog
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Controls.Dialog
{
using System;
using Windows.UI;
Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Controls/Dialog/FileOpenErrorDialog.cs
@@ -1,4 +1,9 @@
namespace Notepads.Controls.Dialog
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Controls.Dialog
{
public sealed class FileOpenErrorDialog : NotepadsDialog
{
Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Controls/Dialog/FileRenameDialog.cs
@@ -1,4 +1,9 @@
namespace Notepads.Controls.Dialog
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Controls.Dialog
{
using System;
using System.Collections.Generic;
Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Controls/Dialog/FileSaveErrorDialog.cs
@@ -1,4 +1,9 @@
namespace Notepads.Controls.Dialog
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Controls.Dialog
{
public sealed class FileSaveErrorDialog : NotepadsDialog
{
Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Controls/Dialog/NotepadsDialog.cs
@@ -1,4 +1,9 @@
namespace Notepads.Controls.Dialog
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Controls.Dialog
{
using Windows.ApplicationModel.Resources;
using Windows.UI;
Expand Down
@@ -1,4 +1,9 @@
namespace Notepads.Controls.Dialog
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Controls.Dialog
{
using System;

Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Controls/Dialog/SessionCorruptionErrorDialog.cs
@@ -1,4 +1,9 @@
namespace Notepads.Controls.Dialog
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Controls.Dialog
{
using System;
using Windows.UI;
Expand Down
7 changes: 6 additions & 1 deletion src/Notepads/Controls/Dialog/SetCloseSaveReminderDialog.cs
@@ -1,4 +1,9 @@
namespace Notepads.Controls.Dialog
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2019-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Notepads.Controls.Dialog
{
using System;

Expand Down

0 comments on commit b41084c

Please sign in to comment.