Improve character display in EditTemplateDialog
This commit is contained in:
parent
acb6d1b335
commit
ed15614288
@ -84,7 +84,7 @@ namespace FileLiberator
|
|||||||
cancellation = Configuration.Instance
|
cancellation = Configuration.Instance
|
||||||
.ObservePropertyChanged<long>(
|
.ObservePropertyChanged<long>(
|
||||||
nameof(Configuration.DownloadSpeedLimit),
|
nameof(Configuration.DownloadSpeedLimit),
|
||||||
(_, s) => DownloadSpeedChanged?.Invoke(this, s));
|
newVal => DownloadSpeedChanged?.Invoke(this, newVal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
<TextBox
|
<TextBox
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
|
FontFamily="{Binding FontFamily}"
|
||||||
Text="{Binding UserTemplateText, Mode=TwoWay}" />
|
Text="{Binding UserTemplateText, Mode=TwoWay}" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -81,6 +81,7 @@ namespace LibationAvalonia.Dialogs
|
|||||||
private class EditTemplateViewModel : ViewModels.ViewModelBase
|
private class EditTemplateViewModel : ViewModels.ViewModelBase
|
||||||
{
|
{
|
||||||
private readonly Configuration config;
|
private readonly Configuration config;
|
||||||
|
public FontFamily FontFamily { get; } = FontManager.Current.DefaultFontFamilyName;
|
||||||
public InlineCollection Inlines { get; } = new();
|
public InlineCollection Inlines { get; } = new();
|
||||||
public Templates Template { get; }
|
public Templates Template { get; }
|
||||||
public EditTemplateViewModel(Configuration configuration, Templates templates)
|
public EditTemplateViewModel(Configuration configuration, Templates templates)
|
||||||
|
|||||||
@ -1,16 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ApplicationServices;
|
using ApplicationServices;
|
||||||
using AppScaffolding;
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using DataLayer;
|
using DataLayer;
|
||||||
using Dinah.Core;
|
|
||||||
using LibationAvalonia.Dialogs;
|
|
||||||
using LibationAvalonia.ViewModels;
|
using LibationAvalonia.ViewModels;
|
||||||
using LibationFileManager;
|
using LibationFileManager;
|
||||||
|
|
||||||
@ -30,8 +26,7 @@ namespace LibationAvalonia.Views
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
this.AttachDevTools();
|
this.AttachDevTools();
|
||||||
#endif
|
#endif
|
||||||
this.FindAllControls();
|
FindAllControls();
|
||||||
|
|
||||||
|
|
||||||
// eg: if one of these init'd productsGrid, then another can't reliably subscribe to it
|
// eg: if one of these init'd productsGrid, then another can't reliably subscribe to it
|
||||||
Configure_BackupCounts();
|
Configure_BackupCounts();
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace LibationFileManager
|
namespace LibationFileManager
|
||||||
{
|
{
|
||||||
@ -50,7 +51,7 @@ namespace LibationFileManager
|
|||||||
|
|
||||||
using var cancellation = propertyChangeFilter.ObservePropertyChanging<int>("MyProperty", MyPropertyChanging);
|
using var cancellation = propertyChangeFilter.ObservePropertyChanging<int>("MyProperty", MyPropertyChanging);
|
||||||
|
|
||||||
void MyPropertyChanging(string propertyName, int oldValue, int newValue)
|
void MyPropertyChanging(int oldValue, int newValue)
|
||||||
{
|
{
|
||||||
// Only the property whose name match
|
// Only the property whose name match
|
||||||
// "MyProperty" will fire this method.
|
// "MyProperty" will fire this method.
|
||||||
@ -62,7 +63,7 @@ namespace LibationFileManager
|
|||||||
* OR *
|
* OR *
|
||||||
******
|
******
|
||||||
|
|
||||||
using var cancellation = propertyChangeFilter.ObservePropertyChanged<bool>("MyProperty", (_, s) =>
|
using var cancellation = propertyChangeFilter.ObservePropertyChanged<bool>("MyProperty", s =>
|
||||||
{
|
{
|
||||||
// Only the property whose name match
|
// Only the property whose name match
|
||||||
// "MyProperty" will fire this action.
|
// "MyProperty" will fire this action.
|
||||||
@ -79,8 +80,8 @@ namespace LibationFileManager
|
|||||||
private readonly Dictionary<string, List<Delegate>> propertyChangedActions = new();
|
private readonly Dictionary<string, List<Delegate>> propertyChangedActions = new();
|
||||||
private readonly Dictionary<string, List<Delegate>> propertyChangingActions = new();
|
private readonly Dictionary<string, List<Delegate>> propertyChangingActions = new();
|
||||||
|
|
||||||
private readonly List<KeyValuePair<PropertyChangedEventHandlerEx, PropertyChangedEventHandlerEx>> changedFilters = new();
|
private readonly List<(PropertyChangedEventHandlerEx subscriber, PropertyChangedEventHandlerEx wrapper)> changedFilters = new();
|
||||||
private readonly List<KeyValuePair<PropertyChangingEventHandlerEx, PropertyChangingEventHandlerEx>> changingFilters = new();
|
private readonly List<(PropertyChangingEventHandlerEx subscriber, PropertyChangingEventHandlerEx wrapper)> changingFilters = new();
|
||||||
|
|
||||||
public PropertyChangeFilter()
|
public PropertyChangeFilter()
|
||||||
{
|
{
|
||||||
@ -102,7 +103,7 @@ namespace LibationFileManager
|
|||||||
{
|
{
|
||||||
add
|
add
|
||||||
{
|
{
|
||||||
var attributes = Attribute.GetCustomAttributes(value.Method, typeof(PropertyChangeFilterAttribute)) as PropertyChangeFilterAttribute[];
|
var attributes = getAttributes<PropertyChangeFilterAttribute>(value.Method);
|
||||||
|
|
||||||
if (attributes.Any())
|
if (attributes.Any())
|
||||||
{
|
{
|
||||||
@ -113,7 +114,7 @@ namespace LibationFileManager
|
|||||||
if (e.PropertyName.In(matches)) value(s, e);
|
if (e.PropertyName.In(matches)) value(s, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
changedFilters.Add(new(value, filterer));
|
changedFilters.Add((value, filterer));
|
||||||
|
|
||||||
_propertyChanged += filterer;
|
_propertyChanged += filterer;
|
||||||
}
|
}
|
||||||
@ -122,12 +123,12 @@ namespace LibationFileManager
|
|||||||
}
|
}
|
||||||
remove
|
remove
|
||||||
{
|
{
|
||||||
var del = changedFilters.LastOrDefault(d => d.Key == value);
|
var del = changedFilters.LastOrDefault(d => d.subscriber == value);
|
||||||
if (del.Key is null)
|
if (del == default)
|
||||||
_propertyChanged -= value;
|
_propertyChanged -= value;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_propertyChanged -= del.Value;
|
_propertyChanged -= del.wrapper;
|
||||||
changedFilters.Remove(del);
|
changedFilters.Remove(del);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +138,7 @@ namespace LibationFileManager
|
|||||||
{
|
{
|
||||||
add
|
add
|
||||||
{
|
{
|
||||||
var attributes = Attribute.GetCustomAttributes(value.Method, typeof(PropertyChangeFilterAttribute)) as PropertyChangeFilterAttribute[];
|
var attributes = getAttributes<PropertyChangeFilterAttribute>(value.Method);
|
||||||
|
|
||||||
if (attributes.Any())
|
if (attributes.Any())
|
||||||
{
|
{
|
||||||
@ -148,7 +149,7 @@ namespace LibationFileManager
|
|||||||
if (e.PropertyName.In(matches)) value(s, e);
|
if (e.PropertyName.In(matches)) value(s, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
changingFilters.Add(new(value, filterer));
|
changingFilters.Add((value, filterer));
|
||||||
|
|
||||||
_propertyChanging += filterer;
|
_propertyChanging += filterer;
|
||||||
|
|
||||||
@ -158,17 +159,20 @@ namespace LibationFileManager
|
|||||||
}
|
}
|
||||||
remove
|
remove
|
||||||
{
|
{
|
||||||
var del = changingFilters.LastOrDefault(d => d.Key == value);
|
var del = changingFilters.LastOrDefault(d => d.subscriber == value);
|
||||||
if (del.Key is null)
|
if (del == default)
|
||||||
_propertyChanging -= value;
|
_propertyChanging -= value;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_propertyChanging -= del.Value;
|
_propertyChanging -= del.wrapper;
|
||||||
changingFilters.Remove(del);
|
changingFilters.Remove(del);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static T[] getAttributes<T>(MethodInfo methodInfo) where T : Attribute
|
||||||
|
=> Attribute.GetCustomAttributes(methodInfo, typeof(T)) as T[];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Observables
|
#region Observables
|
||||||
@ -198,9 +202,9 @@ namespace LibationFileManager
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The <paramref name="propertyName"/>'s <see cref="Type"/></typeparam>
|
/// <typeparam name="T">The <paramref name="propertyName"/>'s <see cref="Type"/></typeparam>
|
||||||
/// <param name="propertyName">Name of the property whose change triggers the <paramref name="action"/></param>
|
/// <param name="propertyName">Name of the property whose change triggers the <paramref name="action"/></param>
|
||||||
/// <param name="action">Action to be executed with parameters: <paramref name="propertyName"/> and <strong>NewValue</strong></param>
|
/// <param name="action">Action to be executed with the NewValue as a parameter</param>
|
||||||
/// <returns>A reference to an interface that allows observers to stop receiving notifications before the provider has finished sending them.</returns>
|
/// <returns>A reference to an interface that allows observers to stop receiving notifications before the provider has finished sending them.</returns>
|
||||||
public IDisposable ObservePropertyChanged<T>(string propertyName, Action<string, T> action)
|
public IDisposable ObservePropertyChanged<T>(string propertyName, Action<T> action)
|
||||||
{
|
{
|
||||||
validateSubscriber<T>(propertyName, action);
|
validateSubscriber<T>(propertyName, action);
|
||||||
|
|
||||||
@ -220,9 +224,9 @@ namespace LibationFileManager
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The <paramref name="propertyName"/>'s <see cref="Type"/></typeparam>
|
/// <typeparam name="T">The <paramref name="propertyName"/>'s <see cref="Type"/></typeparam>
|
||||||
/// <param name="propertyName">Name of the property whose change triggers the <paramref name="action"/></param>
|
/// <param name="propertyName">Name of the property whose change triggers the <paramref name="action"/></param>
|
||||||
/// <param name="action">Action to be executed with parameters: <paramref name="propertyName"/>, <b>OldValue</b>, and <b>NewValue</b></param>
|
/// <param name="action">Action to be executed with OldValue and NewValue as parameters</param>
|
||||||
/// <returns>A reference to an interface that allows observers to stop receiving notifications before the provider has finished sending them.</returns>
|
/// <returns>A reference to an interface that allows observers to stop receiving notifications before the provider has finished sending them.</returns>
|
||||||
public IDisposable ObservePropertyChanging<T>(string propertyName, Action<string, T, T> action)
|
public IDisposable ObservePropertyChanging<T>(string propertyName, Action<T, T> action)
|
||||||
{
|
{
|
||||||
validateSubscriber<T>(propertyName, action);
|
validateSubscriber<T>(propertyName, action);
|
||||||
|
|
||||||
@ -257,7 +261,7 @@ namespace LibationFileManager
|
|||||||
{
|
{
|
||||||
foreach (var action in propertyChangedActions[e.PropertyName])
|
foreach (var action in propertyChangedActions[e.PropertyName])
|
||||||
{
|
{
|
||||||
action.DynamicInvoke(e.PropertyName, e.NewValue);
|
action.DynamicInvoke(e.NewValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,7 +272,7 @@ namespace LibationFileManager
|
|||||||
{
|
{
|
||||||
foreach (var action in propertyChangingActions[e.PropertyName])
|
foreach (var action in propertyChangingActions[e.PropertyName])
|
||||||
{
|
{
|
||||||
action.DynamicInvoke(e.PropertyName, e.OldValue, e.NewValue);
|
action.DynamicInvoke(e.OldValue, e.NewValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user