Skip to content

Commit

Permalink
修改主页面样式和主题颜色。
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjz authored and chenjz committed May 9, 2024
1 parent 1311ac2 commit c5aa00c
Show file tree
Hide file tree
Showing 13 changed files with 325 additions and 39 deletions.
3 changes: 2 additions & 1 deletion PeachPlayer/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</Application.DataTemplates>
<Application.Styles>
<FluentTheme />
<!--<StyleInclude Source="/Themes/ButtonStyles.axaml"/>-->
<StyleInclude Source="/Themes/ButtonStyles.axaml"/>
<!--<StyleInclude Source="/Themes/TextBoxStyles.axaml"/>-->
</Application.Styles>
</Application>
Binary file added PeachPlayer/Assets/Images/pay/weixinpay.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PeachPlayer/Assets/Images/pay/zhifubaopay.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions PeachPlayer/Foundation/ValueConverter.cs
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;
}
}
}
24 changes: 24 additions & 0 deletions PeachPlayer/Foundation/XConverter.cs
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(); }

}




}
}
7 changes: 7 additions & 0 deletions PeachPlayer/PeachPlayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
<AvaloniaResource Include="Assets\**" />
</ItemGroup>


<ItemGroup>
<None Remove="Assets\Images\pay\weixinpay.jpg" />
<None Remove="Assets\Images\pay\zhifubaopay.jpg" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.6" />
Expand All @@ -19,6 +25,7 @@
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.10.9" />
</ItemGroup>

<ItemGroup>
Expand Down
24 changes: 9 additions & 15 deletions PeachPlayer/Themes/ButtonStyles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,29 @@
<Style Selector="RadioButton.Ico">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ControlTemplate TargetType="RadioButton">
<Border Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="5">
<StackPanel>
<TextBlock Text="" FontFamily="../Assets/Fonts/iconfont.ttf#iconfont" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
CornerRadius="5" Name="bg">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>

<Style Selector="^:pointerover">
<Setter Property="Foreground" Value="Red"/>
<Style Selector="^:checked /template/ Border">
<Setter Property="Background" Value="{DynamicResource SystemBaseLowColor}"/>
</Style>

</Style>






</Styles>
30 changes: 30 additions & 0 deletions PeachPlayer/Themes/TextBoxStyles.axaml
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>
24 changes: 24 additions & 0 deletions PeachPlayer/ToolExtend/AttachEffect.cs
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);
}


}

}
38 changes: 38 additions & 0 deletions PeachPlayer/ToolExtend/Singleton.cs
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;
}
}
}
32 changes: 29 additions & 3 deletions PeachPlayer/ViewModels/MainWindowModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ public class MainWindowModel : ViewModelBase
public ViewModelBase ContentViewModel
{
get => _contentViewModel;
private set => this.RaiseAndSetIfChanged(ref _contentViewModel, value);
private set { SetSelectView(value); this.RaiseAndSetIfChanged(ref _contentViewModel, value); }
}

private int selectView;
public int SelectView
{
get => selectView;
private set => this.RaiseAndSetIfChanged(ref selectView, value);
}


public ReactiveCommand<string, Unit> SwitchMenuCommand { get; }
Expand All @@ -25,15 +31,35 @@ public ViewModelBase ContentViewModel
public MainWindowModel()
{
var main = new FilmTelevisionViewModel();
_contentViewModel = main;

ContentViewModel = main;

SwitchMenuCommand = ReactiveCommand.Create<string>(SwitchMenu);
SetUpCommand = ReactiveCommand.Create(() => ContentViewModel = new SetUpViewModel());
SearchCommand = ReactiveCommand.Create<string>(s => ContentViewModel = new SearchViewModel(s));

}

private void SetSelectView(ViewModelBase viewModel)
{
switch (viewModel.ToString().Replace("PeachPlayer.ViewModels.", ""))
{
case "FilmTelevisionViewModel":
SelectView = 1;
break;
case "LiveBroadcastViewModel":
SelectView = 2;
break;
case "NetdiskViewModel":
SelectView = 3;
break;
case "PlayHistoryViewModel":
SelectView = 4;
break;
default:
SelectView = 0;
break;
}
}

public void SwitchMenu(string parameter)
{
Expand Down
Loading

0 comments on commit c5aa00c

Please sign in to comment.