Commit 64cbb1ea authored by 潘栩锋's avatar 潘栩锋 :bicyclist:

合并

parents 112f17fe e1da2583
......@@ -13,5 +13,21 @@ namespace Install
/// </summary>
public partial class App : Application
{
public static T Resolve<T>()
{
return (T)App.Current.Properties[typeof(T).FullName];
}
public static T Resolve<T>(string name)
{
return (T)App.Current.Properties[typeof(T).FullName + $".{name}"];
}
public static void RegisterInstance<T>(T obj)
{
App.Current.Properties[typeof(T).FullName] = obj;
}
public static void RegisterInstance<T>(T obj, string name)
{
App.Current.Properties[typeof(T).FullName + $".{name}"] = obj;
}
}
}
......@@ -42,8 +42,10 @@ namespace Install
return;
}
Application.Current.Properties[nameof(InstallWizard)] = installWizard;
Application.Current.Properties["NavigationService"] = NavigationService;
//注入
App.RegisterInstance(installWizard);
App.RegisterInstance(NavigationService);
Pg1st p = new Pg1st();
p.Init();
NavigationService.Navigate(p);
......
......@@ -51,6 +51,6 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyVersion("4.0.1")]
[assembly: AssemblyFileVersion("4.0.1")]
[assembly: Guid("AB127AC6-16C6-411F-8892-D90413A863C8")]
......@@ -28,7 +28,7 @@ namespace Install.View
}
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
installWizard = App.Resolve<InstallWizard>();
this.DataContext = installWizard;
}
......
......@@ -50,7 +50,7 @@ namespace Install.View
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
installWizard = App.Resolve<InstallWizard>();
Icons = installWizard.Icons;
......@@ -103,7 +103,7 @@ namespace Install.View
PgProgress p = new PgProgress();
p.Init();
(Application.Current.Properties["NavigationService"] as NavigationService).Navigate(p);
App.Resolve<NavigationService>().Navigate(p);
await installWizard.Install(InstallPath, installPacks);
}
}
......
......@@ -30,7 +30,7 @@ namespace Install.View
}
public void Init()
{
installWizard = App.Current.Properties[nameof(InstallWizard)] as InstallWizard;
installWizard = App.Resolve<InstallWizard>();
this.DataContext = installWizard;
installWizard.PropertyChanged += InstallWizard_PropertyChanged;
......
......@@ -57,7 +57,7 @@ namespace Install.View
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
installWizard = App.Resolve<InstallWizard>();
Icons = installWizard.Icons;
......@@ -66,13 +66,16 @@ namespace Install.View
Items.Add(new ListItem() { Item = installInfo, IsSelected = installInfo.NeedToUpdate });
}
if (installWizard.HasInstalled.Count(installInfo => installInfo.NeedToUpdate) > 0)
Option = OPTION.UPDATE;
HasNew = installWizard.ToInstall.Count > 0;
}
private void New()
{
PgInstall p = new PgInstall();
p.Init();
(Application.Current.Properties["NavigationService"] as NavigationService).Navigate(p);
App.Resolve<NavigationService>().Navigate(p);
}
private async void Next()
......@@ -86,7 +89,7 @@ namespace Install.View
}
PgProgress p = new PgProgress();
p.Init();
(Application.Current.Properties["NavigationService"] as NavigationService).Navigate(p);
App.Resolve<NavigationService>().Navigate(p);
switch (Option)
{
......
......@@ -64,7 +64,7 @@ namespace Install.View
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
installWizard = App.Resolve<InstallWizard>();
Msg = $"下载 {installWizard.NewestInstallZipVersionInfo.InstallZipUrl}";
}
......
......@@ -152,7 +152,7 @@
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{TemplateBinding Content}" TextWrapping = "Wrap" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" Margin="5"/>
<TextBlock Text="{TemplateBinding Content}" TextWrapping = "Wrap" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="15" Margin="5"/>
<Button Grid.Column="1" x:Name="button_close" Style="{StaticResource ButtonStyle_empty}" Margin="5" Background="Transparent" VerticalAlignment="Top" HorizontalAlignment="Right"
Click="button_componentDel_Click">
......
......@@ -152,17 +152,15 @@
<Setter Property="Foreground" Value="White"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="FontFamily" Value="YouYuan"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</ResourceDictionary>
</ControlTemplate.Resources>
<Border Background="Transparent" >
<StackPanel Margin="5">
<Rectangle Height="36" Width="36" Stroke="White" StrokeThickness="4"/>
<Viewbox Margin="3" MaxHeight="12">
<TextBlock Text="{TemplateBinding Content}" />
</Viewbox>
<TextBlock Margin="3" Text="{TemplateBinding Content}" />
</StackPanel>
</Border>
</ControlTemplate>
......@@ -225,7 +223,7 @@
<Style TargetType="Button" BasedOn="{StaticResource ButtonStyle_menu}"/>
</StackPanel.Resources>
<Button>
□□
测厚.扫描图12312123123
</Button>
</StackPanel>
<Viewbox Grid.Column="1" Margin="5" MaxWidth="250" VerticalAlignment="Top" Opacity="0.5" >
......
......@@ -3,7 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MultiLayout"
xmlns:local="clr-namespace:MultiLayout" xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:flyctrl="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" Loaded="MainWindow_Loaded">
<Window.Resources>
......@@ -17,8 +18,11 @@
</Window.Resources>
<Grid d:DataContext="{StaticResource viewModel}">
<Frame Name="frame" NavigationUIVisibility="Hidden"/>
<Button Style="{StaticResource Styles.Button.Empty}" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,50,0"
Visibility="{Binding IsErrMsgVisable,Converter={StaticResource visbilityconv}}" Click="btnErrMsgClick">
<Button x:Name="btnErrMsg" Style="{StaticResource Styles.Button.Empty}" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,50,0"
Visibility="{Binding IsErrMsgVisable,Converter={StaticResource visbilityconv}}" Click="btnErrMsgClick" >
<b:Interaction.Behaviors>
<flyctrl:DrapMoveXBehavior Move="DrapMoveXBehavior_Move" />
</b:Interaction.Behaviors>
<Border Background="Red" CornerRadius="0, 0 10 10" Style="{StaticResource Styles.Shadow}">
<StackPanel Orientation="Horizontal">
<Grid Width="15"/>
......
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -93,12 +94,59 @@ namespace MultiLayout
//启动Poll系统
//FObjBase.PollModule.Current.Start();
ErrMsgJsonDb jsonDb = new ErrMsgJsonDb();
if (jsonDb.Load()) {
var m = btnErrMsg.Margin;
m.Right = jsonDb.Right;
btnErrMsg.Margin = m;
}
}
private void btnErrMsgClick(object sender, RoutedEventArgs e)
{
manager.ErrMsgClick?.Invoke();
}
private void DrapMoveXBehavior_Move(object sender, EventArgs e)
{
ErrMsgJsonDb jsonDb = new ErrMsgJsonDb();
jsonDb.Right = (int)btnErrMsg.Margin.Right;
jsonDb.Save();
}
}
public class ErrMsgJsonDb
{
public int Right;
private string filePath = "errMsgPosition.json";
public bool Save()
{
try
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(this);
File.WriteAllText(filePath, json);
return true;
}
catch
{
return false;
}
}
public bool Load()
{
if (!File.Exists(filePath))
return false;
try
{
string json = File.ReadAllText(filePath);
Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
return true;
}
catch {
return false;
}
}
}
public class WdMainVm:INotifyPropertyChanged
{
......
using Microsoft.Xaml.Behaviors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
namespace FLY.ControlLibrary
{
/// <summary>
/// BUTTON 移动行为,附加行为。
/// </summary>
public class DrapMoveXBehavior : Behavior<UIElement>
{
//
// 摘要:
// 发生时 System.Windows.Controls.Button 时发生。
[Category("Behavior")]
public event EventHandler Move;
bool isDown = false;
Point downPoint;
/// <summary>
/// Move 事件滞后5秒触发
/// </summary>
public bool IsMoveEventDelayTrigger { get; set; } = true;
T GetParent<T>(DependencyObject dobj) where T : DependencyObject
{
//一直向上找,直到找到window
do
{
if (dobj is T)
{
break;
}
dobj = System.Windows.Media.VisualTreeHelper.GetParent(dobj);
} while (dobj != null);
return (T)dobj;
}
DispatcherTimer timer = new DispatcherTimer();
/// <summary>
///
/// </summary>
public DrapMoveXBehavior()
{
timer.Tick += Timer_Tick;
timer.Interval = TimeSpan.FromSeconds(3);
}
private void Timer_Tick(object sender, EventArgs e)
{
timer.Stop();
Move?.Invoke(AssociatedObject, null);
}
/// <summary>
///
/// </summary>
protected override void OnAttached()
{
base.OnAttached();
UIElement dobj = AssociatedObject;
dobj.MouseRightButtonDown += Dobj_MouseRightButtonDown;
dobj.MouseRightButtonUp += Dobj_MouseRightButtonUp;
dobj.MouseMove += Dobj_MouseMove;
dobj.MouseLeave += Dobj_MouseLeave;
parent = GetParent<Grid>(dobj);
}
private void Dobj_MouseLeave(object sender, MouseEventArgs e)
{
isDown = false;
}
private void Dobj_MouseMove(object sender, MouseEventArgs e)
{
//string json = Newtonsoft.Json.JsonConvert.SerializeObject(e);
if (!isDown)
return;
FrameworkElement fe = (FrameworkElement)AssociatedObject;
var downPoint = e.GetPosition(parent);
string json = Newtonsoft.Json.JsonConvert.SerializeObject(downPoint);
//移动
int x = (int)(downPoint.X - this.downPoint.X);
if (Math.Abs(x) < 2)
return;
this.downPoint = downPoint;
var m = fe.Margin;
if (fe.HorizontalAlignment == HorizontalAlignment.Center)
{
m.Right -= x * 2;
}
else if(fe.HorizontalAlignment == HorizontalAlignment.Right)
{
m.Right -= x;
}
else if(fe.HorizontalAlignment == HorizontalAlignment.Left)
{
m.Left += x;
}
fe.Margin = m;
if (IsMoveEventDelayTrigger)
{
timer.Start();
}
else
{
Move?.Invoke(AssociatedObject, null);
}
}
Grid parent;
private void Dobj_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
downPoint = e.GetPosition(parent);
string json = Newtonsoft.Json.JsonConvert.SerializeObject(downPoint);
isDown = true;
}
private void Dobj_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
isDown = false;
}
/// <summary>
///
/// </summary>
protected override void OnDetaching()
{
base.OnDetaching();
timer.Stop();
UIElement dobj = AssociatedObject;
dobj.MouseRightButtonDown -= Dobj_MouseRightButtonDown;
dobj.MouseRightButtonUp -= Dobj_MouseRightButtonUp;
dobj.MouseMove -= Dobj_MouseMove;
dobj.MouseLeave -= Dobj_MouseLeave;
}
}
}
......@@ -61,6 +61,7 @@
<Compile Include="COMMON.cs" />
<Compile Include="Converter\Item2IndexConverter.cs" />
<Compile Include="Converter\RatioConverter.cs" />
<Compile Include="DrapMoveXBehavior.cs" />
<Compile Include="GraphRange_coslight.cs" />
<Compile Include="GraphScan3.cs" />
<Compile Include="GraphScan4.xaml.cs">
......@@ -88,6 +89,8 @@
<DependentUpon>PieChart.xaml</DependentUpon>
</Compile>
<Compile Include="ResetAction.cs" />
<Compile Include="Set1Action.cs" />
<Compile Include="ToggleAction.cs" />
<Compile Include="UI.OSK\IVirtualKeyboard.cs" />
<Compile Include="UI.OSK\KeyboardBehavior.cs" />
<Compile Include="GraphScan.xaml.cs">
......
......@@ -136,7 +136,7 @@ namespace FLY.ControlLibrary
/// <summary>
/// ResetAction2 的 XAML 版 ,附加行为。
/// 还没完成
/// 与 NoToggleButton 控件 一起使用
/// </summary>
public class ResetBehavior : Behavior<UIElement>
{
......
using Microsoft.Xaml.Behaviors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace FLY.ControlLibrary
{
/// <summary>
/// 后台添加功能,按钮 click事件 属性=true
/// </summary>
public class Set1Action : IDisposable
{
/// <summary>
/// 对象
/// </summary>
public object obj;
/// <summary>
/// bool 属性
/// </summary>
public string propertyname;
/// <summary>
/// 按下时为 true
/// </summary>
public bool pressIsTrue;
UIElement uIElement;
/// <summary>
///
/// </summary>
/// <param name="uIElement"></param>
/// <param name="obj"></param>
/// <param name="propertyname"></param>
public Set1Action(UIElement uIElement, object obj, string propertyname)
{
this.uIElement = uIElement;
this.obj = obj;
this.propertyname = propertyname;
uIElement.PreviewMouseDown += UIElement_PreviewMouseDown;
uIElement.PreviewTouchDown += UIElement_PreviewTouchDown;
}
/// <summary>
///
/// </summary>
/// <param name="uIElement"></param>
/// <param name="propertyname"></param>
public Set1Action(UIElement uIElement, string propertyname) : this(uIElement, null, propertyname)
{
}
public void Dispose()
{
uIElement.PreviewMouseDown -= UIElement_PreviewMouseDown;
uIElement.PreviewTouchDown -= UIElement_PreviewTouchDown;
}
private void UIElement_PreviewTouchDown(object sender, TouchEventArgs e)
{
Down();
}
private void UIElement_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
Down();
}
bool IsObjNull()
{
if (obj == null)
{
if (uIElement is FrameworkElement)
{
obj = (uIElement as FrameworkElement).DataContext;
if (obj == null)
return true;
}
else
{
return true;
}
}
return false;
}
void Down()
{
if (IsObjNull()) return;
Misc.PropertiesManager.SetValue(obj, propertyname, true);
}
}
/// <summary>
/// Set1Action 的 XAML 版 ,附加行为。
/// </summary>
public class Set1Behavior : Behavior<UIElement>
{
public System.Windows.Data.Binding Binding { get; set; }
Set1Action set1Action = null;
public Set1Behavior()
{
}
protected override void OnAttached()
{
base.OnAttached();
UIElement dobj = AssociatedObject;
if (Binding != null && Binding.Path != null)
{
if (Binding.Source != null)
{
set1Action = new Set1Action(dobj, Binding.Source, Binding.Path.Path);
}
else
{
var obj = COMMON.GetDataContext(dobj);
if (obj == null)
{
set1Action = new Set1Action(dobj, Binding.Path.Path);
}
else
{
set1Action = new Set1Action(dobj, obj, Binding.Path.Path);
}
}
}
}
protected override void OnDetaching()
{
base.OnDetaching();
if (set1Action != null)
{
set1Action.Dispose();
set1Action = null;
}
}
}
}
......@@ -2,9 +2,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Colors.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Colors2.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!-- 标准间隔 -->
<Thickness x:Key="ControlMargin">5</Thickness>
<!--Microsoft Sans Serif-->
<FontFamily x:Key="FontFamily.Field">Microsoft Sans Serif</FontFamily>
<!--<FontFamily x:Key="FontFamily.Field">YouYuan</FontFamily>-->
</ResourceDictionary>
\ No newline at end of file
......@@ -17,7 +17,7 @@
<sys:Double x:Key="FontSize.FieldContent.Small">18</sys:Double>
<sys:Double x:Key="FontSize.FieldContent.Middle">24</sys:Double>
<Thickness x:Key="Margin.Text">3</Thickness>
<!-- 输入框 带虚拟键盘 -->
<Style TargetType="TextBox" x:Key="Styles.Text.Input">
<Setter Property="Template">
......@@ -47,15 +47,15 @@
<Setter Property="Foreground" Value="#FF3B3B3B" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="{StaticResource FontSize.FieldHeader}" />
<Setter Property="FontFamily" Value="Microsoft Sans Serif" />
<Setter Property="FontFamily" Value="{StaticResource FontFamily.Field}" />
<Setter Property="TextAlignment" Value="Left" />
</Style>
<!-- 只读项 的标题 2行 -->
<Style TargetType="TextBlock" x:Key="Styles.Text.FieldHeader.Row2" BasedOn="{StaticResource Styles.Text.FieldHeader}">
<Setter Property="FontSize" Value="{StaticResource FontSize.FieldHeader.Small}" />
</Style>
<!-- 可写项 的标题 -->
<Style TargetType="TextBlock" x:Key="Styles.Text.FieldHeader.Editable" BasedOn="{StaticResource Styles.Text.FieldHeader}">
<Setter Property="Foreground" Value="#FF0083D7" />
......@@ -64,7 +64,7 @@
<Setter Property="Foreground" Value="#FF888888" />
<Setter Property="FontSize" Value="13" />
</Style>
<!-- 可写项 的标题 2行 -->
<Style TargetType="TextBlock" x:Key="Styles.Text.FieldHeader.Editable.Row2" BasedOn="{StaticResource Styles.Text.FieldHeader.Editable}">
<Setter Property="FontSize" Value="{StaticResource FontSize.FieldHeader.Small}" />
......@@ -76,7 +76,7 @@
<Setter Property="Foreground" Value="#FF3B3B3B" />
<!--<Setter Property="FontWeight" Value="Bold" />-->
<Setter Property="FontSize" Value="{StaticResource FontSize.FieldContent}" />
<Setter Property="FontFamily" Value="Microsoft Sans Serif" />
<Setter Property="FontFamily" Value="{StaticResource FontFamily.Field}" />
<Setter Property="TextAlignment" Value="Left" />
</Style>
......@@ -86,7 +86,7 @@
<Setter Property="Foreground" Value="#FF3B3B3B" />
<!--<Setter Property="FontWeight" Value="Bold" />-->
<Setter Property="FontSize" Value="{StaticResource FontSize.FieldContent}" />
<Setter Property="FontFamily" Value="Microsoft Sans Serif" />
<Setter Property="FontFamily" Value="{StaticResource FontFamily.Field}" />
<Setter Property="TextAlignment" Value="Left" />
<Setter Property="MinWidth" Value="30" />
</Style>
......@@ -108,7 +108,7 @@
<Style TargetType="TextBlock" x:Key="Styles.Text.FieldContent.Unit">
<Setter Property="Foreground" Value="#FF888888" />
<Setter Property="FontSize" Value="{StaticResource FontSize.FieldContent.Small}" />
<Setter Property="FontFamily" Value="Microsoft Sans Serif" />
<Setter Property="FontFamily" Value="{StaticResource FontFamily.Field}" />
<Setter Property="TextAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Bottom" />
</Style>
......
using Microsoft.Xaml.Behaviors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
namespace FLY.ControlLibrary
{
/// <summary>
/// 后台添加功能,按钮按下 会切换 属性 状态, true变false,false 变true
/// </summary>
public class ToggleAction : IDisposable
{
/// <summary>
/// 对象
/// </summary>
public object obj;
/// <summary>
/// bool 属性
/// </summary>
public string propertyname;
UIElement uIElement;
/// <summary>
///
/// </summary>
/// <param name="uIElement"></param>
/// <param name="obj"></param>
/// <param name="propertyname"></param>
public ToggleAction(UIElement uIElement, object obj, string propertyname)
{
this.uIElement = uIElement;
this.obj = obj;
this.propertyname = propertyname;
uIElement.PreviewMouseDown += UIElement_PreviewMouseDown;
uIElement.PreviewTouchDown += UIElement_PreviewTouchDown;
}
/// <summary>
///
/// </summary>
/// <param name="uIElement"></param>
/// <param name="propertyname"></param>
public ToggleAction(UIElement uIElement, string propertyname) : this(uIElement, null, propertyname)
{
}
/// <summary>
///
/// </summary>
public void Dispose()
{
uIElement.PreviewMouseDown -= UIElement_PreviewMouseDown;
uIElement.PreviewTouchDown -= UIElement_PreviewTouchDown;
}
private void UIElement_PreviewTouchDown(object sender, TouchEventArgs e)
{
Down();
}
private void UIElement_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
Down();
}
bool IsObjNull()
{
if (obj == null)
{
if (uIElement is FrameworkElement)
{
obj = (uIElement as FrameworkElement).DataContext;
if (obj == null)
return true;
}
else
{
return true;
}
}
return false;
}
void Down()
{
if (IsObjNull()) return;
var value = Misc.PropertiesManager.GetValue(obj, propertyname);
var v = (bool)value;
if (v)
Misc.PropertiesManager.SetValue(obj, propertyname, false);
else
Misc.PropertiesManager.SetValue(obj, propertyname, true);
}
}
/// <summary>
/// ToggleAction 的 XAML 版 ,附加行为。
/// 与 NoToggleButton 控件 一起使用
/// </summary>
public class ToggleBehavior : Behavior<UIElement>
{
/// <summary>
///
/// </summary>
public System.Windows.Data.Binding Binding { get; set; }
ToggleAction toggleAction = null;
/// <summary>
///
/// </summary>
public ToggleBehavior()
{
}
/// <summary>
///
/// </summary>
protected override void OnAttached()
{
base.OnAttached();
UIElement dobj = AssociatedObject;
if (Binding != null && Binding.Path != null)
{
if (Binding.Source != null)
{
toggleAction = new ToggleAction(dobj, Binding.Source, Binding.Path.Path);
}
else
{
var obj = COMMON.GetDataContext(dobj);
if (obj == null)
{
toggleAction = new ToggleAction(dobj, Binding.Path.Path);
}
else
{
toggleAction = new ToggleAction(dobj, obj, Binding.Path.Path);
}
}
}
}
/// <summary>
///
/// </summary>
protected override void OnDetaching()
{
base.OnDetaching();
if (toggleAction != null)
{
toggleAction.Dispose();
toggleAction = null;
}
}
}
}
......@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace FObjBase.Reflect
{
public class Reflect_SeviceClient : FObjServiceClient
public abstract class Reflect_SeviceClient : FObjServiceClient
{
#region Core
/// <summary>
......@@ -20,7 +20,7 @@ namespace FObjBase.Reflect
/// <summary>
/// 代理对象 接口类型
/// </summary>
protected virtual Type InterfaceType { get; }
protected abstract Type InterfaceType { get; }
/// <summary>
/// 已经同步完成;
......
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.Simulation.Casting
{
public class AutoDie
{
/// <summary>
/// 加热通过
/// </summary>
public int ChannelCnt;
/// <summary>
/// 加热量, 数据量为 ChannelCnt
/// </summary>
public int[] Heats;
/// <summary>
/// 第1个加热棒,对应的 数据序号, 数据量为 1000, BeforeData.Count
/// </summary>
public int Channel1stIndex;
/// <summary>
/// 加热 对 厚度的影响
/// </summary>
public double Factor;
//需要别人赋值
/// <summary>
/// 原始数据!! 数据量为1000
/// </summary>
public ObservableCollection<int> BeforeDatas;
/// <summary>
/// 加热后的数据!!!! 数据量为BeforeDatas.Count
/// </summary>
public ObservableCollection<int> AfterDatas;
double[] p;// 一个凸起来的数组 0 1 4 9 16 9 4 1 0
void p_init()
{
int size = ChannelCnt / 10;
p = new double[size];
for (int i = 0; i < size; i++)
{
int index1 = i;
int index2 = size - 1 - i;
double d = i * i;
p[index1] = d;
p[index2] = d;
if (Math.Abs(index2 - index1) <= 1)
break;
}
double sum_p = p.Max();
for (int i = 0; i < size; i++)
{
p[i] = p[i] / sum_p;
}
}
public AutoDie(int channelcnt)
{
SetChannelCnt(channelcnt);
p_init();
Factor = 5;
}
public void Init(ObservableCollection<int> before_datas, ObservableCollection<int> after_datas, int channel1stIndex)
{
BeforeDatas = before_datas;
AfterDatas = after_datas;
Channel1stIndex = channel1stIndex;
}
public void SetChannelCnt(int channelcnt)
{
ChannelCnt = channelcnt;
Heats = new int[ChannelCnt];
Array.Clear(Heats, 0, ChannelCnt);
}
public event Action<ObservableCollection<int>> AfterDatasUpdateEvent;
public void HeatApply()
{
int boltcnt = BeforeDatas.Count();
double b_c = (double)(boltcnt) / ChannelCnt;
int b = Channel1stIndex;
double beforeavg = BeforeDatas.Average();
int[] datas = new int[boltcnt];
for (int i = 0; i < ChannelCnt; i++)
{
int heat = Heats[i];
int e = (int)((i + 1) * b_c) + Channel1stIndex;
if (e >= boltcnt)
e -= boltcnt;
else if (e < 0)
e += boltcnt;
int j = b;
while (j != e)
{
datas[j] = (int)(BeforeDatas[j] - beforeavg * heat / Factor / 100);
j++;
if (j >= boltcnt)
j -= boltcnt;
}
b = e;
}
double afteravg = datas.Average();
for (int j = 0; j < boltcnt; j++)
{
AfterDatas[j] = (int)(beforeavg * datas[j] / afteravg);
}
if (AfterDatasUpdateEvent != null)
{
AfterDatasUpdateEvent(AfterDatas);
}
}
public void Test(int idx, int offset)
{
idx -= p.Count() / 2;
if (idx < 0)
idx += ChannelCnt;
else if (idx >= ChannelCnt)
idx -= ChannelCnt;
for (int i = 0; i < p.Count(); i++)
{
int index = idx + i;
if (index < 0)
index += ChannelCnt;
else if (index >= ChannelCnt)
index -= ChannelCnt;
int heat = Heats[index] + (int)(offset * p[i]);
if (heat > 100)
heat = 100;
else if (heat < 0)
heat = 0;
Heats[index] = heat;
}
HeatApply();
}
}
}
......@@ -43,7 +43,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AutoDie.cs" />
<Compile Include="GageAD.cs" />
<Compile Include="PlcLink.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
......@@ -51,6 +53,10 @@
<Project>{5EE61AC6-5269-4F0F-B8FA-4334FE4A678F}</Project>
<Name>Misc</Name>
</ProjectReference>
<ProjectReference Include="..\..\Project.FLY.ModbusMapper\FLY.ModbusMapper\FLY.ModbusMapper.csproj">
<Project>{6d4b9bda-2a66-4583-b244-758bc4213d9f}</Project>
<Name>FLY.ModbusMapper</Name>
</ProjectReference>
<ProjectReference Include="..\FLY.Simulation\FLY.Simulation.csproj">
<Project>{150F2411-FE62-4042-A968-33E416DC56A1}</Project>
<Name>FLY.Simulation</Name>
......
......@@ -47,11 +47,17 @@ namespace FLY.Simulation.Casting
/// 机架总长 mm
/// </summary>
public int TotalLength { get; set; } = 3000;
PlcLink plcLink;
Random random;
public GageAD()
{
curve = new CurveCollection();
plcLink = new PlcLink();
plcLink.Init();
Load();
random = new Random();
}
public int GetAD(int mm)
......@@ -61,7 +67,8 @@ namespace FLY.Simulation.Casting
else if (mm >= datas_horizontal.Count())
mm = datas_horizontal.Count() - 1;
int ad = datas_horizontal[mm];
ad += (int)(ad * (random.NextDouble() * 0.01 - 0.005));
return ad;
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Net;
using System.IO;
namespace FLY.Simulation.Casting
{
public class PlcLink : INotifyPropertyChanged
{
//D200 4x201 通道数量
//D201 4x202 设置值 更新
//D202 4x203 当前值 更新 //不用
//D400 4x401 设置值 160个
//D600 4x601 当前值 160个 //不用
//M3 0x4 风环开关
//M4 0x5 检测电流
const int ADDR_M_HasElectricity = 3;//检测电流
const int ADDR_M_HasFan = 4;//风环开关
const int ADDR_D_ChannelCnt = 200;
const int ADDR_D_HeatUpdate = 201;
const int ADDR_D_CurrentUpdate = 202;
const UInt16 ADDR_D_Heats = 400;
const UInt16 ADDR_D_Currents = 600;
/// <summary>
/// 加热通道数
/// </summary>
public UInt16 ChannelCnt { get; set; }
/// <summary>
/// 加热量更新
/// </summary>
public UInt16 HeatUpdate { get; set; }
/// <summary>
/// 当前量更新
/// </summary>
public UInt16 CurrentUpdate { get; set; }
/// <summary>
/// 当前电流 有没?
/// </summary>
public bool HasElectricity { get; set; }
/// <summary>
/// 风机是否启动?
/// </summary>
public bool HasFan { get; set; } = true;
UInt16 heatupdate_last = 1;
UInt16[] heats;
bool[] Bads;
AutoDie mAutoDie;
FLY.Modbus.WithThread.ServerTCP mbServer;
public PlcLink()
{
heats = new UInt16[160];
Bads = new bool[160];
Bads[2] = true;
Bads[30] = true;
HeatUpdate = 1;
heatupdate_last = 1;
CurrentUpdate = 1;
}
public void Init()
{
//this.mAutoDie = autoDie;
PlcLinkJsonDb plcLink = new PlcLinkJsonDb();
ChannelCnt = 100;// (UInt16)mAutoDie.ChannelCnt;
mbServer = new Modbus.WithThread.ServerTCP(
Misc.StringConverter.ToIPEndPoint(plcLink.Addr),
GetValue, SetValue);
mbServer.Start();
this.PropertyChanged += PlcLink_PropertyChanged;
}
private void PlcLink_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(ChannelCnt)) {
//mAutoDie.SetChannelCnt(ChannelCnt);
}
}
void GetValue(int addr, object values)
{
if (values is bool[])
GetValue_M(addr, (bool[])values);
else
GetValue_D(addr, (UInt16[])values);
}
void SetValue(int addr, object values)
{
if (values is bool[])
SetValue_M(addr, (bool[])values);
else
SetValue_D(addr, (UInt16[])values);
}
void GetValue_M(int addr, bool[] values)
{
for (int i = 0; i < values.Count(); i++)
{
int single_addr = addr + i;
switch (single_addr)
{
case ADDR_M_HasElectricity:
{
values[i] = HasElectricity;
}
break;
case ADDR_M_HasFan:
{
values[i] = HasFan;
}
break;
}
}
}
void GetValue_D(int addr, UInt16[] values)
{
for (int i = 0; i < values.Count(); i++)
{
int single_addr = addr + i;
if (single_addr == ADDR_D_ChannelCnt)
{
values[i] = ChannelCnt;
}
else if (single_addr == ADDR_D_HeatUpdate)
{
values[i] = HeatUpdate;
}
else if (single_addr == ADDR_D_CurrentUpdate)
{
values[i] = CurrentUpdate;
}
else if (single_addr >= ADDR_D_Heats && single_addr < ADDR_D_Heats + 160)
{
int index = single_addr - ADDR_D_Heats;
values[i] = heats[index];
}
else if (single_addr >= ADDR_D_Currents && single_addr < ADDR_D_Currents + 160)
{
int index = single_addr - ADDR_D_Currents;
values[i] = heats[index];
//if (index < mAutoDie.Heats.Count())
//{
// values[i] = (UInt16)mAutoDie.Heats[index];
//}
}
}
}
void SetValue_M(int addr, bool[] values)
{
}
void SetValue_D(int addr, UInt16[] values)
{
for (int i = 0; i < values.Count(); i++)
{
int single_addr = addr + i;
if (single_addr == ADDR_D_ChannelCnt)
{
ChannelCnt = values[i];
}
else if (single_addr == ADDR_D_HeatUpdate)
{
HeatUpdate = values[i];
if (HeatUpdate != heatupdate_last) {
heatupdate_last = HeatUpdate;
//for (int j = 0; j < ChannelCnt; j++) {
// mAutoDie.Heats[j] = heats[j];
//}
//mAutoDie.HeatApply();
if (heats.Take(ChannelCnt).Any(h => h > 0))
HasElectricity = true;
else
HasElectricity = false;
}
CurrentUpdate++;
}
else if (single_addr == ADDR_D_CurrentUpdate)
{
CurrentUpdate = values[i];
}
else if (single_addr >= ADDR_D_Heats && single_addr < ADDR_D_Heats + 160)
{
int index = single_addr - ADDR_D_Heats;
heats[index] = values[i];
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
public class PlcLinkJsonDb
{
public string Addr = "0.0.0.0:502";
private string filePath = "plclink.json";
public bool Save()
{
try
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(this);
File.WriteAllText(filePath, json);
return true;
}
catch {
return false;
}
}
public bool Load()
{
if (!File.Exists(filePath)) {
return false;
}
try
{
string json = File.ReadAllText(filePath);
Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
return true;
}
catch {
return false;
}
}
}
}
......@@ -48,6 +48,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlyAd2021", "FlyAd2021\FlyA
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlyAd2021_WPF", "FlyAd2021_WPF\FlyAd2021_WPF.csproj", "{CE1BE9F6-8565-429D-B3CB-425B51A337E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FLY.ModbusMapper", "..\Project.FLY.ModbusMapper\FLY.ModbusMapper\FLY.ModbusMapper.csproj", "{6D4B9BDA-2A66-4583-B244-758BC4213D9F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -268,6 +270,18 @@ Global
{CE1BE9F6-8565-429D-B3CB-425B51A337E4}.Release|Mixed Platforms.Build.0 = Release|x86
{CE1BE9F6-8565-429D-B3CB-425B51A337E4}.Release|x86.ActiveCfg = Release|x86
{CE1BE9F6-8565-429D-B3CB-425B51A337E4}.Release|x86.Build.0 = Release|x86
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Debug|x86.ActiveCfg = Debug|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Debug|x86.Build.0 = Debug|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Release|Any CPU.Build.0 = Release|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Release|x86.ActiveCfg = Release|Any CPU
{6D4B9BDA-2A66-4583-B244-758BC4213D9F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -73,6 +73,10 @@ namespace FlyADBase
/// 否则, 设置参数 到 AD盒
/// </summary>
public bool IsReadParamFromDev { get; set; }
/// <summary>
/// 保存的设备参数有效
/// </summary>
public bool IsDevParamValid { get; set; }
/// <summary>
/// 同步列表,完成后,会删除
......@@ -569,7 +573,7 @@ namespace FlyADBase
SENSE_CONFIG.ADD);
if (IsReadParamFromDev)
if (IsReadParamFromDev || !IsDevParamValid)
{
//读取全部参数!!!!!
//OBJ_SYS_DATA
......@@ -585,13 +589,6 @@ namespace FlyADBase
FLYAD7_OBJ_INTERFACE.SYS_DATA_INTERFACE.ID,
ID,
FLYAD7_OBJ_INTERFACE.SYS_DATA_INTERFACE.GET_ZERO_POS);
//DRIVE_MAN
CurrObjSys.GetValueEx(
conn,
FLYAD7_OBJ_INTERFACE.DRIVE_MAN_INTERFACE.ID,
ID,
FLYAD7_OBJ_INTERFACE.DRIVE_MAN_INTERFACE.GET_DRIVEPARAM);
}
else {
//参数不保存在设备中, 保存在电脑。
......@@ -604,6 +601,13 @@ namespace FlyADBase
NotifyPropertyChanged(nameof(JogVelocity));
}
//DRIVE_MAN
CurrObjSys.GetValueEx(
conn,
FLYAD7_OBJ_INTERFACE.DRIVE_MAN_INTERFACE.ID,
ID,
FLYAD7_OBJ_INTERFACE.DRIVE_MAN_INTERFACE.GET_DRIVEPARAM);
CurrObjSys.GetValueEx(
conn,
FLYAD7_OBJ_INTERFACE.SYS_DATA_INTERFACE.ID,
......@@ -823,6 +827,7 @@ namespace FlyADBase
Ratio01 = pack.ratio01;
Ratio02 = pack.ratio02;
IsDevParamValid = true;
}
break;
case FLYAD7_OBJ_INTERFACE.SYS_DATA_INTERFACE.GET_SYSINFO:
......@@ -855,6 +860,7 @@ namespace FlyADBase
PosOffset = pack.zero_pos;
JogVelocity = pack.jog_velocity;
IsDevParamValid = true;
}
break;
}
......@@ -1744,6 +1750,7 @@ namespace FlyADBase
public bool HasPosMaxMin = false;
//备份参数
public bool IsDevParamValid = false;
public MOTORTYPE MotorType = MOTORTYPE.SERVO;
public UInt16 PosOfGrid = 10;
public UInt16 Ratio01 = 4;
......
......@@ -215,7 +215,13 @@ namespace FlyADBase
{
int grid_num = grid_start + i;
if (grid_num >= fGrid.data[index].Length)
{
//剩余全部填入 NULL_VALUE;
for (int j = i; j < dat.Length; j++) {
dat[i] = Misc.MyBase.NULL_VALUE;
}
break;
}
if (GridSmooth > 0)
{
......
......@@ -15,6 +15,11 @@ namespace FLY.Modbus
{
public class PLCDevice
{
/// <summary>
/// PLC 名称 用于报警时,能有提示
/// </summary>
public string PlcName;
[JsonConverter(typeof(IPEndPointJsonConverter))]
public IPEndPoint EP;
}
......
......@@ -16,7 +16,8 @@ namespace FLY.OBJComponents.Server
#region 延时推送 MARKNO
const int MARKNO_DELAY_ISCONNECTED = 4;
#endregion
string plcName;
List<string> plcNames;
/// <summary>
/// 需要设置
/// </summary>
......@@ -30,9 +31,17 @@ namespace FLY.OBJComponents.Server
{
this.PLCos = PLCos;
this.mWarning = mWarning;
this.plcName = plcName;
plcNames = new List<string>();
plcNames.Add(plcName);
}
public ErrorConf(PLCProxySystem PLCos, WarningSystem2 mWarning, string[] plcNames)
{
this.PLCos = PLCos;
this.mWarning = mWarning;
this.plcNames = new List<string>();
if (plcNames.All(s => !string.IsNullOrEmpty(s)))
this.plcNames.AddRange(plcNames);
}
#region 报警
public class ErrorAction
{
......@@ -109,11 +118,7 @@ namespace FLY.OBJComponents.Server
ERRNO errno = PlcErrNos.Instance.ERRNO_PLC_DISCONNECTED;
UInt16 errcode = (UInt16)(errno.Code - i);
string description;
if (PLCos.PLCs.Count() > 1)
description = $"{plcName} No.{i+1} " + errno.Descrption;
else
description = $"{plcName} " + errno.Descrption;
string description = $"{GetPlcName(i)} " + errno.Descrption;
mWarning.Add(errcode, description, state);
}
......@@ -150,7 +155,22 @@ namespace FLY.OBJComponents.Server
// }
// }, TimeSpan.FromSeconds(1));
}
string GetPlcName(int index)
{
if (PLCos.PLCs.Count() == 1)
{
return plcNames[0];
}
//多个PLC
if (PLCos.PLCs.Count() != plcNames.Count())
{
//没有定义全部名字
return $"{plcNames[0]} No.{index + 1}";
}
return plcNames[index];
}
public void ResetError(INotifyPropertyChanged sender)
{
var type = sender.GetType();
......
......@@ -9,7 +9,7 @@
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="GroupBox" />
</ResourceDictionary>
</Application.Resources>
</Application>
......@@ -404,6 +404,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\DynAreaErrorStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\GraphStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
......@@ -95,7 +95,14 @@ namespace FLY.Thick.Base.UI.OnInit
}
}
private void ErrMsg_OnClick() {
//打开管理页面
//当管理页面已经打开,不能再次执行
if (FlyLayoutManager.NavigationService.Content is PgErrorsTable) {
return;
}
var p = container.Resolve<PgErrorsTable>();
FlyLayoutManager.NavigationService.Navigate(p);
}
......
......@@ -62,7 +62,7 @@
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
<DataGrid AlternationCount ="2" AlternatingRowBackground="LightYellow" AutoGenerateColumns="False" Margin="{StaticResource ControlMargin}"
<DataGrid AlternationCount ="2" AlternatingRowBackground="LightGray" AutoGenerateColumns="False" Margin="{StaticResource ControlMargin}"
ItemsSource="{Binding UiLvs}" >
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
......
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="Button" x:Key="DynAreaErrorStyle" BasedOn="{StaticResource Styles.Button.Empty}">
<Setter Property="Command" Value="{Binding OpenWarningCmd}"/>
<Setter Property="Visibility" Value="{Binding IsError,Converter={StaticResource visbilityconv}}"/>
<Setter Property="Content">
<Setter.Value>
<Border Style="{StaticResource Styles.Module.Border}" Background="{StaticResource Brushes.Validation}" >
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Path Margin="{StaticResource ControlMargin}" Fill="White" Stretch="Uniform" Width="60" Height="60" SnapsToDevicePixels="True" Data="{StaticResource Geometry_alert-circle-outline}" >
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding IsError}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever" >
<DoubleAnimation BeginTime="0:0:0" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="00:00:01" />
<DoubleAnimation BeginTime="0:0:1" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="00:00:01" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
<TextBlock Grid.Column="1" Margin="5" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="22" Foreground="White" Text="{Binding ErrMsg}"/>
</Grid>
</Border>
</Setter.Value>
</Setter>
</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/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:,,,/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.MergedDictionaries>
<!--<Style TargetType="GroupBox" />-->
</ResourceDictionary>
\ No newline at end of file
......@@ -46,7 +46,7 @@ namespace FLY.Thick.Base.UI.UiModule
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "边界查找";
public string Title => "测厚.边界查找";
public ComponentType Type => ComponentType.DynArea;
public bool IsUnique => true;
......
......@@ -11,6 +11,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/DynAreaErrorStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="Rectangle" x:Key="IOStyle">
......@@ -26,7 +27,8 @@
</Style>
<local:DynAreaIOVmUt x:Key="ioVm" />
<local:DynAreaErrorVm x:Key="errorVm" IsError="True" ErrMsg="枫莱尔控制器连接断开"/>
<local:DynAreaErrorVm x:Key="errorVm" IsError="True" ErrMsg="枫莱尔控制器连接断开 枫莱尔控制器连接断开"/>
</ResourceDictionary>
</UserControl.Resources>
<Grid Height="100" >
......@@ -113,42 +115,7 @@
</Border>
</Grid>
</Button>
<Button x:Name="grid_error" Style="{StaticResource Styles.Button.Empty}" Command="{Binding OpenWarningCmd}"
Visibility="{Binding IsError,Converter={StaticResource visbilityconv}}"
d:DataContext="{StaticResource errorVm}"
>
<Border Style="{StaticResource Styles.Module.Border}" Background="Red" >
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Path Margin="{StaticResource ControlMargin}" Fill="White" Stretch="Uniform" Width="60" Height="60" SnapsToDevicePixels="True" Data="{StaticResource Geometry_alert-circle-outline}" >
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding IsError}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever" >
<DoubleAnimation BeginTime="0:0:0" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="00:00:01" />
<DoubleAnimation BeginTime="0:0:1" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="00:00:01" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
<Viewbox Grid.Column="1" Margin="{StaticResource ControlMargin}" MaxWidth="190" MaxHeight="80">
<TextBlock VerticalAlignment="Center" MaxWidth="190" TextWrapping="Wrap" FontSize="30" Foreground="White" Text="{Binding ErrMsg}"/>
</Viewbox>
</Grid>
</Border>
</Button>
<Button x:Name="grid_error" Style="{StaticResource DynAreaErrorStyle}" d:DataContext="{StaticResource errorVm}"/>
</Grid>
</UserControl>
......@@ -257,7 +257,125 @@ namespace FLY.Thick.Base.UI.UiModule
}
}
public class DynAreaErrorVm2 : INotifyPropertyChanged
{
/// <summary>
/// 有异常
/// </summary>
public bool IsError { get; set; }
/// <summary>
/// 异常消息
/// </summary>
public string ErrMsg { get; set; }
public RelayCommand OpenWarningCmd { get; }
public event PropertyChangedEventHandler PropertyChanged;
IWarningSystem2Service warningSystem;
IUnityContainer container;
string serverName;
DispatcherTimer timer_error;
private int reason_list_index = -1;
public DynAreaErrorVm2()
{
OpenWarningCmd = new RelayCommand(OpenWarning);
}
public void Init(
IUnityContainer container,
IWarningSystem2Service warningSystem,
string serverName)
{
this.container = container;
this.warningSystem = warningSystem;
this.serverName = serverName;
//报警原因轮流显示
timer_error = new DispatcherTimer();
timer_error.Interval = TimeSpan.FromSeconds(3);
timer_error.Tick += (s, e) =>
{
reason_list_index--;
if (reason_list_index < 0)
if (warningSystem.ReasonList != null && warningSystem.ReasonList.Count() > 0)
reason_list_index = warningSystem.ReasonList.Count();
else
reason_list_index = -1;
UpdateError();
};
warningSystem.PropertyChanged += WarningSystem_PropertyChanged;
UpdateError();
}
private void WarningSystem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Reflect_SeviceClient.IsConnected))
{
UpdateError();
}
else if (e.PropertyName == nameof(warningSystem.ReasonList))
{
if (warningSystem.ReasonList != null && warningSystem.ReasonList.Count() > 0)
reason_list_index = warningSystem.ReasonList.Count() - 1;
else
reason_list_index = -1;
UpdateError();
}
}
void UpdateError()
{
if (this.warningSystem is FObjBase.FObjServiceClient)
{
var client = this.warningSystem as FObjBase.FObjServiceClient;
if (!client.IsConnected)
{
ErrMsg = $"{serverName}服务器连接断开";
IsError = true;
reason_list_index = -1;
timer_error.Stop();
return;
}
}
if (warningSystem.ReasonList != null && warningSystem.ReasonList.Count() > 0)
{
if (reason_list_index >= warningSystem.ReasonList.Count())
reason_list_index = warningSystem.ReasonList.Count() - 1;
else if (reason_list_index < 0)
reason_list_index = 0;
ErrMsg = warningSystem.ReasonList[reason_list_index].Description;
IsError = true;
timer_error.Start();
}
else
{
IsError = false;
ErrMsg = "";
reason_list_index = -1;
timer_error.Stop();
}
}
private void OpenWarning()
{
if (!WdPassword.Authorize("Warning"))
return;
PgErrorTable2 p = new PgErrorTable2();
p.Init(container, warningSystem);
FlyLayoutManager.NavigationService.Navigate(p);
}
}
public class UiModule2_DynAreaIO : IUiModule2
{
public string Title => "测厚.IO状态(报警)";
......
......@@ -58,7 +58,7 @@ namespace FLY.Thick.Base.UI.UiModule
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "样品状态";
public string Title => "测厚.样品状态";
public ComponentType Type => ComponentType.DynArea;
......
......@@ -98,15 +98,6 @@
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Grid.Column="2" Grid.RowSpan="2">
<StackPanel.Resources>
<Style TargetType="{x:Type Path}" x:Key="PathStyle_icon">
<Setter Property="Fill" Value="{StaticResource Color_theme_activity}"/>
<Setter Property="Stretch" Value="Uniform"/>
<Setter Property="Width" Value="40"/>
<Setter Property="Height" Value="40"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
</Style>
</StackPanel.Resources>
<Button Click="button_pause_Click" >
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource Styles.Button.Icon.Rectangle}">
......
<UserControl x:Class="FLY.Thick.Base.UI.Client.UiModule.MenuProfile"
<UserControl x:Class="FLY.Thick.Base.UI.UiModule.MenuProfile"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
......
......@@ -4,7 +4,7 @@ using System.Windows;
using System.Windows.Controls;
using Unity;
namespace FLY.Thick.Base.UI.Client.UiModule
namespace FLY.Thick.Base.UI.UiModule
{
......
<UserControl x:Class="FLY.Thick.Base.UI.Client.UiModule.MenuSetting"
<UserControl x:Class="FLY.Thick.Base.UI.UiModule.MenuSetting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
......
......@@ -17,7 +17,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using Unity;
namespace FLY.Thick.Base.UI.Client.UiModule
namespace FLY.Thick.Base.UI.UiModule
{
......
......@@ -15,9 +15,9 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid TextBlock.FontSize="24" TextBlock.FontStyle="Normal" >
<StackPanel Margin="5,20">
<Grid TextBlock.FontSize="24" TextBlock.FontStyle="Normal" >
<StackPanel Margin="5,20">
<TextBlock x:Name="tbMsg" Margin="5,5,5,30" TextWrapping="Wrap" Text="我是提示信息,平时被隐藏!!!" MaxWidth="450" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
......@@ -30,7 +30,7 @@
<StackPanel Margin="{StaticResource ControlMargin}" Grid.Column="1">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="请输入密码" />
<StackPanel Orientation="Horizontal">
<PasswordBox x:Name="passwordbox" Margin="{StaticResource ControlMargin}"
<PasswordBox x:Name="passwordbox" Margin="{StaticResource ControlMargin}"
Controls:TextBoxHelper.Watermark="请输入密码"
Style="{StaticResource MahApps.Styles.PasswordBox.Win8}" MinWidth="300"/>
<Button Style="{StaticResource Styles.Button.Icon}" Click="ButtonOSK_Click" >
......@@ -40,12 +40,8 @@
</StackPanel>
</Grid>
<Button Style="{StaticResource ButtonStyle2}" Content="确定" Width="Auto" Margin="{StaticResource ControlMargin}" Click="button_apply_Click" />
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</flyctrllib:WindowBigClose>
......@@ -28,11 +28,13 @@ namespace FLY.Thick.Base.UI
{
InitializeComponent();
}
public void Init(PasswordAuthorize passwordAuthorize, int level)
public void Init(PasswordAuthorize passwordAuthorize, int level, string msg=null)
{
this.passwordAuthorize = passwordAuthorize;
this.Level = level;
this.Msg = msg;
}
string Msg = null;
/// <summary>
/// 密码级别
/// </summary>
......@@ -52,13 +54,24 @@ namespace FLY.Thick.Base.UI
return Authorize(uiName, out int pwLv);
}
/// <summary>
///
/// </summary>
/// <param name="uiName"></param>
/// <returns></returns>
public static bool Authorize(string uiName, string msg)
{
return Authorize(uiName, out int pwLv, msg);
}
/// <summary>
///
/// </summary>
/// <param name="uiName">界面</param>
/// <param name="pwLv">当密码正确时,密码的级别</param>
/// <returns></returns>
public static bool Authorize(string uiName, out int pwLv)
public static bool Authorize(string uiName, out int pwLv, string msg=null)
{
pwLv = 0;
//从容器获取
......@@ -72,7 +85,7 @@ namespace FLY.Thick.Base.UI
return true;
WdPassword w = new WdPassword();
w.Init(passwordAuthorize, level);
w.Init(passwordAuthorize, level, msg);
w.Owner = Application.Current.MainWindow;
bool ret = (bool)w.ShowDialog();
pwLv = w.PwLv;
......@@ -160,6 +173,15 @@ namespace FLY.Thick.Base.UI
//从容器获取
//this.DataContext = this;
togglebutton_keep5min.DataContext = mPwKeep;
if (string.IsNullOrEmpty(Msg))
{
tbMsg.Visibility = Visibility.Collapsed;
}
else {
tbMsg.Text = Msg;
}
if (mPwKeep.GetPSK(out string psk))
{
passwordbox.Password = psk;
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FLY.Thick.RemoteHistory;
namespace FLY.Thick.Base.Common
namespace FLY.Thick.Base.Common
{
/// <summary>
/// 报警状态
......
......@@ -331,9 +331,7 @@ namespace SQLite
return;//no datas
DateTime curr_month = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
int curr_total_month = curr_month.Year * 12 + curr_month.Month;
int limit_total_month = curr_total_month - month;
DateTime limit_month = new DateTime( limit_total_month/12, limit_total_month % 12, 1);
DateTime limit_month = curr_month.AddMonths(-month);
DateTime start_month = firstTimes.Min();
start_month = new DateTime(start_month.Year, start_month.Month, 1);
if (start_month < limit_month)
......
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