-
Notifications
You must be signed in to change notification settings - Fork 14
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
chenjz
authored and
chenjz
committed
May 9, 2024
1 parent
1311ac2
commit c5aa00c
Showing
13 changed files
with
325 additions
and
39 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,36 @@ | ||
using Avalonia.Data.Converters; | ||
using System; | ||
using System.Globalization; | ||
|
||
|
||
namespace PeachPlayer.Foundation | ||
{ | ||
/// <summary> | ||
/// 数字转bool(默认:1等于true,需要其他转换通过参数传递,值等于参数值返回true) | ||
/// </summary> | ||
public class IntToBoolConverter : IValueConverter | ||
{ | ||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
if (parameter == null) | ||
{ | ||
int gender = value == null ? 0 : (int)value; | ||
return gender == 1; | ||
} | ||
else | ||
{ | ||
int.TryParse(parameter?.ToString(), out int par); | ||
int gender = value == null ? 0 : (int)value; | ||
return gender == par; | ||
} | ||
} | ||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
if (value == null) | ||
{ | ||
return 0; | ||
} | ||
return ((bool)value) ? 1 : 0; | ||
} | ||
} | ||
} |
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,24 @@ | ||
using PeachPlayer.ToolExtend; | ||
|
||
namespace PeachPlayer.Foundation | ||
{ | ||
/// <summary> | ||
/// 常用转换器的静态引用 | ||
/// 使用实例:Converter={x:Static local:XConverter.TrueToFalseConverter} | ||
/// </summary> | ||
public sealed class XConverter | ||
{ | ||
/// <summary> | ||
/// bool取反 | ||
/// </summary> | ||
public static IntToBoolConverter InverseBooleanConverter | ||
{ | ||
get { return Singleton<IntToBoolConverter>.GetInstance(); } | ||
|
||
} | ||
|
||
|
||
|
||
|
||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Styles xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<Design.PreviewWith> | ||
<Border Padding="20" Background="Red"> | ||
<!-- Add Controls for Previewer Here --> | ||
</Border> | ||
</Design.PreviewWith> | ||
|
||
<Style Selector="TextBox.NuStyle"> | ||
<Setter Property="Background" Value="Transparent"/> | ||
<Setter Property="FontSize" Value="14"/> | ||
<Setter Property="BorderThickness" Value="0"/> | ||
<Setter Property="BorderBrush" Value="Black"/> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="TextBox"> | ||
<Border Background="{TemplateBinding Background}" | ||
BorderThickness="{TemplateBinding BorderThickness}" | ||
BorderBrush="{TemplateBinding BorderBrush}" | ||
CornerRadius="5"> | ||
<ContentPresenter Name="PART_TextPresenter" HorizontalAlignment="Center" VerticalAlignment="Center"/> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
|
||
|
||
</Styles> |
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,24 @@ | ||
using Avalonia.Controls; | ||
using Avalonia; | ||
|
||
|
||
namespace PeachPlayer.ToolExtend | ||
{ | ||
public class AttachEffect | ||
{ | ||
|
||
public static readonly AttachedProperty<string> IconProperty =AvaloniaProperty.RegisterAttached<AttachEffect, RadioButton, string>("Icon"); | ||
|
||
public static string GetColumn(RadioButton element) | ||
{ | ||
return element.GetValue(IconProperty); | ||
} | ||
public static void SetColumn(RadioButton element, string value) | ||
{ | ||
element.SetValue(IconProperty, value); | ||
} | ||
|
||
|
||
} | ||
|
||
} |
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,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace PeachPlayer.ToolExtend | ||
{ | ||
/// <summary> | ||
/// 单例模式。 | ||
/// </summary> | ||
public static class Singleton<T> where T : class, new() | ||
{ | ||
private static T _Instance; | ||
private static object _lockObj = new object(); | ||
|
||
/// <summary> | ||
/// 获取单例对象的实例 | ||
/// </summary> | ||
public static T GetInstance() | ||
{ | ||
if (_Instance != null) | ||
{ | ||
return _Instance; | ||
} | ||
|
||
lock (_lockObj) | ||
{ | ||
if (_Instance == null) | ||
{ | ||
var temp = Activator.CreateInstance<T>(); | ||
System.Threading.Interlocked.Exchange(ref _Instance, temp); | ||
} | ||
} | ||
return _Instance; | ||
} | ||
} | ||
} |
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.