Commit 2bfcb8c4 by liulongfei

配置 支持

parent 97ed6f92
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.ElectricRabbit.Domain
{
/// <summary>
/// 应用程序常量
/// </summary>
public static class ApplicationConstant
{
/// <summary>
/// 视频宽度
/// </summary>
public const int VIDEO_WIDTH = 1920;
/// <summary>
/// 视频宽度
/// </summary>
public const int VIDEO_HEIGHT = 1080;
/// <summary>
/// 视频宽度 double 类型
/// </summary>
public const double VIDEO_WIDTH__DOUBLE = VIDEO_WIDTH;
/// <summary>
/// 视频宽度 double 类型
/// </summary>
public const double VIDEO_HEIGHT__DOUBLE = VIDEO_HEIGHT;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Domain;
namespace VIZ.ElectricRabbit.Domain
{
/// <summary>
/// 应用程序域
/// </summary>
public class ApplicationDomainEx : ApplicationDomain
{
/// <summary>
/// 客户端配置信息
/// </summary>
public static ClientConfigInfo ClientConfigInfo { get; private set; } = new ClientConfigInfo();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace VIZ.ElectricRabbit.Domain
{
/// <summary>
/// 客户端配置信息
/// </summary>
public class ClientConfigInfo
{
/// <summary>
/// 安全距离(单位:像素)
/// </summary>
public int SafeDistance { get; set; }
/// <summary>
/// 安全轴位置(单位:像素)
/// </summary>
public int SafeAxis { get; set; }
/// <summary>
/// 是否启用闪烁
/// </summary>
public bool IsFlashingEnabled { get; set; }
/// <summary>
/// 闪烁间隔
/// </summary>
public double FlashingInterval { get; set; }
/// <summary>
/// 方向向左颜色
/// </summary>
public Color LeftColor { get; set; }
/// <summary>
/// 方向向右颜色
/// </summary>
public Color RightColor { get; set; }
/// <summary>
/// 安全颜色
/// </summary>
public Color SafeColor { get; set; }
}
}
...@@ -52,18 +52,24 @@ ...@@ -52,18 +52,24 @@
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Windows" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ApplicationConstant.cs" />
<Compile Include="ApplicationDomainEx.cs" />
<Compile Include="Info\ClientConfigInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="CheckBox"> <ControlTemplate TargetType="CheckBox">
<Grid Background="Transparent"> <Grid Background="Transparent">
<Image x:Name="img" Width="24" Height="24" RenderTransformOrigin="0.5,0.5" <Image x:Name="img" Width="24" Height="24" RenderTransformOrigin="0.5,0.5" Opacity="0.7"
Source="/VIZ.ElectricRabbit.Module.Resource;component/Icons/expand_right_24x24.png"> Source="/VIZ.ElectricRabbit.Module.Resource;component/Icons/expand_right_24x24.png">
<Image.RenderTransform> <Image.RenderTransform>
<RotateTransform Angle="-180"></RotateTransform> <RotateTransform Angle="-180"></RotateTransform>
...@@ -52,6 +52,9 @@ ...@@ -52,6 +52,9 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Trigger> </Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="img" Property="Opacity" Value="1"></Setter>
</Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common" xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core" xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:common="clr-namespace:VIZ.ElectricRabbit.Common;assembly=VIZ.ElectricRabbit.Common" xmlns:common="clr-namespace:VIZ.ElectricRabbit.Common;assembly=VIZ.ElectricRabbit.Common"
d:DataContext="{d:DesignInstance Type=local:MainViewModel}" Background="Transparent" d:DataContext="{d:DesignInstance Type=local:MainViewModel}"
Background="Transparent"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920"> d:DesignHeight="1080" d:DesignWidth="1920">
<UserControl.Resources> <UserControl.Resources>
...@@ -32,8 +33,6 @@ ...@@ -32,8 +33,6 @@
<Grid Background="#ff12202d"> <Grid Background="#ff12202d">
<TextBlock Text="电兔子" FontSize="12" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock> <TextBlock Text="电兔子" FontSize="12" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
<StackPanel Orientation="Horizontal" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top"> <StackPanel Orientation="Horizontal" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top">
<Button Command="{Binding Path=SettingCommand}" ToolTip="系统设置"
Style="{StaticResource Button_Setting}" Height="30"></Button>
<Button Command="{Binding Path=MinCommand}" ToolTip="最小化" <Button Command="{Binding Path=MinCommand}" ToolTip="最小化"
Style="{StaticResource Button_Min}" Height="30"></Button> Style="{StaticResource Button_Min}" Height="30"></Button>
<Button Command="{Binding Path=CloseCommand}" ToolTip="关闭" <Button Command="{Binding Path=CloseCommand}" ToolTip="关闭"
...@@ -52,7 +51,8 @@ ...@@ -52,7 +51,8 @@
<ColumnDefinition Width="Auto"></ColumnDefinition> <ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- 提示区域 --> <!-- 提示区域 -->
<fcommon:FlashingBorder IsFlashingEnabled="True" FlashingInterval="0:0:0.5"> <fcommon:FlashingBorder IsFlashingEnabled="{Binding Path=SettingViewModel.IsFlashingEnabled}"
FlashingInterval="{Binding Path=SettingViewModel.FlashingInterval}">
<common:ArrowShape ArrowMaxHeight="120" ArrowMaxWidth="120" ArrowMinHeigh="60" ArrowMinWidth="60" <common:ArrowShape ArrowMaxHeight="120" ArrowMaxWidth="120" ArrowMinHeigh="60" ArrowMinWidth="60"
RectangleMaxHeigh="40" RectangleMaxWidth="1200" RectangleMinHeigh="5" RectangleMinWidth="20" RectangleMaxHeigh="40" RectangleMaxWidth="1200" RectangleMinHeigh="5" RectangleMinWidth="20"
SafeRectangleWidth="400" RectangleHeightProportion="0.4" SafeRectangleWidth="400" RectangleHeightProportion="0.4"
......
...@@ -49,6 +49,20 @@ namespace VIZ.ElectricRabbit.Module ...@@ -49,6 +49,20 @@ namespace VIZ.ElectricRabbit.Module
#endregion #endregion
#region SettingViewModel -- 设置视图模型
private SettingViewModel settingViewModel = new SettingViewModel();
/// <summary>
/// 设置视图模型
/// </summary>
public SettingViewModel SettingViewModel
{
get { return settingViewModel; }
set { settingViewModel = value; this.RaisePropertyChanged(nameof(SettingViewModel)); }
}
#endregion
// ================================================================================ // ================================================================================
// Command // Command
// ================================================================================ // ================================================================================
......
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core" xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common" xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:domain="clr-namespace:VIZ.ElectricRabbit.Domain;assembly=VIZ.ElectricRabbit.Domain"
xmlns:local="clr-namespace:VIZ.ElectricRabbit.Module" xmlns:local="clr-namespace:VIZ.ElectricRabbit.Module"
d:DataContext="{d:DesignInstance Type=local:MainViewModel}"
mc:Ignorable="d" d:Background="#ff12202d" mc:Ignorable="d" d:Background="#ff12202d"
d:DesignHeight="1080" d:DesignWidth="400"> d:DesignHeight="1080" d:DesignWidth="400">
<UserControl.Resources> <UserControl.Resources>
...@@ -21,7 +23,6 @@ ...@@ -21,7 +23,6 @@
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<fcore:Color2SolidColorBrushConverter x:Key="Color2SolidColorBrushConverter"></fcore:Color2SolidColorBrushConverter> <fcore:Color2SolidColorBrushConverter x:Key="Color2SolidColorBrushConverter"></fcore:Color2SolidColorBrushConverter>
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
...@@ -51,17 +52,23 @@ ...@@ -51,17 +52,23 @@
<!-- 安全范围 --> <!-- 安全范围 -->
<TextBlock Text="安全范围(像素)" Foreground="#AAFFFFFF" VerticalAlignment="Center" FontSize="14" <TextBlock Text="安全范围(像素)" Foreground="#AAFFFFFF" VerticalAlignment="Center" FontSize="14"
Margin="10,0,10,0" Grid.Row="1"></TextBlock> Margin="10,0,10,0" Grid.Row="1"></TextBlock>
<toolkit:IntegerUpDown Grid.Row="1" Grid.Column="1" Height="30" Margin="10,0,10,0"></toolkit:IntegerUpDown> <toolkit:IntegerUpDown Grid.Row="1" Grid.Column="1" Height="30" Margin="10,0,10,0"
Minimum="0" Maximum="{x:Static Member=domain:ApplicationConstant.VIDEO_WIDTH}"
Value="{Binding Path=SettingViewModel.SafeDistance,UpdateSourceTrigger=PropertyChanged}"></toolkit:IntegerUpDown>
<!-- 安全轴 --> <!-- 安全轴 -->
<TextBlock Text="安全轴位置" Foreground="#AAFFFFFF" VerticalAlignment="Center" FontSize="14" Grid.Row="2" <TextBlock Text="安全轴位置(像素)" Foreground="#AAFFFFFF" VerticalAlignment="Center" FontSize="14" Grid.Row="2"
Margin="10,0,10,0"></TextBlock> Margin="10,0,10,0"></TextBlock>
<Grid Grid.Row="2" Grid.Column="1"> <Grid Grid.Row="2" Grid.Column="1">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="80"></ColumnDefinition> <ColumnDefinition Width="80"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Slider VerticalAlignment="Center" Margin="10,0,10,0" Style="{StaticResource Slider_Setting}"></Slider> <Slider VerticalAlignment="Center" Margin="10,0,10,0" Style="{StaticResource Slider_Setting}"
<toolkit:IntegerUpDown Grid.Column="1" Height="30" Margin="0,0,10,0"></toolkit:IntegerUpDown> Minimum="0" Maximum="{x:Static Member=domain:ApplicationConstant.VIDEO_WIDTH__DOUBLE}"
Value="{Binding Path=SettingViewModel.SafeAxis,Mode=TwoWay}"></Slider>
<toolkit:IntegerUpDown Grid.Column="1" Height="30" Margin="0,0,10,0"
Minimum="0" Maximum="{x:Static Member=domain:ApplicationConstant.VIDEO_WIDTH}"
Value="{Binding Path=SettingViewModel.SafeAxis,Mode=TwoWay}"></toolkit:IntegerUpDown>
</Grid> </Grid>
</Grid> </Grid>
<Rectangle Grid.Row="0" Height="1" VerticalAlignment="Bottom" Fill="#ff3d4758"></Rectangle> <Rectangle Grid.Row="0" Height="1" VerticalAlignment="Bottom" Fill="#ff3d4758"></Rectangle>
...@@ -86,11 +93,15 @@ ...@@ -86,11 +93,15 @@
<!-- 安全范围 --> <!-- 安全范围 -->
<TextBlock Text="是否启用闪烁" Foreground="#AAFFFFFF" VerticalAlignment="Center" FontSize="14" <TextBlock Text="是否启用闪烁" Foreground="#AAFFFFFF" VerticalAlignment="Center" FontSize="14"
Margin="10,0,10,0" Grid.Row="1"></TextBlock> Margin="10,0,10,0" Grid.Row="1"></TextBlock>
<CheckBox Grid.Row="1" Grid.Column="1" Style="{StaticResource CheckBox_Setting}" Margin="10,0,10,0"></CheckBox> <CheckBox Grid.Row="1" Grid.Column="1" Style="{StaticResource CheckBox_Setting}" Margin="10,0,10,0"
Height="30" Width="60" HorizontalAlignment="Left"
IsChecked="{Binding Path=SettingViewModel.IsFlashingEnabled,Mode=TwoWay}"></CheckBox>
<!-- 闪烁间隔 --> <!-- 闪烁间隔 -->
<TextBlock Text="闪烁间隔(秒)" Foreground="#AAFFFFFF" VerticalAlignment="Center" FontSize="14" Grid.Row="2" <TextBlock Text="闪烁间隔(秒)" Foreground="#AAFFFFFF" VerticalAlignment="Center" FontSize="14" Grid.Row="2"
Margin="10,0,10,0"></TextBlock> Margin="10,0,10,0"></TextBlock>
<toolkit:IntegerUpDown Grid.Row="2" Grid.Column="1" Height="30" Margin="10,0,10,0"></toolkit:IntegerUpDown> <toolkit:DoubleUpDown Grid.Row="2" Grid.Column="1" Height="30" Margin="10,0,10,0"
Minimum="0.3" Maximum="5"
Value="{Binding Path=SettingViewModel.FlashingInterval,Mode=TwoWay}"></toolkit:DoubleUpDown>
<!-- 配色 --> <!-- 配色 -->
<TextBlock Text="配色" Foreground="#AAFFFFFF" VerticalAlignment="Center" FontSize="14" Grid.Row="3" <TextBlock Text="配色" Foreground="#AAFFFFFF" VerticalAlignment="Center" FontSize="14" Grid.Row="3"
Margin="10,0,10,0"></TextBlock> Margin="10,0,10,0"></TextBlock>
...@@ -100,16 +111,19 @@ ...@@ -100,16 +111,19 @@
<ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<fcommon:ColorPickButton Style="{StaticResource ColorPickButton_Setting}"> <fcommon:ColorPickButton Style="{StaticResource ColorPickButton_Setting}"
Color="{Binding Path=SettingViewModel.LeftColor,Mode=TwoWay}">
<Path Data="{StaticResource ResourceKey=ARROW_RESOURCE_LEFT}" <Path Data="{StaticResource ResourceKey=ARROW_RESOURCE_LEFT}"
Fill="{Binding Path=Color,RelativeSource={RelativeSource AncestorLevel=1,Mode=FindAncestor,AncestorType=fcommon:ColorPickButton},Converter={StaticResource Color2SolidColorBrushConverter}}" Fill="{Binding Path=Color,RelativeSource={RelativeSource AncestorLevel=1,Mode=FindAncestor,AncestorType=fcommon:ColorPickButton},Converter={StaticResource Color2SolidColorBrushConverter}}"
Stretch="Fill" Width="40" Height="20"></Path> Stretch="Fill" Width="40" Height="20"></Path>
</fcommon:ColorPickButton> </fcommon:ColorPickButton>
<fcommon:ColorPickButton Grid.Column="1" Style="{StaticResource ColorPickButton_Setting}"> <fcommon:ColorPickButton Grid.Column="1" Style="{StaticResource ColorPickButton_Setting}"
Color="{Binding Path=SettingViewModel.SafeColor,Mode=TwoWay}">
<Rectangle Width="40" Height="20" <Rectangle Width="40" Height="20"
Fill="{Binding Path=Color,RelativeSource={RelativeSource AncestorLevel=1,Mode=FindAncestor,AncestorType=fcommon:ColorPickButton},Converter={StaticResource Color2SolidColorBrushConverter}}" ></Rectangle> Fill="{Binding Path=Color,RelativeSource={RelativeSource AncestorLevel=1,Mode=FindAncestor,AncestorType=fcommon:ColorPickButton},Converter={StaticResource Color2SolidColorBrushConverter}}" ></Rectangle>
</fcommon:ColorPickButton> </fcommon:ColorPickButton>
<fcommon:ColorPickButton Grid.Column="2" Style="{StaticResource ColorPickButton_Setting}"> <fcommon:ColorPickButton Grid.Column="2" Style="{StaticResource ColorPickButton_Setting}"
Color="{Binding Path=SettingViewModel.RightColor,Mode=TwoWay}">
<Path Data="{StaticResource ResourceKey=ARROW_RESOURCE_RIGHT}" <Path Data="{StaticResource ResourceKey=ARROW_RESOURCE_RIGHT}"
Stretch="Fill" Width="40" Height="20" Stretch="Fill" Width="40" Height="20"
Fill="{Binding Path=Color,RelativeSource={RelativeSource AncestorLevel=1,Mode=FindAncestor,AncestorType=fcommon:ColorPickButton},Converter={StaticResource Color2SolidColorBrushConverter}}" ></Path> Fill="{Binding Path=Color,RelativeSource={RelativeSource AncestorLevel=1,Mode=FindAncestor,AncestorType=fcommon:ColorPickButton},Converter={StaticResource Color2SolidColorBrushConverter}}" ></Path>
......
...@@ -24,8 +24,6 @@ namespace VIZ.ElectricRabbit.Module ...@@ -24,8 +24,6 @@ namespace VIZ.ElectricRabbit.Module
public SettingView() public SettingView()
{ {
InitializeComponent(); InitializeComponent();
WPFHelper.BindingViewModel(this, new SettingViewModel());
} }
} }
} }
...@@ -3,6 +3,12 @@ using System.Collections.Generic; ...@@ -3,6 +3,12 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.Configuration;
using System.Web.UI.HtmlControls;
using System.Windows.Media;
using VIZ.ElectricRabbit.Domain;
using VIZ.ElectricRabbit.Storage;
using VIZ.Framework.Common;
using VIZ.Framework.Core; using VIZ.Framework.Core;
namespace VIZ.ElectricRabbit.Module namespace VIZ.ElectricRabbit.Module
...@@ -12,6 +18,137 @@ namespace VIZ.ElectricRabbit.Module ...@@ -12,6 +18,137 @@ namespace VIZ.ElectricRabbit.Module
/// </summary> /// </summary>
public class SettingViewModel : ViewModelBase public class SettingViewModel : ViewModelBase
{ {
#region SafeDistance -- 安全距离(单位:像素)
private int safeDistance = ApplicationDomainEx.ClientConfigInfo.SafeDistance;
/// <summary>
/// 安全距离(单位:像素)
/// </summary>
public int SafeDistance
{
get { return safeDistance; }
set
{
safeDistance = value;
this.RaisePropertyChanged(nameof(SafeDistance));
ApplicationDomainEx.ClientConfigInfo.SafeDistance = value;
}
}
#endregion
#region SafeAxis -- 安全轴位置(单位:像素)
private int safeAxis = ApplicationDomainEx.ClientConfigInfo.SafeAxis;
/// <summary>
/// 安全轴位置(单位:像素)
/// </summary>
public int SafeAxis
{
get { return safeAxis; }
set
{
safeAxis = value;
this.RaisePropertyChanged(nameof(SafeAxis));
ApplicationDomainEx.ClientConfigInfo.SafeAxis = value;
}
}
#endregion
#region IsFlashingEnabled -- 是否启用闪烁
private bool isFlashingEnabled = ApplicationDomainEx.ClientConfigInfo.IsFlashingEnabled;
/// <summary>
/// 是否启用闪烁
/// </summary>
public bool IsFlashingEnabled
{
get { return isFlashingEnabled; }
set
{
isFlashingEnabled = value;
this.RaisePropertyChanged(nameof(IsFlashingEnabled));
ApplicationDomainEx.ClientConfigInfo.IsFlashingEnabled = value;
}
}
#endregion
#region FlashingInterval -- 闪烁间隔
private double flashingInterval = ApplicationDomainEx.ClientConfigInfo.FlashingInterval;
/// <summary>
/// 闪烁间隔
/// </summary>
public double FlashingInterval
{
get { return flashingInterval; }
set
{
flashingInterval = value;
this.RaisePropertyChanged(nameof(FlashingInterval));
ApplicationDomainEx.ClientConfigInfo.FlashingInterval = value;
}
}
#endregion
#region LeftColor -- 方向向左颜色
private Color leftColor = ApplicationDomainEx.ClientConfigInfo.LeftColor;
/// <summary>
/// 方向向左颜色
/// </summary>
public Color LeftColor
{
get { return leftColor; }
set
{
leftColor = value;
this.RaisePropertyChanged(nameof(LeftColor));
ApplicationDomainEx.ClientConfigInfo.LeftColor = value;
}
}
#endregion
#region RightColor -- 方向向右颜色
private Color rightColor = ApplicationDomainEx.ClientConfigInfo.RightColor;
/// <summary>
/// 方向向右颜色
/// </summary>
public Color RightColor
{
get { return rightColor; }
set
{
rightColor = value;
this.RaisePropertyChanged(nameof(RightColor));
ApplicationDomainEx.ClientConfigInfo.RightColor = value;
}
}
#endregion
#region SafeColor -- 安全颜色
private Color safeColor = ApplicationDomainEx.ClientConfigInfo.SafeColor;
/// <summary>
/// 安全颜色
/// </summary>
public Color SafeColor
{
get { return safeColor; }
set
{
safeColor = value;
this.RaisePropertyChanged(nameof(SafeColor));
ApplicationDomainEx.ClientConfigInfo.SafeColor = value;
}
}
#endregion
} }
} }
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using VIZ.ElectricRabbit.Domain;
using VIZ.ElectricRabbit.Storage;
using VIZ.Framework.Core;
using VIZ.Framework.Domain;
using VIZ.Framework.Module;
namespace VIZ.ElectricRabbit.Module
{
/// <summary>
/// 应用程序启动 -- 初始化INI
/// </summary>
public class AppSetup_InitINI : AppSetupBase
{/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(AppSetup_InitINI));
/// <summary>
/// 描述
/// </summary>
public override string Detail { get; } = "应用程序启动 -- 初始化INI";
/// <summary>
/// 执行启动
/// </summary>
/// <param name="context">应用程序启动上下文</param>
/// <returns>是否成功执行</returns>
public override bool Setup(AppSetupContext context)
{
// 安全距离
ApplicationDomainEx.ClientConfigInfo.SafeDistance = ApplicationDomainEx.IniStorage.GetValue<ClientConfig, int>(p => p.CLIENT_SAFE_DISTANCE);
// 安全轴位置
ApplicationDomainEx.ClientConfigInfo.SafeAxis = ApplicationDomainEx.IniStorage.GetValue<ClientConfig, int>(p => p.CLIENT_SAFE_AXIS);
// 是否启用闪烁
ApplicationDomainEx.ClientConfigInfo.IsFlashingEnabled = ApplicationDomainEx.IniStorage.GetValue<ClientConfig, bool>(p => p.CLIENT_IS_FLASHING_ENABLED);
// 闪烁间隔
ApplicationDomainEx.ClientConfigInfo.FlashingInterval = ApplicationDomainEx.IniStorage.GetValue<ClientConfig, double>(p => p.CLIENT_FLASHING_INTERVAL);
// 方向向左箭头颜色
ApplicationDomainEx.ClientConfigInfo.LeftColor = ApplicationDomainEx.IniStorage.GetValue<ClientConfig, Color>(p => p.CLIENT_LEFT_COLOR);
// 方向向右箭头颜色
ApplicationDomainEx.ClientConfigInfo.RightColor = ApplicationDomainEx.IniStorage.GetValue<ClientConfig, Color>(p => p.CLIENT_RIGHT_COLOR);
// 安全颜色
ApplicationDomainEx.ClientConfigInfo.SafeColor = ApplicationDomainEx.IniStorage.GetValue<ClientConfig, Color>(p => p.CLIENT_SAFE_COLOR);
// 注册保存任务
ApplicationDomainEx.LoopManager.Register("AppSetup_InitINI.saveIni", 30, this.saveIni);
return true;
}
/// <summary>
/// 执行关闭
/// </summary>
/// <param name="context">应用程序启动上下文</param>
public override void Shutdown(AppSetupContext context)
{
this.saveIni();
}
/// <summary>
/// 保存INI配置
/// </summary>
private void saveIni()
{
// 安全距离
ApplicationDomainEx.IniStorage.SetValue<ClientConfig>(p => p.CLIENT_SAFE_DISTANCE, ApplicationDomainEx.ClientConfigInfo.SafeDistance);
// 安全轴位置
ApplicationDomainEx.IniStorage.SetValue<ClientConfig>(p => p.CLIENT_SAFE_AXIS, ApplicationDomainEx.ClientConfigInfo.SafeAxis);
// 是否启用闪烁
ApplicationDomainEx.IniStorage.SetValue<ClientConfig>(p => p.CLIENT_IS_FLASHING_ENABLED, ApplicationDomainEx.ClientConfigInfo.IsFlashingEnabled);
// 闪烁间隔
ApplicationDomainEx.IniStorage.SetValue<ClientConfig>(p => p.CLIENT_FLASHING_INTERVAL, ApplicationDomainEx.ClientConfigInfo.FlashingInterval);
// 方向向左箭头颜色
ApplicationDomainEx.IniStorage.SetValue<ClientConfig>(p => p.CLIENT_LEFT_COLOR, ApplicationDomainEx.ClientConfigInfo.LeftColor);
// 方向向右箭头颜色
ApplicationDomainEx.IniStorage.SetValue<ClientConfig>(p => p.CLIENT_RIGHT_COLOR, ApplicationDomainEx.ClientConfigInfo.RightColor);
// 安全颜色
ApplicationDomainEx.IniStorage.SetValue<ClientConfig>(p => p.CLIENT_SAFE_COLOR, ApplicationDomainEx.ClientConfigInfo.SafeColor);
}
}
}
\ No newline at end of file
...@@ -124,6 +124,7 @@ ...@@ -124,6 +124,7 @@
<Compile Include="SettingView\View\SettingView.xaml.cs"> <Compile Include="SettingView\View\SettingView.xaml.cs">
<DependentUpon>SettingView.xaml</DependentUpon> <DependentUpon>SettingView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Setup\Provider\AppSetup_InitINI.cs" />
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using VIZ.Framework.Storage;
namespace VIZ.ElectricRabbit.Storage
{
/// <summary>
/// 客户端配置
/// </summary>
public class ClientConfig : IniConfigBase
{
/// <summary>
/// 安全范围(单位:像素)
/// </summary>
[Ini(Section = "Client", DefaultValue = "200", Type = typeof(int))]
public string CLIENT_SAFE_DISTANCE { get; set; }
/// <summary>
/// 安全轴位置(单位:像素)
/// </summary>
[Ini(Section = "Client", DefaultValue = "200", Type = typeof(int))]
public string CLIENT_SAFE_AXIS { get; set; }
/// <summary>
/// 是否使用闪烁
/// </summary>
[Ini(Section = "Client", DefaultValue = "false", Type = typeof(bool))]
public string CLIENT_IS_FLASHING_ENABLED { get; set; }
/// <summary>
/// 闪烁间隔(单位:秒)
/// </summary>
[Ini(Section = "Client", DefaultValue = "1", Type = typeof(double))]
public string CLIENT_FLASHING_INTERVAL { get; set; }
/// <summary>
/// 箭头向左颜色(格式:#AARRGGBB)
/// </summary>
[Ini(Section = "Client", DefaultValue = "#FF0000FF", Type = typeof(Color))]
public string CLIENT_LEFT_COLOR { get; set; }
/// <summary>
/// 箭头向右颜色(格式:#AARRGGBB)
/// </summary>
[Ini(Section = "Client", DefaultValue = "#FFFF0000", Type = typeof(Color))]
public string CLIENT_RIGHT_COLOR { get; set; }
/// <summary>
/// 箭头安全颜色(格式:#AARRGGBB)
/// </summary>
[Ini(Section = "Client", DefaultValue = "#FF00FF00", Type = typeof(Color))]
public string CLIENT_SAFE_COLOR { get; set; }
}
}
...@@ -52,18 +52,22 @@ ...@@ -52,18 +52,22 @@
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Windows" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Ini\ClientConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -5,6 +5,7 @@ using System.Data; ...@@ -5,6 +5,7 @@ using System.Data;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using VIZ.ElectricRabbit.Module;
using VIZ.Framework.Module; using VIZ.Framework.Module;
namespace VIZ.ElectricRabbit namespace VIZ.ElectricRabbit
...@@ -16,6 +17,9 @@ namespace VIZ.ElectricRabbit ...@@ -16,6 +17,9 @@ namespace VIZ.ElectricRabbit
{ {
public App() public App()
{ {
// 初始化 INI
AppSetup.AppendSetup(new AppSetup_InitINI());
// 执行启动流程 // 执行启动流程
AppSetupContext context = AppSetup.Setup(); AppSetupContext context = AppSetup.Setup();
......
...@@ -132,6 +132,12 @@ ...@@ -132,6 +132,12 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="config\config.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config\log.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
......
; ============================================================
; === Application ===
; ============================================================
[Application]
; 是否是调试模式
APPLICATION_IS_DEBUG=false
; ============================================================
; === Video ===
; ============================================================
[Video]
; 视频是否显示FPS
VIDEO_IS_SHOW_FPS=false
; 视频渲染等待(单位:毫秒)
VIDEO_RENDER_WAIT=10
; ============================================================
; === Client ===
; ============================================================
[Client]
; 安全范围(单位:像素)
CLIENT_SAFE_DISTANCE=200
; 安全轴位置(单位:像素)
CLIENT_SAFE_AXIS=960
; 是否使用闪烁
CLIENT_IS_FLASHING_ENABLED=false
; 闪烁间隔(单位:秒)
CLIENT_FLASHING_INTERVAL=1
; 箭头向左颜色(格式:#AARRGGBB)
CLIENT_LEFT_COLOR=#FF0000FF
; 箭头向右颜色(格式:#AARRGGBB)
CLIENT_RIGHT_COLOR=#FFFF0000
; 箭头安全颜色(格式:#AARRGGBB)
CLIENT_SAFE_COLOR=#FF00FF00
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="errorAppender" type="log4net.Appender.RollingFileAppender">
<filter type="log4net.Filter.LevelMatchFilter">
<levelToMatch value="ERROR" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<file value="Logs\err.log" />
<encoding value="utf-8"/>
<preserveLogFileNameExtension value="true" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<appender name="infoAppender" type="log4net.Appender.RollingFileAppender">
<filter type="log4net.Filter.LevelMatchFilter">
<levelToMatch value="INFO" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<file value="Logs\info.log" />
<encoding value="utf-8"/>
<preserveLogFileNameExtension value="true" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<appender name="debugAppender" type="log4net.Appender.RollingFileAppender">
<filter type="log4net.Filter.LevelMatchFilter">
<levelToMatch value="DEBUG" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<file value="Logs\debug.log" />
<encoding value="utf-8"/>
<preserveLogFileNameExtension value="true" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<appender name="perfAppender" type="log4net.Appender.RollingFileAppender">
<filter type="log4net.Filter.LevelMatchFilter">
<levelToMatch value="INFO" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<file value="Logs\perf.log" />
<encoding value="utf-8"/>
<preserveLogFileNameExtension value="true" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="errorAppender" />
<appender-ref ref="infoAppender" />
<appender-ref ref="debugAppender" />
</root>
<logger name="Performance" additivity="false">
<level value="ALL" />
<appender-ref ref="perfAppender" />
</logger>
</log4net>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment