Commit ed7bf665 authored by 潘栩锋's avatar 潘栩锋 🚴

修改 Base.UI 的 Styles.xaml, 删除每个界面文件都加载一次 Styles.xaml. 写在了App.xaml 统一处理

parent afe8521c
......@@ -8,6 +8,11 @@
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
<ResourceDictionary Source="Themes/Styles.xaml"/>
<ResourceDictionary Source="Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="GroupBox" />
</ResourceDictionary>
......
......@@ -2,6 +2,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:FLY.Thick.Base.UI.Converter"
>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<conv:ThickConverter x:Key="thickconv" />
<conv:IntConverter x:Key="intconv" />
<conv:DoubleConverter x:Key="doubleconv" />
......
......@@ -9,10 +9,6 @@
Title="AD盒IO口定义" Height="537" Width="484" >
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="IOStyle" TargetType="Rectangle" >
<Setter Property="Width" Value="10" />
<Setter Property="Height" Value="20" />
......
using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Unity;
namespace FLY.Thick.Base.UI
......@@ -21,17 +11,24 @@ namespace FLY.Thick.Base.UI
/// <summary>
/// WdIOTip.xaml 的交互逻辑
/// </summary>
public partial class WdIOTip : FLY.ControlLibrary.WindowBigClose
public partial class WdIOTip : FLY.ControlLibrary.WindowBigClose
{
WdIoTipVm viewModel;
public WdIOTip()
{
InitializeComponent();
this.Unloaded += WdIOTip_Unloaded;
}
private void WdIOTip_Unloaded(object sender, System.Windows.RoutedEventArgs e)
{
viewModel.DisposeBinding();
}
[InjectionMethod]
public void Init(IFlyAdIoDefineService iODefineService, ITDGageService gageService) {
public void Init(IFlyAdIoDefineService iODefineService, ITDGageService gageService)
{
viewModel = new WdIoTipVm();
viewModel.Init(iODefineService, gageService.DynArea);
......@@ -44,55 +41,87 @@ namespace FLY.Thick.Base.UI
{
public event PropertyChangedEventHandler PropertyChanged;
IFlyAdIoDefineService iODefineService;
Base.Common.DynArea dynArea;
public ObservableCollection<FlyAdIoStatus> IStatus { get; } = new ObservableCollection<FlyAdIoStatus>();
public ObservableCollection<FlyAdIoStatus> OStatus { get; } = new ObservableCollection<FlyAdIoStatus>();
public WdIoTipVm() {
}
IFlyAdIoDefineService iODefineService;
public void Init(IFlyAdIoDefineService iODefineService, DynArea dynArea)
{
this.dynArea = dynArea;
this.iODefineService = iODefineService;
DynArea dynArea;
for (int i = 0; i < 12; i++) {
Dictionary<object, List<Misc.BindingOperations.PropertyChangedEventContexts>> bindingConexts = new Dictionary<object, List<Misc.BindingOperations.PropertyChangedEventContexts>>();
/// <summary>
/// 数据已经绑定了
/// </summary>
bool isBinding;
public WdIoTipVm()
{
for (int i = 0; i < 12; i++)
{
IStatus.Add(new FlyAdIoStatus()
{
Number = $"i{i+1}"
});
Number = $"i{i + 1}"
});
};
for (int i = 0; i < 4; i++)
{
OStatus.Add(new FlyAdIoStatus()
{
Number = $"o{i+1}"
Number = $"o{i + 1}"
});
};
}
if (this.iODefineService is FObjBase.FObjServiceClient)
{
var client = this.iODefineService as FObjBase.FObjServiceClient;
if (client.IsConnected)
{
update();
}
client.PropertyChanged += Client_PropertyChanged;
}
else
public void Init(IFlyAdIoDefineService iODefineService, DynArea dynArea)
{
this.dynArea = dynArea;
this.iODefineService = iODefineService;
SetBinding();
}
/// <summary>
/// 参数绑定
/// </summary>
public void SetBinding()
{
if (isBinding)//已经绑定了
return;
isBinding = true;
//下面全部event保存在bindingConexts
Misc.BindingOperations.StartMarkdownEvents(bindingConexts);
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IStatus), this, updateIsOn_In);
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.OStatus), this, updateIsOn_Out);
//备份event完毕, 必须关闭记录
Misc.BindingOperations.StopMarkdownEvents();
var client = this.iODefineService as FObjBase.FObjServiceClient;
if (client.IsConnected)
{
update();
}
client.PropertyChanged += Client_PropertyChanged;
}
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IStatus), updateIsOn_In);
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.OStatus), updateIsOn_Out);
/// <summary>
/// 解除绑定
/// </summary>
public void DisposeBinding()
{
if (!isBinding)//已经解除绑定了
return;
isBinding = false;
Misc.BindingOperations.DisposeEventTargetObject(bindingConexts);
var client = this.iODefineService as FObjBase.FObjServiceClient;
client.PropertyChanged -= Client_PropertyChanged;
}
void updateIsOn_In()
void updateIsOn_In()
{
for (int i = 0; i < IStatus.Count(); i++)
{
......@@ -120,10 +149,12 @@ namespace FLY.Thick.Base.UI
void update()
{
iODefineService.GetIODefine((asyncContext, retData) => {
iODefineService.GetIODefine((asyncContext, retData) =>
{
var reponse = retData as IODefineCollection;
if (reponse == null) {
if (reponse == null)
{
return;
}
var list = reponse.List;
......@@ -142,7 +173,7 @@ namespace FLY.Thick.Base.UI
IODefine.IOTYPE ioType,
ObservableCollection<FlyAdIoStatus> ioStatus,
int ioCnt,
List<IODefine> list)
List<IODefine> list)
{
//补够数量
if (ioStatus.Count() != ioCnt && ioCnt > 0)
......@@ -231,21 +262,21 @@ namespace FLY.Thick.Base.UI
});
};
IStatus[2-1].IsOn = true;
IStatus[4-1].IsOn = true;
IStatus[1].IsOn = true;
IStatus[3].IsOn = true;
IStatus[11 - 1].IsOn = true;
IStatus[10].IsOn = true;
OStatus[4 - 1].IsOn = true;
OStatus[3].IsOn = true;
IStatus[2 - 1].Desp = "归零信号";
IStatus[3 - 1].Desp = "正向限位";
IStatus[4 - 1].Desp = "反向限位";
IStatus[7 - 1].Desp = "急停 & 手动正转";
IStatus[8 - 1].Desp = "急停 & 手动反转";
IStatus[1].Desp = "归零信号";
IStatus[2].Desp = "正向限位";
IStatus[3].Desp = "反向限位";
IStatus[4].Desp = "急停 & 手动正转";
IStatus[5].Desp = "急停 & 手动反转";
OStatus[4 - 1].Desp = "报警信号";
OStatus[3].Desp = "报警信号";
......
......@@ -38,6 +38,7 @@
</Style>
<!--Axis.Section-->
<!--图表中选择器-->
<Style x:Key="Styles.Axis.Section.Selected" TargetType="lvc:AxisSection" >
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="DataLabel" Value="False"/>
......@@ -51,6 +52,35 @@
<!--<Setter Property="Fill" Value="#59F7D8D8"/>-->
</Style>
<!--图表中放大用选择器-->
<Style x:Key="Styles.Axis.Section.Selected.ZoomIn" TargetType="lvc:AxisSection" >
<!--<Setter Property="StrokeThickness" Value="2"/>
<Setter Property="StrokeDashArray" Value="1 1"/>
<Setter Property="DataLabel" Value="True"/>
<Setter Property="DisableAnimations" Value="True"/>
<Setter Property="DataLabelForeground" Value="White"/>
<Setter Property="Opacity" Value="0.1"/>
<Setter Property="Stroke" Value="{StaticResource MahApps.Brushes.Accent2}"/>-->
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="DataLabel" Value="True"/>
<Setter Property="DisableAnimations" Value="True"/>
<Setter Property="DataLabelForeground" Value="White"/>
<Setter Property="Opacity" Value="0.5"/>
<Setter Property="Stroke" Value="{StaticResource MahApps.Brushes.Accent2}"/>
</Style>
<!--图表中的边界-->
<Style x:Key="Styles.Axis.Section.Border" TargetType="lvc:AxisSection" >
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="DataLabel" Value="True"/>
<Setter Property="DisableAnimations" Value="True"/>
<Setter Property="DataLabelForeground" Value="White"/>
<Setter Property="Opacity" Value="1"/>
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="Stroke" Value="Orange"/>
</Style>
<!--扫描图,纵向趋势图Y轴 标签-->
<Style x:Key="AxisSectionStyle" TargetType="lvc:AxisSection" >
<Setter Property="StrokeThickness" Value="1"/>
......@@ -60,4 +90,13 @@
<Setter Property="Opacity" Value="0.5"/>
<Setter Property="Panel.ZIndex" Value="1"/>
</Style>
<Style x:Key="GraphButton" TargetType="Button" BasedOn="{StaticResource Styles.Button.Icon}">
<Setter Property="Margin" Value="48,0,0,-20"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsYAxisTitleHidden}" Value="False">
<Setter Property="Margin" Value="80,0,0,-20"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />-->
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
<ResourceDictionary Source=" GraphStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!--<Style TargetType="GroupBox" />-->
</ResourceDictionary>
\ 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