refactor: 将Framework库和RT、UI放在同一个解决方案中。
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<Window x:Class="MECF.Framework.UI.Client.CenterViews.Dialogs.PresetGroupSaveDialog"
|
||||
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"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:MECF.Framework.UI.Client.CenterViews.Dialogs"
|
||||
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:Height="200" d:Width="400"
|
||||
WindowStyle="None"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ResizeMode="NoResize"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent">
|
||||
<Grid Height="140" Width="330">
|
||||
<Grid.Effect>
|
||||
<DropShadowEffect BlurRadius="40" ShadowDepth="10" Opacity="0.7" />
|
||||
</Grid.Effect>
|
||||
<Border
|
||||
Background="{DynamicResource Tab_BG}"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="3">
|
||||
<Grid Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="70"/>
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border
|
||||
Background="{DynamicResource Table_BG_Content_Highlight}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="1">
|
||||
<Canvas>
|
||||
<TextBlock
|
||||
Canvas.Left="10"
|
||||
Canvas.Top="22"
|
||||
FontFamily="Arial"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource FG_Black}"
|
||||
Text="Group Name" />
|
||||
<controls:TextBoxEx
|
||||
x:Name="txtGroupName"
|
||||
Canvas.Left="100"
|
||||
Canvas.Top="16"
|
||||
Width="200"
|
||||
Height="28"
|
||||
MaxLength="30"
|
||||
AllowBackgroundChange="False" />
|
||||
<TextBlock
|
||||
x:Name="txtErrors"
|
||||
Canvas.Left="100"
|
||||
Canvas.Top="47"
|
||||
Text="" Foreground="Red"/>
|
||||
|
||||
</Canvas>
|
||||
</Border>
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Margin="0 10 0 0"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<Button x:Name="btnOk"
|
||||
Width="90"
|
||||
Height="30"
|
||||
Content="OK"
|
||||
Click="BtnOk_OnClick">
|
||||
</Button>
|
||||
<Button x:Name="btnCancel"
|
||||
Width="90"
|
||||
Height="30"
|
||||
Margin="10,0,0,0"
|
||||
Content="Cancel"
|
||||
Click="BtnCancel_OnClick">
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for PresetGroupSaveDialog.xaml
|
||||
/// </summary>
|
||||
public partial class PresetGroupSaveDialog
|
||||
{
|
||||
|
||||
private readonly IEnumerable<string> _existFileNames;
|
||||
|
||||
public PresetGroupSaveDialog(string title, IEnumerable<string> existFileNames)
|
||||
{
|
||||
InitializeComponent();
|
||||
Title = title;
|
||||
_existFileNames = existFileNames;
|
||||
}
|
||||
|
||||
|
||||
public string GroupName => txtGroupName.Text;
|
||||
|
||||
|
||||
private void BtnOk_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 检查文件明是否为空
|
||||
if (string.IsNullOrEmpty(GroupName))
|
||||
{
|
||||
txtErrors.Text = "Group Name is Empty";
|
||||
txtGroupName.SelectAll();
|
||||
txtGroupName.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查文件名是否包含非法字符
|
||||
if (GroupName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
|
||||
{
|
||||
txtErrors.Text = "illegal char(s) in Group Name";
|
||||
txtGroupName.SelectAll();
|
||||
txtGroupName.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_existFileNames != null && _existFileNames.Contains(GroupName))
|
||||
{
|
||||
txtErrors.Text = "Group Name has existed";
|
||||
txtGroupName.SelectAll();
|
||||
txtGroupName.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
this.DialogResult = true;
|
||||
}
|
||||
|
||||
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.DialogResult = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Dialogs.PurgeDialogView"
|
||||
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"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
|
||||
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
mc:Ignorable="d"
|
||||
Width="450"
|
||||
Height="200">
|
||||
<UserControl.Resources>
|
||||
|
||||
</UserControl.Resources>
|
||||
<Border BorderBrush="Gray" BorderThickness="0,1,0,0" Background="{DynamicResource Tab_BG}">
|
||||
<Grid Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Content_Highlight}">
|
||||
<Canvas>
|
||||
<TextBlock Text="Cycle Purge Count:" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" Canvas.Left="103" Canvas.Top="22"></TextBlock>
|
||||
<controls:TextBoxEx Text="{Binding CycleCount, UpdateSourceTrigger=PropertyChanged}" AllowBackgroundChange="False" Canvas.Left="215" Canvas.Top="16" Width="117" Height="28"></controls:TextBoxEx>
|
||||
|
||||
<TextBlock Text="Cycle Pump Base Pressure (Torr):" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" Canvas.Left="25" Canvas.Top="65"></TextBlock>
|
||||
<controls:TextBoxEx Text="{Binding PumpPressure, UpdateSourceTrigger=PropertyChanged}" AllowBackgroundChange="False" Canvas.Left="215" Canvas.Top="59" Width="117" Height="28"></controls:TextBoxEx>
|
||||
|
||||
<TextBlock Text="Cycle Vent Pressure (Torr):" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" Canvas.Left="63" Canvas.Top="108"></TextBlock>
|
||||
<controls:TextBoxEx Text="{Binding VentPressure, UpdateSourceTrigger=PropertyChanged}" AllowBackgroundChange="False" Canvas.Left="215" Canvas.Top="101" Width="117" Height="28"></controls:TextBoxEx>
|
||||
|
||||
</Canvas>
|
||||
</Border>
|
||||
<StackPanel Grid.Row="1" Margin="0,10,0,0" Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button Content="OK" Width="90" Height="30">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="OK">
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
<Button Content="Cancel" Margin="10,0,0,0" Width="90" Height="30">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="Cancel">
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// PurgeDialogView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class PurgeDialogView : UserControl
|
||||
{
|
||||
public PurgeDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using OpenSEMI.ClientBase;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Dialogs
|
||||
{
|
||||
public class PurgeDialogViewModel : DialogViewModel<string>
|
||||
{
|
||||
public int CycleCountValue { get; set; }
|
||||
public double PumpPressureValue { get; set; }
|
||||
public double VentPressureValue { get; set; }
|
||||
|
||||
public string CycleCount { get; set; }
|
||||
public string PumpPressure { get; set; }
|
||||
public string VentPressure { get; set; }
|
||||
|
||||
public void OK()
|
||||
{
|
||||
if (!int.TryParse(CycleCount, out int cycleCount) || cycleCount<0)
|
||||
{
|
||||
DialogBox.ShowWarning($"{CycleCount} is not a valid cycle count value");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!double.TryParse(PumpPressure, out double pumpPressureValue) || pumpPressureValue < 0)
|
||||
{
|
||||
DialogBox.ShowWarning($"{PumpPressure} is not a valid pump base value");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!double.TryParse(VentPressure, out double ventPressureValue) || ventPressureValue < 0)
|
||||
{
|
||||
DialogBox.ShowWarning($"{VentPressure} is not a valid vent pressure value");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pumpPressureValue >= ventPressureValue)
|
||||
{
|
||||
DialogBox.ShowWarning($"Pump pressure {pumpPressureValue} should be less than {ventPressureValue}");
|
||||
return;
|
||||
}
|
||||
|
||||
CycleCountValue = cycleCount;
|
||||
PumpPressureValue = pumpPressureValue;
|
||||
VentPressureValue = ventPressureValue;
|
||||
|
||||
IsCancel = false;
|
||||
TryClose(true);
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
IsCancel = true;
|
||||
TryClose(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Dialogs.SystemInfoView"
|
||||
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"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:bhv="clr-namespace:MECF.Framework.UI.Core.Behaviors;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:conv="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:cal="clr-namespace:Caliburn.Micro"
|
||||
mc:Ignorable="d"
|
||||
Height="700" Width="600">
|
||||
<UserControl.Resources>
|
||||
<conv:MarkdownToHtmlConverter x:Key="MarkdownToHtmlConverter"/>
|
||||
</UserControl.Resources>
|
||||
<DockPanel Margin="10">
|
||||
<StackPanel DockPanel.Dock="Top" Margin="0 0 0 20">
|
||||
|
||||
<TextBlock Text="SiC CVD System" Foreground="Black" FontSize="30" FontFamily="Segoe UI Semibold" FontWeight="Bold"/>
|
||||
<TextBlock Text="{Binding SicUIVersion}" Foreground="Black" FontSize="12" FontFamily="Segoe UI"/>
|
||||
<TextBlock Text="© 2023 Sicentury Semiconductor Technology (Suzhou) Co., Ltd" Foreground="Black" FontSize="12" FontFamily="Segoe UI"/>
|
||||
<TextBlock Text="All rights reserved." Foreground="Black" FontSize="12" FontFamily="Segoe UI"/>
|
||||
</StackPanel>
|
||||
|
||||
<TabControl>
|
||||
<TabItem Header="Dependencies">
|
||||
<DockPanel>
|
||||
<Button DockPanel.Dock="Bottom" Content="Copy Info" Height="30" cal:Message.Attach="CopyAssembliesInfo()"/>
|
||||
<ListBox
|
||||
Style="{x:Null}"
|
||||
Margin="0 0 0 5" ItemsSource="{Binding DependenciesInfo}"/>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Release Note">
|
||||
<DockPanel>
|
||||
<WebBrowser bhv:BrowserBehavior.Html="{Binding MdReleaseNote}"/>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Dialogs
|
||||
{
|
||||
public partial class SystemInfoView
|
||||
{
|
||||
|
||||
public SystemInfoView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
using MECF.Framework.Common.CommonData;
|
||||
using OpenSEMI.ClientBase;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.UI.Core.Converters;
|
||||
using System.Text;
|
||||
using System;
|
||||
using Aitex.Core.RT.Log;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Documents;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Dialogs
|
||||
{
|
||||
public class SystemInfoViewModel: DialogViewModel<string>
|
||||
{
|
||||
#region Variables
|
||||
|
||||
private const string KEY_ASSE = "System.AssembliesInfo";
|
||||
private const string KEY_RN = "System.ReleaseNote";
|
||||
|
||||
private readonly CancellationTokenSource _cts;
|
||||
private readonly MarkdownToHtmlConverter _mdToHtmlConverter;
|
||||
|
||||
private List<ReferencedAssemblyInfo> _dependencyAssembliesInfo;
|
||||
private string _mdReleaseNote;
|
||||
private Task _taskLoadData;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public SystemInfoViewModel()
|
||||
{
|
||||
_cts = new CancellationTokenSource();
|
||||
_mdToHtmlConverter = new MarkdownToHtmlConverter();
|
||||
|
||||
PollDataAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public string SicUIVersion => $"SicUI Version {Assembly.GetEntryAssembly().GetName().Version}";
|
||||
|
||||
|
||||
public List<ReferencedAssemblyInfo> DependenciesInfo
|
||||
{
|
||||
get => _dependencyAssembliesInfo;
|
||||
private set
|
||||
{
|
||||
_dependencyAssembliesInfo = value;
|
||||
NotifyOfPropertyChange();
|
||||
}
|
||||
}
|
||||
|
||||
public string MdReleaseNote
|
||||
{
|
||||
get => _mdReleaseNote;
|
||||
private set
|
||||
{
|
||||
_mdReleaseNote = value;
|
||||
NotifyOfPropertyChange();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
_cts?.Cancel();
|
||||
_taskLoadData?.Dispose();
|
||||
}
|
||||
|
||||
private void PollData()
|
||||
{
|
||||
var dict = QueryDataClient.Instance.Service.PollData(new[] { KEY_ASSE, KEY_RN });
|
||||
var list = dict[KEY_ASSE] as List<ReferencedAssemblyInfo>;
|
||||
var releaseNote = _mdToHtmlConverter.Convert(dict[KEY_RN], null, null, CultureInfo.CurrentCulture)?.ToString();
|
||||
DependenciesInfo = list;
|
||||
MdReleaseNote = releaseNote;
|
||||
}
|
||||
|
||||
private void PollDataAsync()
|
||||
{
|
||||
// Load信息用于提醒用户正在加载
|
||||
DependenciesInfo = new List<ReferencedAssemblyInfo>(new[]
|
||||
{
|
||||
new ReferencedAssemblyInfo()
|
||||
{
|
||||
Name = "Loading..."
|
||||
}
|
||||
});
|
||||
|
||||
// 异步拉取数据,以便窗口及时弹出
|
||||
List<ReferencedAssemblyInfo> list = null;
|
||||
var releaseNote = "";
|
||||
_taskLoadData = Task.Run(() =>
|
||||
{
|
||||
var dict = QueryDataClient.Instance.Service.PollData(new[] { KEY_ASSE, KEY_RN });
|
||||
list = dict[KEY_ASSE] as List<ReferencedAssemblyInfo>;
|
||||
releaseNote = _mdToHtmlConverter.Convert(dict[KEY_RN], null, null, CultureInfo.CurrentCulture)?.ToString();
|
||||
}, _cts.Token).ContinueWith(t =>
|
||||
{
|
||||
if (t.IsCompleted)
|
||||
{
|
||||
Application.Current?.Dispatcher.Invoke(() =>
|
||||
{
|
||||
DependenciesInfo = list;
|
||||
MdReleaseNote = releaseNote;
|
||||
Debug.WriteLine($"{MdReleaseNote.Substring(0, 100)} =- {releaseNote.Substring(0, 100)}");
|
||||
});
|
||||
}
|
||||
}, _cts.Token);
|
||||
}
|
||||
|
||||
public void CopyAssembliesInfo()
|
||||
{
|
||||
if(DependenciesInfo.Count > 0)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach(var dependency in DependenciesInfo)
|
||||
{
|
||||
sb.AppendLine(dependency.ToString());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(sb.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Error($"Unable to copy assemblis info to clipboard, {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user