@@ -0,0 +1,7 @@ | |||||
<Application | |||||
x:Class="BPASmart.ConfigurationSoftware.App" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:local="clr-namespace:BPASmart.ConfigurationSoftware"> | |||||
<Application.Resources /> | |||||
</Application> |
@@ -0,0 +1,42 @@ | |||||
using BPA.Helper; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Configuration; | |||||
using System.Data; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
using System.Windows; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
/// <summary> | |||||
/// Interaction logic for App.xaml | |||||
/// </summary> | |||||
public partial class App : Application | |||||
{ | |||||
protected override void OnStartup(StartupEventArgs e) | |||||
{ | |||||
base.OnStartup(e); | |||||
if (e.Args != null && e.Args.Length == 1) | |||||
{ | |||||
var res = e.Args[0]; | |||||
Json<ProjectModel>.Read(res); | |||||
var rrr = Json<ProjectModel>.Data.Pages.OrderBy(p => p.Key).ToDictionary(p => p.Key, s => s.Value); | |||||
rrr?.ToList()?.ForEach(item => | |||||
{ | |||||
MessageBox.Show(item.Key); | |||||
}); | |||||
} | |||||
MainWindow window = new MainWindow(); | |||||
window.Show(); | |||||
} | |||||
protected override void OnExit(ExitEventArgs e) | |||||
{ | |||||
base.OnExit(e); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,10 @@ | |||||
using System.Windows; | |||||
[assembly: ThemeInfo( | |||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | |||||
//(used if a resource is not found in the page, | |||||
// or application resource dictionaries) | |||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | |||||
//(used if a resource is not found in the page, | |||||
// app, or any theme specific resource dictionaries) | |||||
)] |
@@ -0,0 +1,39 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>WinExe</OutputType> | |||||
<TargetFramework>net6.0-windows</TargetFramework> | |||||
<Nullable>enable</Nullable> | |||||
<UseWPF>true</UseWPF> | |||||
<UseWindowsForms>true</UseWindowsForms> | |||||
<ApplicationIcon>fyf.ico</ApplicationIcon> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<None Remove="fyf.ico" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<Content Include="fyf.ico"> | |||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | |||||
</Content> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="BPA.Helper" Version="1.0.8" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\BeDesignerSCADA\BeDesignerSCADA.csproj" /> | |||||
<ProjectReference Include="..\BPASmart.DataServer\BPASmart.DataServer.csproj" /> | |||||
<ProjectReference Include="..\BPASmart.Model\BPASmart.Model.csproj" /> | |||||
<ProjectReference Include="..\BPASmart.RecipeManagement\BPASmart.RecipeManagement.csproj" /> | |||||
<ProjectReference Include="..\BPASmart.VariableManager\BPASmart.VariableManager.csproj" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<Folder Include="ViewModel\" /> | |||||
<Folder Include="View\" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -0,0 +1,18 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
public class BasicInformation | |||||
{ | |||||
/// <summary> | |||||
/// 项目上次保存的目录 | |||||
/// </summary> | |||||
public string ProjectDefaultPath { get; set; } = string.Empty; | |||||
} | |||||
} |
@@ -0,0 +1,88 @@ | |||||
using BPA.Helper; | |||||
using Microsoft.Win32; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.IO; | |||||
using System.Linq; | |||||
using System.Runtime.InteropServices; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows.Forms; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
public class FileHelper | |||||
{ | |||||
private volatile static FileHelper _Instance; | |||||
public static FileHelper GetInstance => _Instance ?? (_Instance = new FileHelper()); | |||||
private FileHelper() { } | |||||
public void RegisterOpenFileType() | |||||
{ | |||||
string icoFile = System.Windows.Forms.Application.StartupPath + $"\\fyf.ico"; | |||||
string DirectoryPath = $"{Json<ProjectModel>.Data.ProjectPath}\\Images"; | |||||
Directory.CreateDirectory(DirectoryPath); | |||||
File.Copy(icoFile, $"{DirectoryPath}\\fyf.ico"); | |||||
RegisterFileType(".project", "HBL", ".project", System.Windows.Forms.Application.ExecutablePath, $"{DirectoryPath}\\fyf.ico"); | |||||
} | |||||
private void RegisterFileType(string typeName, string fileType, string fileContent, string app, string ico) | |||||
{ | |||||
string toolPath = app;//工具启动路径 | |||||
string extension = typeName;//fileType = "自定义文件类型"; | |||||
//fileContent = "AAAA"; | |||||
//获取信息 | |||||
RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(extension); | |||||
if (registryKey != null) | |||||
{ | |||||
try | |||||
{ | |||||
RegistryKey _Regkey = Registry.ClassesRoot.OpenSubKey("", true); | |||||
RegistryKey _VRPkey = _Regkey.OpenSubKey(extension); | |||||
if (_VRPkey != null) _Regkey.DeleteSubKeyTree(extension, true); | |||||
if (_VRPkey != null) _Regkey.DeleteSubKeyTree("Exec"); | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
} | |||||
} | |||||
if (registryKey != null && registryKey.OpenSubKey("shell") != null && registryKey.OpenSubKey("shell").OpenSubKey("open") != null && | |||||
registryKey.OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command") != null) | |||||
{ | |||||
var varSub = registryKey.OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command"); | |||||
var varValue = varSub.GetValue(""); | |||||
if (Equals(varValue, toolPath + " \"%1\"")) | |||||
{ | |||||
return; | |||||
} | |||||
} | |||||
//文件注册 | |||||
registryKey = Registry.ClassesRoot.CreateSubKey(extension); | |||||
registryKey.SetValue("", fileType); | |||||
registryKey.SetValue("Content Type", fileContent); | |||||
//设置默认图标 | |||||
RegistryKey iconKey = registryKey.CreateSubKey("DefaultIcon"); | |||||
//iconKey.SetValue("", Application.StartupPath + $"\\{ico}.ico"); | |||||
iconKey.SetValue("", ico); | |||||
iconKey.Close(); | |||||
//设置默认打开程序路径 | |||||
registryKey = registryKey.CreateSubKey("shell\\open\\command"); | |||||
registryKey.SetValue("", toolPath + " \"%1\""); | |||||
//关闭 | |||||
registryKey.Close(); | |||||
SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero); | |||||
} | |||||
[DllImport("shell32.dll")] | |||||
public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2); | |||||
} | |||||
} | |||||
@@ -0,0 +1,32 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
public class Global | |||||
{ | |||||
/// <summary> | |||||
/// 页面文件夹名称 | |||||
/// </summary> | |||||
public const string PageDirectoryName = "Layouts"; | |||||
/// <summary> | |||||
/// 项目路径 | |||||
/// </summary> | |||||
public static string ProjectPath { get; set; } = string.Empty; | |||||
/// <summary> | |||||
/// 项目名称 | |||||
/// </summary> | |||||
public static string ProjectName { get; set; } | |||||
/// <summary> | |||||
/// 变量管理器路径 | |||||
/// </summary> | |||||
public static string VarManagerPath => $"{AppDomain.CurrentDomain.BaseDirectory}BPASmart.VariableManager.exe"; | |||||
} | |||||
} |
@@ -0,0 +1,16 @@ | |||||
using BeDesignerSCADA.Controls; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
public class MainCanvasPageModel | |||||
{ | |||||
public MainCanvasPanel MainCanvasPanelModel { get; set; } | |||||
public string PageName { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,214 @@ | |||||
<Window | |||||
x:Class="BPASmart.ConfigurationSoftware.MainWindow" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmart.ConfigurationSoftware" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
Title="MainWindow" | |||||
WindowState="Maximized" | |||||
Width="800" | |||||
Height="450" | |||||
Topmost="False" | |||||
WindowStartupLocation="CenterScreen" | |||||
mc:Ignorable="d"> | |||||
<Window.DataContext> | |||||
<local:MainWindowViewModel /> | |||||
</Window.DataContext> | |||||
<Window.Resources> | |||||
<!--#region 下拉列表单选按钮样式--> | |||||
<Style x:Key="RadioMiniButtonStyle" TargetType="{x:Type RadioButton}"> | |||||
<Setter Property="Margin" Value="20,1,1,1" /> | |||||
<!--<Setter Property="Width" Value="160" />--> | |||||
<!--<Setter Property="Height" Value="30" />--> | |||||
<Setter Property="FontSize" Value="14" /> | |||||
<Setter Property="FontFamily" Value="粗体" /> | |||||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||||
<Setter Property="HorizontalContentAlignment" Value="left" /> | |||||
<Setter Property="BorderBrush" Value="Transparent" /> | |||||
<Setter Property="BorderThickness" Value="0" /> | |||||
<Setter Property="Background" Value="#ddd" /> | |||||
<Setter Property="HorizontalAlignment" Value="left" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type RadioButton}"> | |||||
<Grid | |||||
x:Name="templateRoot" | |||||
Background="Transparent" | |||||
SnapsToDevicePixels="True"> | |||||
<Border x:Name="border2" /> | |||||
<ContentPresenter | |||||
x:Name="contentPresenter" | |||||
Margin="{TemplateBinding Padding}" | |||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |||||
Content="{TemplateBinding Content}" | |||||
ContentStringFormat="{TemplateBinding ContentStringFormat}" | |||||
ContentTemplate="{TemplateBinding ContentTemplate}" | |||||
Focusable="False" | |||||
RecognizesAccessKey="True" | |||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="HasContent" Value="True"> | |||||
<Setter Property="FocusVisualStyle"> | |||||
<Setter.Value> | |||||
<Style> | |||||
<Setter Property="Control.Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate> | |||||
<Rectangle | |||||
Margin="14,0,0,0" | |||||
SnapsToDevicePixels="True" | |||||
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" | |||||
StrokeDashArray="1 2" | |||||
StrokeThickness="1" /> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
</Setter.Value> | |||||
</Setter> | |||||
<Setter Property="Padding" Value="4,-1,0,0" /> | |||||
</Trigger> | |||||
<Trigger Property="IsChecked" Value="{x:Null}" /> | |||||
<Trigger Property="IsChecked" Value="true"> | |||||
<!--<Setter Property="Foreground" Value="White" />--> | |||||
<Setter TargetName="border2" Property="Background" Value="red" /> | |||||
</Trigger> | |||||
<Trigger Property="IsChecked" Value="false"> | |||||
<Setter TargetName="border2" Property="Background" Value="Transparent" /> | |||||
<!--<Setter Property="Foreground" Value="#4B8EC4" />--> | |||||
</Trigger> | |||||
<MultiTrigger> | |||||
<MultiTrigger.Conditions> | |||||
<Condition Property="IsChecked" Value="false" /> | |||||
<Condition Property="IsMouseOver" Value="True" /> | |||||
</MultiTrigger.Conditions> | |||||
<MultiTrigger.Setters> | |||||
<Setter TargetName="border2" Property="Background" Value="#55007acc" /> | |||||
</MultiTrigger.Setters> | |||||
</MultiTrigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<!--#endregion--> | |||||
</Window.Resources> | |||||
<Grid> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="30" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<StackPanel Orientation="Horizontal"> | |||||
<Button | |||||
Width="60" | |||||
Margin="5" | |||||
Command="{Binding NewProjectCommand}" | |||||
Content="新建" /> | |||||
<Button | |||||
Width="60" | |||||
Margin="5" | |||||
Command="{Binding SaveProjectCommand}" | |||||
Content="保存" /> | |||||
<Button | |||||
Width="60" | |||||
Margin="5" | |||||
Command="{Binding}" | |||||
Content="打开" /> | |||||
<Button | |||||
Width="60" | |||||
Margin="5" | |||||
Content="运行" /> | |||||
<Button | |||||
Width="60" | |||||
Margin="5" | |||||
Command="{Binding OpenVarManagerCommand}" | |||||
Content="变量管理" /> | |||||
</StackPanel> | |||||
<Grid Grid.Row="1"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="150" /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<Grid> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="20" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<TextBlock | |||||
Margin="5,0,0,0" | |||||
HorizontalAlignment="Left" | |||||
VerticalAlignment="Center" | |||||
Text="{Binding Head}"> | |||||
<TextBlock.ContextMenu> | |||||
<ContextMenu> | |||||
<MenuItem Command="{Binding NewPageCommand}" Header="新建页面" /> | |||||
</ContextMenu> | |||||
</TextBlock.ContextMenu> | |||||
</TextBlock> | |||||
<ScrollViewer | |||||
Grid.Row="1" | |||||
HorizontalScrollBarVisibility="Hidden" | |||||
VerticalScrollBarVisibility="Hidden"> | |||||
<ItemsControl ItemsSource="{Binding Pages}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid> | |||||
<RadioButton | |||||
Command="{Binding DataContext.SelectedPageCommand, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}" | |||||
CommandParameter="{Binding}" | |||||
Content="{Binding}" | |||||
GroupName="All" | |||||
Style="{StaticResource RadioMiniButtonStyle}"> | |||||
<RadioButton.ContextMenu> | |||||
<ContextMenu> | |||||
<MenuItem Header="删除页面" /> | |||||
<MenuItem Header="设为启动界面" /> | |||||
<MenuItem Header="重命名" /> | |||||
</ContextMenu> | |||||
</RadioButton.ContextMenu> | |||||
</RadioButton> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
</ScrollViewer> | |||||
</Grid> | |||||
<ContentControl | |||||
Grid.Row="1" | |||||
Grid.Column="1" | |||||
Width="auto" | |||||
Height="auto" | |||||
Content="{Binding MainContent}" /> | |||||
<!--<Canvas Name="cav" Grid.Column="1" Grid.Row="1"> | |||||
</Canvas>--> | |||||
</Grid> | |||||
</Grid> | |||||
</Window> |
@@ -0,0 +1,31 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
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.Navigation; | |||||
using System.Windows.Shapes; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
/// <summary> | |||||
/// Interaction logic for MainWindow.xaml | |||||
/// </summary> | |||||
public partial class MainWindow : Window | |||||
{ | |||||
public MainWindow() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,150 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using BPASmart.Model; | |||||
using Microsoft.Toolkit.Mvvm.Input; | |||||
using System.Collections.ObjectModel; | |||||
using System.Windows.Forms; | |||||
using System.IO; | |||||
using BPA.Helper; | |||||
using System.Diagnostics; | |||||
using BeDesignerSCADA; | |||||
using BeDesignerSCADA.Controls; | |||||
using System.Windows; | |||||
using System.Reflection; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
public class MainWindowViewModel : NoticeBase | |||||
{ | |||||
public MainWindowViewModel() | |||||
{ | |||||
Init(); | |||||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||||
{ | |||||
Pages.Add(o.ToString()); | |||||
string path = $"{ Json<ProjectModel>.Data.ProjectPath}\\{Global.PageDirectoryName}"; | |||||
Directory.CreateDirectory(path); | |||||
File.WriteAllText($"{path}\\{o.ToString()}.lay", null, Encoding.Unicode); | |||||
Json<ProjectModel>.Data.Pages.TryAdd(o.ToString(), $"{path}\\{o.ToString()}.lay"); | |||||
}), "AddPage"); | |||||
NewProjectCommand = new RelayCommand(() => | |||||
{ | |||||
NewProjectView newProjectView = new NewProjectView(); | |||||
bool? result = newProjectView.ShowDialog(); | |||||
if (result != null && result == true) | |||||
{ | |||||
if (newProjectView.Tag != null && newProjectView.Tag is NewDataModel objModel) | |||||
{ | |||||
string path = $"{objModel.ProjectPath}\\{objModel.ProjectName}"; | |||||
Directory.CreateDirectory(path); | |||||
Json<ProjectModel>.Data.ProjectPath = path; | |||||
Json<ProjectModel>.Data.ProjectName = objModel.ProjectName; | |||||
Head = objModel.ProjectName; | |||||
Save(); | |||||
FileHelper.GetInstance.RegisterOpenFileType(); | |||||
} | |||||
} | |||||
}); | |||||
NewPageCommand = new RelayCommand(() => | |||||
{ | |||||
NewPageView newPageView = new NewPageView(); | |||||
newPageView.ShowDialog(); | |||||
}); | |||||
OpenVarManagerCommand = new RelayCommand(() => | |||||
{ | |||||
//if (File.Exists(Global.VarManagerPath)) | |||||
//{ | |||||
// Process[] pro = Process.GetProcesses(); | |||||
// if (pro?.ToList().FirstOrDefault(p => p.ProcessName.Contains("BPASmart.VariableManager")) == null) | |||||
// { | |||||
// Process.Start(Global.VarManagerPath); | |||||
// } | |||||
//} | |||||
VariableManager.App.Start(Json<ProjectModel>.Data.ProjectPath); | |||||
}); | |||||
SelectedPageCommand = new RelayCommand<object>((o) => | |||||
{ | |||||
string path = $"{Json<ProjectModel>.Data.ProjectPath}\\{Global.PageDirectoryName}\\{o.ToString()}.lay"; | |||||
if (mainCanvasPanels.FirstOrDefault(p => p.PageName == o.ToString()) == null) | |||||
{ | |||||
mainCanvasPanels.Add(new MainCanvasPageModel() | |||||
{ | |||||
MainCanvasPanelModel = new MainCanvasPanel(path), | |||||
PageName = o.ToString(), | |||||
}); | |||||
} | |||||
var res = mainCanvasPanels.FirstOrDefault(p => p.PageName == o.ToString()); | |||||
if (res != null) | |||||
{ | |||||
MainContent = res.MainCanvasPanelModel; | |||||
} | |||||
}); | |||||
SaveProjectCommand = new RelayCommand(() => | |||||
{ | |||||
for (int i = 0; i < mainCanvasPanels.Count; i++) | |||||
{ | |||||
mainCanvasPanels.ElementAt(i).MainCanvasPanelModel.FileSave(); | |||||
} | |||||
Save(); | |||||
}); | |||||
} | |||||
private void Init() | |||||
{ | |||||
if (Json<ProjectModel>.Data.ProjectName != null && Json<ProjectModel>.Data.ProjectName.Length > 0) | |||||
{ | |||||
Head = Json<ProjectModel>.Data.ProjectName; | |||||
} | |||||
if (Json<ProjectModel>.Data.Pages?.Count > 0) | |||||
{ | |||||
for (int i = 0; i < Json<ProjectModel>.Data.Pages.Count; i++) | |||||
{ | |||||
Pages.Add(Json<ProjectModel>.Data.Pages.ElementAt(i).Key); | |||||
} | |||||
} | |||||
} | |||||
public void Save() | |||||
{ | |||||
string path = Json<ProjectModel>.Data.ProjectPath; | |||||
string name = Json<ProjectModel>.Data.ProjectName; | |||||
Json<ProjectModel>.Save($"{path}\\{name}.project"); | |||||
} | |||||
public RelayCommand NewProjectCommand { get; set; } | |||||
public RelayCommand OpenVarManagerCommand { get; set; } | |||||
public RelayCommand<object> SelectedPageCommand { get; set; } | |||||
public RelayCommand SaveProjectCommand { get; set; } | |||||
public RelayCommand NewPageCommand { get; set; } | |||||
public string Head { get { return _mHead; } set { _mHead = value; OnPropertyChanged(); } } | |||||
private string _mHead; | |||||
public FrameworkElement MainContent { get { return _mMainContent; } set { _mMainContent = value; OnPropertyChanged(); } } | |||||
private FrameworkElement _mMainContent; | |||||
public List<MainCanvasPageModel> mainCanvasPanels { get; set; } = new List<MainCanvasPageModel>(); | |||||
public ObservableCollection<string> Pages { get; set; } = new ObservableCollection<string>(); | |||||
} | |||||
} |
@@ -0,0 +1,19 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using BPASmart.Model; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
public class NewDataModel : NoticeBase | |||||
{ | |||||
public string ProjectName { get { return _mProjectName; } set { _mProjectName = value; OnPropertyChanged(); } } | |||||
private string _mProjectName; | |||||
public string ProjectPath { get { return _mProjectPath; } set { _mProjectPath = value; OnPropertyChanged(); } } | |||||
private string _mProjectPath; | |||||
} | |||||
} |
@@ -0,0 +1,65 @@ | |||||
<Window | |||||
x:Class="BPASmart.ConfigurationSoftware.NewPageView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmart.ConfigurationSoftware" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
Title="新建页面" | |||||
Width="300" | |||||
Height="180" | |||||
WindowStartupLocation="CenterScreen" | |||||
mc:Ignorable="d"> | |||||
<Grid Margin="10"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<TextBlock | |||||
Margin="0,0,0,5" | |||||
VerticalAlignment="Bottom" | |||||
Text="页面名称:" /> | |||||
<TextBox | |||||
Name="pageName" | |||||
Grid.Row="1" | |||||
Height="30" | |||||
VerticalAlignment="Top" | |||||
FontSize="16" | |||||
Text="{Binding NewData.ProjectName}" /> | |||||
<TextBlock | |||||
Name="ErrorInfo" | |||||
Grid.Row="2" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Foreground="Red" /> | |||||
<Grid Grid.Row="3"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="35*" /> | |||||
<ColumnDefinition Width="32*" /> | |||||
<ColumnDefinition Width="3*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<Button | |||||
Margin="10,2,10,2" | |||||
Click="Button_Click_1" | |||||
Content="创建" /> | |||||
<Button | |||||
Grid.Column="1" | |||||
Grid.ColumnSpan="2" | |||||
Margin="10,2,10,2" | |||||
Click="Button_Click" | |||||
Content="取消" /> | |||||
</Grid> | |||||
</Grid> | |||||
</Window> |
@@ -0,0 +1,56 @@ | |||||
using BPA.Helper; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
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; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
/// <summary> | |||||
/// NewPageView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class NewPageView : Window | |||||
{ | |||||
public NewPageView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
private void Button_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
this.DialogResult = false; | |||||
this.Close(); | |||||
} | |||||
private void Button_Click_1(object sender, RoutedEventArgs e) | |||||
{ | |||||
if (this.pageName.Text.Trim().Length > 0) | |||||
{ | |||||
if (!Json<ProjectModel>.Data.Pages.ContainsKey(this.pageName.Text.Trim())) | |||||
{ | |||||
this.DialogResult = true; | |||||
ActionManage.GetInstance.Send("AddPage", this.pageName.Text); | |||||
this.Close(); | |||||
} | |||||
else | |||||
{ | |||||
ErrorInfo.Text = "该页面已存在"; | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
ErrorInfo.Text = "请输入页面名称"; | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,80 @@ | |||||
<Window | |||||
x:Class="BPASmart.ConfigurationSoftware.NewProjectView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmart.ConfigurationSoftware" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
Title="创建新项目" | |||||
Width="300" | |||||
Height="180" | |||||
WindowStartupLocation="CenterScreen" | |||||
mc:Ignorable="d"> | |||||
<Window.DataContext> | |||||
<local:NewProjectViewModel /> | |||||
</Window.DataContext> | |||||
<Grid Margin="10"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<TextBlock VerticalAlignment="Center" Text="项目名称:" /> | |||||
<TextBox | |||||
Grid.Row="1" | |||||
VerticalAlignment="Center" | |||||
Text="{Binding NewData.ProjectName}" /> | |||||
<TextBlock | |||||
Grid.Row="2" | |||||
VerticalAlignment="Center" | |||||
Text="项目路径:" /> | |||||
<Grid Grid.Row="3"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="30" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock VerticalAlignment="Center" Text="{Binding NewData.ProjectPath}" /> | |||||
<Button | |||||
Grid.Column="1" | |||||
VerticalAlignment="Center" | |||||
Command="{Binding OpenBrowserDialogCommand}" | |||||
Content="..." /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Row="4" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Text="{Binding ErrorInfo}" Foreground="Red"/> | |||||
<Grid Grid.Row="5"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="35*" /> | |||||
<ColumnDefinition Width="32*" /> | |||||
<ColumnDefinition Width="3*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<Button | |||||
Margin="10,2,10,2" | |||||
Command="{Binding CreateCommand}" | |||||
Content="创建" /> | |||||
<Button | |||||
Grid.Column="1" | |||||
Grid.ColumnSpan="2" | |||||
Margin="10,2,10,2" | |||||
Command="{Binding CancelCommand}" | |||||
Content="取消" /> | |||||
</Grid> | |||||
</Grid> | |||||
</Window> |
@@ -0,0 +1,41 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
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 BPA.Helper; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
/// <summary> | |||||
/// NewProjectView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class NewProjectView : Window | |||||
{ | |||||
public NewProjectView() | |||||
{ | |||||
InitializeComponent(); | |||||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||||
{ | |||||
this.DialogResult = true; | |||||
this.Tag = o; | |||||
this.Close(); | |||||
}), "CreateCommand", true); | |||||
ActionManage.GetInstance.Register(new Action(() => | |||||
{ | |||||
this.DialogResult = false; | |||||
this.Close(); | |||||
}), "CancelCommand", true); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,77 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using BPASmart.Model; | |||||
using Microsoft.Toolkit.Mvvm.Input; | |||||
using System.Windows; | |||||
using BPA.Helper; | |||||
using System.Windows.Forms; | |||||
using System.IO; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
public class NewProjectViewModel : NoticeBase | |||||
{ | |||||
public NewProjectViewModel() | |||||
{ | |||||
Json<BasicInformation>.Read(); | |||||
NewData.ProjectPath = Json<BasicInformation>.Data.ProjectDefaultPath; | |||||
OpenBrowserDialogCommand = new RelayCommand(() => | |||||
{ | |||||
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); | |||||
if (folderBrowserDialog.ShowDialog() == DialogResult.OK) | |||||
{ | |||||
NewData.ProjectPath = folderBrowserDialog.SelectedPath; | |||||
Json<BasicInformation>.Data.ProjectDefaultPath = NewData.ProjectPath; | |||||
Json<BasicInformation>.Save(); | |||||
} | |||||
}); | |||||
CreateCommand = new RelayCommand(() => | |||||
{ | |||||
if (NewData.ProjectName == null || NewData.ProjectName?.Length <= 0) | |||||
{ | |||||
ErrorInfo = "项目名不能为空"; | |||||
return; | |||||
} | |||||
if (NewData.ProjectPath == null || NewData.ProjectPath?.Length <= 0) | |||||
{ | |||||
ErrorInfo = "项目路径不合法"; | |||||
return; | |||||
} | |||||
var res = Directory.GetDirectories(NewData.ProjectPath); | |||||
if (res?.ToList()?.FirstOrDefault(p => p.Contains(NewData.ProjectName)) == null) | |||||
{ | |||||
ActionManage.GetInstance.Send("CreateCommand", NewData); | |||||
} | |||||
else | |||||
{ | |||||
ErrorInfo = "该项目已经存在"; | |||||
return; | |||||
} | |||||
}); | |||||
CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("CancelCommand"); }); | |||||
} | |||||
public NewDataModel NewData { get { return _mNewData; } set { _mNewData = value; OnPropertyChanged(); } } | |||||
private NewDataModel _mNewData = new NewDataModel(); | |||||
public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | |||||
private string _mErrorInfo; | |||||
public RelayCommand CreateCommand { get; set; } | |||||
public RelayCommand OpenBrowserDialogCommand { get; set; } | |||||
public RelayCommand CancelCommand { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,40 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.IO; | |||||
using System.Linq; | |||||
using System.Runtime.Serialization.Formatters.Binary; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
public class ProjectDataServer<TClass> where TClass : class, new() | |||||
{ | |||||
public static TClass Data { get; set; } = new TClass(); | |||||
/// <summary> | |||||
/// 保存数据 | |||||
/// </summary> | |||||
public static void Save(string path) | |||||
{ | |||||
FileStream fs = new FileStream(path, FileMode.Create); | |||||
BinaryFormatter bf = new BinaryFormatter();//创建一个二进制格式化器 | |||||
bf?.Serialize(fs, Data); | |||||
fs.Close(); | |||||
} | |||||
/// <summary> | |||||
/// 获取保存的数据 | |||||
/// </summary> | |||||
public static void Read(string path) | |||||
{ | |||||
if (File.Exists(path)) | |||||
{ | |||||
FileStream fs = new FileStream(path, FileMode.Open); | |||||
BinaryFormatter bf = new BinaryFormatter(); | |||||
var res = (TClass)bf.Deserialize(fs); | |||||
fs.Close(); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,35 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Collections.Concurrent; | |||||
using System.Runtime.Serialization; | |||||
namespace BPASmart.ConfigurationSoftware | |||||
{ | |||||
public class ProjectModel | |||||
{ | |||||
/// <summary> | |||||
/// 项目名称 | |||||
/// </summary> | |||||
public string ProjectName { get; set; } | |||||
/// <summary> | |||||
/// 项目路径 | |||||
/// </summary> | |||||
public string ProjectPath { get; set; } | |||||
/// <summary> | |||||
/// 页面集合 | |||||
/// key 是页面名称 | |||||
/// value 是页面路径 | |||||
/// </summary> | |||||
public ConcurrentDictionary<string, string> Pages { get; set; } = new ConcurrentDictionary<string, string>(); | |||||
/// <summary> | |||||
/// 变量表配置路径 | |||||
/// </summary> | |||||
public string VariableTabPath { get; set; } | |||||
} | |||||
} |
@@ -7,6 +7,9 @@ using System.Collections.ObjectModel; | |||||
namespace BPASmart.Model | namespace BPASmart.Model | ||||
{ | { | ||||
/// <summary> | |||||
/// 通讯参数配置 | |||||
/// </summary> | |||||
public class CommunicationPar | public class CommunicationPar | ||||
{ | { | ||||
public ObservableCollection<CommunicationModel> CommunicationDevices { get; set; } = new ObservableCollection<CommunicationModel>(); | public ObservableCollection<CommunicationModel> CommunicationDevices { get; set; } = new ObservableCollection<CommunicationModel>(); |
@@ -0,0 +1,29 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmart.Model | |||||
{ | |||||
/// <summary> | |||||
/// 连接参数 | |||||
/// </summary> | |||||
public class ConnectPar | |||||
{ | |||||
#region Redis 连接信息 | |||||
public string Redis_Host { get; set; } | |||||
public int Redis_Port { get; set; } | |||||
public string Redis_Password { get; set; } | |||||
public int Redis_DB { get; set; } | |||||
#endregion | |||||
#region MQTT 连接信息 | |||||
public string MQTT_IP { get; set; } | |||||
public int MQTT_Port { get; set; } | |||||
public string MQTT_UserName { get; set; } | |||||
public string MQTT_Password { get; set; } | |||||
#endregion | |||||
} | |||||
} |
@@ -11,5 +11,6 @@ namespace BPASmart.Model | |||||
{ | { | ||||
public class NoticeBase : ObservableObject | public class NoticeBase : ObservableObject | ||||
{ | { | ||||
} | } | ||||
} | } |
@@ -0,0 +1,26 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmart.Model | |||||
{ | |||||
public class Topics | |||||
{ | |||||
/// <summary> | |||||
/// 设备控制主题 | |||||
/// </summary> | |||||
public const string DeviceControl = "DistributedHostComputer/Control"; | |||||
/// <summary> | |||||
/// 配方下发主题 | |||||
/// </summary> | |||||
public const string RecipeIssued = "DistributedHostComputer/RecipeIssued"; | |||||
/// <summary> | |||||
/// 业务主题下发 | |||||
/// </summary> | |||||
public const string Business = "DistributedHostComputer/Business"; | |||||
} | |||||
} |
@@ -9,7 +9,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Communication" Version="1.0.13" /> | <PackageReference Include="BPA.Communication" Version="1.0.13" /> | ||||
<PackageReference Include="BPA.Helper" Version="1.0.7" /> | |||||
<PackageReference Include="BPA.Helper" Version="1.0.8" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -19,7 +19,6 @@ namespace BPASmart.Server | |||||
MqttInit(); | MqttInit(); | ||||
Json<CommunicationPar>.Data.CommunicationDevices.ToList()?.ForEach(item => | Json<CommunicationPar>.Data.CommunicationDevices.ToList()?.ForEach(item => | ||||
{ | { | ||||
ThreadManage.GetInstance().Start(new Action(() => | ThreadManage.GetInstance().Start(new Action(() => | ||||
{ | { | ||||
switch (item.CommDevice) | switch (item.CommDevice) | ||||
@@ -35,82 +34,38 @@ namespace BPASmart.Server | |||||
ThreadManage.GetInstance().StartLong(new Action(() => | ThreadManage.GetInstance().StartLong(new Action(() => | ||||
{ | { | ||||
item.VarTableModels.GetReadDataModels().ToList()?.ForEach(temp => | item.VarTableModels.GetReadDataModels().ToList()?.ForEach(temp => | ||||
{ | |||||
//switch (temp.Key) | |||||
//{ | |||||
// case EDataType.Bool: | |||||
// temp.Value?.ForEach(value => | |||||
// { | |||||
// //var res = modbusTcpMaster.ReadBool(value.StartAddress.ToString(), value.Length); | |||||
// var res = modbusTcpMaster.Read<bool[]>(value.StartAddress.ToString(), value.Length); | |||||
// SetValue(res.Content, item.DeviceName, value, 1); | |||||
// }); | |||||
// break; | |||||
// case EDataType.Byte: | |||||
// break; | |||||
// case EDataType.Int: | |||||
// break; | |||||
// case EDataType.Word: | |||||
// temp.Value?.ForEach(value => | |||||
// { | |||||
// //var res = modbusTcpMaster.ReadUshort(value.StartAddress.ToString(), value.Length); | |||||
// var res = modbusTcpMaster.Read<ushort[]>(value.StartAddress.ToString(), value.Length); | |||||
// SetValue(res.Content, item.DeviceName, value, 1); | |||||
// }); | |||||
// break; | |||||
// case EDataType.Dint: | |||||
// break; | |||||
// case EDataType.Dword: | |||||
// temp.Value?.ForEach(value => | |||||
// { | |||||
// //var res = modbusTcpMaster.ReadUint(value.StartAddress.ToString(), value.Length); | |||||
// var res = modbusTcpMaster.Read<uint[]>(value.StartAddress.ToString(), value.Length); | |||||
// SetValue(res.Content, item.DeviceName, value, 2); | |||||
// }); | |||||
// break; | |||||
// case EDataType.Float: | |||||
// temp.Value?.ForEach(value => | |||||
// { | |||||
// //var res = modbusTcpMaster.ReadFloat(value.StartAddress.ToString(), value.Length); | |||||
// var res = modbusTcpMaster.Read<float[]>(value.StartAddress.ToString(), value.Length); | |||||
// SetValue(res.Content, item.DeviceName, value, 2); | |||||
// }); | |||||
// break; | |||||
// default: | |||||
// break; | |||||
//} | |||||
Array ResultArray = null; | |||||
temp.Value?.ForEach(value => | |||||
{ | |||||
switch (temp.Key) | |||||
{ | |||||
case EDataType.Bool: | |||||
ResultArray = modbusTcpMaster.Read<bool[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
case EDataType.Byte: | |||||
break; | |||||
case EDataType.Int: | |||||
ResultArray = modbusTcpMaster.Read<short[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
case EDataType.Word: | |||||
ResultArray = modbusTcpMaster.Read<ushort[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
case EDataType.Dint: | |||||
ResultArray = modbusTcpMaster.Read<int[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
case EDataType.Dword: | |||||
ResultArray = modbusTcpMaster.Read<uint[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
case EDataType.Float: | |||||
ResultArray = modbusTcpMaster.Read<float[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
SetValue(ResultArray, item.DeviceName, value, temp.Key); | |||||
}); | |||||
}); | |||||
{ | |||||
Array ResultArray = null; | |||||
temp.Value?.ForEach(value => | |||||
{ | |||||
switch (temp.Key) | |||||
{ | |||||
case EDataType.Bool: | |||||
ResultArray = modbusTcpMaster.Read<bool[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
case EDataType.Byte: | |||||
break; | |||||
case EDataType.Int: | |||||
ResultArray = modbusTcpMaster.Read<short[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
case EDataType.Word: | |||||
ResultArray = modbusTcpMaster.Read<ushort[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
case EDataType.Dint: | |||||
ResultArray = modbusTcpMaster.Read<int[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
case EDataType.Dword: | |||||
ResultArray = modbusTcpMaster.Read<uint[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
case EDataType.Float: | |||||
ResultArray = modbusTcpMaster.Read<float[]>(value.StartAddress.ToString(), value.Length)?.Content; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
SetValue(ResultArray, item.DeviceName, value, temp.Key); | |||||
}); | |||||
}); | |||||
Thread.Sleep(100); | Thread.Sleep(100); | ||||
}), $"{item.DeviceName} 设备数据采集"); | }), $"{item.DeviceName} 设备数据采集"); | ||||
@@ -135,7 +90,7 @@ namespace BPASmart.Server | |||||
mqttHelper.Connect("admin", "fengyoufu067101!@#", "124.222.238.75", 61613, $"分布式上位机:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); | mqttHelper.Connect("admin", "fengyoufu067101!@#", "124.222.238.75", 61613, $"分布式上位机:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); | ||||
mqttHelper.ConnectOk = new Action(() => | mqttHelper.ConnectOk = new Action(() => | ||||
{ | { | ||||
mqttHelper.Subscrib("DistributedHostComputer/Control"); | |||||
mqttHelper.Subscrib(Topics.DeviceControl); | |||||
ThreadManage.GetInstance().StartLong(new Action(() => | ThreadManage.GetInstance().StartLong(new Action(() => | ||||
{ | { | ||||
while (msg.Count > 0) | while (msg.Count > 0) | ||||
@@ -175,31 +130,24 @@ namespace BPASmart.Server | |||||
switch (item.DataType) | switch (item.DataType) | ||||
{ | { | ||||
case EDataType.Bool: | case EDataType.Bool: | ||||
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToBoolean(item.Value)); | |||||
CommunicationDevices[item.DeviceName].Write(address, Convert.ToBoolean(item.Value)); | CommunicationDevices[item.DeviceName].Write(address, Convert.ToBoolean(item.Value)); | ||||
break; | break; | ||||
case EDataType.Byte: | case EDataType.Byte: | ||||
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToByte(item.Value)); | |||||
CommunicationDevices[item.DeviceName].Write(address, Convert.ToByte(item.Value)); | CommunicationDevices[item.DeviceName].Write(address, Convert.ToByte(item.Value)); | ||||
break; | break; | ||||
case EDataType.Int: | case EDataType.Int: | ||||
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToInt16(item.Value)); | |||||
CommunicationDevices[item.DeviceName].Write(address, Convert.ToInt16(item.Value)); | CommunicationDevices[item.DeviceName].Write(address, Convert.ToInt16(item.Value)); | ||||
break; | break; | ||||
case EDataType.Word: | case EDataType.Word: | ||||
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToUInt16(item.Value)); | |||||
CommunicationDevices[item.DeviceName].Write(address, Convert.ToUInt16(item.Value)); | CommunicationDevices[item.DeviceName].Write(address, Convert.ToUInt16(item.Value)); | ||||
break; | break; | ||||
case EDataType.Dint: | case EDataType.Dint: | ||||
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToInt32(item.Value)); | |||||
CommunicationDevices[item.DeviceName].Write(address, Convert.ToInt32(item.Value)); | CommunicationDevices[item.DeviceName].Write(address, Convert.ToInt32(item.Value)); | ||||
break; | break; | ||||
case EDataType.Dword: | case EDataType.Dword: | ||||
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToUInt32(item.Value)); | |||||
CommunicationDevices[item.DeviceName].Write(address, Convert.ToUInt32(item.Value)); | CommunicationDevices[item.DeviceName].Write(address, Convert.ToUInt32(item.Value)); | ||||
break; | break; | ||||
case EDataType.Float: | case EDataType.Float: | ||||
//CommunicationDevices[item.DeviceName].Write(address, Convert.ToSingle(item.Value)); | |||||
CommunicationDevices[item.DeviceName].Write(address, Convert.ToSingle(item.Value)); | CommunicationDevices[item.DeviceName].Write(address, Convert.ToSingle(item.Value)); | ||||
break; | break; | ||||
default: | default: | ||||
@@ -213,64 +161,6 @@ namespace BPASmart.Server | |||||
} | } | ||||
} | } | ||||
//private void SetValue<TArray>(TArray[] arrays, string DeviceName, ReadDataModel readDataModel, ushort by) | |||||
//{ | |||||
// if (arrays != null) | |||||
// { | |||||
// int index = Array.FindIndex(Json<CommunicationPar>.Data.CommunicationDevices.ToArray(), p => p.DeviceName == DeviceName);//获取设备所在集合位置 | |||||
// if (index >= 0 && index < Json<CommunicationPar>.Data.CommunicationDevices.Count) | |||||
// { | |||||
// var tempArray = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(index).VarTableModels.ToArray(); | |||||
// for (int i = 0; i < arrays.Length; i++) | |||||
// { | |||||
// int varIndex = Array.FindIndex(tempArray, p => p.RealAddress == (readDataModel.StartAddress + (i * by)).ToString()); | |||||
// if (varIndex >= 0 && varIndex < tempArray.Length) | |||||
// { | |||||
// Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(index).VarTableModels.ElementAt(varIndex).CurrentValue = arrays[i].ToString(); | |||||
// } | |||||
// } | |||||
// var Devicename = Json<CommunicationPar>.Data.CommunicationDevices[index].DeviceName; | |||||
// List<ReeisDataModel> reeisDataModels = new List<ReeisDataModel>(); | |||||
// Json<CommunicationPar>.Data.CommunicationDevices[index].VarTableModels.ToList().ForEach(tempVar => | |||||
// { | |||||
// if (tempVar.VarName.Length > 0) | |||||
// { | |||||
// reeisDataModels.Add(new ReeisDataModel() | |||||
// { | |||||
// VarName = tempVar.VarName, | |||||
// VarVaule = tempVar.CurrentValue, | |||||
// DataType = (EDataType)Enum.Parse(typeof(EDataType), tempVar.DataType) | |||||
// }); | |||||
// } | |||||
// }); | |||||
// RedisHelper.GetInstance.SetValue($"{Devicename}", reeisDataModels); | |||||
// } | |||||
// } | |||||
//} | |||||
//private ushort GetBySize(EDataType eDataType) | |||||
//{ | |||||
// switch (eDataType) | |||||
// { | |||||
// case EDataType.Bool: | |||||
// case EDataType.Byte: | |||||
// case EDataType.Int: | |||||
// case EDataType.Word: | |||||
// return 1; | |||||
// case EDataType.Dint: | |||||
// case EDataType.Dword: | |||||
// case EDataType.Float: | |||||
// return 2; | |||||
// case EDataType.Double: | |||||
// break; | |||||
// case EDataType.String: | |||||
// break; | |||||
// default: | |||||
// break; | |||||
// } | |||||
// return 1; | |||||
//} | |||||
private void SetValue(Array arrays, string DeviceName, ReadDataModel readDataModel, EDataType eDataType) | private void SetValue(Array arrays, string DeviceName, ReadDataModel readDataModel, EDataType eDataType) | ||||
{ | { | ||||
if (arrays != null) | if (arrays != null) | ||||
@@ -307,72 +197,5 @@ namespace BPASmart.Server | |||||
} | } | ||||
} | } | ||||
//private Dictionary<EDataType, List<ReadDataModel>> GetReadDataModels(CommunicationModel communicationModel) | |||||
//{ | |||||
// Dictionary<EDataType, List<ReadDataModel>> readDataModels = new Dictionary<EDataType, List<ReadDataModel>>(); | |||||
// communicationModel.VarTableModels.GroupBy(p => p.DataType)?.ToList()?.ForEach(tempVar => | |||||
// { | |||||
// if (tempVar.Key != null && tempVar.Key.Length > 0) | |||||
// { | |||||
// //int address = tempVar.Min(p => p.RealAddress); | |||||
// EDataType dataType = (EDataType)Enum.Parse(typeof(EDataType), tempVar.Key); | |||||
// switch (dataType) | |||||
// { | |||||
// case EDataType.Bool: | |||||
// case EDataType.Byte: | |||||
// case EDataType.Int: | |||||
// case EDataType.Word: | |||||
// if (!readDataModels.ContainsKey(dataType)) readDataModels.TryAdd(dataType, GetDataGroup(tempVar)); | |||||
// break; | |||||
// case EDataType.Dint: | |||||
// case EDataType.Dword: | |||||
// case EDataType.Float: | |||||
// if (!readDataModels.ContainsKey(dataType)) readDataModels.TryAdd(dataType, GetDataGroup(tempVar, 2)); | |||||
// break; | |||||
// default: | |||||
// break; | |||||
// } | |||||
// } | |||||
// }); | |||||
// return readDataModels; | |||||
//} | |||||
//private List<ReadDataModel> GetDataGroup(IGrouping<string, VariableInfo> variableInfos, int by = 1) | |||||
//{ | |||||
// List<ReadDataModel> ReturnValue = new List<ReadDataModel>(); | |||||
// var res = variableInfos?.OrderBy(p => p.RealAddress).ToList(); | |||||
// List<int> RealAddresss = new List<int>(); | |||||
// variableInfos.ToList()?.ForEach(item => { if (int.TryParse(item.RealAddress, out int add)) RealAddresss.Add(add); }); | |||||
// int count = 0; | |||||
// if (res != null) | |||||
// { | |||||
// //int address = variableInfos.Min(p => p.RealAddress); | |||||
// int address = RealAddresss.Min(); | |||||
// int startAddress = address; | |||||
// for (int i = 0; i < res.Count; i++) | |||||
// { | |||||
// if (int.TryParse(res.ElementAt(i).RealAddress, out int TempAddress)) | |||||
// { | |||||
// if (TempAddress == address) | |||||
// { | |||||
// count++; | |||||
// address += by; | |||||
// } | |||||
// else | |||||
// { | |||||
// ReturnValue.Add(new ReadDataModel() { StartAddress = (ushort)startAddress, Length = (ushort)count }); | |||||
// count = 1; | |||||
// address = TempAddress + by; | |||||
// startAddress = TempAddress; | |||||
// } | |||||
// } | |||||
// } | |||||
// ReturnValue.Add(new ReadDataModel() { StartAddress = (ushort)startAddress, Length = (ushort)count }); | |||||
// } | |||||
// return ReturnValue; | |||||
//} | |||||
} | } | ||||
} | } |
@@ -0,0 +1,9 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>net6.0</TargetFramework> | |||||
<ImplicitUsings>enable</ImplicitUsings> | |||||
<Nullable>enable</Nullable> | |||||
</PropertyGroup> | |||||
</Project> |
@@ -0,0 +1,44 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Collections.Concurrent; | |||||
namespace BPASmart.SmallBatchingSystem | |||||
{ | |||||
public class DataModel | |||||
{ | |||||
public ConcurrentDictionary<string, string> OutletInformation { get; set; } = new ConcurrentDictionary<string, string>(); | |||||
} | |||||
/// <summary> | |||||
/// 料仓信息 | |||||
/// </summary> | |||||
public class SiloInformation | |||||
{ | |||||
/// <summary> | |||||
/// 料仓位置 | |||||
/// </summary> | |||||
public string SiloLoc { get; set; } = string.Empty; | |||||
/// <summary> | |||||
/// 料仓名称 | |||||
/// </summary> | |||||
public string SiloName { get; set; } = string.Empty; | |||||
} | |||||
/// <summary> | |||||
/// 出料口信息 | |||||
/// </summary> | |||||
public class FeedMouth | |||||
{ | |||||
public string FeedMouthLoc { get; set; } = string.Empty; | |||||
public string FeedMouthName { get; set; } = string.Empty; | |||||
public List<SiloInformation> SiloInformations { get; set; } = new List<SiloInformation>(); | |||||
} | |||||
} |
@@ -0,0 +1,14 @@ | |||||
namespace BPASmart.SmallBatchingSystem | |||||
{ | |||||
public class Main | |||||
{ | |||||
private volatile static Main _Instance; | |||||
public static Main GetInstance => _Instance ?? (_Instance = new Main()); | |||||
private Main() { } | |||||
public void Start() | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -1,7 +1,6 @@ | |||||
using BPASmartClient.CustomResource.Pages.Enums; | using BPASmartClient.CustomResource.Pages.Enums; | ||||
using BPASmartClient.CustomResource.Pages.Model; | using BPASmartClient.CustomResource.Pages.Model; | ||||
using BPASmartClient.CustomResource.Pages.View; | using BPASmartClient.CustomResource.Pages.View; | ||||
using BPASmartClient.Helper; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
@@ -11,6 +10,8 @@ using System.Linq; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Windows; | using System.Windows; | ||||
using BPASmart.Model; | using BPASmart.Model; | ||||
using BPA.Helper; | |||||
using System.IO; | |||||
namespace BPASmart.VariableManager | namespace BPASmart.VariableManager | ||||
{ | { | ||||
@@ -19,6 +20,7 @@ namespace BPASmart.VariableManager | |||||
/// </summary> | /// </summary> | ||||
public partial class App : Application | public partial class App : Application | ||||
{ | { | ||||
public static string ConstPath = string.Empty; | |||||
public static Window MainWindow; | public static Window MainWindow; | ||||
protected override void OnStartup(StartupEventArgs e) | protected override void OnStartup(StartupEventArgs e) | ||||
{ | { | ||||
@@ -33,7 +35,19 @@ namespace BPASmart.VariableManager | |||||
} | } | ||||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) | |||||
public static void Start(string path) | |||||
{ | |||||
ConstPath = path; | |||||
DataRead(); | |||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | |||||
MenuInit(); | |||||
MainView mv = new MainView(); | |||||
mv.WindowState = WindowState.Normal; | |||||
MainWindow = mv; | |||||
mv.Show(); | |||||
} | |||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) | |||||
{ | { | ||||
DataSave(); | DataSave(); | ||||
} | } | ||||
@@ -44,7 +58,7 @@ namespace BPASmart.VariableManager | |||||
DataSave(); | DataSave(); | ||||
} | } | ||||
private void MenuInit() | |||||
private static void MenuInit() | |||||
{ | { | ||||
#region 设备管理 | #region 设备管理 | ||||
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>(); | ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>(); | ||||
@@ -99,7 +113,7 @@ namespace BPASmart.VariableManager | |||||
} | } | ||||
private SubMenumodel AddSubMenuModel(string s) | |||||
private static SubMenumodel AddSubMenuModel(string s) | |||||
{ | { | ||||
return new SubMenumodel() | return new SubMenumodel() | ||||
{ | { | ||||
@@ -110,26 +124,24 @@ namespace BPASmart.VariableManager | |||||
}; | }; | ||||
} | } | ||||
private void DataSave() | |||||
static string path | |||||
{ | { | ||||
//for (int i = 0; i < Json<CommunicationPar>.Data.CommunicationDevices.Count; i++) | |||||
//{ | |||||
// for (int m = 0; m < Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(i).VarTableModels.Count; m++) | |||||
// { | |||||
// var deviceType = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(i).CommDevice; | |||||
// var deviceValue = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(i).VarTableModels.ElementAt(m).Address; | |||||
// string RealAddress = AddressConvert.GetInstance.PlcConverter(deviceType, deviceValue); | |||||
// Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(i).VarTableModels.ElementAt(m).RealAddress = RealAddress; | |||||
// } | |||||
//} | |||||
Json<CommunicationPar>.Save(); | |||||
get | |||||
{ | |||||
string path = $"{ConstPath}\\AccessFile\\JSON"; | |||||
Directory.CreateDirectory(path); | |||||
return $"{ConstPath}\\AccessFile\\JSON\\CommunicationPar.json"; | |||||
} | |||||
} | } | ||||
private static void DataSave() | |||||
{ | |||||
Json<CommunicationPar>.Save(path); | |||||
} | |||||
private void DataRead() | |||||
private static void DataRead() | |||||
{ | { | ||||
Json<CommunicationPar>.Read(); | |||||
Json<CommunicationPar>.Read(path); | |||||
} | } | ||||
} | } | ||||
@@ -30,6 +30,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Communication" Version="1.0.13" /> | <PackageReference Include="BPA.Communication" Version="1.0.13" /> | ||||
<PackageReference Include="BPA.Helper" Version="1.0.8" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -2,11 +2,11 @@ | |||||
x:Class="BPASmartClient.CustomResource.Pages.View.NfcSetView" | x:Class="BPASmartClient.CustomResource.Pages.View.NfcSetView" | ||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:common="clr-namespace:BPASmartClient.CustomResource.Pages.Model" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View" | xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View" | ||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel" | xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel" | ||||
xmlns:common="clr-namespace:BPASmartClient.CustomResource.Pages.Model" | |||||
Title="NfcSetView" | Title="NfcSetView" | ||||
Width="500" | Width="500" | ||||
Height="250" | Height="250" | ||||
@@ -139,8 +139,8 @@ | |||||
<Setter Property="Background" Value="Transparent" /> | <Setter Property="Background" Value="Transparent" /> | ||||
<Setter Property="BorderBrush" Value="#009DFF" /> | <Setter Property="BorderBrush" Value="#009DFF" /> | ||||
<Setter Property="BorderThickness" Value="0,0,0,1" /> | <Setter Property="BorderThickness" Value="0,0,0,1" /> | ||||
</Style> | </Style> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
@@ -148,9 +148,9 @@ | |||||
<Style x:Key="UserTextBoxStyle" TargetType="TextBox"> | <Style x:Key="UserTextBoxStyle" TargetType="TextBox"> | ||||
<Setter Property="Background" Value="Transparent" /> | <Setter Property="Background" Value="Transparent" /> | ||||
<Setter Property="CaretBrush" Value="#009DFF" /> | <Setter Property="CaretBrush" Value="#009DFF" /> | ||||
<Setter Property="BorderBrush" Value="#009DFF"/> | |||||
<Setter Property="BorderThickness" Value="0,0,0,1"/> | |||||
<Setter Property="Foreground" Value="White"/> | |||||
<Setter Property="BorderBrush" Value="#009DFF" /> | |||||
<Setter Property="BorderThickness" Value="0,0,0,1" /> | |||||
<Setter Property="Foreground" Value="White" /> | |||||
<Setter Property="FontSize" Value="14" /> | <Setter Property="FontSize" Value="14" /> | ||||
</Style> | </Style> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
@@ -170,9 +170,9 @@ | |||||
<Grid Background="Transparent"> | <Grid Background="Transparent"> | ||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> | <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> | ||||
<TextBlock | <TextBlock | ||||
Margin="0,0,0,10" | |||||
FontSize="16" | FontSize="16" | ||||
Foreground="#32B8FF" | Foreground="#32B8FF" | ||||
Margin="0,0,0,10" | |||||
Text="用户权限列表:" /> | Text="用户权限列表:" /> | ||||
<ItemsControl ItemsSource="{Binding permissions}"> | <ItemsControl ItemsSource="{Binding permissions}"> | ||||
@@ -222,50 +222,66 @@ | |||||
<RowDefinition /> | <RowDefinition /> | ||||
</Grid.RowDefinitions> | </Grid.RowDefinitions> | ||||
<Grid.ColumnDefinitions> | <Grid.ColumnDefinitions> | ||||
<ColumnDefinition Width="92*"/> | |||||
<ColumnDefinition Width="135*"/> | |||||
<ColumnDefinition Width="67*"/> | |||||
<ColumnDefinition Width="92*" /> | |||||
<ColumnDefinition Width="135*" /> | |||||
<ColumnDefinition Width="67*" /> | |||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<TextBlock | <TextBlock | ||||
HorizontalAlignment="Center" | |||||
FontSize="16" | |||||
VerticalAlignment="Center" | |||||
Foreground="#FF32B8FF" | |||||
Text="当前卡号:" Height="21" Width="80" /> | |||||
<TextBlock Grid.Row="1" | |||||
HorizontalAlignment="Center" | |||||
FontSize="16" | |||||
VerticalAlignment="Center" | |||||
Foreground="#FF32B8FF" | |||||
Text="用户名:" Height="20" Width="64" /> | |||||
<TextBlock Grid.Row="2" | |||||
HorizontalAlignment="Center" | |||||
FontSize="16" | |||||
VerticalAlignment="Center" | |||||
Foreground="#FF32B8FF" | |||||
Text="当前密码:" Height="20" Width="80" /> | |||||
<TextBlock Grid.Row="3" | |||||
HorizontalAlignment="Center" | |||||
FontSize="16" | |||||
VerticalAlignment="Center" | |||||
Foreground="#FF32B8FF" | |||||
Text="确认密码:" Height="20" Width="80" /> | |||||
<TextBlock Grid.Column="1" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="#FF32B8FF" | |||||
Text="{Binding CardNum}" /> | |||||
<TextBox Grid.Row="1" Grid.Column="1" | |||||
Margin="11,4,10,4" | |||||
Text="{Binding UserName}" | |||||
Style="{DynamicResource UserTextBoxStyle}"/> | |||||
<PasswordBox Grid.Column="1" Grid.Row="2" | |||||
Width="80" | |||||
Height="21" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="#FF32B8FF" | |||||
Text="当前卡号:" /> | |||||
<TextBlock | |||||
Grid.Row="1" | |||||
Width="64" | |||||
Height="20" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="#FF32B8FF" | |||||
Text="用户名:" /> | |||||
<TextBlock | |||||
Grid.Row="2" | |||||
Width="80" | |||||
Height="20" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="#FF32B8FF" | |||||
Text="当前密码:" /> | |||||
<TextBlock | |||||
Grid.Row="3" | |||||
Width="80" | |||||
Height="20" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="#FF32B8FF" | |||||
Text="确认密码:" /> | |||||
<TextBlock | |||||
Grid.Column="1" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="#FF32B8FF" | |||||
Text="{Binding CardNum}" /> | |||||
<TextBox | |||||
Grid.Row="1" | |||||
Grid.Column="1" | |||||
Margin="11,4,10,4" | |||||
Style="{DynamicResource UserTextBoxStyle}" | |||||
Text="{Binding UserName}" /> | |||||
<PasswordBox | |||||
Name="newpb1" | Name="newpb1" | ||||
Grid.Row="2" | |||||
Grid.Column="1" | |||||
Margin="11,4,10,4" | Margin="11,4,10,4" | ||||
common:PasswordHelper.Attach="True" | common:PasswordHelper.Attach="True" | ||||
common:PasswordHelper.Password="{Binding CurrentPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | common:PasswordHelper.Password="{Binding CurrentPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | ||||
@@ -274,8 +290,10 @@ | |||||
Foreground="#aadddddd" | Foreground="#aadddddd" | ||||
Style="{DynamicResource PasswordBoxStyle}" | Style="{DynamicResource PasswordBoxStyle}" | ||||
TabIndex="2" /> | TabIndex="2" /> | ||||
<PasswordBox Grid.Column="1" Grid.Row="3" | |||||
<PasswordBox | |||||
Name="newpb2" | Name="newpb2" | ||||
Grid.Row="3" | |||||
Grid.Column="1" | |||||
Margin="11,4,10,4" | Margin="11,4,10,4" | ||||
common:PasswordHelper.Attach="True" | common:PasswordHelper.Attach="True" | ||||
common:PasswordHelper.Password="{Binding CheckPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | common:PasswordHelper.Password="{Binding CheckPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | ||||
@@ -284,23 +302,30 @@ | |||||
Foreground="#aadddddd" | Foreground="#aadddddd" | ||||
Style="{DynamicResource PasswordBoxStyle}" | Style="{DynamicResource PasswordBoxStyle}" | ||||
TabIndex="2" /> | TabIndex="2" /> | ||||
<TextBlock Grid.Row="2" Grid.Column="2" | |||||
HorizontalAlignment="Center" | |||||
FontSize="10" | |||||
VerticalAlignment="Center" | |||||
Foreground="#FF32B8FF" | |||||
Text="(默认888888)" Height="12" Width="62" /> | |||||
<TextBlock Grid.Row="4" Grid.ColumnSpan="3" Grid.Column="0" | |||||
<TextBlock | |||||
Grid.Row="2" | |||||
Grid.Column="2" | |||||
Width="62" | |||||
Height="12" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
FontSize="10" | |||||
Foreground="#FF32B8FF" | |||||
Text="(默认888888)" /> | |||||
<TextBlock | |||||
Grid.Row="4" | |||||
Grid.Column="0" | |||||
Grid.ColumnSpan="3" | |||||
HorizontalAlignment="Center" | HorizontalAlignment="Center" | ||||
VerticalAlignment="Center" | |||||
FontSize="16" | FontSize="16" | ||||
Foreground="#FFF53F62" | Foreground="#FFF53F62" | ||||
Text="{Binding Info}" /> | Text="{Binding Info}" /> | ||||
</Grid> | </Grid> | ||||
<Grid Grid.Row="1"> | <Grid Grid.Row="1"> | ||||
<Grid.ColumnDefinitions> | <Grid.ColumnDefinitions> | ||||
@@ -308,24 +333,26 @@ | |||||
<ColumnDefinition /> | <ColumnDefinition /> | ||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<Button VerticalAlignment="Center" | |||||
HorizontalAlignment="Center" | |||||
HorizontalContentAlignment="Center" | |||||
VerticalContentAlignment="Center" | |||||
Content="用户添加" | |||||
FontSize="16" | |||||
Style="{DynamicResource ButtonStyle}" | |||||
Command="{Binding UserAddCommand}"/> | |||||
<Button Grid.Column="1" | |||||
VerticalAlignment="Center" | |||||
HorizontalAlignment="Center" | |||||
HorizontalContentAlignment="Center" | |||||
VerticalContentAlignment="Center" | |||||
Content="用户注销" | |||||
FontSize="16" | |||||
Style="{DynamicResource ButtonStyle}" | |||||
Command="{Binding UserCancelCommand}"/> | |||||
<Button | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
HorizontalContentAlignment="Center" | |||||
VerticalContentAlignment="Center" | |||||
Command="{Binding UserAddCommand}" | |||||
Content="用户添加" | |||||
FontSize="16" | |||||
Style="{DynamicResource ButtonStyle}" /> | |||||
<Button | |||||
Grid.Column="1" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
HorizontalContentAlignment="Center" | |||||
VerticalContentAlignment="Center" | |||||
Command="{Binding UserCancelCommand}" | |||||
Content="用户注销" | |||||
FontSize="16" | |||||
Style="{DynamicResource ButtonStyle}" /> | |||||
@@ -122,13 +122,6 @@ namespace BPASmartClient.JXJFoodBigStation | |||||
#region 硬件设备监控 | #region 硬件设备监控 | ||||
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>(); | ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>(); | ||||
DeviceMonitor.Add(new SubMenumodel() | DeviceMonitor.Add(new SubMenumodel() | ||||
{ | |||||
SubMenuName = "料仓管理", | |||||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||||
AssemblyName = "BPASmartClient.JXJFoodBigStation", | |||||
ToggleWindowPath = "View.DeviceManageView" | |||||
}); | |||||
DeviceMonitor.Add(new SubMenumodel() | |||||
{ | { | ||||
SubMenuName = "设备状态", | SubMenuName = "设备状态", | ||||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | ||||
@@ -384,9 +384,9 @@ | |||||
<Border Margin="5" Background="Transparent"> | <Border Margin="5" Background="Transparent"> | ||||
<Grid Height="220"> | <Grid Height="220"> | ||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
<RowDefinition Height="0.45*"/> | |||||
<RowDefinition Height="0.45*"/> | |||||
<RowDefinition Height="0.1*"/> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<!--<RowDefinition Height="0.1*"/>--> | |||||
</Grid.RowDefinitions> | </Grid.RowDefinitions> | ||||
<TextBlock | <TextBlock | ||||
@@ -402,13 +402,22 @@ | |||||
Margin="55,100,0,0" | Margin="55,100,0,0" | ||||
HorizontalAlignment="Center"> | HorizontalAlignment="Center"> | ||||
<Path x:Name="path" Tag="{Binding DeviceName}" Visibility="Collapsed" Fill="LightGreen" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z"> | |||||
<Path x:Name="path" Tag="{Binding DeviceName}" Visibility="Collapsed" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z"> | |||||
<Path.RenderTransform> | <Path.RenderTransform> | ||||
<TransformGroup> | <TransformGroup> | ||||
<RotateTransform Angle="90"/> | <RotateTransform Angle="90"/> | ||||
<TranslateTransform Y="0"/> | <TranslateTransform Y="0"/> | ||||
</TransformGroup> | </TransformGroup> | ||||
</Path.RenderTransform> | </Path.RenderTransform> | ||||
<Path.Fill> | |||||
<LinearGradientBrush> | |||||
<LinearGradientBrush.RelativeTransform> | |||||
<RotateTransform Angle="-15"/> | |||||
</LinearGradientBrush.RelativeTransform> | |||||
<GradientStop Color="LightGreen" Offset="0"/> | |||||
<GradientStop Color="LightSeaGreen" Offset="0.6"/> | |||||
</LinearGradientBrush> | |||||
</Path.Fill> | |||||
</Path> | </Path> | ||||
</StackPanel> | </StackPanel> | ||||
@@ -452,7 +461,7 @@ | |||||
Source="/BPASmartClient.CustomResource;component/Image/光柱.png" | Source="/BPASmartClient.CustomResource;component/Image/光柱.png" | ||||
Stretch="Fill" /> | Stretch="Fill" /> | ||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2"> | |||||
<!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2"> | |||||
<pry:IcoButton | <pry:IcoButton | ||||
Width="80" | Width="80" | ||||
@@ -489,7 +498,7 @@ | |||||
Foreground="#FFF53F62" | Foreground="#FFF53F62" | ||||
IcoText="" | IcoText="" | ||||
Style="{StaticResource IcoButtonStyle}" /> | Style="{StaticResource IcoButtonStyle}" /> | ||||
</StackPanel> | |||||
</StackPanel>--> | |||||
</Grid> | </Grid> | ||||
</Border> | </Border> | ||||
@@ -538,9 +547,9 @@ | |||||
<Border Margin="5" Background="Transparent"> | <Border Margin="5" Background="Transparent"> | ||||
<Grid Height="220"> | <Grid Height="220"> | ||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
<RowDefinition Height="0.45*"/> | |||||
<RowDefinition Height="0.45*"/> | |||||
<RowDefinition Height="0.1*"/> | |||||
<RowDefinition/> | |||||
<RowDefinition/> | |||||
<!--<RowDefinition Height="0.1*"/>--> | |||||
</Grid.RowDefinitions> | </Grid.RowDefinitions> | ||||
<TextBlock | <TextBlock | ||||
@@ -556,13 +565,22 @@ | |||||
Margin="55,100,0,0" | Margin="55,100,0,0" | ||||
HorizontalAlignment="Center"> | HorizontalAlignment="Center"> | ||||
<Path x:Name="path1" Tag="{Binding DeviceName}" Visibility="Collapsed" Fill="LightGreen" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z"> | |||||
<Path x:Name="path1" Tag="{Binding DeviceName}" Visibility="Collapsed" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z"> | |||||
<Path.RenderTransform> | <Path.RenderTransform> | ||||
<TransformGroup> | <TransformGroup> | ||||
<RotateTransform Angle="90"/> | <RotateTransform Angle="90"/> | ||||
<TranslateTransform Y="0"/> | <TranslateTransform Y="0"/> | ||||
</TransformGroup> | </TransformGroup> | ||||
</Path.RenderTransform> | </Path.RenderTransform> | ||||
<Path.Fill> | |||||
<LinearGradientBrush> | |||||
<LinearGradientBrush.RelativeTransform> | |||||
<RotateTransform Angle="-15"/> | |||||
</LinearGradientBrush.RelativeTransform> | |||||
<GradientStop Color="LightGreen" Offset="0"/> | |||||
<GradientStop Color="LightSeaGreen" Offset="0.5"/> | |||||
</LinearGradientBrush> | |||||
</Path.Fill> | |||||
</Path> | </Path> | ||||
</StackPanel> | </StackPanel> | ||||
<StackPanel | <StackPanel | ||||
@@ -602,7 +620,7 @@ | |||||
Grid.RowSpan="2" | Grid.RowSpan="2" | ||||
Source="/BPASmartClient.CustomResource;component/Image/光柱.png" | Source="/BPASmartClient.CustomResource;component/Image/光柱.png" | ||||
Stretch="Fill" /> | Stretch="Fill" /> | ||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2"> | |||||
<!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2"> | |||||
<pry:IcoButton | <pry:IcoButton | ||||
Width="80" | Width="80" | ||||
@@ -639,7 +657,7 @@ | |||||
Foreground="#FFF53F62" | Foreground="#FFF53F62" | ||||
IcoText="" | IcoText="" | ||||
Style="{StaticResource IcoButtonStyle}" /> | Style="{StaticResource IcoButtonStyle}" /> | ||||
</StackPanel> | |||||
</StackPanel>--> | |||||
</Grid> | </Grid> | ||||
@@ -334,7 +334,7 @@ | |||||
<ColumnDefinition Width="225"></ColumnDefinition> | <ColumnDefinition Width="225"></ColumnDefinition> | ||||
<ColumnDefinition></ColumnDefinition> | <ColumnDefinition></ColumnDefinition> | ||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding RawMaterialLocation}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus"> | |||||
<!--<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding RawMaterialLocation}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus"> | |||||
<ComboBox.ItemContainerStyle> | <ComboBox.ItemContainerStyle> | ||||
<Style TargetType="{x:Type ComboBoxItem}"> | <Style TargetType="{x:Type ComboBoxItem}"> | ||||
<Setter Property="Background" Value="White" /> | <Setter Property="Background" Value="White" /> | ||||
@@ -342,8 +342,10 @@ | |||||
</Style> | </Style> | ||||
</ComboBox.ItemContainerStyle> | |||||
</ComboBox> | |||||
</ComboBox.ItemContainerStyle>--> | |||||
<!--</ComboBox>--> | |||||
<TextBox Text="{Binding RawMaterialName}" Background="Transparent" FontSize="14" | |||||
BorderBrush="#e69519" Foreground="LightGray" Width="190" Margin="10,0,0,10" ></TextBox> | |||||
<StackPanel Grid.Column="1" Orientation="Horizontal" > | <StackPanel Grid.Column="1" Orientation="Horizontal" > | ||||
<TextBox Text="{Binding RawMaterialBarrelNum}" Background="Transparent" FontSize="14" | <TextBox Text="{Binding RawMaterialBarrelNum}" Background="Transparent" FontSize="14" | ||||
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox> | BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox> | ||||
@@ -362,7 +364,7 @@ | |||||
Background="Transparent" | Background="Transparent" | ||||
BorderBrush="#e69519" Foreground="LightGray" HorizontalAlignment="Right" | BorderBrush="#e69519" Foreground="LightGray" HorizontalAlignment="Right" | ||||
Command="{Binding DataContext.RemoveRecipe,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" | Command="{Binding DataContext.RemoveRecipe,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" | ||||
CommandParameter="{Binding RawMaterialLocation}"></Button> | |||||
CommandParameter="{Binding RawMaterialName}"></Button> | |||||
</Grid> | </Grid> | ||||
</ControlTemplate> | </ControlTemplate> | ||||
</RadioButton.Template> | </RadioButton.Template> | ||||
@@ -168,7 +168,7 @@ | |||||
Foreground="Aqua" | Foreground="Aqua" | ||||
IcoText="" | IcoText="" | ||||
Style="{StaticResource IcoButtonStyle}" /> | Style="{StaticResource IcoButtonStyle}" /> | ||||
<pry:IcoButton | |||||
<!--<pry:IcoButton | |||||
Width="140" | Width="140" | ||||
Margin="10" | Margin="10" | ||||
HorizontalAlignment="Left" | HorizontalAlignment="Left" | ||||
@@ -177,7 +177,7 @@ | |||||
FontSize="16" | FontSize="16" | ||||
Foreground="Aqua" | Foreground="Aqua" | ||||
IcoText="" | IcoText="" | ||||
Style="{StaticResource IcoButtonStyle}" /> | |||||
Style="{StaticResource IcoButtonStyle}" />--> | |||||
<pry:IcoButton | <pry:IcoButton | ||||
Grid.Column="3" | Grid.Column="3" | ||||
@@ -241,6 +241,7 @@ | |||||
<TextBlock | <TextBlock | ||||
Grid.Row="1" | Grid.Row="1" | ||||
FontSize="16" | |||||
Margin="5,0,0,0" | Margin="5,0,0,0" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
Foreground="#FF2AB2E7" | Foreground="#FF2AB2E7" | ||||
@@ -271,13 +272,13 @@ | |||||
</RadialGradientBrush> | </RadialGradientBrush> | ||||
</Border.Background> | </Border.Background> | ||||
</Border> | </Border> | ||||
<TextBlock Text="{Binding RawMaterialLocation }" Foreground="#FF2AB2E7" VerticalAlignment="Center"/> | |||||
<TextBlock Text="{Binding RawMaterialName }" Foreground="#FF2AB2E7" VerticalAlignment="Center" FontSize="14" /> | |||||
</StackPanel> | </StackPanel> | ||||
</Expander.Header> | </Expander.Header> | ||||
<Expander.Content> | <Expander.Content> | ||||
<StackPanel Margin="36,0,0,0"> | <StackPanel Margin="36,0,0,0"> | ||||
<StackPanel Orientation="Horizontal"> | <StackPanel Orientation="Horizontal"> | ||||
<TextBlock Text="托盘编号:" Foreground="#FF2AB2E7"/> | |||||
<TextBlock Text="托盘桶号:" Foreground="#FF2AB2E7"/> | |||||
<TextBlock Text="{Binding RawMaterialBarrelNum}" Foreground="#FF2AB2E7"/> | <TextBlock Text="{Binding RawMaterialBarrelNum}" Foreground="#FF2AB2E7"/> | ||||
</StackPanel> | </StackPanel> | ||||
<StackPanel Orientation="Horizontal"> | <StackPanel Orientation="Horizontal"> | ||||
@@ -473,6 +473,7 @@ | |||||
<TextBlock | <TextBlock | ||||
Grid.Row="1" | Grid.Row="1" | ||||
FontSize="16" | |||||
Margin="5,0,0,0" | Margin="5,0,0,0" | ||||
VerticalAlignment="Top" | VerticalAlignment="Top" | ||||
Foreground="#FF2AB2E7" | Foreground="#FF2AB2E7" | ||||
@@ -503,7 +504,7 @@ | |||||
</RadialGradientBrush> | </RadialGradientBrush> | ||||
</Border.Background> | </Border.Background> | ||||
</Border> | </Border> | ||||
<TextBlock Text="{Binding RawMaterialLocation }" Foreground="#FF2AB2E7" VerticalAlignment="Center"/> | |||||
<TextBlock Text="{Binding RawMaterialName }" Foreground="#FF2AB2E7" VerticalAlignment="Center" FontSize="14"/> | |||||
</StackPanel> | </StackPanel> | ||||
</Expander.Header> | </Expander.Header> | ||||
<Expander.Content> | <Expander.Content> | ||||
@@ -73,6 +73,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||||
bom.RawMaterial.Add(item); | bom.RawMaterial.Add(item); | ||||
} | } | ||||
bom.RecipeName = RecipeName; | bom.RecipeName = RecipeName; | ||||
bom.TrayCode = TrayCode; | |||||
Json<LocaPar>.Save(); | Json<LocaPar>.Save(); | ||||
ActionManage.GetInstance.Send("CloseRecipeInfosView"); | ActionManage.GetInstance.Send("CloseRecipeInfosView"); | ||||
} | } | ||||
@@ -105,9 +106,9 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | ActionManage.GetInstance.Send("CloseNewRecipeView"); | ||||
}); | }); | ||||
RemoveRecipe = new RelayCommand<int>((materilaName) => | |||||
{ | |||||
var res = RawMaterialsInfo.FirstOrDefault(p => p.RawMaterialLocation == materilaName); | |||||
RemoveRecipe = new RelayCommand<string>((materilaName) => { | |||||
var res= RawMaterialsInfo.FirstOrDefault(p=>p.RawMaterialName==materilaName); | |||||
if (res != null) | if (res != null) | ||||
RawMaterialsInfo.Remove(res); | RawMaterialsInfo.Remove(res); | ||||
}); | }); | ||||
@@ -130,7 +131,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||||
public RelayCommand SaveAs { get; set; } | public RelayCommand SaveAs { get; set; } | ||||
public RelayCommand<int> RemoveRecipe { get; set; } | |||||
public RelayCommand<string> RemoveRecipe { get; set; } | |||||
public ObservableCollection<RawMaterialModel> RawMaterialsInfo { get; set; } = new ObservableCollection<RawMaterialModel>() ; | public ObservableCollection<RawMaterialModel> RawMaterialsInfo { get; set; } = new ObservableCollection<RawMaterialModel>() ; | ||||
} | } | ||||
@@ -45,44 +45,44 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||||
RecipeInfosView nrv = new RecipeInfosView(); | RecipeInfosView nrv = new RecipeInfosView(); | ||||
nrv.ShowDialog(); | nrv.ShowDialog(); | ||||
}); | }); | ||||
NewSimulateRecipe = new RelayCommand(() => | |||||
{ | |||||
RawMaterials.Clear(); | |||||
string recipeName = "配方" + (Json<LocaPar>.Data.Recipes.Count + 1) + ""; | |||||
go: | |||||
string recipeCode = new Random().Next(10000, 99999).ToString(); | |||||
foreach (var item in Recipes) | |||||
{ | |||||
if (item.RecipeCode == recipeCode) | |||||
{ | |||||
goto go; | |||||
} | |||||
} | |||||
int trayCode = new Random().Next(1,6); | |||||
for (int i = 1; i < 13; i++) | |||||
{ | |||||
int a = new Random().Next(1, 5); | |||||
if (a == 3) | |||||
{ | |||||
a = 1; | |||||
} | |||||
RawMaterials.Add(new RawMaterialModel() | |||||
{ | |||||
RawMaterialWeight = new Random().Next(10, 1000), | |||||
RawMaterialBarrelNum = a, | |||||
RawMaterialLocation = i, | |||||
}); | |||||
} | |||||
Json<LocaPar>.Data.Recipes.Add(new RecipeModel() | |||||
{ | |||||
RecipeName = recipeName, | |||||
RecipeCode = recipeCode, | |||||
TrayCode = trayCode, | |||||
RawMaterial = RawMaterials, | |||||
}); | |||||
Json<LocaPar>.Save(); | |||||
}); | |||||
//模拟配方 | |||||
//NewSimulateRecipe = new RelayCommand(() => | |||||
//{ | |||||
// RawMaterials.Clear(); | |||||
// string recipeName = "配方" + (Json<LocaPar>.Data.Recipes.Count + 1) + ""; | |||||
//go: | |||||
// string recipeCode = new Random().Next(10000, 99999).ToString(); | |||||
// foreach (var item in Recipes) | |||||
// { | |||||
// if (item.RecipeCode == recipeCode) | |||||
// { | |||||
// goto go; | |||||
// } | |||||
// } | |||||
// int trayCode = new Random().Next(1,6); | |||||
// for (int i = 1; i < 13; i++) | |||||
// { | |||||
// int a = new Random().Next(1, 5); | |||||
// if (a == 3) | |||||
// { | |||||
// a = 1; | |||||
// } | |||||
// RawMaterials.Add(new RawMaterialModel() | |||||
// { | |||||
// RawMaterialWeight = new Random().Next(10, 1000), | |||||
// RawMaterialBarrelNum = a, | |||||
// RawMaterialLocation = i, | |||||
// }); | |||||
// } | |||||
// Json<LocaPar>.Data.Recipes.Add(new RecipeModel() | |||||
// { | |||||
// RecipeName = recipeName, | |||||
// RecipeCode = recipeCode, | |||||
// TrayCode = trayCode, | |||||
// RawMaterial = RawMaterials, | |||||
// }); | |||||
// Json<LocaPar>.Save(); | |||||
//}); | |||||
ClearAllRecipe = new RelayCommand(() => | ClearAllRecipe = new RelayCommand(() => | ||||
{ | { | ||||
Json<LocaPar>.Data.Recipes.Clear(); | Json<LocaPar>.Data.Recipes.Clear(); | ||||
@@ -14,7 +14,5 @@ | |||||
<ImageBrush ImageSource="/Images/bj.png"/> | <ImageBrush ImageSource="/Images/bj.png"/> | ||||
</Grid.Background> | </Grid.Background> | ||||
<ctrl:RunCanvas x:Name="runCanvas"/> | <ctrl:RunCanvas x:Name="runCanvas"/> | ||||
<ctrl:HBLControl></ctrl:HBLControl> | |||||
</Grid> | </Grid> | ||||
</Window> | </Window> |
@@ -32,7 +32,16 @@ namespace BPASmartClient.S7Net | |||||
public TResult Read<TResult>(string address) | public TResult Read<TResult>(string address) | ||||
{ | { | ||||
if (!IsConnected) return default; | if (!IsConnected) return default; | ||||
return (TResult)myPlc?.Read(address); | |||||
var value = myPlc?.Read(address); | |||||
if (typeof(TResult).Name == "Single") | |||||
{ | |||||
var obj = ((uint)value).ConvertToFloat(); | |||||
return (TResult)Convert.ChangeType(obj, typeof(TResult)); | |||||
} | |||||
else | |||||
{ | |||||
return (TResult)Convert.ChangeType(value, typeof(TResult)); | |||||
} | |||||
} | } | ||||
public bool[] ReadBools(int address, int count) | public bool[] ReadBools(int address, int count) | ||||
@@ -13,7 +13,7 @@ | |||||
<None Remove="Images\api.png" /> | <None Remove="Images\api.png" /> | ||||
<None Remove="Images\biogebj.png" /> | <None Remove="Images\biogebj.png" /> | ||||
<None Remove="Images\bj.png" /> | <None Remove="Images\bj.png" /> | ||||
<None Remove="Images\btnnormal.png" /> | |||||
<None Remove="Images\btnkeys.png" /> | |||||
<None Remove="Images\button1.png" /> | <None Remove="Images\button1.png" /> | ||||
<None Remove="Images\button2.png" /> | <None Remove="Images\button2.png" /> | ||||
<None Remove="Images\Cb_Checked.png" /> | <None Remove="Images\Cb_Checked.png" /> | ||||
@@ -30,6 +30,8 @@ | |||||
<None Remove="Images\State1.png" /> | <None Remove="Images\State1.png" /> | ||||
<None Remove="Images\State11.png" /> | <None Remove="Images\State11.png" /> | ||||
<None Remove="Images\State2.png" /> | <None Remove="Images\State2.png" /> | ||||
<None Remove="Images\Tab4_No.png" /> | |||||
<None Remove="Images\Tab4_Select.png" /> | |||||
<None Remove="Images\timericon.png" /> | <None Remove="Images\timericon.png" /> | ||||
<None Remove="Images\借出.png" /> | <None Remove="Images\借出.png" /> | ||||
<None Remove="Images\光柱.png" /> | <None Remove="Images\光柱.png" /> | ||||
@@ -70,7 +72,7 @@ | |||||
<Resource Include="Images\bj.png"> | <Resource Include="Images\bj.png"> | ||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||
</Resource> | </Resource> | ||||
<Resource Include="Images\btnnormal.png"> | |||||
<Resource Include="Images\btnkeys.png"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||
</Resource> | </Resource> | ||||
<Resource Include="Images\Cb_Checked.png"> | <Resource Include="Images\Cb_Checked.png"> | ||||
@@ -115,6 +117,12 @@ | |||||
<Resource Include="Images\State2.png"> | <Resource Include="Images\State2.png"> | ||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||
</Resource> | </Resource> | ||||
<Resource Include="Images\Tab4_No.png"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</Resource> | |||||
<Resource Include="Images\Tab4_Select.png"> | |||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||||
</Resource> | |||||
<Resource Include="Images\timericon.png"> | <Resource Include="Images\timericon.png"> | ||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||||
</Resource> | </Resource> | ||||
@@ -45,7 +45,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
IsEnabled = true; | IsEnabled = true; | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -45,7 +45,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
IsEnabled = true; | IsEnabled = true; | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -105,7 +105,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
IsEnabled = true; | IsEnabled = true; | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -71,7 +71,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
IsEnabled = true; | IsEnabled = true; | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
Focusable = true; | Focusable = true; | ||||
} | } | ||||
} | } | ||||
@@ -111,7 +111,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
IsEnabled = true; | IsEnabled = true; | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -314,8 +314,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
private static readonly DependencyProperty EventSendNameListProperty = | private static readonly DependencyProperty EventSendNameListProperty = | ||||
DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged))); | DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged))); | ||||
private static void onEventNameListChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh(); | private static void onEventNameListChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh(); | ||||
#endregion | #endregion | ||||
#region 数据绑定模块 | #region 数据绑定模块 | ||||
@@ -72,16 +72,16 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
switch (StatusValue) | switch (StatusValue) | ||||
{ | { | ||||
case 0: | case 0: | ||||
image.Source = new BitmapImage(new Uri("pack://application:,,,/Images/State0.png", UriKind.Absolute)); | |||||
image.Source = new BitmapImage(new Uri(@"/BPASmartClient.SCADAControl;component/Images/State0.png", UriKind.Relative)); | |||||
break; | break; | ||||
case -1: | case -1: | ||||
image.Source = new BitmapImage(new Uri("pack://application:,,,/Images/State11.png", UriKind.Absolute)); | |||||
image.Source = new BitmapImage(new Uri(@"/BPASmartClient.SCADAControl;component/Images/State11.png", UriKind.Relative)); | |||||
break; | break; | ||||
case 1: | case 1: | ||||
image.Source = new BitmapImage(new Uri("pack://application:,,,/Images/State1.png", UriKind.Absolute)); | |||||
image.Source = new BitmapImage(new Uri(@"/BPASmartClient.SCADAControl;component/Images/State1.png", UriKind.Relative)); | |||||
break; | break; | ||||
case 2: | case 2: | ||||
image.Source = new BitmapImage(new Uri("pack://application:,,,/Images/State2.png", UriKind.Absolute)); | |||||
image.Source = new BitmapImage(new Uri(@"/BPASmartClient.SCADAControl;component/Images/State2.png", UriKind.Relative)); | |||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
@@ -45,22 +45,22 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(SwitchButton), new FrameworkPropertyMetadata(typeof(SwitchButton))); | DefaultStyleKeyProperty.OverrideMetadata(typeof(SwitchButton), new FrameworkPropertyMetadata(typeof(SwitchButton))); | ||||
} | } | ||||
[Category("事件")] | |||||
public string Value | |||||
[Category("事件")] | |||||
public string BindingIsChecked | |||||
{ | { | ||||
get { return (string)GetValue(ValueProperty); } | |||||
set { SetValue(ValueProperty,value); } | |||||
get { return (string)GetValue(BingIsCheckedProperty); } | |||||
set { SetValue(BingIsCheckedProperty, value); } | |||||
} | } | ||||
public static readonly DependencyProperty ValueProperty = | |||||
DependencyProperty.Register("Value",typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty)); | |||||
public static readonly DependencyProperty BingIsCheckedProperty = | |||||
DependencyProperty.Register("BindingIsChecked", typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty)); | |||||
[Category("事件")] | [Category("事件")] | ||||
public string Text | |||||
public string SendText | |||||
{ | { | ||||
get { return (string)GetValue(TextProperty); } | |||||
set { SetValue(TextProperty,value); } | |||||
get { return (string)GetValue(SendTextProperty); } | |||||
set { SetValue(SendTextProperty, value); } | |||||
} | } | ||||
public static readonly DependencyProperty TextProperty = | |||||
DependencyProperty.Register("Text",typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty)); | |||||
public static readonly DependencyProperty SendTextProperty = | |||||
DependencyProperty.Register("SendText", typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty)); | |||||
/// <summary> | /// <summary> | ||||
/// 不勾选时执行代码 | /// 不勾选时执行代码 | ||||
@@ -92,7 +92,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
set { SetValue(TimeCountProperty,value); } | set { SetValue(TimeCountProperty,value); } | ||||
} | } | ||||
public static readonly DependencyProperty TimeCountProperty = | public static readonly DependencyProperty TimeCountProperty = | ||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(SwitchButton),new PropertyMetadata(5)); | |||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(SwitchButton),new PropertyMetadata(100)); | |||||
protected override void OnRender(DrawingContext drawingContext) | protected override void OnRender(DrawingContext drawingContext) | ||||
{ | { | ||||
base.OnRender(drawingContext); | base.OnRender(drawingContext); | ||||
@@ -175,9 +175,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
propertyBing[propertyInfo.Name] = propName.ToString(); | propertyBing[propertyInfo.Name] = propName.ToString(); | ||||
} | } | ||||
} | } | ||||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||||
timer.Tick += Timer_Tick; ; | |||||
timer.Start(); | |||||
if (propertyBing.Count > 0) | |||||
{ | |||||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||||
timer.Tick += Timer_Tick; ; | |||||
timer.Start(); | |||||
} | |||||
this.Click += SwitchButton_Click; | this.Click += SwitchButton_Click; | ||||
} | } | ||||
@@ -214,7 +217,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
_checked = false; | _checked = false; | ||||
} | } | ||||
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); | EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); | ||||
Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType }); | |||||
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType }); | |||||
this.GetType().GetProperty("IsChecked").SetValue(this,_checked); | this.GetType().GetProperty("IsChecked").SetValue(this,_checked); | ||||
} | } | ||||
} | } | ||||
@@ -243,7 +246,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
object _value = b[str[1]].VarVaule; | object _value = b[str[1]].VarVaule; | ||||
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); | EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); | ||||
Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = this.IsChecked.ToString(),DataType = eDataType }); | |||||
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = this.IsChecked.ToString(),DataType = eDataType }); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -86,7 +86,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -46,7 +46,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -61,7 +61,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
Focusable = true; | Focusable = true; | ||||
IsEnabled = true; | IsEnabled = true; | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -59,7 +59,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
isExecuteState = value; | isExecuteState = value; | ||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Style = null; | |||||
//Style = null; | |||||
Register(); | Register(); | ||||
} | } | ||||
} | } | ||||
@@ -47,7 +47,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -73,7 +73,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
isExecuteState = value; | isExecuteState = value; | ||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Style = null; | |||||
//Style = null; | |||||
Register(); | Register(); | ||||
} | } | ||||
} | } | ||||
@@ -108,7 +108,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -140,7 +140,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
Direction = 2; | Direction = 2; | ||||
} | } | ||||
} | } | ||||
timer.Interval = TimeSpan.FromSeconds(TimeCount); | |||||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||||
timer.Tick += Timer_Tick; | timer.Tick += Timer_Tick; | ||||
timer.Start(); | timer.Start(); | ||||
@@ -189,13 +189,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
#region 属性 | #region 属性 | ||||
[Category("事件")] | [Category("事件")] | ||||
public string Value | |||||
public string SendText | |||||
{ | { | ||||
get { return (string)GetValue(ValueProperty); } | |||||
set { SetValue(ValueProperty,value); } | |||||
get { return (string)GetValue(SendTextProperty); } | |||||
set { SetValue(SendTextProperty, value); } | |||||
} | } | ||||
public static readonly DependencyProperty ValueProperty = | |||||
DependencyProperty.Register("Value",typeof(string),typeof(TheMQTT),new PropertyMetadata(string.Empty,new PropertyChangedCallback(OnValuePropertyChanged))); | |||||
public static readonly DependencyProperty SendTextProperty = | |||||
DependencyProperty.Register("SendText", typeof(string),typeof(TheMQTT),new PropertyMetadata(string.Empty,new PropertyChangedCallback(OnValuePropertyChanged))); | |||||
private static void OnValuePropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) | private static void OnValuePropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) | ||||
{ | { | ||||
(d as TheMQTT)?.RefreshMQTT(); | (d as TheMQTT)?.RefreshMQTT(); | ||||
@@ -203,9 +203,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
public void RefreshMQTT() | public void RefreshMQTT() | ||||
{ | { | ||||
PublishInfo publishInfo = new PublishInfo(); | PublishInfo publishInfo = new PublishInfo(); | ||||
if (!string.IsNullOrEmpty(Value)) | |||||
if (!string.IsNullOrEmpty(SendText)) | |||||
{ | { | ||||
publishInfo.PublishModels.Add(JsonConvert.DeserializeObject<PublishModel>(Value)); | |||||
publishInfo.PublishModels.Add(JsonConvert.DeserializeObject<PublishModel>(SendText)); | |||||
if (mQTT.client != null && mQTT.client.IsConnected) | if (mQTT.client != null && mQTT.client.IsConnected) | ||||
mQTT.MqttPublishAsync("DistributedHostComputer/Control",JsonConvert.SerializeObject(publishInfo)); | mQTT.MqttPublishAsync("DistributedHostComputer/Control",JsonConvert.SerializeObject(publishInfo)); | ||||
} | } | ||||
@@ -278,7 +278,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
set { SetValue(TimeCountProperty,value); } | set { SetValue(TimeCountProperty,value); } | ||||
} | } | ||||
public static readonly DependencyProperty TimeCountProperty = | public static readonly DependencyProperty TimeCountProperty = | ||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheMQTT),new PropertyMetadata(5)); | |||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheMQTT),new PropertyMetadata(1000)); | |||||
[Category("数据绑定-数据来源")] | [Category("数据绑定-数据来源")] | ||||
public string DataSouceInformation | public string DataSouceInformation | ||||
{ | { | ||||
@@ -50,7 +50,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -26,7 +26,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
ResourceDictionary languageResDic = new ResourceDictionary(); | ResourceDictionary languageResDic = new ResourceDictionary(); | ||||
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute); | languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute); | ||||
this.Resources.MergedDictionaries.Add(languageResDic); | this.Resources.MergedDictionaries.Add(languageResDic); | ||||
//SetCurrentValue(ContentProperty, "单选按钮"); | |||||
SetCurrentValue(ContentProperty, "单选按钮"); | |||||
} | } | ||||
static TheRadioButton() | static TheRadioButton() | ||||
{ | { | ||||
@@ -45,7 +45,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -47,7 +47,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -108,7 +108,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -130,7 +130,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
Direction = 2; | Direction = 2; | ||||
} | } | ||||
} | } | ||||
timer.Interval = TimeSpan.FromSeconds(TimeCount); | |||||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||||
timer.Tick += Timer_Tick; | timer.Tick += Timer_Tick; | ||||
timer.Start(); | timer.Start(); | ||||
@@ -271,7 +271,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
set { SetValue(TimeCountProperty,value); } | set { SetValue(TimeCountProperty,value); } | ||||
} | } | ||||
public static readonly DependencyProperty TimeCountProperty = | public static readonly DependencyProperty TimeCountProperty = | ||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheRedis),new PropertyMetadata(5)); | |||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheRedis),new PropertyMetadata(100)); | |||||
[Category("数据绑定-数据来源")] | [Category("数据绑定-数据来源")] | ||||
public string DataSouceInformation | public string DataSouceInformation | ||||
{ | { | ||||
@@ -38,7 +38,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -0,0 +1,11 @@ | |||||
<TabControl x:Class="BPASmartClient.SCADAControl.CustomerControls.TheTabControl" | |||||
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:BPASmartClient.SCADAControl.CustomerControls" | |||||
mc:Ignorable="d" | |||||
Background="Transparent" | |||||
BorderBrush="Transparent" | |||||
d:DesignHeight="450" d:DesignWidth="800"> | |||||
</TabControl> |
@@ -0,0 +1,183 @@ | |||||
using BPASmartClient.Compiler; | |||||
using BPASmartClient.SCADAControl; | |||||
using Newtonsoft.Json; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Collections.ObjectModel; | |||||
using System.ComponentModel; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
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.Navigation; | |||||
using System.Windows.Shapes; | |||||
namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | |||||
/// <summary> | |||||
/// TheTabControl.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class TheTabControl : TabControl, IExecutable | |||||
{ | |||||
public event EventHandler PropertyChange; //声明一个事件 | |||||
public TheTabControl() | |||||
{ | |||||
InitializeComponent(); | |||||
ResourceDictionary languageResDic = new ResourceDictionary(); | |||||
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute); | |||||
this.Resources.MergedDictionaries.Add(languageResDic); | |||||
Width = 150; | |||||
Height = 150; | |||||
this.Loaded += TheTabControl_Loaded; | |||||
this.SelectionChanged += TheTabControl_SelectionChanged; | |||||
} | |||||
private void TheTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) | |||||
{ | |||||
try | |||||
{ | |||||
object _header = (this.SelectedItem as TabItem).Header; | |||||
TabItems?.ToList().ForEach(par => | |||||
{ | |||||
if (_header!=null && par.Header == (string)_header) | |||||
{ | |||||
if(!string.IsNullOrEmpty(par.ClickStr)) | |||||
Config.GetInstance().RunJsScipt(par.ClickStr); | |||||
} | |||||
}); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
throw; | |||||
} | |||||
} | |||||
private void TheTabControl_Loaded(object sender, RoutedEventArgs e) | |||||
{ | |||||
TabItems.CollectionChanged += TabItems_CollectionChanged; | |||||
} | |||||
private void TabItems_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) | |||||
{ | |||||
this.Items.Clear(); | |||||
if (TabItems.Count > 0) | |||||
{ | |||||
try | |||||
{ | |||||
TabItemsStr = JsonConvert.SerializeObject(TabItems); | |||||
TabItems?.ToList().ForEach(item => { | |||||
this.Items.Add(new TabItem { Header = item.Header, Style = (FindResource("TheTabItem") as Style) }); | |||||
}); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
} | |||||
public string ControlType => "控件"; | |||||
private bool isExecuteState; | |||||
public bool IsExecuteState | |||||
{ | |||||
get { return isExecuteState; } | |||||
set | |||||
{ | |||||
isExecuteState = value; | |||||
if (IsExecuteState) | |||||
{ | |||||
Register(); | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 注册需要处理的事件 | |||||
/// </summary> | |||||
public void Register() | |||||
{ | |||||
if (!string.IsNullOrEmpty(TabItemsStr)) | |||||
{ | |||||
try | |||||
{ | |||||
TabItems = JsonConvert.DeserializeObject<ObservableCollection<TheTabItemModel>>(TabItemsStr); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
} | |||||
#region 属性 | |||||
[Category("名称[自动生成]")] | |||||
private string TabItemsStr | |||||
{ | |||||
get { return (string)GetValue(TabItemsStrProperty); } | |||||
set { SetValue(TabItemsStrProperty, value); } | |||||
} | |||||
private static readonly DependencyProperty TabItemsStrProperty = | |||||
DependencyProperty.Register("TabItemsStr", typeof(string), typeof(TheTabControl), new PropertyMetadata(string.Empty, new PropertyChangedCallback(onEventReceiveNameListStrChanged))); | |||||
private static void onEventReceiveNameListStrChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as TheTabControl)?.TabItemsStrPropertyRefresh(); | |||||
[Category("集合")] | |||||
public ObservableCollection<TheTabItemModel> TabItems | |||||
{ | |||||
get { return (ObservableCollection<TheTabItemModel>)GetValue(TabItemsProperty); } | |||||
set { SetValue(TabItemsProperty, value); } | |||||
} | |||||
private static readonly DependencyProperty TabItemsProperty = | |||||
DependencyProperty.Register("TabItems", typeof(ObservableCollection<TheTabItemModel>), typeof(TheTabControl), new PropertyMetadata(new ObservableCollection<TheTabItemModel>(), new PropertyChangedCallback(onEventNameListChanged))); | |||||
private static void onEventNameListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as TheTabControl)?.TabItemsPropertyRefresh(); | |||||
public void TabItemsStrPropertyRefresh() | |||||
{ | |||||
if (!string.IsNullOrEmpty(TabItemsStr)) | |||||
{ | |||||
try | |||||
{ | |||||
// TabItems = JsonConvert.DeserializeObject<ObservableCollection<TheTabItemModel>>(TabItemsStr); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
} | |||||
public void TabItemsPropertyRefresh() | |||||
{ | |||||
} | |||||
#endregion | |||||
} | |||||
public class TheTabItemModel | |||||
{ | |||||
/// <summary> | |||||
/// 序号 | |||||
/// </summary> | |||||
public int SortID { get; set; } | |||||
/// <summary> | |||||
/// 标题 | |||||
/// </summary> | |||||
public string Header { get; set; } | |||||
/// <summary> | |||||
/// 单机事件 | |||||
/// </summary> | |||||
public string ClickStr { get; set; } | |||||
public TheTabItemModel() | |||||
{ | |||||
SortID = 0; | |||||
} | |||||
} | |||||
} |
@@ -31,8 +31,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
public TheTextBlock() | public TheTextBlock() | ||||
{ | { | ||||
ResourceDictionary languageResDic = new ResourceDictionary(); | ResourceDictionary languageResDic = new ResourceDictionary(); | ||||
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute); | |||||
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute); | |||||
this.Resources.MergedDictionaries.Add(languageResDic); | this.Resources.MergedDictionaries.Add(languageResDic); | ||||
Height = 30; | |||||
Width = 80; | |||||
} | } | ||||
public string ControlType => "控件"; | public string ControlType => "控件"; | ||||
@@ -87,9 +89,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
} | } | ||||
} | } | ||||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||||
timer.Tick += Timer_Tick; ; | |||||
timer.Start(); | |||||
if (propertyBing.Count > 0) | |||||
{ | |||||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||||
timer.Tick += Timer_Tick; ; | |||||
timer.Start(); | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 属性刷新事件 | /// 属性刷新事件 | ||||
@@ -67,7 +67,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
object _value = b[str[1]].VarVaule; | object _value = b[str[1]].VarVaule; | ||||
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); | EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); | ||||
ChangedText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = Text,DataType = eDataType }); | |||||
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = Text,DataType = eDataType }); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -93,7 +93,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
IsEnabled = true; | IsEnabled = true; | ||||
Focusable = true; | Focusable = true; | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -109,13 +109,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
public static readonly DependencyProperty ValueChangedExecuteProperty = | public static readonly DependencyProperty ValueChangedExecuteProperty = | ||||
DependencyProperty.Register("ValueChangedExecute",typeof(string),typeof(TheTextBox),new PropertyMetadata(string.Empty)); | DependencyProperty.Register("ValueChangedExecute",typeof(string),typeof(TheTextBox),new PropertyMetadata(string.Empty)); | ||||
[Category("事件")] | [Category("事件")] | ||||
public string ChangedText | |||||
public string SendText | |||||
{ | { | ||||
get { return (string)GetValue(ChaTextProperty); } | |||||
set { SetValue(ChaTextProperty,value); } | |||||
get { return (string)GetValue(SendTextProperty); } | |||||
set { SetValue(SendTextProperty, value); } | |||||
} | } | ||||
public static readonly DependencyProperty ChaTextProperty = | |||||
DependencyProperty.Register("ChangedText",typeof(string),typeof(TheTextBox),new PropertyMetadata(string.Empty)); | |||||
public static readonly DependencyProperty SendTextProperty = | |||||
DependencyProperty.Register("SendText", typeof(string),typeof(TheTextBox),new PropertyMetadata(string.Empty)); | |||||
[Category("数据绑定-数据来源")] | [Category("数据绑定-数据来源")] | ||||
public int TimeCount | public int TimeCount | ||||
{ | { | ||||
@@ -123,7 +123,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
set { SetValue(TimeCountProperty,value); } | set { SetValue(TimeCountProperty,value); } | ||||
} | } | ||||
public static readonly DependencyProperty TimeCountProperty = | public static readonly DependencyProperty TimeCountProperty = | ||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBox),new PropertyMetadata(5)); | |||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBox),new PropertyMetadata(100)); | |||||
public event EventHandler PropertyChange; //声明一个事件 | public event EventHandler PropertyChange; //声明一个事件 | ||||
/// <summary> | /// <summary> | ||||
/// 属性刷新器 | /// 属性刷新器 | ||||
@@ -147,9 +147,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
propertyBing[propertyInfo.Name] = propName.ToString(); | propertyBing[propertyInfo.Name] = propName.ToString(); | ||||
} | } | ||||
} | } | ||||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||||
timer.Tick += Timer_Tick; ; | |||||
timer.Start(); | |||||
if (propertyBing.Count > 0) | |||||
{ | |||||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||||
timer.Tick += Timer_Tick; ; | |||||
timer.Start(); | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 属性刷新事件 | /// 属性刷新事件 | ||||
@@ -27,6 +27,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
Width = 40; | Width = 40; | ||||
Height = 40; | Height = 40; | ||||
ResourceDictionary languageResDic = new ResourceDictionary(); | |||||
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute); | |||||
this.Resources.MergedDictionaries.Add(languageResDic); | |||||
} | } | ||||
static TheTimer() | static TheTimer() | ||||
{ | { | ||||
@@ -46,7 +49,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
if (IsExecuteState) | if (IsExecuteState) | ||||
{ | { | ||||
Register(); | Register(); | ||||
Style = null; | |||||
//Style = null; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -62,21 +62,21 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
} | } | ||||
} | } | ||||
[Category("事件")] | [Category("事件")] | ||||
public string Value | |||||
public string BindingIsChecked | |||||
{ | { | ||||
get { return (string)GetValue(ValueProperty); } | |||||
set { SetValue(ValueProperty,value); } | |||||
get { return (string)GetValue(BindingIsCheckedProperty); } | |||||
set { SetValue(BindingIsCheckedProperty, value); } | |||||
} | } | ||||
public static readonly DependencyProperty ValueProperty = | |||||
DependencyProperty.Register("Value",typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty)); | |||||
public static readonly DependencyProperty BindingIsCheckedProperty = | |||||
DependencyProperty.Register("BindingIsChecked", typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty)); | |||||
[Category("事件")] | [Category("事件")] | ||||
public string Text | |||||
public string SendText | |||||
{ | { | ||||
get { return (string)GetValue(TextProperty); } | |||||
set { SetValue(TextProperty,value); } | |||||
get { return (string)GetValue(SendTextProperty); } | |||||
set { SetValue(SendTextProperty, value); } | |||||
} | } | ||||
public static readonly DependencyProperty TextProperty = | |||||
DependencyProperty.Register("Text",typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty)); | |||||
public static readonly DependencyProperty SendTextProperty = | |||||
DependencyProperty.Register("SendText", typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty)); | |||||
/// <summary> | /// <summary> | ||||
/// 不勾选时执行代码 | /// 不勾选时执行代码 | ||||
/// </summary> | /// </summary> | ||||
@@ -107,7 +107,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
set { SetValue(TimeCountProperty,value); } | set { SetValue(TimeCountProperty,value); } | ||||
} | } | ||||
public static readonly DependencyProperty TimeCountProperty = | public static readonly DependencyProperty TimeCountProperty = | ||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheToggleButton),new PropertyMetadata(5)); | |||||
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheToggleButton),new PropertyMetadata(100)); | |||||
/// <summary> | /// <summary> | ||||
/// 属性刷新器 | /// 属性刷新器 | ||||
/// </summary> | /// </summary> | ||||
@@ -127,9 +127,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
propertyBing[propertyInfo.Name] = propName.ToString(); | propertyBing[propertyInfo.Name] = propName.ToString(); | ||||
} | } | ||||
} | } | ||||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||||
timer.Tick += Timer_Tick; ; | |||||
timer.Start(); | |||||
if (propertyBing.Count > 0) | |||||
{ | |||||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||||
timer.Tick += Timer_Tick; ; | |||||
timer.Start(); | |||||
} | |||||
Click += TheToggleButton_Click; | Click += TheToggleButton_Click; | ||||
Checked += TheCheckBox_Checked; | Checked += TheCheckBox_Checked; | ||||
Unchecked += TheCheckBox_Unchecked; | Unchecked += TheCheckBox_Unchecked; | ||||
@@ -168,7 +171,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
_checked = false; | _checked = false; | ||||
} | } | ||||
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); | EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); | ||||
Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType }); | |||||
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType }); | |||||
this.GetType().GetProperty("IsChecked").SetValue(this,_checked); | this.GetType().GetProperty("IsChecked").SetValue(this,_checked); | ||||
} | } | ||||
@@ -198,7 +201,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||||
{ | { | ||||
object _value = b[str[1]].VarVaule; | object _value = b[str[1]].VarVaule; | ||||
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); | EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); | ||||
Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "False",DataType = eDataType }); | |||||
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "False",DataType = eDataType }); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -200,6 +200,7 @@ | |||||
Tag="Close" /> | Tag="Close" /> | ||||
</MenuItem> | </MenuItem> | ||||
</Menu> | </Menu> | ||||
</Grid> | </Grid> | ||||
<StackPanel | <StackPanel | ||||
@@ -21,14 +21,34 @@ namespace BeDesignerSCADA.Adorners | |||||
base.OnRender(drawingContext); | base.OnRender(drawingContext); | ||||
Rect adornerRect = new Rect(AdornedElement.DesiredSize); | Rect adornerRect = new Rect(AdornedElement.DesiredSize); | ||||
SolidColorBrush renderBrush = Brushes.Transparent; | SolidColorBrush renderBrush = Brushes.Transparent; | ||||
Pen render = new Pen(new SolidColorBrush(Colors.OrangeRed), 1); | |||||
render.DashStyle = new DashStyle(new List<double>() { 4, 2 }, 2); | |||||
drawingContext.DrawRectangle(renderBrush, render, new Rect(adornerRect.TopLeft.X, adornerRect.TopLeft.Y, adornerRect.Width, adornerRect.Height)); | |||||
Pen renderPen1 = new Pen(new SolidColorBrush(Colors.Tomato), 1); | |||||
Pen renderPen = new Pen(new SolidColorBrush(Colors.Tomato), 1); | |||||
renderPen1.DashStyle = new DashStyle(new List<double>() { 6, 4 }, 4); | |||||
//1.绘制边框 | |||||
drawingContext.DrawRectangle(renderBrush, renderPen1, new Rect(adornerRect.TopLeft.X, adornerRect.TopLeft.Y, adornerRect.Width, adornerRect.Height)); | |||||
//2.绘制拖动正方形 | |||||
// Draw a circle at each corner. | |||||
drawingContext.DrawRectangle(renderBrush, renderPen, new Rect(adornerRect.TopLeft.X - 2.5, adornerRect.TopLeft.Y - 2.5, 5, 5)); | |||||
drawingContext.DrawRectangle(renderBrush, renderPen, new Rect(adornerRect.TopRight.X - 2.5, adornerRect.TopRight.Y - 2.5, 5, 5)); | |||||
drawingContext.DrawRectangle(renderBrush, renderPen, new Rect(adornerRect.BottomLeft.X - 2.5, adornerRect.BottomLeft.Y - 2.5, 5, 5)); | |||||
drawingContext.DrawRectangle(renderBrush, renderPen, new Rect(adornerRect.BottomRight.X - 2.5, adornerRect.BottomRight.Y - 2.5, 5, 5)); | |||||
//3.绘制4个中心正方形 | |||||
drawingContext.DrawRectangle(renderBrush, renderPen, | |||||
new Rect(adornerRect.TopLeft.X + adornerRect.Width / (double)2 - 2.5, adornerRect.TopLeft.Y - 2.5, 5, 5)); | |||||
drawingContext.DrawRectangle(renderBrush, renderPen, | |||||
new Rect(adornerRect.TopRight.X - 2.5, adornerRect.TopRight.Y + adornerRect.Height / (double)2 - 2.5, 5, 5)); | |||||
drawingContext.DrawRectangle(renderBrush, renderPen, | |||||
new Rect(adornerRect.BottomLeft.X - 2.5, adornerRect.BottomLeft.Y - adornerRect.Height / (double)2 - 2.5, 5, 5)); | |||||
drawingContext.DrawRectangle(renderBrush, renderPen, | |||||
new Rect(adornerRect.BottomRight.X - adornerRect.Width / (double)2 - 2.5, adornerRect.BottomRight.Y - 2.5, 5, 5)); | |||||
MouseDown += SelectionAdorner_MouseDown; | MouseDown += SelectionAdorner_MouseDown; | ||||
MouseMove += SelectionAdorner_MouseMove; | MouseMove += SelectionAdorner_MouseMove; | ||||
MouseUp += SelectionAdorner_MouseUp; | MouseUp += SelectionAdorner_MouseUp; | ||||
ResourceDictionary languageResDic = new ResourceDictionary(); | |||||
languageResDic.Source = new Uri(@"/BeDesignerSCADA;component/Themes/Styles.xaml", UriKind.RelativeOrAbsolute); | |||||
this.Resources.MergedDictionaries.Add(languageResDic); | |||||
ContextMenu = FindResource("AdornerRightMenu") as ContextMenu; | ContextMenu = FindResource("AdornerRightMenu") as ContextMenu; | ||||
Tag = CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement); | Tag = CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement); | ||||
@@ -43,13 +63,83 @@ namespace BeDesignerSCADA.Adorners | |||||
CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement).ClearAlignLine(); | CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement).ClearAlignLine(); | ||||
} | } | ||||
/// <summary> | |||||
/// 鼠标最后一次按下位置 | |||||
/// </summary> | |||||
Point lastPoint = new Point(); | Point lastPoint = new Point(); | ||||
/// <summary> | |||||
/// 鼠标在控件中的位置 | |||||
/// </summary> | |||||
public MousePos mousePos; | |||||
double tempX = 0d; | double tempX = 0d; | ||||
double tempY = 0d; | double tempY = 0d; | ||||
double movePx = 0d; | double movePx = 0d; | ||||
/// <summary> | |||||
/// 改变鼠标状态,鼠标在控件上,下,左,右,左上,右上,左下,右下,向上不同的光标 | |||||
/// </summary> | |||||
private void SetCursor() | |||||
{ | |||||
Rect adornerRect = new Rect(AdornedElement.DesiredSize); | |||||
double _left = CanvasPanel.GetLeft(AdornedElement); | |||||
double _top = CanvasPanel.GetTop(AdornedElement); | |||||
var DQPoint = Mouse.GetPosition(CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement)); | |||||
if (DQPoint.X >= (adornerRect.TopLeft.X - 2.5 + _left) && DQPoint.X <= (adornerRect.TopLeft.X + 2.5 + _left) && DQPoint.Y >= (adornerRect.TopLeft.Y - 2.5 + _top) && DQPoint.Y <= (adornerRect.TopLeft.Y + 2.5 + _top)) | |||||
{ | |||||
//左上 | |||||
this.Cursor = Cursors.SizeNWSE; mousePos = MousePos.LeftTop; | |||||
} | |||||
else if (DQPoint.X >= (adornerRect.TopRight.X - 2.5 + _left) && DQPoint.X <= (adornerRect.TopRight.X + 2.5 + _left) && DQPoint.Y >= (adornerRect.TopRight.Y - 2.5 + _top) && DQPoint.Y <= (adornerRect.TopRight.Y + 2.5 + _top)) | |||||
{ | |||||
//右上 | |||||
this.Cursor = Cursors.SizeNESW; mousePos = MousePos.RightTop; | |||||
} | |||||
else if (DQPoint.X >= (adornerRect.BottomLeft.X - 2.5 + _left) && DQPoint.X <= (adornerRect.BottomLeft.X + 2.5 + _left) && DQPoint.Y >= (adornerRect.BottomLeft.Y - 2.5 + _top) && DQPoint.Y <= (adornerRect.BottomLeft.Y + 2.5 + _top)) | |||||
{ | |||||
//左下 | |||||
this.Cursor = Cursors.SizeNESW; mousePos = MousePos.LeftBottom ; | |||||
} | |||||
else if (DQPoint.X >= (adornerRect.BottomRight.X - 2.5 + _left) && DQPoint.X <= (adornerRect.BottomRight.X + 2.5 + _left) && DQPoint.Y >= (adornerRect.BottomRight.Y - 2.5 + _top) && DQPoint.Y <= (adornerRect.BottomRight.Y + 2.5 + _top)) | |||||
{ | |||||
//右下 | |||||
this.Cursor = Cursors.SizeNWSE; mousePos = MousePos.RightBottom; | |||||
} | |||||
else if (DQPoint.X >= (adornerRect.TopLeft.X + adornerRect.Width / (double)2 - 2.5 + _left) && DQPoint.X <= (adornerRect.TopLeft.X + adornerRect.Width / (double)2 + 2.5 + _left) && DQPoint.Y >= (adornerRect.TopLeft.Y - 2.5 + _top) && DQPoint.Y <= (adornerRect.TopLeft.Y + 2.5 + _top)) | |||||
{ | |||||
//上中 | |||||
this.Cursor = Cursors.SizeNS; mousePos = MousePos.Top; | |||||
} | |||||
else if (DQPoint.X >= (adornerRect.BottomRight.X - adornerRect.Width / (double)2 - 2.5 + _left) && DQPoint.X <= (adornerRect.BottomRight.X - adornerRect.Width / (double)2 + 2.5 + _left) && DQPoint.Y >= (adornerRect.BottomRight.Y - 2.5 + _top) && DQPoint.Y <= (adornerRect.BottomRight.Y + 2.5 + _top)) | |||||
{ | |||||
//下中 | |||||
this.Cursor = Cursors.SizeNS; mousePos = MousePos.Bottom; | |||||
} | |||||
else if (DQPoint.X >= (adornerRect.TopRight.X - 2.5 + _left) && DQPoint.X <= (adornerRect.TopRight.X + 2.5 + _left) && DQPoint.Y >= (adornerRect.TopRight.Y + adornerRect.Height / (double)2 - 2.5 + _top) && DQPoint.Y <= (adornerRect.TopRight.Y + adornerRect.Height / (double)2 + 2.5 + _top)) | |||||
{ | |||||
//右中 | |||||
this.Cursor = Cursors.SizeWE; mousePos = MousePos.Right; | |||||
} | |||||
else if (DQPoint.X >= (adornerRect.BottomLeft.X - 2.5 + _left) && DQPoint.X <= (adornerRect.BottomLeft.X + 2.5 + _left) && DQPoint.Y >= (adornerRect.BottomLeft.Y - adornerRect.Height / (double)2 - 2.5 + _top) && DQPoint.Y <= (adornerRect.BottomLeft.Y - adornerRect.Height / (double)2 + 2.5 + _top)) | |||||
{ | |||||
//左中 | |||||
this.Cursor = Cursors.SizeWE; mousePos = MousePos.Left; | |||||
} | |||||
else | |||||
{ | |||||
this.Cursor = Cursors.Arrow; mousePos = MousePos.None; | |||||
} | |||||
} | |||||
private void SelectionAdorner_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) | private void SelectionAdorner_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) | ||||
{ | { | ||||
if (Mouse.LeftButton == MouseButtonState.Pressed) | |||||
if (Mouse.LeftButton != MouseButtonState.Pressed | |||||
&& Mouse.MiddleButton != MouseButtonState.Pressed | |||||
&& Mouse.RightButton != MouseButtonState.Pressed)//鼠标没有按下,改变鼠标状态 | |||||
{ | |||||
SetCursor(); | |||||
} | |||||
if (this.Cursor == Cursors.Arrow && Mouse.LeftButton == MouseButtonState.Pressed)//移动控件 | |||||
{ | { | ||||
if (lastPoint.X == 0 && lastPoint.Y == 0) | if (lastPoint.X == 0 && lastPoint.Y == 0) | ||||
{ | { | ||||
@@ -81,15 +171,21 @@ namespace BeDesignerSCADA.Adorners | |||||
tempY -= offsetY; | tempY -= offsetY; | ||||
canvas.MoveControls(0, offsetY); | canvas.MoveControls(0, offsetY); | ||||
} | } | ||||
} | } | ||||
else if (Mouse.MiddleButton == MouseButtonState.Pressed) | |||||
else if (this.Cursor != Cursors.Arrow && Mouse.LeftButton == MouseButtonState.Pressed) | |||||
{ | |||||
CaptureMouse(); | |||||
//lastPoint 最后一次鼠标按下位置 nowPonit 鼠标当前位置 mousePos 鼠标在控件中的位置 | |||||
var nowPoint = Mouse.GetPosition(CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement)); | |||||
CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement).ReCtrlSize(lastPoint, nowPoint, mousePos); | |||||
lastPoint = nowPoint; | |||||
} | |||||
else if (Mouse.MiddleButton == MouseButtonState.Pressed)//中间同步拖拽控件大小 | |||||
{ | { | ||||
CaptureMouse(); | CaptureMouse(); | ||||
var nowPoint = Mouse.GetPosition(CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement)); | var nowPoint = Mouse.GetPosition(CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement)); | ||||
int offsetX = (int)(nowPoint.X - lastPoint.X); | int offsetX = (int)(nowPoint.X - lastPoint.X); | ||||
int offsetY = (int)(nowPoint.Y - lastPoint.Y); | int offsetY = (int)(nowPoint.Y - lastPoint.Y); | ||||
CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement).ZoomControls(offsetX, offsetY); | CanvasPanel.GetParentObject<CanvasPanel>(AdornedElement).ZoomControls(offsetX, offsetY); | ||||
lastPoint = nowPoint; | lastPoint = nowPoint; | ||||
} | } | ||||
@@ -101,14 +197,32 @@ namespace BeDesignerSCADA.Adorners | |||||
lastPoint = Mouse.GetPosition(canv); | lastPoint = Mouse.GetPosition(canv); | ||||
Keyboard.Focus(canv); | Keyboard.Focus(canv); | ||||
//if (Keyboard.Modifiers == ModifierKeys.Control) | |||||
//{ | |||||
// if (canv.SelectedItems.Contains(AdornedElement)) | |||||
// { | |||||
// canv.SelectedItems.Remove(AdornedElement as FrameworkElement); | |||||
// canv.RefreshSelection(); | |||||
// } | |||||
//} | |||||
if (Keyboard.Modifiers == ModifierKeys.Control && e != null) | |||||
{ | |||||
var layer = AdornerLayer.GetAdornerLayer(AdornedElement); | |||||
var arr = layer.GetAdorners(AdornedElement); | |||||
if (canv.SelectedItems.Contains(AdornedElement)) | |||||
{ | |||||
canv.SelectedItems.Remove(AdornedElement as FrameworkElement); | |||||
canv.RefreshSelection(); | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 鼠标在控件中的位置 | |||||
/// </summary> | |||||
public enum MousePos | |||||
{ | |||||
None, | |||||
Top, | |||||
Right, | |||||
Bottom, | |||||
Left, | |||||
LeftTop, | |||||
LeftBottom, | |||||
RightTop, | |||||
RightBottom | |||||
} | |||||
} | } |
@@ -1,9 +1,8 @@ | |||||
<Application x:Class="BeDesignerSCADA.App" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:local="clr-namespace:BeDesignerSCADA" | |||||
StartupUri="MainWindow.xaml"> | |||||
<Application.Resources> | |||||
</Application.Resources> | |||||
<Application | |||||
x:Class="BeDesignerSCADA.App" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:local="clr-namespace:BeDesignerSCADA" | |||||
StartupUri="MainWindow.xaml"> | |||||
<Application.Resources /> | |||||
</Application> | </Application> |
@@ -14,7 +14,7 @@ namespace BeDesignerSCADA.Common | |||||
{ | { | ||||
public static string[] ableProperties = new string[] | public static string[] ableProperties = new string[] | ||||
{ "IsChecked", "Value", "CurValue", "StatusValue", "NumberValue", "Text", | { "IsChecked", "Value", "CurValue", "StatusValue", "NumberValue", "Text", | ||||
"Direction","RefreshData","ChangedText","Content" | |||||
"Direction","RefreshData","ChangedText","Content","SendText" | |||||
}; | }; | ||||
public static List<ControlName> GetCustomerControlProperty(List<FrameworkElement> selectItems) | public static List<ControlName> GetCustomerControlProperty(List<FrameworkElement> selectItems) | ||||
{ | { | ||||
@@ -35,9 +35,6 @@ namespace BeDesignerSCADA.Controls | |||||
SetTopLayerCommand = new RelayCommand(SetTopLayer); | SetTopLayerCommand = new RelayCommand(SetTopLayer); | ||||
SetBottomLayerCommand = new RelayCommand(SetBottomLayer); | SetBottomLayerCommand = new RelayCommand(SetBottomLayer); | ||||
SelectedItems = new ObservableCollection<FrameworkElement>(); | SelectedItems = new ObservableCollection<FrameworkElement>(); | ||||
//ResourceDictionary resourceDictionary = new ResourceDictionary(); | |||||
//Application.LoadComponent(resourceDictionary, new Uri("/BeDesignerSCADA;component/Themes/Styles.xaml", UriKind.Relative)); | |||||
//ContextMenu = resourceDictionary.FindName("CanvasRightMenu") as ContextMenu; | |||||
ContextMenu=Application.Current.Resources["CanvasRightMenu"] as ContextMenu; | ContextMenu=Application.Current.Resources["CanvasRightMenu"] as ContextMenu; | ||||
KeyDown += CanvasPanel_KeyDown; | KeyDown += CanvasPanel_KeyDown; | ||||
} | } | ||||
@@ -549,6 +546,98 @@ namespace BeDesignerSCADA.Controls | |||||
} | } | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 调整控件大小:鼠标在控件中的不同位置,调整控件大小 | |||||
/// </summary> | |||||
public void ReCtrlSize(Point lastPoint,Point currentPoint, MousePos mousePos) | |||||
{ | |||||
foreach (var control in SelectedItems) | |||||
{ | |||||
//计算偏移量 | |||||
double x = currentPoint.X - lastPoint.X; | |||||
double y = currentPoint.Y - lastPoint.Y; | |||||
switch (mousePos) | |||||
{ | |||||
case MousePos.None: | |||||
break; | |||||
case MousePos.Top://上,调整 | |||||
if (control.Height - y > control.MinHeight) | |||||
{ | |||||
SetTop(control, GetTop(control) + y); | |||||
//control.Top += y; | |||||
control.Height -= y; | |||||
} | |||||
break; | |||||
case MousePos.Right: | |||||
if (control.Width + x > control.MinWidth) | |||||
{ | |||||
control.Width += x; | |||||
} | |||||
break; | |||||
case MousePos.Bottom: | |||||
if (control.Height + y > control.MinHeight) | |||||
{ | |||||
control.Height += y; | |||||
} | |||||
break; | |||||
case MousePos.Left: | |||||
if (control.Width - x > control.MinWidth) | |||||
{ | |||||
SetLeft(control, GetLeft(control) + x);//control.Left += x; | |||||
control.Width -= x; | |||||
} | |||||
break; | |||||
case MousePos.LeftTop://左上 | |||||
if (control.Width - x > control.MinWidth) | |||||
{ | |||||
SetLeft(control, GetLeft(control) + x);//control.Left += x; | |||||
control.Width -= x; | |||||
} | |||||
if (control.Height - y > control.MinHeight) | |||||
{ | |||||
SetTop(control, GetTop(control) + y);//control.Top += y; | |||||
control.Height -= y; | |||||
} | |||||
break; | |||||
case MousePos.LeftBottom: | |||||
if (control.Width - x > control.MinWidth) | |||||
{ | |||||
SetLeft(control, GetLeft(control) + x);//control.Left += x; | |||||
control.Width -= x; | |||||
} | |||||
if (control.Height + y > control.MinHeight) | |||||
{ | |||||
control.Height += y; | |||||
} | |||||
break; | |||||
case MousePos.RightTop: | |||||
if (control.Width + x > MinWidth) | |||||
{ | |||||
control.Width += x; | |||||
} | |||||
if (control.Height - y > MinHeight) | |||||
{ | |||||
SetTop(control, GetTop(control) + y);//control.Top += y; | |||||
control.Height -= y; | |||||
} | |||||
break; | |||||
case MousePos.RightBottom: | |||||
if (control.Width + x > MinWidth) | |||||
{ | |||||
control.Width += x; | |||||
} | |||||
if (control.Height + y > MinHeight) | |||||
{ | |||||
control.Height += y; | |||||
} | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
#endregion | #endregion | ||||
#region 对齐操作 | #region 对齐操作 | ||||
@@ -0,0 +1,294 @@ | |||||
<UserControl x:Class="BeDesignerSCADA.Controls.MainCanvasPanel" | |||||
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:BeDesignerSCADA.Controls" | |||||
xmlns:s="clr-namespace:BeDesignerSCADA.Converters" | |||||
xmlns:icon="http://metro.mahapps.com/winfx/xaml/iconpacks" | |||||
xmlns:avae="http://icsharpcode.net/sharpdevelop/avalonedit" | |||||
xmlns:ctl="clr-namespace:BeDesignerSCADA.Controls" | |||||
xmlns:mypro="http://schemas.xceed.com/wpf/xaml/toolkit" | |||||
mc:Ignorable="d" | |||||
d:DesignHeight="900" d:DesignWidth="1400"> | |||||
<UserControl.Resources> | |||||
<ResourceDictionary> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</UserControl.Resources> | |||||
<Grid x:Name="grid"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="240"/> | |||||
<ColumnDefinition/> | |||||
<ColumnDefinition Width="350"/> | |||||
</Grid.ColumnDefinitions> | |||||
<!--左侧选择区域--> | |||||
<Grid Background="White" > | |||||
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4"> | |||||
<ListBox x:Name="CtlList" Background="Transparent" ItemTemplate="{DynamicResource ToolBoxStyle}" BorderThickness="0" PreviewMouseMove="CtlList_PreviewMouseMove"> | |||||
</ListBox> | |||||
</Border> | |||||
</Grid> | |||||
<!--中间控制区域--> | |||||
<DockPanel Grid.Column="1"> | |||||
<!--按钮控制--> | |||||
<DockPanel LastChildFill="False" DockPanel.Dock="Top" Height="24" Margin="4 4 4 0"> | |||||
<Button Margin="0" Width="24" Padding="0" Click="AglinLeftBtn_Click" ToolTip="左对齐"> | |||||
<icon:PackIconModern Kind="AlignLeft"/> | |||||
</Button> | |||||
<Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinRightBtn_Click" ToolTip="右对齐"> | |||||
<icon:PackIconModern Kind="AlignRight"/> | |||||
</Button> | |||||
<Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinCenterBtn_Click" ToolTip="中心对齐"> | |||||
<icon:PackIconModern Kind="AlignCenter"/> | |||||
</Button> | |||||
<Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinTopBtn_Click" ToolTip="上对齐"> | |||||
<icon:PackIconModern Kind="BorderTop"/> | |||||
</Button> | |||||
<Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinBottomBtn_Click" ToolTip="下对齐"> | |||||
<icon:PackIconModern Kind="BorderBottom"/> | |||||
</Button> | |||||
<Button Margin="16 0 0 0" Width="24" Padding="0" Click="HorizontalLayoutBtn_Click" ToolTip="水平分布"> | |||||
<icon:PackIconModern Kind="BorderHorizontal"/> | |||||
</Button> | |||||
<Button Margin="4 0 0 0" Width="24" Padding="0" Click="VerticalLayoutBtn_Click" ToolTip="垂直分布"> | |||||
<icon:PackIconModern Kind="BorderVertical"/> | |||||
</Button> | |||||
<ToggleButton IsChecked="{Binding UseAutoAlignment, ElementName=cav, Mode=TwoWay}" ToolTip="使用对齐网格" Margin="4 0 0 0" Width="24" Padding="0"> | |||||
<icon:PackIconModern Kind="CellAlign"/> | |||||
</ToggleButton> | |||||
<Button Margin="16 0 0 0" Width="24" Padding="0" ToolTip="复制" Command="{Binding ElementName=cav, Path=CopySelectItemsCommand}"> | |||||
<icon:PackIconModern Kind="PageCopy"/> | |||||
</Button> | |||||
<Button Margin="4 0 0 0" Width="24" Padding="0" ToolTip="粘贴" Command="{Binding ElementName=cav, Path=PasteSelectItemsCommand}"> | |||||
<icon:PackIconModern Kind="ClipboardPaste"/> | |||||
</Button> | |||||
<Button Margin="4 0 0 0" Width="24" Padding="0" ToolTip="删除" Command="{Binding ElementName=cav, Path=DeleteSelectItemsCommand}"> | |||||
<icon:PackIconModern Kind="Delete"/> | |||||
</Button> | |||||
<Button x:Name="RunBtn" Margin="16 0 0 0" Padding="0" Click="RunBtn_Click" Command="{Binding RunUiCommand}"> | |||||
<Button.Style> | |||||
<Style TargetType="Button"> | |||||
<Setter Property="Tag" Value="运行"/> | |||||
<Setter Property="Content"> | |||||
<Setter.Value> | |||||
<StackPanel Orientation="Horizontal" Margin="8 0"> | |||||
<icon:PackIconModern Kind="ControlPlay" VerticalAlignment="Center" Foreground="#28B60F" Width="8"/> | |||||
<TextBlock Text="运行" Margin="4 0" VerticalAlignment="Center"/> | |||||
</StackPanel> | |||||
</Setter.Value> | |||||
</Setter> | |||||
<Style.Triggers> | |||||
<DataTrigger Binding="{Binding IsRunning}" Value="True"> | |||||
<Setter Property="Tag" Value="停止"/> | |||||
<Setter Property="Content"> | |||||
<Setter.Value> | |||||
<StackPanel Orientation="Horizontal" Margin="8 0"> | |||||
<icon:PackIconModern Kind="ControlStop" VerticalAlignment="Center" Foreground="#B60F0F" Width="8"/> | |||||
<TextBlock Text="停止" Margin="4 0" VerticalAlignment="Center"/> | |||||
</StackPanel> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</DataTrigger> | |||||
</Style.Triggers> | |||||
</Style> | |||||
</Button.Style> | |||||
</Button> | |||||
<Button x:Name="SaveBtn" Margin="16 0 0 0" Padding="0" Click="SaveBtn_Click"> | |||||
<StackPanel Orientation="Horizontal" Margin="8 0"> | |||||
<icon:PackIconModern Kind="Save" VerticalAlignment="Center" Width="12"/> | |||||
<TextBlock Text="保存" Margin="4 0" VerticalAlignment="Center"/> | |||||
</StackPanel> | |||||
</Button> | |||||
<Button x:Name="LoadBtn" Margin="4 0 0 0" Padding="0" Click="LoadBtn_Click"> | |||||
<StackPanel Orientation="Horizontal" Margin="8 0"> | |||||
<icon:PackIconModern Kind="DiskDownload" VerticalAlignment="Center" Width="14"/> | |||||
<TextBlock Text="加载" Margin="4 0" VerticalAlignment="Center"/> | |||||
</StackPanel> | |||||
</Button> | |||||
<Button x:Name="MNBtn" Margin="4 0 0 0" Padding="0" Click="MNBtn_Click"> | |||||
<StackPanel Orientation="Horizontal" Margin="8 0"> | |||||
<icon:PackIconModern Kind="MessageSend" VerticalAlignment="Center" Width="14"/> | |||||
<TextBlock Text="模拟消息" Margin="4 0" VerticalAlignment="Center"/> | |||||
</StackPanel> | |||||
</Button> | |||||
<ToggleButton x:Name="showCode" Click="showCode_Click" DockPanel.Dock="Right" Margin="4 0 0 0" Padding="4 0"> | |||||
<icon:Material Kind="FileCode"/> | |||||
</ToggleButton> | |||||
<Slider DockPanel.Dock="Right" Width="100" Maximum="16" Minimum="1" Margin="4 0 0 0" | |||||
HorizontalContentAlignment="Center" Value="{Binding ElementName=cav,Path=GridPxiel}" ></Slider> | |||||
<TextBlock DockPanel.Dock="Right" Text="对齐:" VerticalAlignment="Center" Margin="16 0 0 0"/> | |||||
</DockPanel> | |||||
<!--中间画布--> | |||||
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4"> | |||||
<Border.Background> | |||||
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/> | |||||
</Border.Background> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition/> | |||||
<ColumnDefinition Width="auto"/> | |||||
</Grid.ColumnDefinitions> | |||||
<ctl:CanvasPanel x:Name="cav" Visibility="{Binding CanvasPanelVisibility}" SelectedItem="{Binding CanSelectedItem,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AllowDrop="True" RenderTransformOrigin="0.5,0.5" ClipToBounds="True" UseLayoutRounding="True" Focusable="True" SnapsToDevicePixels="True"> | |||||
<ctl:CanvasPanel.Background> | |||||
<VisualBrush TileMode="Tile" Viewport="0,0,20,20" ViewportUnits="Absolute"> | |||||
<VisualBrush.Visual> | |||||
<Rectangle Width="20" Height="20" StrokeDashArray="4,2" StrokeThickness="0.5" Stroke="#CBCBCB"> | |||||
<Rectangle.Style> | |||||
<Style TargetType="{x:Type Rectangle}"> | |||||
<Style.Triggers> | |||||
<DataTrigger Binding="{Binding UseAutoAlignment, RelativeSource={RelativeSource AncestorType={x:Type ctl:CanvasPanel}, Mode=FindAncestor}}" Value="True"> | |||||
<Setter Property="Visibility" Value="Visible"/> | |||||
</DataTrigger> | |||||
<DataTrigger Binding="{Binding UseAutoAlignment, RelativeSource={RelativeSource AncestorType={x:Type ctl:CanvasPanel}, Mode=FindAncestor}}" Value="False"> | |||||
<Setter Property="Visibility" Value="Collapsed"/> | |||||
</DataTrigger> | |||||
</Style.Triggers> | |||||
</Style> | |||||
</Rectangle.Style> | |||||
</Rectangle> | |||||
</VisualBrush.Visual> | |||||
</VisualBrush> | |||||
</ctl:CanvasPanel.Background> | |||||
<ctl:CanvasPanel.RenderTransform> | |||||
<TransformGroup> | |||||
<TranslateTransform x:Name="CanvasTranslate"/> | |||||
</TransformGroup> | |||||
</ctl:CanvasPanel.RenderTransform> | |||||
</ctl:CanvasPanel> | |||||
<ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding RunCanvasVisibility}" /> | |||||
<avae:TextEditor x:Name="codeEditor" ShowLineNumbers="True" Padding="4" WordWrap="True" IsReadOnly="True" SyntaxHighlighting="XML" BorderThickness="1 0 0 0" BorderBrush="{StaticResource ControlBorderBrush}" Grid.Column="1" Width="480" Visibility="{Binding ElementName=showCode, Path=IsChecked, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"/> | |||||
</Grid> | |||||
</Border> | |||||
</DockPanel> | |||||
<GridSplitter HorizontalAlignment="Right" Grid.Column="1" VerticalAlignment="Stretch" Width="5" Background="Transparent"/> | |||||
<!--右侧属性栏--> | |||||
<Grid Grid.Column="2"> | |||||
<TabControl SelectedIndex="0"> | |||||
<TabItem Header="控制协议"> | |||||
<mypro:PropertyGrid x:Name="kzxy" SelectedObject="{Binding PropeObject}" | |||||
Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True" | |||||
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False" | |||||
CategoryGroupHeaderTemplate="{DynamicResource Category}"> | |||||
<mypro:PropertyGrid.EditorDefinitions> | |||||
<!--EditorTemplateDefinition可添加多个--> | |||||
<!--要修改编辑模板的属性的名称--> | |||||
<mypro:EditorTemplateDefinition TargetProperties="点击事件,值改变事件,定时触发,勾选事件,取消勾选事件" > | |||||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||||
<DataTemplate> | |||||
<!--此处可自由发挥--> | |||||
<Grid> | |||||
<!-- Command生效: DataTemplate的DataContext指代不明确,需要改为父类的DataContext。 参数Value表示原对象--> | |||||
<!--Command="{Binding Path=DataContext.PropeSetCommand ,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=xctk:PropertyGrid}}"--> | |||||
<!--DataContext="{Binding DataContext, ElementName=window}" Command="{Binding PropeSetCommand}" CommandParameter="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"--> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="*" x:Name="key"/> | |||||
<ColumnDefinition Width="35"/> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBox Width="{Binding Width, ElementName=key}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox> | |||||
<ToggleButton Grid.Column="1" Height="25" Content="编辑" Width="30" HorizontalAlignment="Left" Click="ToggleButton_Click"></ToggleButton> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||||
</mypro:EditorTemplateDefinition> | |||||
<mypro:EditorTemplateDefinition TargetProperties="代码过滤脚本" > | |||||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||||
<DataTemplate> | |||||
<!--此处可自由发挥--> | |||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> | |||||
<TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" TextWrapping="Wrap"></TextBox> | |||||
</ScrollViewer> | |||||
</DataTemplate> | |||||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||||
</mypro:EditorTemplateDefinition> | |||||
<mypro:EditorTemplateDefinition TargetProperties="设备解析变量" > | |||||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||||
<DataTemplate> | |||||
<!--此处可自由发挥--> | |||||
<Grid> | |||||
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}" | |||||
></ComboBox> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||||
</mypro:EditorTemplateDefinition> | |||||
<mypro:EditorTemplateDefinition TargetProperties="设备名称" > | |||||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||||
<DataTemplate> | |||||
<!--此处可自由发挥--> | |||||
<Grid> | |||||
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevNameList}" | |||||
></ComboBox> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||||
</mypro:EditorTemplateDefinition> | |||||
<mypro:EditorTemplateDefinition TargetProperties="文本,文本1,标题,变量,勾选状态" > | |||||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||||
<DataTemplate> | |||||
<!--此处可自由发挥--> | |||||
<Grid> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition/> | |||||
<RowDefinition/> | |||||
</Grid.RowDefinitions> | |||||
<Grid Margin="0,5,0,5"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="40" /> | |||||
<ColumnDefinition Width="*" x:Name="key"/> | |||||
<ColumnDefinition Width="*" x:Name="Text"/> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock>绑定:</TextBlock> | |||||
<ComboBox x:Name="namebox" DropDownOpened="namebox_DropDownOpened" Grid.Column="1" Height="25" IsTextSearchEnabled="True" IsEditable="True" Tag="{Binding Text, ElementName=valuebox}" TextBoxBase.TextChanged="ComboBoxName_TextChanged" | |||||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevNameList}"> | |||||
</ComboBox> | |||||
<ComboBox x:Name="valuebox" DropDownOpened="valuebox_DropDownOpened" Grid.Column="2" Height="25" IsTextSearchEnabled="True" IsEditable="True" Tag="{Binding Text, ElementName=namebox}" TextBoxBase.TextChanged="ComboBoxValue_TextChanged" | |||||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}"/> | |||||
</Grid> | |||||
<TextBox Grid.Row="2" x:Name="wenben" Padding="5" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||||
</mypro:EditorTemplateDefinition> | |||||
</mypro:PropertyGrid.EditorDefinitions> | |||||
</mypro:PropertyGrid> | |||||
</TabItem> | |||||
<TabItem Header="控件样式"> | |||||
<mypro:PropertyGrid x:Name="dsdsdsd" | |||||
Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True" | |||||
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False" | |||||
CategoryGroupHeaderTemplate="{DynamicResource Category}" SelectedObject="{Binding SelectedItem,ElementName=cav,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||||
</TabItem> | |||||
</TabControl> | |||||
</Grid> | |||||
</Grid> | |||||
</UserControl> |
@@ -0,0 +1,359 @@ | |||||
using BeDesignerSCADA.ViewModel; | |||||
using BeDesignerSCADA.ViewModel; | |||||
using BPASmart.Model; | |||||
using BPASmartClient.Compiler; | |||||
using BPASmartClient.DATABUS; | |||||
using BPASmartClient.MessageName; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.IO; | |||||
using System.Linq; | |||||
using System.Reflection; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows; | |||||
using System.Windows.Controls; | |||||
using System.Windows.Controls.Primitives; | |||||
using System.Windows.Data; | |||||
using System.Windows.Documents; | |||||
using System.Windows.Forms; | |||||
using System.Windows.Input; | |||||
using System.Windows.Media; | |||||
using System.Windows.Media.Animation; | |||||
using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | |||||
using System.Windows.Shapes; | |||||
namespace BeDesignerSCADA.Controls | |||||
{ | |||||
/// <summary> | |||||
/// MainCanvasPanel.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class MainCanvasPanel : System.Windows.Controls.UserControl | |||||
{ | |||||
/// <summary> | |||||
/// 布局文件路径 | |||||
/// </summary> | |||||
public string Path=string.Empty; | |||||
MainViewModel viewModel = new MainViewModel(); | |||||
public MainCanvasPanel(string _Path) | |||||
{ | |||||
InitializeComponent(); | |||||
Path= _Path; | |||||
this.DataContext = viewModel; | |||||
viewModel.Loaded(cav, runCanvas); | |||||
//控件加载 | |||||
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); | |||||
var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name); | |||||
CtlList.ItemsSource = controls; | |||||
//读取文件 | |||||
FileRead(_Path); | |||||
} | |||||
//public MainCanvasPanel() | |||||
//{ | |||||
// InitializeComponent(); | |||||
// this.DataContext = viewModel; | |||||
// viewModel.Loaded(cav, runCanvas); | |||||
// //控件加载 | |||||
// Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); | |||||
// var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name); | |||||
// CtlList.ItemsSource = controls; | |||||
//} | |||||
#region 位置调整 | |||||
/// <summary> | |||||
/// 左对齐 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void AglinLeftBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
cav.AlignLeft(); | |||||
} | |||||
/// <summary> | |||||
/// 底部对齐 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void AglinBottomBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
cav.AlignBottom(); | |||||
} | |||||
/// <summary> | |||||
/// 顶部对齐 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void AglinTopBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
cav.AlignTop(); | |||||
} | |||||
/// <summary> | |||||
/// 右对齐 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void AglinRightBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
cav.AlignRight(); | |||||
} | |||||
/// <summary> | |||||
/// 居中 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void AglinCenterBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
cav.AlignCenter(); | |||||
} | |||||
/// <summary> | |||||
/// 垂直分布 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void VerticalLayoutBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
cav.VertialLayout(); | |||||
} | |||||
/// <summary> | |||||
/// 水平分布 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void HorizontalLayoutBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
cav.HorizontalLayout(); | |||||
} | |||||
#endregion | |||||
#region 其他事件操作 | |||||
/// <summary> | |||||
/// 运行 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void RunBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
if (sender is System.Windows.Controls.Button btn) | |||||
{ | |||||
if (btn.Tag.ToString() == "运行") | |||||
{ | |||||
cav.ClearSelection(); | |||||
runCanvas.Run(cav.Generator()); | |||||
} | |||||
else if (btn.Tag.ToString() == "停止") | |||||
{ | |||||
runCanvas.Destory(); | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 加载 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void LoadBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
OpenFileDialog ofd = new OpenFileDialog(); | |||||
ofd.Filter = "布局文件|*.lay"; | |||||
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) | |||||
{ | |||||
cav.Load(ofd.FileName); | |||||
} | |||||
DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromMilliseconds(250))); | |||||
da.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; | |||||
CanvasTranslate.BeginAnimation(TranslateTransform.XProperty, da); | |||||
DoubleAnimation daop = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(250))); | |||||
daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; | |||||
cav.BeginAnimation(OpacityProperty, daop); | |||||
} | |||||
/// <summary> | |||||
/// 读取文件 | |||||
/// </summary> | |||||
/// <param name="path"></param> | |||||
public void FileRead(string path) | |||||
{ | |||||
try | |||||
{ | |||||
if (File.Exists(path)) | |||||
{ | |||||
cav.Load(path); | |||||
DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromMilliseconds(250))); | |||||
da.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; | |||||
CanvasTranslate.BeginAnimation(TranslateTransform.XProperty, da); | |||||
DoubleAnimation daop = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(250))); | |||||
daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; | |||||
cav.BeginAnimation(OpacityProperty, daop); | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 保存文件 | |||||
/// </summary> | |||||
public void FileSave() | |||||
{ | |||||
SaveBtn_Click(null, null); | |||||
} | |||||
/// <summary> | |||||
/// 保存 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void SaveBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
string str = cav.Save(); | |||||
File.WriteAllText(Path, str, Encoding.Unicode); | |||||
} | |||||
/// <summary> | |||||
/// 模拟消息发送 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void MNBtn_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
} | |||||
#endregion | |||||
#region 左侧控件栏移动 | |||||
/// <summary> | |||||
/// 移动到右侧 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void CtlList_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e) | |||||
{ | |||||
if (CtlList.SelectedItem != null && e.LeftButton == MouseButtonState.Pressed) | |||||
{ | |||||
DragDrop.DoDragDrop(CtlList, CtlList.SelectedItem, System.Windows.DragDropEffects.Copy); | |||||
codeEditor.Text = cav.Save(); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 显示代码 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void showCode_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
codeEditor.Text = cav.Save(); | |||||
} | |||||
/// <summary> | |||||
/// 编辑 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void ToggleButton_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
try | |||||
{ | |||||
if (sender is ToggleButton) | |||||
{ | |||||
ToggleButton toggle = (ToggleButton)sender; | |||||
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; | |||||
if (propertyGridCommand != null) | |||||
{ | |||||
viewModel.Edit(propertyGridCommand); | |||||
} | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 变量选择 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void ComboBoxValue_TextChanged(object sender, TextChangedEventArgs e) | |||||
{ | |||||
try | |||||
{ | |||||
if (sender is System.Windows.Controls.ComboBox) | |||||
{ | |||||
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; | |||||
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; | |||||
if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text)) | |||||
propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}.{toggle.Text}" + "}"; | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 变量下拉框打开事件 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void valuebox_DropDownOpened(object sender, EventArgs e) | |||||
{ | |||||
try | |||||
{ | |||||
viewModel.DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>(); | |||||
if (sender is System.Windows.Controls.ComboBox) | |||||
{ | |||||
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; | |||||
if (toggle.Tag == null) return; | |||||
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(toggle.Tag.ToString())) | |||||
{ | |||||
Class_DataBus.GetInstance().Dic_DeviceData[toggle.Tag.ToString()].Keys?.ToList().ForEach(key => { viewModel.DevValueList.Add(key); }); | |||||
} | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 设备名称选择 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void ComboBoxName_TextChanged(object sender, TextChangedEventArgs e) | |||||
{ | |||||
try | |||||
{ | |||||
if (sender is System.Windows.Controls.ComboBox) | |||||
{ | |||||
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; | |||||
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; | |||||
if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text)) | |||||
propertyGridCommand.Value = "{" + $"Binding {toggle.Text}.{toggle.Tag}" + "}"; | |||||
else if (!string.IsNullOrEmpty(toggle.Text)) | |||||
propertyGridCommand.Value = "{" + $"Binding {toggle.Text}." + "}"; | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 设备名称下拉框打开事件 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void namebox_DropDownOpened(object sender, EventArgs e) | |||||
{ | |||||
viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection<string>(); | |||||
Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { viewModel.DevNameList.Add(key); }); | |||||
} | |||||
#endregion | |||||
} | |||||
} |
@@ -1,31 +1,48 @@ | |||||
<UserControl x:Class="BeDesignerSCADA.Controls.RunCanvas" | |||||
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:BeDesignerSCADA.Controls" | |||||
xmlns:con="clr-namespace:BeDesignerSCADA.Converters" | |||||
mc:Ignorable="d" | |||||
d:DesignHeight="450" d:DesignWidth="800"> | |||||
<UserControl | |||||
x:Class="BeDesignerSCADA.Controls.RunCanvas" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:con="clr-namespace:BeDesignerSCADA.Converters" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BeDesignerSCADA.Controls" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<UserControl.Resources> | <UserControl.Resources> | ||||
<con:ZoomConverter x:Key="ZoomX" IsHeight="False"/> | |||||
<con:ZoomConverter x:Key="ZoomY" IsHeight="True"/> | |||||
<con:ZoomConverter x:Key="ZoomX" IsHeight="False" /> | |||||
<con:ZoomConverter x:Key="ZoomY" IsHeight="True" /> | |||||
</UserControl.Resources> | </UserControl.Resources> | ||||
<Grid ClipToBounds="True"> | |||||
<Canvas x:Name="RootCanvas" ClipToBounds="True" Background="Transparent" MouseLeftButtonUp="RootCanvas_MouseLeftButtonUp" | |||||
MouseMove="RootCanvas_MouseMove" MouseLeftButtonDown="RootCanvas_MouseLeftButtoDown" MouseWheel="RootCanvas_MouseWheel"> | |||||
<Grid ClipToBounds="True"> | |||||
<Canvas | |||||
x:Name="RootCanvas" | |||||
Background="Transparent" | |||||
ClipToBounds="True" | |||||
MouseLeftButtonDown="RootCanvas_MouseLeftButtoDown" | |||||
MouseLeftButtonUp="RootCanvas_MouseLeftButtonUp" | |||||
MouseMove="RootCanvas_MouseMove" | |||||
MouseWheel="RootCanvas_MouseWheel"> | |||||
<Canvas.RenderTransform> | <Canvas.RenderTransform> | ||||
<TransformGroup> | <TransformGroup> | ||||
<ScaleTransform x:Name="Scale"/> | |||||
<TranslateTransform x:Name="Translate"/> | |||||
<ScaleTransform x:Name="Scale" /> | |||||
<TranslateTransform x:Name="Translate" /> | |||||
</TransformGroup> | </TransformGroup> | ||||
</Canvas.RenderTransform> | </Canvas.RenderTransform> | ||||
</Canvas> | </Canvas> | ||||
<Grid VerticalAlignment="Bottom" Background="#4B959595"> | <Grid VerticalAlignment="Bottom" Background="#4B959595"> | ||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="8 0"> | |||||
<CheckBox x:Name="DragEnable" Content="拖动" Margin="4"/> | |||||
<CheckBox x:Name="ZoomEnable" Content="缩放" Margin="4"/> | |||||
<StackPanel | |||||
Margin="8,0" | |||||
HorizontalAlignment="Right" | |||||
Orientation="Horizontal"> | |||||
<CheckBox | |||||
x:Name="DragEnable" | |||||
Margin="4" | |||||
Content="拖动" /> | |||||
<CheckBox | |||||
x:Name="ZoomEnable" | |||||
Margin="4" | |||||
Content="缩放" /> | |||||
</StackPanel> | </StackPanel> | ||||
</Grid> | </Grid> | ||||
</Grid> | </Grid> | ||||
@@ -47,11 +47,6 @@ namespace BeDesignerSCADA.Controls | |||||
RootCanvas.Children.Clear(); | RootCanvas.Children.Clear(); | ||||
foreach (FrameworkElement element in canvas) | foreach (FrameworkElement element in canvas) | ||||
{ | { | ||||
//if (element.GetType().GetInterface("IExecutable")!=null) | |||||
//{ | |||||
// element.GetType().GetProperty("IsExecuteState").SetValue(element, true); | |||||
//} | |||||
if (element is IExecutable executable) | if (element is IExecutable executable) | ||||
executable.IsExecuteState = true; | executable.IsExecuteState = true; | ||||
@@ -0,0 +1,13 @@ | |||||
<Window x:Class="BeDesignerSCADA.MainTest" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
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:BeDesignerSCADA" | |||||
xmlns:k="clr-namespace:BeDesignerSCADA.Controls" | |||||
mc:Ignorable="d" | |||||
Title="MainTest" Height="450" Width="800"> | |||||
<Grid x:Name="main"> | |||||
</Grid> | |||||
</Window> |
@@ -0,0 +1,30 @@ | |||||
using BeDesignerSCADA.Controls; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
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; | |||||
namespace BeDesignerSCADA | |||||
{ | |||||
/// <summary> | |||||
/// MainTest.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class MainTest : Window | |||||
{ | |||||
public MainTest() | |||||
{ | |||||
InitializeComponent(); | |||||
MainCanvasPanel mainCanvas=new MainCanvasPanel(@"D:\fengyoufu\代码\Code\C#项目\新上位机代码\BPASmartClient.MinimalistUI\bin\Debug\net6.0-windows\LayoutFile\物料仓管理.lay"); | |||||
main.Children.Add(mainCanvas); | |||||
} | |||||
} | |||||
} |
@@ -28,12 +28,16 @@ | |||||
<ColumnDefinition/> | <ColumnDefinition/> | ||||
<ColumnDefinition Width="350"/> | <ColumnDefinition Width="350"/> | ||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<!--<icon:PackIconMaterial x:Name="icon" Kind="LineScan" BorderThickness="1" VerticalAlignment="Stretch" Width="24" HorizontalAlignment="Stretch"/>--> | |||||
<!--左侧控件栏--> | |||||
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4"> | |||||
<ListBox x:Name="CtlList" Background="Transparent" ItemTemplate="{DynamicResource ToolBoxStyle}" BorderThickness="0" PreviewMouseMove="CtlList_PreviewMouseMove"> | |||||
</ListBox> | |||||
</Border> | |||||
<!--左侧选择区域--> | |||||
<Grid > | |||||
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4"> | |||||
<ListBox x:Name="CtlList" Background="Transparent" ItemTemplate="{DynamicResource ToolBoxStyle}" BorderThickness="0" PreviewMouseMove="CtlList_PreviewMouseMove"> | |||||
</ListBox> | |||||
</Border> | |||||
</Grid> | |||||
<!--中间控制区域--> | <!--中间控制区域--> | ||||
<DockPanel Grid.Column="1"> | <DockPanel Grid.Column="1"> | ||||
@@ -175,9 +179,7 @@ | |||||
</ctl:CanvasPanel.RenderTransform> | </ctl:CanvasPanel.RenderTransform> | ||||
</ctl:CanvasPanel> | </ctl:CanvasPanel> | ||||
<ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding RunCanvasVisibility}" > | |||||
</ctl:RunCanvas> | |||||
<ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding RunCanvasVisibility}" /> | |||||
<avae:TextEditor x:Name="codeEditor" ShowLineNumbers="True" Padding="4" WordWrap="True" IsReadOnly="True" SyntaxHighlighting="XML" BorderThickness="1 0 0 0" BorderBrush="{StaticResource ControlBorderBrush}" Grid.Column="1" Width="480" Visibility="{Binding ElementName=showCode, Path=IsChecked, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"/> | <avae:TextEditor x:Name="codeEditor" ShowLineNumbers="True" Padding="4" WordWrap="True" IsReadOnly="True" SyntaxHighlighting="XML" BorderThickness="1 0 0 0" BorderBrush="{StaticResource ControlBorderBrush}" Grid.Column="1" Width="480" Visibility="{Binding ElementName=showCode, Path=IsChecked, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"/> | ||||
</Grid> | </Grid> | ||||
@@ -253,7 +255,7 @@ | |||||
</mypro:EditorTemplateDefinition.EditingTemplate> | </mypro:EditorTemplateDefinition.EditingTemplate> | ||||
</mypro:EditorTemplateDefinition> | </mypro:EditorTemplateDefinition> | ||||
<mypro:EditorTemplateDefinition TargetProperties="文本,文本1,标题,变量" > | |||||
<mypro:EditorTemplateDefinition TargetProperties="文本,文本1,标题,变量,勾选状态" > | |||||
<mypro:EditorTemplateDefinition.EditingTemplate> | <mypro:EditorTemplateDefinition.EditingTemplate> | ||||
<DataTemplate> | <DataTemplate> | ||||
<!--此处可自由发挥--> | <!--此处可自由发挥--> | ||||
@@ -269,13 +271,13 @@ | |||||
<ColumnDefinition Width="*" x:Name="Text"/> | <ColumnDefinition Width="*" x:Name="Text"/> | ||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<TextBlock>绑定:</TextBlock> | <TextBlock>绑定:</TextBlock> | ||||
<ComboBox x:Name="namebox" DropDownOpened="namebox_DropDownOpened" Grid.Column="1" Height="25" IsTextSearchEnabled="True" IsEditable="True" Tag="{Binding Text, ElementName=valuebox}" Width="{Binding Width, ElementName=key}" TextBoxBase.TextChanged="ComboBoxName_TextChanged" | |||||
<ComboBox x:Name="namebox" DropDownOpened="namebox_DropDownOpened" Grid.Column="1" Height="25" IsTextSearchEnabled="True" IsEditable="True" Tag="{Binding Text, ElementName=valuebox}" TextBoxBase.TextChanged="ComboBoxName_TextChanged" | |||||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevNameList}"> | ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevNameList}"> | ||||
</ComboBox> | </ComboBox> | ||||
<ComboBox x:Name="valuebox" DropDownOpened="valuebox_DropDownOpened" Grid.Column="2" Height="25" IsTextSearchEnabled="True" IsEditable="True" Tag="{Binding Text, ElementName=namebox}" Width="{Binding Width, ElementName=Text}" TextBoxBase.TextChanged="ComboBoxValue_TextChanged" | |||||
<ComboBox x:Name="valuebox" DropDownOpened="valuebox_DropDownOpened" Grid.Column="2" Height="25" IsTextSearchEnabled="True" IsEditable="True" Tag="{Binding Text, ElementName=namebox}" TextBoxBase.TextChanged="ComboBoxValue_TextChanged" | |||||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}"/> | ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}"/> | ||||
</Grid> | </Grid> | ||||
<TextBox Grid.Row="2" x:Name="wenben" Width="{Binding Width, ElementName=Text}" Padding="5" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox> | |||||
<TextBox Grid.Row="2" x:Name="wenben" Padding="5" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox> | |||||
</Grid> | </Grid> | ||||
</DataTemplate> | </DataTemplate> | ||||
@@ -33,23 +33,37 @@ namespace BeDesignerSCADA | |||||
/// </summary> | /// </summary> | ||||
public partial class MainWindow : Window | public partial class MainWindow : Window | ||||
{ | { | ||||
MainViewModel viewModel=new MainViewModel(); | MainViewModel viewModel=new MainViewModel(); | ||||
public MainWindow() | public MainWindow() | ||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
//Loading(); | |||||
this.DataContext = viewModel; | this.DataContext = viewModel; | ||||
viewModel.Loaded(cav); | |||||
viewModel.Loaded(cav, runCanvas); | |||||
//控件加载 | //控件加载 | ||||
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); | |||||
//Assembly assembly = Assembly.GetExecutingAssembly(); | |||||
var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null); | |||||
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); | |||||
var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o=>o.Name); | |||||
CtlList.ItemsSource = controls; | CtlList.ItemsSource = controls; | ||||
viewModel.propertyGrid = kzxy; | |||||
//LoadFile(); | |||||
this.GotFocus += MainWindow_GotFocus; | |||||
this.LostFocus += MainWindow_LostFocus; | |||||
} | |||||
private void MainWindow_LostFocus(object sender, RoutedEventArgs e) | |||||
{ | |||||
System.Diagnostics.Trace.WriteLine("失去焦点:" + e.OriginalSource.ToString()); | |||||
// Console.WriteLine(e.OriginalSource.ToString()); | |||||
} | |||||
private void MainWindow_GotFocus(object sender, RoutedEventArgs e) | |||||
{ | |||||
System.Diagnostics.Trace.WriteLine("获得焦点:"+e.OriginalSource.ToString()); | |||||
} | } | ||||
#region 加载数据中心与事件中心 | #region 加载数据中心与事件中心 | ||||
/// <summary> | |||||
/// 加载数据中心 | |||||
/// </summary> | |||||
public void Loading() | public void Loading() | ||||
{ | { | ||||
//try | //try | ||||
@@ -132,7 +146,6 @@ namespace BeDesignerSCADA | |||||
// System.Windows.MessageBox.Show(ex.Message); | // System.Windows.MessageBox.Show(ex.Message); | ||||
//} | //} | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 加载本地文件 | /// 加载本地文件 | ||||
/// </summary> | /// </summary> | ||||
@@ -257,7 +270,6 @@ namespace BeDesignerSCADA | |||||
} | } | ||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 加载 | /// 加载 | ||||
/// </summary> | /// </summary> | ||||
@@ -280,7 +292,6 @@ namespace BeDesignerSCADA | |||||
daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; | daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; | ||||
cav.BeginAnimation(OpacityProperty, daop); | cav.BeginAnimation(OpacityProperty, daop); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 保存 | /// 保存 | ||||
/// </summary> | /// </summary> | ||||
@@ -297,7 +308,6 @@ namespace BeDesignerSCADA | |||||
File.WriteAllText(sfd.FileName, str, Encoding.Unicode); | File.WriteAllText(sfd.FileName, str, Encoding.Unicode); | ||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 模拟消息发送 | /// 模拟消息发送 | ||||
/// </summary> | /// </summary> | ||||
@@ -310,6 +320,11 @@ namespace BeDesignerSCADA | |||||
#endregion | #endregion | ||||
#region 左侧控件栏移动 | #region 左侧控件栏移动 | ||||
/// <summary> | |||||
/// 移动到右侧 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void CtlList_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e) | private void CtlList_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e) | ||||
{ | { | ||||
if (CtlList.SelectedItem != null && e.LeftButton == MouseButtonState.Pressed) | if (CtlList.SelectedItem != null && e.LeftButton == MouseButtonState.Pressed) | ||||
@@ -318,7 +333,6 @@ namespace BeDesignerSCADA | |||||
codeEditor.Text = cav.Save(); | codeEditor.Text = cav.Save(); | ||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 显示代码 | /// 显示代码 | ||||
/// </summary> | /// </summary> | ||||
@@ -328,7 +342,6 @@ namespace BeDesignerSCADA | |||||
{ | { | ||||
codeEditor.Text = cav.Save(); | codeEditor.Text = cav.Save(); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 编辑 | /// 编辑 | ||||
/// </summary> | /// </summary> | ||||
@@ -353,9 +366,8 @@ namespace BeDesignerSCADA | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 变量编辑 | |||||
/// 变量选择 | |||||
/// </summary> | /// </summary> | ||||
/// <param name="sender"></param> | /// <param name="sender"></param> | ||||
/// <param name="e"></param> | /// <param name="e"></param> | ||||
@@ -367,10 +379,8 @@ namespace BeDesignerSCADA | |||||
{ | { | ||||
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; | System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; | ||||
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; | Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; | ||||
if (toggle.Tag != null) | |||||
if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text)) | |||||
propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}.{toggle.Text}" + "}"; | propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}.{toggle.Text}" + "}"; | ||||
else | |||||
propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}." + "}"; | |||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -378,12 +388,16 @@ namespace BeDesignerSCADA | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 变量下拉框打开事件 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void valuebox_DropDownOpened(object sender,EventArgs e) | private void valuebox_DropDownOpened(object sender,EventArgs e) | ||||
{ | { | ||||
try | try | ||||
{ | { | ||||
viewModel.DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>(); | viewModel.DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>(); | ||||
if (sender is System.Windows.Controls.ComboBox) | if (sender is System.Windows.Controls.ComboBox) | ||||
{ | { | ||||
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; | System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; | ||||
@@ -413,9 +427,9 @@ namespace BeDesignerSCADA | |||||
{ | { | ||||
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; | System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; | ||||
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; | Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; | ||||
if(toggle.Tag!=null) | |||||
if(toggle.Tag!=null && !string.IsNullOrEmpty(toggle.Text)) | |||||
propertyGridCommand.Value = "{" + $"Binding {toggle.Text}.{toggle.Tag}" + "}"; | propertyGridCommand.Value = "{" + $"Binding {toggle.Text}.{toggle.Tag}" + "}"; | ||||
else | |||||
else if(!string.IsNullOrEmpty(toggle.Text)) | |||||
propertyGridCommand.Value = "{" + $"Binding {toggle.Text}." + "}"; | propertyGridCommand.Value = "{" + $"Binding {toggle.Text}." + "}"; | ||||
} | } | ||||
@@ -425,17 +439,16 @@ namespace BeDesignerSCADA | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 设备名称下拉框打开事件 | |||||
/// </summary> | |||||
/// <param name="sender"></param> | |||||
/// <param name="e"></param> | |||||
private void namebox_DropDownOpened(object sender,EventArgs e) | private void namebox_DropDownOpened(object sender,EventArgs e) | ||||
{ | { | ||||
viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection<string>(); | viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection<string>(); | ||||
Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { viewModel.DevNameList.Add(key); }); | Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { viewModel.DevNameList.Add(key); }); | ||||
} | } | ||||
#endregion | #endregion | ||||
} | } | ||||
} | } |
@@ -1,81 +1,119 @@ | |||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:icon="http://metro.mahapps.com/winfx/xaml/iconpacks" | |||||
xmlns:con="clr-namespace:BeDesignerSCADA.Converters" | |||||
xmlns:dxmvmm="clr-namespace:BeDesignerSCADA.Converters" | |||||
xmlns:input="clr-namespace:System.Windows.Input;assembly=PresentationCore" | |||||
xmlns:ctrl="clr-namespace:BeDesignerSCADA.CustomerControls"> | |||||
<!--#region 主题笔刷 --> | |||||
<ResourceDictionary | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:con="clr-namespace:BeDesignerSCADA.Converters" | |||||
xmlns:ctrl="clr-namespace:BeDesignerSCADA.CustomerControls" | |||||
xmlns:dxmvmm="clr-namespace:BeDesignerSCADA.Converters" | |||||
xmlns:icon="http://metro.mahapps.com/winfx/xaml/iconpacks" | |||||
xmlns:input="clr-namespace:System.Windows.Input;assembly=PresentationCore"> | |||||
<!--#region 主题笔刷--> | |||||
<LinearGradientBrush x:Key="NormalBackground" StartPoint="0.5,0" EndPoint="0.5,1"> | <LinearGradientBrush x:Key="NormalBackground" StartPoint="0.5,0" EndPoint="0.5,1"> | ||||
<GradientStopCollection> | <GradientStopCollection> | ||||
<GradientStop Color="White" /> | <GradientStop Color="White" /> | ||||
<GradientStop Color="#D0D0D0" Offset="0.5"/> | |||||
<GradientStop Color="#E3E3E3" Offset="1"/> | |||||
<GradientStop Offset="0.5" Color="#D0D0D0" /> | |||||
<GradientStop Offset="1" Color="#E3E3E3" /> | |||||
</GradientStopCollection> | </GradientStopCollection> | ||||
</LinearGradientBrush> | </LinearGradientBrush> | ||||
<SolidColorBrush x:Key="AccentBrush" Color="#2B79E2"/> | |||||
<SolidColorBrush x:Key="ControlBorderBrush" Color="LightGray"/> | |||||
<SolidColorBrush x:Key="ControlBackground" Color="White"/> | |||||
<SolidColorBrush x:Key="ControlForeground" Color="Black"/> | |||||
<SolidColorBrush x:Key="AccentBrush" Color="#2B79E2" /> | |||||
<SolidColorBrush x:Key="ControlBorderBrush" Color="LightGray" /> | |||||
<SolidColorBrush x:Key="ControlBackground" Color="White" /> | |||||
<SolidColorBrush x:Key="ControlForeground" Color="Black" /> | |||||
<!--#endregion--> | <!--#endregion--> | ||||
<!--#region 转换器 --> | |||||
<con:HalfNumberConverter x:Key="HalfNumber"/> | |||||
<!--#region 转换器--> | |||||
<con:HalfNumberConverter x:Key="HalfNumber" /> | |||||
<!--#endregion--> | <!--#endregion--> | ||||
<!--#region 编辑模板 --> | |||||
<!--#region 编辑模板--> | |||||
<DataTemplate x:Key="EventEditTemplate"> | <DataTemplate x:Key="EventEditTemplate"> | ||||
<DockPanel Height="24"> | <DockPanel Height="24"> | ||||
<Button DockPanel.Dock="Right" Command="{Binding DataContext.EditCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window}}" | |||||
Content="..." CommandParameter="{Binding .}" Margin="2"/> | |||||
<TextBlock Text="{Binding Value}" VerticalAlignment="Center" Margin="4 0 0 0"/> | |||||
<Button | |||||
Margin="2" | |||||
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" | |||||
CommandParameter="{Binding .}" | |||||
Content="..." | |||||
DockPanel.Dock="Right" /> | |||||
<TextBlock | |||||
Margin="4,0,0,0" | |||||
VerticalAlignment="Center" | |||||
Text="{Binding Value}" /> | |||||
</DockPanel> | </DockPanel> | ||||
</DataTemplate> | </DataTemplate> | ||||
<DataTemplate x:Key="ListEditTemplate"> | <DataTemplate x:Key="ListEditTemplate"> | ||||
<DockPanel MaxHeight="100"> | <DockPanel MaxHeight="100"> | ||||
<DockPanel DockPanel.Dock="Top"> | <DockPanel DockPanel.Dock="Top"> | ||||
<Button DockPanel.Dock="Right" Command="{Binding Value.AddCommand}" | |||||
CommandParameter="{Binding ElementName=AddTxt, Path=Text}" Margin="2" Padding="2"> | |||||
<icon:PackIconModern Kind="EditAdd"/> | |||||
<Button | |||||
Margin="2" | |||||
Padding="2" | |||||
Command="{Binding Value.AddCommand}" | |||||
CommandParameter="{Binding ElementName=AddTxt, Path=Text}" | |||||
DockPanel.Dock="Right"> | |||||
<icon:PackIconModern Kind="EditAdd" /> | |||||
</Button> | </Button> | ||||
<Button DockPanel.Dock="Right" Command="{Binding Value.DeleteCommand}" | |||||
CommandParameter="{Binding ElementName=list, Path=SelectedItem}" Margin="2" Padding="2"> | |||||
<Button | |||||
Margin="2" | |||||
Padding="2" | |||||
Command="{Binding Value.DeleteCommand}" | |||||
CommandParameter="{Binding ElementName=list, Path=SelectedItem}" | |||||
DockPanel.Dock="Right"> | |||||
<icon:PackIconModern Kind="Delete" /> | <icon:PackIconModern Kind="Delete" /> | ||||
</Button> | </Button> | ||||
<TextBox x:Name="AddTxt" Margin="2"/> | |||||
<TextBox x:Name="AddTxt" Margin="2" /> | |||||
</DockPanel> | </DockPanel> | ||||
<ListBox x:Name="list" ItemsSource="{Binding Value}" Margin="2"/> | |||||
<ListBox | |||||
x:Name="list" | |||||
Margin="2" | |||||
ItemsSource="{Binding Value}" /> | |||||
</DockPanel> | </DockPanel> | ||||
</DataTemplate> | </DataTemplate> | ||||
<DataTemplate x:Key="ImagePathEditTemplate"> | <DataTemplate x:Key="ImagePathEditTemplate"> | ||||
<DockPanel> | <DockPanel> | ||||
<Button DockPanel.Dock="Right" Content="..." Padding="0" Margin="2" Width="20" Height="20" | |||||
Command="{Binding DataContext.SelectPathCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window}}" CommandParameter="{Binding .}"/> | |||||
<TextBox DockPanel.Dock="Right" x:Name="AddTxt" Text="{Binding Value}" BorderThickness="0"/> | |||||
<Button | |||||
Width="20" | |||||
Height="20" | |||||
Margin="2" | |||||
Padding="0" | |||||
Command="{Binding DataContext.SelectPathCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" | |||||
CommandParameter="{Binding .}" | |||||
Content="..." | |||||
DockPanel.Dock="Right" /> | |||||
<TextBox | |||||
x:Name="AddTxt" | |||||
BorderThickness="0" | |||||
DockPanel.Dock="Right" | |||||
Text="{Binding Value}" /> | |||||
</DockPanel> | </DockPanel> | ||||
</DataTemplate> | </DataTemplate> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
<!--#region 为某些获取焦点的控件设计设计时样式 --> | |||||
<Style TargetType="ComboBox" x:Key="DesignComboBox"> | |||||
<!--#region 为某些获取焦点的控件设计设计时样式--> | |||||
<Style x:Key="DesignComboBox" TargetType="ComboBox"> | |||||
<Setter Property="Focusable" Value="False" /> | <Setter Property="Focusable" Value="False" /> | ||||
<Setter Property="Template"> | <Setter Property="Template"> | ||||
<Setter.Value> | <Setter.Value> | ||||
<ControlTemplate TargetType="ComboBox"> | <ControlTemplate TargetType="ComboBox"> | ||||
<Border BorderThickness="1" BorderBrush="{StaticResource ControlBorderBrush}"> | |||||
<Border BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1"> | |||||
<Grid> | <Grid> | ||||
<Grid.ColumnDefinitions> | <Grid.ColumnDefinitions> | ||||
<ColumnDefinition/> | |||||
<ColumnDefinition Width="auto"/> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="auto" /> | |||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<Border Background="{StaticResource ControlBackground}"/> | |||||
<Border Grid.Column="1" Background="{StaticResource ControlBackground}" BorderThickness="0" IsEnabled="False"> | |||||
<Path Data="M0,0 8,0 4,4z" Fill="{StaticResource ControlForeground}" Margin="3" VerticalAlignment="Center"/> | |||||
<Border Background="{StaticResource ControlBackground}" /> | |||||
<Border | |||||
Grid.Column="1" | |||||
Background="{StaticResource ControlBackground}" | |||||
BorderThickness="0" | |||||
IsEnabled="False"> | |||||
<Path | |||||
Margin="3" | |||||
VerticalAlignment="Center" | |||||
Data="M0,0 8,0 4,4z" | |||||
Fill="{StaticResource ControlForeground}" /> | |||||
</Border> | </Border> | ||||
</Grid> | </Grid> | ||||
</Border> | </Border> | ||||
@@ -89,7 +127,7 @@ | |||||
<Setter.Value> | <Setter.Value> | ||||
<ControlTemplate TargetType="Button"> | <ControlTemplate TargetType="Button"> | ||||
<Border BorderThickness="1" BorderBrush="{StaticResource ControlBorderBrush}" Background="{StaticResource ControlBackground}"> | <Border BorderThickness="1" BorderBrush="{StaticResource ControlBorderBrush}" Background="{StaticResource ControlBackground}"> | ||||
<TextBlock Text="{TemplateBinding Content}" FontSize="{TemplateBinding FontSize}" | |||||
<TextBlock Text="{TemplateBinding Content}" FontSize="{TemplateBinding FontSize}" | |||||
FontWeight="{TemplateBinding FontWeight}" HorizontalAlignment="Center" VerticalAlignment="Center"/> | FontWeight="{TemplateBinding FontWeight}" HorizontalAlignment="Center" VerticalAlignment="Center"/> | ||||
</Border> | </Border> | ||||
</ControlTemplate> | </ControlTemplate> | ||||
@@ -97,39 +135,56 @@ | |||||
</Setter> | </Setter> | ||||
</Style>--> | </Style>--> | ||||
<Style TargetType="ToggleButton" x:Key="DesignToggleButton"> | |||||
<Style x:Key="DesignToggleButton" TargetType="ToggleButton"> | |||||
<Setter Property="Foreground" Value="{StaticResource ControlForeground}" /> | <Setter Property="Foreground" Value="{StaticResource ControlForeground}" /> | ||||
<Setter Property="Template"> | <Setter Property="Template"> | ||||
<Setter.Value> | <Setter.Value> | ||||
<ControlTemplate TargetType="ToggleButton"> | <ControlTemplate TargetType="ToggleButton"> | ||||
<Border BorderThickness="1" Background="{StaticResource NormalBackground}" BorderBrush="{StaticResource ControlBorderBrush}" CornerRadius="2"> | |||||
<TextBlock Text="{TemplateBinding Content}" FontSize="{TemplateBinding FontSize}" | |||||
FontWeight="{TemplateBinding FontWeight}" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |||||
<Border | |||||
Background="{StaticResource NormalBackground}" | |||||
BorderBrush="{StaticResource ControlBorderBrush}" | |||||
BorderThickness="1" | |||||
CornerRadius="2"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="{TemplateBinding FontSize}" | |||||
FontWeight="{TemplateBinding FontWeight}" | |||||
Text="{TemplateBinding Content}" /> | |||||
</Border> | </Border> | ||||
</ControlTemplate> | </ControlTemplate> | ||||
</Setter.Value> | </Setter.Value> | ||||
</Setter> | </Setter> | ||||
</Style> | </Style> | ||||
<Style TargetType="ToggleButton" x:Key="ExecuteToggleButton"> | |||||
<Style x:Key="ExecuteToggleButton" TargetType="ToggleButton"> | |||||
<Setter Property="Foreground" Value="{StaticResource ControlForeground}" /> | <Setter Property="Foreground" Value="{StaticResource ControlForeground}" /> | ||||
<Setter Property="Foreground" Value="{StaticResource ControlForeground}" /> | <Setter Property="Foreground" Value="{StaticResource ControlForeground}" /> | ||||
<Setter Property="Template"> | <Setter Property="Template"> | ||||
<Setter.Value> | <Setter.Value> | ||||
<ControlTemplate TargetType="ToggleButton"> | <ControlTemplate TargetType="ToggleButton"> | ||||
<Border x:Name="bd" BorderThickness="1" Background="{StaticResource NormalBackground}" BorderBrush="{StaticResource ControlBorderBrush}" CornerRadius="2"> | |||||
<TextBlock Text="{TemplateBinding Content}" FontSize="{TemplateBinding FontSize}" | |||||
FontWeight="{TemplateBinding FontWeight}" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |||||
<Border | |||||
x:Name="bd" | |||||
Background="{StaticResource NormalBackground}" | |||||
BorderBrush="{StaticResource ControlBorderBrush}" | |||||
BorderThickness="1" | |||||
CornerRadius="2"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="{TemplateBinding FontSize}" | |||||
FontWeight="{TemplateBinding FontWeight}" | |||||
Text="{TemplateBinding Content}" /> | |||||
</Border> | </Border> | ||||
<ControlTemplate.Triggers> | <ControlTemplate.Triggers> | ||||
<Trigger Property="IsChecked" Value="True"> | <Trigger Property="IsChecked" Value="True"> | ||||
<Setter Property="Background" TargetName="bd"> | |||||
<Setter TargetName="bd" Property="Background"> | |||||
<Setter.Value> | <Setter.Value> | ||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | ||||
<GradientStopCollection> | <GradientStopCollection> | ||||
<GradientStop Color="#6AD456" /> | <GradientStop Color="#6AD456" /> | ||||
<GradientStop Color="#1DAE06" Offset="0.5"/> | |||||
<GradientStop Color="#8BDC7C" Offset="1"/> | |||||
<GradientStop Offset="0.5" Color="#1DAE06" /> | |||||
<GradientStop Offset="1" Color="#8BDC7C" /> | |||||
</GradientStopCollection> | </GradientStopCollection> | ||||
</LinearGradientBrush> | </LinearGradientBrush> | ||||
</Setter.Value> | </Setter.Value> | ||||
@@ -145,148 +200,163 @@ | |||||
<DataTemplate x:Key="ToolBoxStyle"> | <DataTemplate x:Key="ToolBoxStyle"> | ||||
<Grid Margin="2" Background="Transparent"> | <Grid Margin="2" Background="Transparent"> | ||||
<Grid.ColumnDefinitions> | <Grid.ColumnDefinitions> | ||||
<ColumnDefinition Width="30"/> | |||||
<ColumnDefinition/> | |||||
<ColumnDefinition Width="30" /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<icon:PackIconMaterial x:Name="icon" Kind="Ellipse" BorderThickness="1" VerticalAlignment="Stretch" Width="24" HorizontalAlignment="Stretch"/> | |||||
<TextBlock x:Name="txt" Grid.Column="1" Text="{Binding Name}" Margin="4"/> | |||||
<icon:PackIconMaterial | |||||
x:Name="icon" | |||||
Width="24" | |||||
HorizontalAlignment="Stretch" | |||||
VerticalAlignment="Stretch" | |||||
BorderThickness="1" | |||||
Kind="Ellipse" /> | |||||
<TextBlock | |||||
x:Name="txt" | |||||
Grid.Column="1" | |||||
Margin="4" | |||||
Text="{Binding Name}" /> | |||||
</Grid> | </Grid> | ||||
<DataTemplate.Triggers> | <DataTemplate.Triggers> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheButton"> | <DataTrigger Binding="{Binding Name}" Value="TheButton"> | ||||
<Setter Property="Kind" TargetName="icon" Value="GestureTapButton"/> | |||||
<Setter Property="Text" TargetName="txt" Value="按钮"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="GestureTapButton" /> | |||||
<Setter TargetName="txt" Property="Text" Value="按钮" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheTimer"> | <DataTrigger Binding="{Binding Name}" Value="TheTimer"> | ||||
<Setter Property="Kind" TargetName="icon" Value="Timer"/> | |||||
<Setter Property="Text" TargetName="txt" Value="计时器"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="Timer" /> | |||||
<Setter TargetName="txt" Property="Text" Value="计时器" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheCheckBox"> | <DataTrigger Binding="{Binding Name}" Value="TheCheckBox"> | ||||
<Setter Property="Kind" TargetName="icon" Value="CheckboxMarked"/> | |||||
<Setter Property="Text" TargetName="txt" Value="勾选框"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="CheckboxMarked" /> | |||||
<Setter TargetName="txt" Property="Text" Value="勾选框" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="DigitalNumber"> | <DataTrigger Binding="{Binding Name}" Value="DigitalNumber"> | ||||
<Setter Property="Kind" TargetName="icon" Value="LedStrip"/> | |||||
<Setter Property="Text" TargetName="txt" Value="液晶数字"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="LedStrip" /> | |||||
<Setter TargetName="txt" Property="Text" Value="液晶数字" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheComboBox"> | <DataTrigger Binding="{Binding Name}" Value="TheComboBox"> | ||||
<Setter Property="Kind" TargetName="icon" Value="ViewList"/> | |||||
<Setter Property="Text" TargetName="txt" Value="下拉框"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="ViewList" /> | |||||
<Setter TargetName="txt" Property="Text" Value="下拉框" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheImage"> | <DataTrigger Binding="{Binding Name}" Value="TheImage"> | ||||
<Setter Property="Kind" TargetName="icon" Value="Image"/> | |||||
<Setter Property="Text" TargetName="txt" Value="图片"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="Image" /> | |||||
<Setter TargetName="txt" Property="Text" Value="图片" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheTextBlock"> | <DataTrigger Binding="{Binding Name}" Value="TheTextBlock"> | ||||
<Setter Property="Kind" TargetName="icon" Value="TagText"/> | |||||
<Setter Property="Text" TargetName="txt" Value="文本块"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="TagText" /> | |||||
<Setter TargetName="txt" Property="Text" Value="文本块" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="ArcGauge"> | <DataTrigger Binding="{Binding Name}" Value="ArcGauge"> | ||||
<Setter Property="Kind" TargetName="icon" Value="Gauge"/> | |||||
<Setter Property="Text" TargetName="txt" Value="仪表盘"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="Gauge" /> | |||||
<Setter TargetName="txt" Property="Text" Value="仪表盘" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="StatusLight"> | <DataTrigger Binding="{Binding Name}" Value="StatusLight"> | ||||
<Setter Property="Kind" TargetName="icon" Value="CeilingLight"/> | |||||
<Setter Property="Text" TargetName="txt" Value="状态灯"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="CeilingLight" /> | |||||
<Setter TargetName="txt" Property="Text" Value="状态灯" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheToggleButton"> | <DataTrigger Binding="{Binding Name}" Value="TheToggleButton"> | ||||
<Setter Property="Kind" TargetName="icon" Value="CheckOutline"/> | |||||
<Setter Property="Text" TargetName="txt" Value="开关按钮"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="CheckOutline" /> | |||||
<Setter TargetName="txt" Property="Text" Value="开关按钮" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheGroupBox"> | <DataTrigger Binding="{Binding Name}" Value="TheGroupBox"> | ||||
<Setter Property="Kind" TargetName="icon" Value="Group"/> | |||||
<Setter Property="Text" TargetName="txt" Value="分组"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="Group" /> | |||||
<Setter TargetName="txt" Property="Text" Value="分组" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheTextBox"> | <DataTrigger Binding="{Binding Name}" Value="TheTextBox"> | ||||
<Setter Property="Kind" TargetName="icon" Value="TextBox"/> | |||||
<Setter Property="Text" TargetName="txt" Value="文本框"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="TextBox" /> | |||||
<Setter TargetName="txt" Property="Text" Value="文本框" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="NumberBox"> | <DataTrigger Binding="{Binding Name}" Value="NumberBox"> | ||||
<Setter Property="Kind" TargetName="icon" Value="Numeric8Box"/> | |||||
<Setter Property="Text" TargetName="txt" Value="数值框"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="Numeric8Box" /> | |||||
<Setter TargetName="txt" Property="Text" Value="数值框" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="GraphArrow"> | <DataTrigger Binding="{Binding Name}" Value="GraphArrow"> | ||||
<Setter Property="Kind" TargetName="icon" Value="ArrowRightBold"/> | |||||
<Setter Property="Text" TargetName="txt" Value="箭头"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="ArrowRightBold" /> | |||||
<Setter TargetName="txt" Property="Text" Value="箭头" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="GraphStar"> | <DataTrigger Binding="{Binding Name}" Value="GraphStar"> | ||||
<Setter Property="Kind" TargetName="icon" Value="Star"/> | |||||
<Setter Property="Text" TargetName="txt" Value="五角星"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="Star" /> | |||||
<Setter TargetName="txt" Property="Text" Value="五角星" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheSlider"> | <DataTrigger Binding="{Binding Name}" Value="TheSlider"> | ||||
<Setter Property="Kind" TargetName="icon" Value="ArrowDownBold"/> | |||||
<Setter Property="Text" TargetName="txt" Value="滑块"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="ArrowDownBold" /> | |||||
<Setter TargetName="txt" Property="Text" Value="滑块" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheRadioButton"> | <DataTrigger Binding="{Binding Name}" Value="TheRadioButton"> | ||||
<Setter Property="Kind" TargetName="icon" Value="RadioboxMarked"/> | |||||
<Setter Property="Text" TargetName="txt" Value="单选按钮"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="RadioboxMarked" /> | |||||
<Setter TargetName="txt" Property="Text" Value="单选按钮" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="SwitchButton"> | <DataTrigger Binding="{Binding Name}" Value="SwitchButton"> | ||||
<Setter Property="Kind" TargetName="icon" Value="ToggleSwitch"/> | |||||
<Setter Property="Text" TargetName="txt" Value="开关"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="ToggleSwitch" /> | |||||
<Setter TargetName="txt" Property="Text" Value="开关" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="KnobButton"> | <DataTrigger Binding="{Binding Name}" Value="KnobButton"> | ||||
<Setter Property="Kind" TargetName="icon" Value="Ellipse"/> | |||||
<Setter Property="Text" TargetName="txt" Value="旋钮"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="Ellipse" /> | |||||
<Setter TargetName="txt" Property="Text" Value="旋钮" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="Silos"> | <DataTrigger Binding="{Binding Name}" Value="Silos"> | ||||
<Setter Property="Kind" TargetName="icon" Value="StoreSettings"/> | |||||
<Setter Property="Text" TargetName="txt" Value="物料仓"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="StoreSettings" /> | |||||
<Setter TargetName="txt" Property="Text" Value="物料仓" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="NewConveyorBelt"> | <DataTrigger Binding="{Binding Name}" Value="NewConveyorBelt"> | ||||
<Setter Property="Kind" TargetName="icon" Value="ArrowLeftRightBoldOutline"/> | |||||
<Setter Property="Text" TargetName="txt" Value="滚动线"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="Attachment" /> | |||||
<Setter TargetName="txt" Property="Text" Value="滚动线" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheDataGrid"> | <DataTrigger Binding="{Binding Name}" Value="TheDataGrid"> | ||||
<Setter Property="Kind" TargetName="icon" Value="LineScan"/> | |||||
<Setter Property="Text" TargetName="txt" Value="表格"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="BorderAll" /> | |||||
<Setter TargetName="txt" Property="Text" Value="表格" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheListBox"> | <DataTrigger Binding="{Binding Name}" Value="TheListBox"> | ||||
<Setter Property="Kind" TargetName="icon" Value="LineScan"/> | |||||
<Setter Property="Text" TargetName="txt" Value="列表控件"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="ViewHeadline" /> | |||||
<Setter TargetName="txt" Property="Text" Value="列表控件" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheRedis"> | <DataTrigger Binding="{Binding Name}" Value="TheRedis"> | ||||
<Setter Property="Kind" TargetName="icon" Value="AlphaDBoxOutline"/> | |||||
<Setter Property="Text" TargetName="txt" Value="Redis控件"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="AlphaDBoxOutline" /> | |||||
<Setter TargetName="txt" Property="Text" Value="Redis控件" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="WaveProgressBar"> | <DataTrigger Binding="{Binding Name}" Value="WaveProgressBar"> | ||||
<Setter Property="Kind" TargetName="icon" Value="Wave"/> | |||||
<Setter Property="Text" TargetName="txt" Value="进度条波浪"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="Wave" /> | |||||
<Setter TargetName="txt" Property="Text" Value="进度条波浪" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheProgressBar"> | <DataTrigger Binding="{Binding Name}" Value="TheProgressBar"> | ||||
<Setter Property="Kind" TargetName="icon" Value="LineScan"/> | |||||
<Setter Property="Text" TargetName="txt" Value="进度条正常"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="Texture" /> | |||||
<Setter TargetName="txt" Property="Text" Value="进度条正常" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheRedProgressBar"> | <DataTrigger Binding="{Binding Name}" Value="TheRedProgressBar"> | ||||
<Setter Property="Kind" TargetName="icon" Value="LineScan"/> | |||||
<Setter Property="Text" TargetName="txt" Value="进度条圆形红"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="CircleSlice5" /> | |||||
<Setter TargetName="txt" Property="Text" Value="进度条圆形红" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheBlueProgressBar"> | <DataTrigger Binding="{Binding Name}" Value="TheBlueProgressBar"> | ||||
<Setter Property="Kind" TargetName="icon" Value="LineScan"/> | |||||
<Setter Property="Text" TargetName="txt" Value="进度条圆形蓝"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="CircleSlice5" /> | |||||
<Setter TargetName="txt" Property="Text" Value="进度条圆形蓝" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheGreenProgressBar"> | <DataTrigger Binding="{Binding Name}" Value="TheGreenProgressBar"> | ||||
<Setter Property="Kind" TargetName="icon" Value="LineScan"/> | |||||
<Setter Property="Text" TargetName="txt" Value="进度条圆形绿"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="CircleSlice5" /> | |||||
<Setter TargetName="txt" Property="Text" Value="进度条圆形绿" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheAPI"> | <DataTrigger Binding="{Binding Name}" Value="TheAPI"> | ||||
<Setter Property="Kind" TargetName="icon" Value="AlphaABoxOutline"/> | |||||
<Setter Property="Text" TargetName="txt" Value="API接口"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="AlphaABoxOutline" /> | |||||
<Setter TargetName="txt" Property="Text" Value="API接口" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheMQTT"> | <DataTrigger Binding="{Binding Name}" Value="TheMQTT"> | ||||
<Setter Property="Kind" TargetName="icon" Value="AlphaMBoxOutline"/> | |||||
<Setter Property="Text" TargetName="txt" Value="MQTT"/> | |||||
<Setter TargetName="icon" Property="Kind" Value="AlphaMBoxOutline" /> | |||||
<Setter TargetName="txt" Property="Text" Value="MQTT" /> | |||||
</DataTrigger> | </DataTrigger> | ||||
<DataTrigger Binding="{Binding Name}" Value="TheTabControl"> | |||||
<Setter TargetName="icon" Property="Kind" Value="PeriodicTable" /> | |||||
<Setter TargetName="txt" Property="Text" Value="选项卡控件" /> | |||||
</DataTrigger> | |||||
</DataTemplate.Triggers> | </DataTemplate.Triggers> | ||||
</DataTemplate> | </DataTemplate> | ||||
@@ -295,48 +365,78 @@ | |||||
</FontFamily> | </FontFamily> | ||||
<!--#region 右键菜单--> | <!--#region 右键菜单--> | ||||
<ContextMenu x:Key="CanvasRightMenu" DataContext="{Binding PlacementTarget,RelativeSource={RelativeSource Self}}" FontFamily="Microsoft YaHei Ui"> | |||||
<MenuItem Header="复制" Command="{Binding CopySelectItemsCommand}"> | |||||
<ContextMenu | |||||
x:Key="CanvasRightMenu" | |||||
DataContext="{Binding PlacementTarget, RelativeSource={RelativeSource Self}}" | |||||
FontFamily="Microsoft YaHei Ui"> | |||||
<MenuItem Command="{Binding CopySelectItemsCommand}" Header="复制"> | |||||
<MenuItem.Icon> | <MenuItem.Icon> | ||||
<icon:PackIconModern Kind="PageCopy" HorizontalAlignment="Center" Width="10"/> | |||||
<icon:PackIconModern | |||||
Width="10" | |||||
HorizontalAlignment="Center" | |||||
Kind="PageCopy" /> | |||||
</MenuItem.Icon> | </MenuItem.Icon> | ||||
</MenuItem> | </MenuItem> | ||||
<MenuItem Header="粘贴" Command="{Binding PasteSelectItemsCommand}"> | |||||
<MenuItem Command="{Binding PasteSelectItemsCommand}" Header="粘贴"> | |||||
<MenuItem.Icon> | <MenuItem.Icon> | ||||
<icon:PackIconModern Kind="ClipboardPaste" HorizontalAlignment="Center" Width="10"/> | |||||
<icon:PackIconModern | |||||
Width="10" | |||||
HorizontalAlignment="Center" | |||||
Kind="ClipboardPaste" /> | |||||
</MenuItem.Icon> | </MenuItem.Icon> | ||||
</MenuItem> | </MenuItem> | ||||
<MenuItem Header="删除" Command="{Binding DeleteSelectItemsCommand}"> | |||||
<MenuItem Command="{Binding DeleteSelectItemsCommand}" Header="删除"> | |||||
<MenuItem.Icon> | <MenuItem.Icon> | ||||
<icon:PackIconModern Kind="Delete" HorizontalAlignment="Center" Width="10"/> | |||||
<icon:PackIconModern | |||||
Width="10" | |||||
HorizontalAlignment="Center" | |||||
Kind="Delete" /> | |||||
</MenuItem.Icon> | </MenuItem.Icon> | ||||
</MenuItem> | </MenuItem> | ||||
</ContextMenu> | </ContextMenu> | ||||
<ContextMenu x:Key="AdornerRightMenu" DataContext="{Binding PlacementTarget.Tag,RelativeSource={RelativeSource Mode=Self}}" FontFamily="Microsoft YaHei Ui"> | |||||
<MenuItem Header="复制" Command="{Binding CopySelectItemsCommand}"> | |||||
<ContextMenu | |||||
x:Key="AdornerRightMenu" | |||||
DataContext="{Binding PlacementTarget.Tag, RelativeSource={RelativeSource Mode=Self}}" | |||||
FontFamily="Microsoft YaHei Ui"> | |||||
<MenuItem Command="{Binding CopySelectItemsCommand}" Header="复制"> | |||||
<MenuItem.Icon> | <MenuItem.Icon> | ||||
<icon:PackIconModern Kind="PageCopy" HorizontalAlignment="Center" Width="10"/> | |||||
<icon:PackIconModern | |||||
Width="10" | |||||
HorizontalAlignment="Center" | |||||
Kind="PageCopy" /> | |||||
</MenuItem.Icon> | </MenuItem.Icon> | ||||
</MenuItem> | </MenuItem> | ||||
<MenuItem Header="粘贴" Command="{Binding PasteSelectItemsCommand}"> | |||||
<MenuItem Command="{Binding PasteSelectItemsCommand}" Header="粘贴"> | |||||
<MenuItem.Icon> | <MenuItem.Icon> | ||||
<icon:PackIconModern Kind="ClipboardPaste" HorizontalAlignment="Center" Width="10"/> | |||||
<icon:PackIconModern | |||||
Width="10" | |||||
HorizontalAlignment="Center" | |||||
Kind="ClipboardPaste" /> | |||||
</MenuItem.Icon> | </MenuItem.Icon> | ||||
</MenuItem> | </MenuItem> | ||||
<MenuItem Header="删除" Command="{Binding DeleteSelectItemsCommand}"> | |||||
<MenuItem Command="{Binding DeleteSelectItemsCommand}" Header="删除"> | |||||
<MenuItem.Icon> | <MenuItem.Icon> | ||||
<icon:PackIconModern Kind="Delete" HorizontalAlignment="Center" Width="10"/> | |||||
<icon:PackIconModern | |||||
Width="10" | |||||
HorizontalAlignment="Center" | |||||
Kind="Delete" /> | |||||
</MenuItem.Icon> | </MenuItem.Icon> | ||||
</MenuItem> | </MenuItem> | ||||
<MenuItem Header="置于顶层" Command="{Binding SetTopLayerCommand}"> | |||||
<MenuItem Command="{Binding SetTopLayerCommand}" Header="置于顶层"> | |||||
<MenuItem.Icon> | <MenuItem.Icon> | ||||
<icon:PackIconMaterial Kind="ArrangeSendToBack" HorizontalAlignment="Center" Width="10"/> | |||||
<icon:PackIconMaterial | |||||
Width="10" | |||||
HorizontalAlignment="Center" | |||||
Kind="ArrangeSendToBack" /> | |||||
</MenuItem.Icon> | </MenuItem.Icon> | ||||
</MenuItem> | </MenuItem> | ||||
<MenuItem Header="置于底层" Command="{Binding SetBottomLayerCommand}"> | |||||
<MenuItem Command="{Binding SetBottomLayerCommand}" Header="置于底层"> | |||||
<MenuItem.Icon> | <MenuItem.Icon> | ||||
<icon:PackIconMaterial Kind="ArrangeBringToFront" HorizontalAlignment="Center" Width="10"/> | |||||
<icon:PackIconMaterial | |||||
Width="10" | |||||
HorizontalAlignment="Center" | |||||
Kind="ArrangeBringToFront" /> | |||||
</MenuItem.Icon> | </MenuItem.Icon> | ||||
</MenuItem> | </MenuItem> | ||||
</ContextMenu> | </ContextMenu> | ||||
@@ -353,16 +453,16 @@ | |||||
<Setter.Value> | <Setter.Value> | ||||
<ControlTemplate TargetType="ctrl:DigitalNumber"> | <ControlTemplate TargetType="ctrl:DigitalNumber"> | ||||
<Grid Background="{TemplateBinding Background}"> | <Grid Background="{TemplateBinding Background}"> | ||||
<TextBlock x:Name="line" VerticalAlignment="Center" HorizontalAlignment="Center" | |||||
<TextBlock x:Name="line" VerticalAlignment="Center" HorizontalAlignment="Center" | |||||
FontFamily="{StaticResource Digital}" FontSize="{TemplateBinding FontSize}" | FontFamily="{StaticResource Digital}" FontSize="{TemplateBinding FontSize}" | ||||
Text="{Binding NumberValue,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ctrl:DigitalNumber},Mode=TwoWay}" | |||||
Text="{Binding NumberValue,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ctrl:DigitalNumber},Mode=TwoWay}" | |||||
Foreground="{TemplateBinding Foreground}"/> | Foreground="{TemplateBinding Foreground}"/> | ||||
</Grid> | </Grid> | ||||
</ControlTemplate> | </ControlTemplate> | ||||
</Setter.Value> | </Setter.Value> | ||||
</Setter> | </Setter> | ||||
</Style> | </Style> | ||||
<Style TargetType="{x:Type ctrl:TheTimer}"> | <Style TargetType="{x:Type ctrl:TheTimer}"> | ||||
<Setter Property="Template"> | <Setter Property="Template"> | ||||
<Setter.Value> | <Setter.Value> | ||||
@@ -540,7 +640,7 @@ | |||||
<StackPanel> | <StackPanel> | ||||
<Border Background="{TemplateBinding Background}"> | <Border Background="{TemplateBinding Background}"> | ||||
<Viewbox> | <Viewbox> | ||||
<Border x:Name="PART_Clip" BorderThickness="{TemplateBinding BorderThickness}" ClipToBounds="True" | |||||
<Border x:Name="PART_Clip" BorderThickness="{TemplateBinding BorderThickness}" ClipToBounds="True" | |||||
BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="100" Width="200" Height="200"> | BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="100" Width="200" Height="200"> | ||||
<Border.Clip> | <Border.Clip> | ||||
<EllipseGeometry RadiusX="100" RadiusY="100" Center="100,100"/> | <EllipseGeometry RadiusX="100" RadiusY="100" Center="100,100"/> | ||||
@@ -558,8 +658,8 @@ | |||||
</PathGeometry> | </PathGeometry> | ||||
</Path.Data> | </Path.Data> | ||||
</Path> | </Path> | ||||
<TextBlock Visibility="{Binding ShowText,RelativeSource={RelativeSource TemplatedParent},Converter={x:Static dxmvmm:BoolToVisibilityConverter.Instance}}" | |||||
HorizontalAlignment="Center" VerticalAlignment="Center" | |||||
<TextBlock Visibility="{Binding ShowText,RelativeSource={RelativeSource TemplatedParent},Converter={x:Static dxmvmm:BoolToVisibilityConverter.Instance}}" | |||||
HorizontalAlignment="Center" VerticalAlignment="Center" | |||||
Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" | Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" | ||||
Text="{Binding Value,RelativeSource={RelativeSource Mode=TemplatedParent},StringFormat={}{0:f2}%}"/> | Text="{Binding Value,RelativeSource={RelativeSource Mode=TemplatedParent},StringFormat={}{0:f2}%}"/> | ||||
</Grid> | </Grid> | ||||
@@ -589,10 +689,10 @@ | |||||
<Setter Property="Template"> | <Setter Property="Template"> | ||||
<Setter.Value> | <Setter.Value> | ||||
<ControlTemplate TargetType="ctrl:SwitchButton"> | <ControlTemplate TargetType="ctrl:SwitchButton"> | ||||
<Border CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=ActualHeight,Converter={StaticResource HalfNumber}}" | |||||
<Border CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=ActualHeight,Converter={StaticResource HalfNumber}}" | |||||
BorderThickness="1" Background="{StaticResource ControlBackground}" BorderBrush="{TemplateBinding BorderBrush}"> | BorderThickness="1" Background="{StaticResource ControlBackground}" BorderBrush="{TemplateBinding BorderBrush}"> | ||||
<Grid> | <Grid> | ||||
<Ellipse x:Name="ELLIPSE" HorizontalAlignment="Left" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" | |||||
<Ellipse x:Name="ELLIPSE" HorizontalAlignment="Left" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" | |||||
Fill="Gray" Stroke="{StaticResource ControlBorderBrush}" StrokeThickness="1"> | Fill="Gray" Stroke="{StaticResource ControlBorderBrush}" StrokeThickness="1"> | ||||
<Ellipse.RenderTransform> | <Ellipse.RenderTransform> | ||||
<TransformGroup> | <TransformGroup> | ||||
@@ -630,7 +730,7 @@ | |||||
<Ellipse Margin="12" Fill="{TemplateBinding Background}" Width="8" Height="8" VerticalAlignment="Bottom"> | <Ellipse Margin="12" Fill="{TemplateBinding Background}" Width="8" Height="8" VerticalAlignment="Bottom"> | ||||
</Ellipse> | </Ellipse> | ||||
</Grid> | </Grid> | ||||
<TextBlock Text="{Binding Value,RelativeSource={RelativeSource Mode=TemplatedParent}, StringFormat={}{0:F2}}" | |||||
<TextBlock Text="{Binding Value,RelativeSource={RelativeSource Mode=TemplatedParent}, StringFormat={}{0:F2}}" | |||||
VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}"/> | VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}"/> | ||||
</Grid> | </Grid> | ||||
</ControlTemplate> | </ControlTemplate> | ||||
@@ -638,32 +738,44 @@ | |||||
</Setter> | </Setter> | ||||
</Style>--> | </Style>--> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
<!--#region 控制集合--> | <!--#region 控制集合--> | ||||
<Style TargetType="{x:Type ToggleButton}" > | |||||
<Setter Property="Foreground" Value="White"/> | |||||
<Setter Property="FontFamily" Value="Microsoft YaHei"/> | |||||
<Setter Property="FontSize" Value="12"/> | |||||
<Setter Property="FontWeight" Value="Bold"/> | |||||
<Style TargetType="{x:Type ToggleButton}"> | |||||
<Setter Property="Foreground" Value="White" /> | |||||
<Setter Property="FontFamily" Value="Microsoft YaHei" /> | |||||
<Setter Property="FontSize" Value="12" /> | |||||
<Setter Property="FontWeight" Value="Bold" /> | |||||
<Setter Property="Template"> | <Setter Property="Template"> | ||||
<Setter.Value> | <Setter.Value> | ||||
<ControlTemplate TargetType="ToggleButton"> | <ControlTemplate TargetType="ToggleButton"> | ||||
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="0" CornerRadius="2"> | |||||
<Border | |||||
BorderBrush="{TemplateBinding Control.BorderBrush}" | |||||
BorderThickness="0" | |||||
CornerRadius="2"> | |||||
<Border.Background> | <Border.Background> | ||||
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> | |||||
<GradientStop Color="#FF71E0C6" Offset="0.0" /> | |||||
<GradientStop Color="#FF43A88D" Offset="0.2" /> | |||||
<GradientStop Color="#FF5BB07D" Offset="0.0" /> | |||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> | |||||
<GradientStop Offset="0.0" Color="#FF71E0C6" /> | |||||
<GradientStop Offset="0.2" Color="#FF43A88D" /> | |||||
<GradientStop Offset="0.0" Color="#FF5BB07D" /> | |||||
</LinearGradientBrush> | </LinearGradientBrush> | ||||
</Border.Background> | </Border.Background> | ||||
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter> | |||||
<ContentPresenter | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding ContentControl.Content}" /> | |||||
</Border> | </Border> | ||||
<ControlTemplate.Triggers> | <ControlTemplate.Triggers> | ||||
<Trigger Property="ButtonBase.IsPressed" Value="True"> | <Trigger Property="ButtonBase.IsPressed" Value="True"> | ||||
<Setter Property="UIElement.Effect"> | <Setter Property="UIElement.Effect"> | ||||
<Setter.Value> | <Setter.Value> | ||||
<DropShadowEffect BlurRadius="10" Color="#276AB0" Direction="0" Opacity="0.9" RenderingBias="Performance" ShadowDepth="0" /> | |||||
<DropShadowEffect | |||||
BlurRadius="10" | |||||
Direction="0" | |||||
Opacity="0.9" | |||||
RenderingBias="Performance" | |||||
ShadowDepth="0" | |||||
Color="#276AB0" /> | |||||
</Setter.Value> | </Setter.Value> | ||||
</Setter> | </Setter> | ||||
<Setter Property="RenderTransform"> | <Setter Property="RenderTransform"> | ||||
@@ -680,7 +792,10 @@ | |||||
</Setter> | </Setter> | ||||
</Style> | </Style> | ||||
<DataTemplate x:Key="Category"> | <DataTemplate x:Key="Category"> | ||||
<TextBlock Text="{Binding}" FontSize="20" Foreground="#4EB9E4" /> | |||||
<TextBlock | |||||
FontSize="20" | |||||
Foreground="#4EB9E4" | |||||
Text="{Binding}" /> | |||||
</DataTemplate> | </DataTemplate> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
</ResourceDictionary> | </ResourceDictionary> |
@@ -38,15 +38,10 @@ namespace BeDesignerSCADA.ViewModel | |||||
{ | { | ||||
IsRunning = !IsRunning; | IsRunning = !IsRunning; | ||||
}); | }); | ||||
} | } | ||||
#region 变量 | #region 变量 | ||||
/// <summary> | /// <summary> | ||||
/// 设置 | |||||
/// </summary> | |||||
public Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid propertyGrid = null; | |||||
/// <summary> | |||||
/// 是否正在运行状态 | /// 是否正在运行状态 | ||||
/// </summary> | /// </summary> | ||||
private bool _IsRunning = false; | private bool _IsRunning = false; | ||||
@@ -72,6 +67,7 @@ namespace BeDesignerSCADA.ViewModel | |||||
OnPropertyChanged("IsRunning"); | OnPropertyChanged("IsRunning"); | ||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 画布是否显示 | /// 画布是否显示 | ||||
/// </summary> | /// </summary> | ||||
@@ -144,12 +140,14 @@ namespace BeDesignerSCADA.ViewModel | |||||
if (_CanSelectedItem == value) | if (_CanSelectedItem == value) | ||||
return; | return; | ||||
_CanSelectedItem = value; | _CanSelectedItem = value; | ||||
DataSX(); | |||||
SelectedPropertyDataRefresh(); | |||||
OnPropertyChanged("CanSelectedItem"); | OnPropertyChanged("CanSelectedItem"); | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 控制协议属性 | |||||
/// </summary> | |||||
private PropertyGridCommand _pro; | private PropertyGridCommand _pro; | ||||
public PropertyGridCommand PropeObject | public PropertyGridCommand PropeObject | ||||
{ | { | ||||
@@ -164,6 +162,9 @@ namespace BeDesignerSCADA.ViewModel | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 设备名称集合 | |||||
/// </summary> | |||||
private ObservableCollection<string> _DevNameList; | private ObservableCollection<string> _DevNameList; | ||||
public ObservableCollection<string> DevNameList | public ObservableCollection<string> DevNameList | ||||
{ | { | ||||
@@ -177,6 +178,10 @@ namespace BeDesignerSCADA.ViewModel | |||||
OnPropertyChanged("DevNameList"); | OnPropertyChanged("DevNameList"); | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 设备变量集合 | |||||
/// </summary> | |||||
private ObservableCollection<string> _DevValueList; | private ObservableCollection<string> _DevValueList; | ||||
public ObservableCollection<string> DevValueList | public ObservableCollection<string> DevValueList | ||||
{ | { | ||||
@@ -197,11 +202,9 @@ namespace BeDesignerSCADA.ViewModel | |||||
/// 启动或者停止 | /// 启动或者停止 | ||||
/// </summary> | /// </summary> | ||||
public RelayCommand RunUiCommand { get; set; } | public RelayCommand RunUiCommand { get; set; } | ||||
#endregion | #endregion | ||||
#region 常用函数 | #region 常用函数 | ||||
/// <summary> | /// <summary> | ||||
/// 显示当前xaml代码 | /// 显示当前xaml代码 | ||||
/// </summary> | /// </summary> | ||||
@@ -212,16 +215,24 @@ namespace BeDesignerSCADA.ViewModel | |||||
#endregion | #endregion | ||||
#region 脚本编辑数据 | #region 脚本编辑数据 | ||||
/// <summary> | |||||
/// 当前编辑界面 | |||||
/// </summary> | |||||
public CanvasPanel canvasPanel; | public CanvasPanel canvasPanel; | ||||
/// <summary> | /// <summary> | ||||
/// 当前运行界面 | |||||
/// </summary> | |||||
public RunCanvas runCanvas; | |||||
/// <summary> | |||||
/// 加载 | /// 加载 | ||||
/// </summary> | /// </summary> | ||||
/// <param name="obj"></param> | /// <param name="obj"></param> | ||||
public void Loaded(object obj) | |||||
public void Loaded(object objCan,object objRun) | |||||
{ | { | ||||
canvasPanel = obj as CanvasPanel; | |||||
} | |||||
canvasPanel = objCan as CanvasPanel; | |||||
runCanvas = objRun as RunCanvas; | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 编辑 | /// 编辑 | ||||
/// </summary> | /// </summary> | ||||
@@ -246,42 +257,14 @@ namespace BeDesignerSCADA.ViewModel | |||||
#endregion | #endregion | ||||
#region 属性填充 | #region 属性填充 | ||||
Dictionary<string,string> EventName = new Dictionary<string,string> { | |||||
{"Name","名称" }, | |||||
{"Text","文本" }, | |||||
{"Content","按钮文本" }, | |||||
{"Title","标题" }, | |||||
{"Value","变量" }, | |||||
{"ClickExec","点击事件" }, | |||||
{"ValueChangedExecute" , "值改变事件"}, | |||||
{"TikcExecute" , "定时触发"}, | |||||
{"CheckedExec" , "勾选事件"}, | |||||
{"UnCheckedExec" , "取消勾选事件"}, | |||||
{"EventReceiveNameList" , "接收消息集"}, | |||||
//{"DataSouceType" , "数据来源类型"}, | |||||
{ "TimeCount" , "定时间隔"}, | |||||
{ "InterfaceMode" , "接口类型"}, | |||||
{ "InterfaceParameters" , "接口参数"}, | |||||
{ "DataSouceInformation" , "连接信息"}, | |||||
{ "DeviceName" , "设备名称"}, | |||||
{ "DeviceValuleName" , "设备解析变量"}, | |||||
{"FDataSouce" , "数据源"}, | |||||
{ "Code" , "代码过滤脚本"}, | |||||
{ "GenerateData" , "数据结果"}, | |||||
}; | |||||
/// <summary> | /// <summary> | ||||
/// 数据刷新 | |||||
/// 选中属性数据刷新 | |||||
/// </summary> | /// </summary> | ||||
public void DataSX() | |||||
public void SelectedPropertyDataRefresh() | |||||
{ | { | ||||
//属性变量 | //属性变量 | ||||
PropertyGridCommand cmd = new PropertyGridCommand(); | PropertyGridCommand cmd = new PropertyGridCommand(); | ||||
var content = CanSelectedItem;// as System.Windows.Controls.Control; | |||||
var content = CanSelectedItem; | |||||
if (content is IExecutable executable) | if (content is IExecutable executable) | ||||
executable.PropertyChange += Executable_PropertyChange; | executable.PropertyChange += Executable_PropertyChange; | ||||
@@ -303,7 +286,6 @@ namespace BeDesignerSCADA.ViewModel | |||||
PropeObject = null; | PropeObject = null; | ||||
PropeObject = cmd; | PropeObject = cmd; | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 内部属性变化通知 | /// 内部属性变化通知 | ||||
/// </summary> | /// </summary> | ||||
@@ -319,7 +301,6 @@ namespace BeDesignerSCADA.ViewModel | |||||
DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>(); | DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>(); | ||||
Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { DevNameList.Add(key); }); | Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { DevNameList.Add(key); }); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 修改属性后 | /// 修改属性后 | ||||
/// </summary> | /// </summary> | ||||
@@ -348,7 +329,6 @@ namespace BeDesignerSCADA.ViewModel | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 设置变量 | /// 设置变量 | ||||
/// </summary> | /// </summary> | ||||
@@ -357,13 +337,28 @@ namespace BeDesignerSCADA.ViewModel | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
// if (CanSelectedItem is System.Windows.Controls.Control) | |||||
var content = CanSelectedItem; | |||||
if (Name == "Content" ? (content is BPASmartClient.SCADAControl.CustomerControls.TheButton) : true) | |||||
{ | { | ||||
var content = CanSelectedItem;// as System.Windows.Controls.Control; | |||||
if (Name == "Content" ? (content is BPASmartClient.SCADAControl.CustomerControls.TheButton) : true) | |||||
System.Reflection.PropertyInfo info = content.GetType().GetProperty(Name); | |||||
if (info != null) | |||||
{ | { | ||||
System.Reflection.PropertyInfo info = content.GetType().GetProperty(Name); | |||||
info?.SetValue(content,value,null); | |||||
if (info.ToString().Contains("Double")) | |||||
{ | |||||
info?.SetValue(content, Double.Parse(value.ToString()), null); | |||||
} | |||||
else if (info.ToString().Contains("String")) | |||||
{ | |||||
info?.SetValue(content, value, null); | |||||
} | |||||
else if (info.ToString().Contains("Int")) | |||||
{ | |||||
info?.SetValue(content, int.Parse(value.ToString()), null); | |||||
} | |||||
else | |||||
{ | |||||
info?.SetValue(content, value, null); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -390,7 +385,6 @@ namespace BeDesignerSCADA.ViewModel | |||||
// FieldInfo fld = type.GetField("Browsable",BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreReturn | BindingFlags.GetProperty); | // FieldInfo fld = type.GetField("Browsable",BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreReturn | BindingFlags.GetProperty); | ||||
fld.SetValue(attrs[type],visible); | fld.SetValue(attrs[type],visible); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 获取指定对象的指定成员变量 | /// 获取指定对象的指定成员变量 | ||||
/// </summary> | /// </summary> | ||||
@@ -472,6 +466,33 @@ namespace BeDesignerSCADA.ViewModel | |||||
} | } | ||||
#endregion | #endregion | ||||
Dictionary<string, string> EventName = new Dictionary<string, string> { | |||||
{"Name","名称" }, | |||||
{"Text","文本" }, | |||||
{"Content","按钮文本" }, | |||||
{"Title","标题" }, | |||||
{"Value","变量" }, | |||||
{"BindingIsChecked","勾选状态" }, | |||||
{"ClickExec","点击事件" }, | |||||
{"ValueChangedExecute" , "值改变事件"}, | |||||
{"TikcExecute" , "定时触发"}, | |||||
{"CheckedExec" , "勾选事件"}, | |||||
{"UnCheckedExec" , "取消勾选事件"}, | |||||
{"EventReceiveNameList" , "接收消息集"}, | |||||
{ "TimeCount" , "定时间隔"}, | |||||
{ "InterfaceMode" , "接口类型"}, | |||||
{ "InterfaceParameters" , "接口参数"}, | |||||
{ "DataSouceInformation" , "连接信息"}, | |||||
{ "DeviceName" , "设备名称"}, | |||||
{ "DeviceValuleName" , "设备解析变量"}, | |||||
{"FDataSouce" , "数据源"}, | |||||
{ "Code" , "代码过滤脚本"}, | |||||
{ "GenerateData" , "数据结果"}, | |||||
}; | |||||
} | } | ||||
@@ -483,7 +504,8 @@ namespace BeDesignerSCADA.ViewModel | |||||
private string _标题; | private string _标题; | ||||
private string _文本1; | private string _文本1; | ||||
private object _变量; | private object _变量; | ||||
private string _勾选状态; | |||||
[Category("基本属性"), Description("Name"), Browsable(false), PropertyOrder(1)] | [Category("基本属性"), Description("Name"), Browsable(false), PropertyOrder(1)] | ||||
public string 名称 | public string 名称 | ||||
{ | { | ||||
@@ -559,6 +581,22 @@ namespace BeDesignerSCADA.ViewModel | |||||
OnPropertyChanged("变量"); | OnPropertyChanged("变量"); | ||||
} | } | ||||
} | } | ||||
[Category("基本属性"), Description("BindingIsChecked"), Browsable(false), PropertyOrder(5)] | |||||
public string 勾选状态 | |||||
{ | |||||
get | |||||
{ | |||||
return _勾选状态; | |||||
} | |||||
set | |||||
{ | |||||
if (_勾选状态 == value) | |||||
return; | |||||
_勾选状态 = value; | |||||
OnPropertyChanged("勾选状态"); | |||||
} | |||||
} | |||||
//[Category("基本属性"), Description("Content"), Browsable(true), PropertyOrder(2)] | //[Category("基本属性"), Description("Content"), Browsable(true), PropertyOrder(2)] | ||||
//public string 内容 { get; set; } | //public string 内容 { get; set; } | ||||
//[Category("基本属性"), Description("Header"), Browsable(true), PropertyOrder(3)] | //[Category("基本属性"), Description("Header"), Browsable(true), PropertyOrder(3)] | ||||
@@ -696,26 +734,6 @@ namespace BeDesignerSCADA.ViewModel | |||||
} | } | ||||
} | } | ||||
//private DataTypeEnum _数据来源类型; | |||||
//[Category("*数据绑定模块*"), Description("DataSouceType"), Browsable(true), PropertyOrder(1)] | |||||
//public DataTypeEnum 数据来源类型 | |||||
//{ | |||||
// get | |||||
// { | |||||
// return _数据来源类型; | |||||
// } | |||||
// set | |||||
// { | |||||
// if (_数据来源类型 == value) | |||||
// return; | |||||
// _数据来源类型 = value; | |||||
// OnPropertyChanged("数据来源类型"); | |||||
// } | |||||
//} | |||||
private string _设备名称; | private string _设备名称; | ||||
[Category("*数据绑定模块*"), Description("DeviceName"), Browsable(true), PropertyOrder(2)] | [Category("*数据绑定模块*"), Description("DeviceName"), Browsable(true), PropertyOrder(2)] | ||||
public string 设备名称 | public string 设备名称 | ||||
@@ -10,7 +10,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Communication" Version="1.0.13" /> | <PackageReference Include="BPA.Communication" Version="1.0.13" /> | ||||
<PackageReference Include="BPA.Helper" Version="1.0.7" /> | |||||
<PackageReference Include="BPA.Helper" Version="1.0.8" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -42,7 +42,7 @@ namespace FryPot_DosingSystem | |||||
DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取 | DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取 | ||||
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序 | DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序 | ||||
HubHelper.GetInstance.Connect("192.168.1.40", 8089); | HubHelper.GetInstance.Connect("192.168.1.40", 8089); | ||||
AlarmHelper<AlarmInfo>.Init(); | |||||
AlarmHelper<AlarmInfo>.Init();//报警实时监控 | |||||
} | } | ||||
else | else | ||||
mv.Close(); | mv.Close(); | ||||
@@ -1,7 +1,7 @@ | |||||
| | ||||
using BPASmartClient.CustomResource.Pages.Model; | using BPASmartClient.CustomResource.Pages.Model; | ||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using BPASmartClient.Message; | |||||
using BPASmartClient.Modbus; | using BPASmartClient.Modbus; | ||||
using FryPot_DosingSystem.Model; | using FryPot_DosingSystem.Model; | ||||
using System; | using System; | ||||
@@ -122,16 +122,19 @@ namespace FryPot_DosingSystem.Control | |||||
} | } | ||||
} | } | ||||
IsConfig = true; | IsConfig = true; | ||||
MessageLog.GetInstance.ShowRunLog("PLC变量配置成功"); | |||||
} | } | ||||
catch (Exception) | catch (Exception) | ||||
{ | { | ||||
IsConfig = false; | IsConfig = false; | ||||
MessageLog.GetInstance.ShowRunLog("PLC变量配置错误,请重新配置并重启软件"); | |||||
//throw; | //throw; | ||||
} | } | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
IsConfig = false; | IsConfig = false; | ||||
MessageLog.GetInstance.ShowRunLog("PLC变量配置失败:文件无数据,请重新配置"); | |||||
} | } | ||||
//Variables.Add(new PlcVariableModel() { Address = "D2001", Length = 8 });//1号线体滚筒工位号 | //Variables.Add(new PlcVariableModel() { Address = "D2001", Length = 8 });//1号线体滚筒工位号 | ||||
//Variables.Add(new PlcVariableModel() { Address = "D2011", Length = 8 });//2号线体滚筒工位号 | //Variables.Add(new PlcVariableModel() { Address = "D2011", Length = 8 });//2号线体滚筒工位号 | ||||
@@ -166,17 +169,16 @@ namespace FryPot_DosingSystem.Control | |||||
string DeviceName = devices.Devices[i].DeviceName; | string DeviceName = devices.Devices[i].DeviceName; | ||||
switch (DeviceName) | switch (DeviceName) | ||||
{ | { | ||||
case "滚筒输送线": Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; | |||||
case "炒锅1": Task.Run(() => { fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; | |||||
case "炒锅2": Task.Run(() => { fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; | |||||
case "炒锅3": Task.Run(() => { fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; | |||||
case "炒锅4": Task.Run(() => { fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; | |||||
case "炒锅5": Task.Run(() => { fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; | |||||
case "滚筒输送线": Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC连接成功"); }); break; | |||||
case "炒锅1": Task.Run(() => { fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC连接成功"); }); break; | |||||
case "炒锅2": Task.Run(() => { fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC连接成功"); }); break; | |||||
case "炒锅3": Task.Run(() => { fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC连接成功"); }); break; | |||||
case "炒锅4": Task.Run(() => { fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC连接成功"); }); break; | |||||
case "炒锅5": Task.Run(() => { fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC连接成功"); }); break; | |||||
} | } | ||||
} | } | ||||
// Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); App.Current.Dispatcher.Invoke(new Action(() => { BPASmartClient.CustomResource.Pages.Model.MessageLog.GetInstance.RunLog("PLC连接成功"); })); }); | |||||
// Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); App.Current.Dispatcher.Invoke(new Action(() => { BPASmartClient.CustomResource.Pages.Model.MessageLog.GetInstance.ShowRunLog("PLC连接成功"); })); }); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -417,8 +417,8 @@ namespace FryPot_DosingSystem.Control | |||||
ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearOneRecipes"); | ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearOneRecipes"); | ||||
ActionManage.GetInstance.Register(new Action(() => { LTwoRecipeQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); }), "ClearTwoRecipes"); | ActionManage.GetInstance.Register(new Action(() => { LTwoRecipeQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); }), "ClearTwoRecipes"); | ||||
ActionManage.GetInstance.Register(new Action(() => { LThreeRecipeQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearThreeRecipes"); | ActionManage.GetInstance.Register(new Action(() => { LThreeRecipeQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearThreeRecipes"); | ||||
ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite"); | |||||
ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite"); | |||||
//ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite"); | |||||
//ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite"); | |||||
ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineOneTask = true; LineOneTaskRestart(); }), "LineOneTaskExit"); | ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineOneTask = true; LineOneTaskRestart(); }), "LineOneTaskExit"); | ||||
ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineTwoTask = true; LineTwoTaskRestart(); }), "LineTwoTaskExit"); | ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineTwoTask = true; LineTwoTaskRestart(); }), "LineTwoTaskExit"); | ||||
ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineThreeTask = true; LineThreeTaskRestart(); }), "LineThreeTaskExit"); | ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineThreeTask = true; LineThreeTaskRestart(); }), "LineThreeTaskExit"); | ||||
@@ -727,7 +727,6 @@ namespace FryPot_DosingSystem.Control | |||||
globalVar.LThreeagvArriveUnLoad = true;//AGV到达下料位置 | globalVar.LThreeagvArriveUnLoad = true;//AGV到达下料位置 | ||||
} | } | ||||
#endregion | #endregion | ||||
#region 炒锅到线体4请求上下料 | #region 炒锅到线体4请求上下料 | ||||
if (objData.robotJobId == LFourrobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料 | if (objData.robotJobId == LFourrobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料 | ||||
{ | { | ||||
@@ -930,13 +929,6 @@ namespace FryPot_DosingSystem.Control | |||||
AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes); | AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes); | ||||
} | } | ||||
#endregion | #endregion | ||||
#region 炒锅空桶上下料任务信息回报 | #region 炒锅空桶上下料任务信息回报 | ||||
//线体1任务上报 | //线体1任务上报 | ||||
if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料 | if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料 | ||||
@@ -1315,7 +1307,7 @@ namespace FryPot_DosingSystem.Control | |||||
globalVar.agvArriveLineOneLoadEmptyRoller = false; | globalVar.agvArriveLineOneLoadEmptyRoller = false; | ||||
globalVar.agvArriveLineOneLoadCom = false; | globalVar.agvArriveLineOneLoadCom = false; | ||||
ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线1空桶清洗任务线程"); | ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线1空桶清洗任务线程"); | ||||
MessageLog.GetInstance.ShowUserLog("滚筒线1空桶清洗任务重启成功"); | |||||
MessageLog.GetInstance.ShowUserLog("滚筒线【1】空桶清洗任务重启成功"); | |||||
})); | })); | ||||
} | } | ||||
@@ -1338,8 +1330,8 @@ namespace FryPot_DosingSystem.Control | |||||
globalVar.rollerLineTwo.agvArriveCleanUnLoad = false; | globalVar.rollerLineTwo.agvArriveCleanUnLoad = false; | ||||
globalVar.agvArriveLineTwoLoadEmptyRoller = false; | globalVar.agvArriveLineTwoLoadEmptyRoller = false; | ||||
globalVar.agvArriveLineTwoLoadCom = false; | globalVar.agvArriveLineTwoLoadCom = false; | ||||
ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线2空桶清洗任务线程"); | |||||
MessageLog.GetInstance.ShowUserLog("滚筒线2空桶清洗任务重启成功"); | |||||
ThreadManage.GetInstance().StartLong(new Action(() => { LineTwoToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线2空桶清洗任务线程"); | |||||
MessageLog.GetInstance.ShowUserLog("滚筒线【2】空桶清洗任务重启成功"); | |||||
})); | })); | ||||
} | } | ||||
@@ -1347,8 +1339,6 @@ namespace FryPot_DosingSystem.Control | |||||
{ | { | ||||
ThreadManage.GetInstance().StopTask("滚筒线3空桶清洗任务线程", new Action(() => | ThreadManage.GetInstance().StopTask("滚筒线3空桶清洗任务线程", new Action(() => | ||||
{ | { | ||||
globalVar.rollerLineThree.StationEight = 0; | globalVar.rollerLineThree.StationEight = 0; | ||||
globalVar.rollerLineThree.EmptyRollerNums.Clear(); | globalVar.rollerLineThree.EmptyRollerNums.Clear(); | ||||
globalVar.rollerLineThree.EmptyRollerNums.Add(308); | globalVar.rollerLineThree.EmptyRollerNums.Add(308); | ||||
@@ -1360,8 +1350,8 @@ namespace FryPot_DosingSystem.Control | |||||
globalVar.rollerLineThree.agvArriveCleanUnLoad = false; | globalVar.rollerLineThree.agvArriveCleanUnLoad = false; | ||||
globalVar.agvArriveLineThreeLoadEmptyRoller = false; | globalVar.agvArriveLineThreeLoadEmptyRoller = false; | ||||
globalVar.agvArriveLineThreeLoadCom = false; | globalVar.agvArriveLineThreeLoadCom = false; | ||||
ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线3空桶清洗任务线程"); | |||||
MessageLog.GetInstance.ShowUserLog("滚筒线3空桶清洗任务重启成功"); | |||||
ThreadManage.GetInstance().StartLong(new Action(() => { LineThreeToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线3空桶清洗任务线程"); | |||||
MessageLog.GetInstance.ShowUserLog("滚筒线【3】空桶清洗任务重启成功"); | |||||
})); | })); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -1501,7 +1491,7 @@ namespace FryPot_DosingSystem.Control | |||||
//炒锅1状态数据 | //炒锅1状态数据 | ||||
GetFryOneData("D2001", new Action<ushort[]>(data => | GetFryOneData("D2001", new Action<ushort[]>(data => | ||||
{ | { | ||||
//FryPotMonitorManage.GetInstance.fryOne.Temperature =?; | |||||
})); | })); | ||||
//炒锅2状态数据 | //炒锅2状态数据 | ||||
GetFryTwoData("D2001", new Action<ushort[]>(data => | GetFryTwoData("D2001", new Action<ushort[]>(data => | ||||
@@ -2122,12 +2112,23 @@ namespace FryPot_DosingSystem.Control | |||||
if (globalVar.agvArriveCleanLoad) | if (globalVar.agvArriveCleanLoad) | ||||
{ | { | ||||
globalVar.agvArriveCleanLoad = false; | globalVar.agvArriveCleanLoad = false; | ||||
WritePlcData("D1066", 1);//AGV空桶出桶就位信号下发PlC | |||||
MessageLog.GetInstance.ShowRunLog("AGV到达清洗台空桶上料位置"); | MessageLog.GetInstance.ShowRunLog("AGV到达清洗台空桶上料位置"); | ||||
// MessageLog.GetInstance.ShowRunLog("清洗台空桶装载完成"); | |||||
if (globalVar.CleadBarrelExitSingle == 0) | |||||
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanOutputRollerRunning == 0) | |||||
{ | { | ||||
MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶上料信号已发送,出桶滚筒未运行!!"); | |||||
//plc交互 | |||||
WritePlcData("D1066", 1);//AGV空桶出桶就位信号下发PlC | |||||
} | |||||
else//有故障 | |||||
{ | |||||
while (AlarmHelper<AlarmInfo>.Alarm.CleanOutputRollerRunning == 1) | |||||
{ | |||||
Thread.Sleep(5); | |||||
if (globalVar.ExitLineOneTask) | |||||
return; | |||||
} | |||||
MessageLog.GetInstance.ShowRunLog("清洗台空桶出桶滚筒重新运行!!"); | |||||
goto erp; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -2143,7 +2144,7 @@ namespace FryPot_DosingSystem.Control | |||||
if (!globalVar.rollerLineOne.IsEpmtyBefore && globalVar.rollerLineOne.CanRun) | if (!globalVar.rollerLineOne.IsEpmtyBefore && globalVar.rollerLineOne.CanRun) | ||||
{ | { | ||||
var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight); | var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight); | ||||
if ((globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0) && InputMaterialQuene.Count > 0 && globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0)))//工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶 | |||||
if ((globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0) && InputMaterialQuene.Count > 0 && globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0)))//一种情况工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶,另一种在没有下单的情况下,线体上的桶都认为是空桶 | |||||
{ | { | ||||
//下发AGV去空桶线洗桶任务 | //下发AGV去空桶线洗桶任务 | ||||
@@ -2156,8 +2157,7 @@ namespace FryPot_DosingSystem.Control | |||||
Thread.Sleep(500); | Thread.Sleep(500); | ||||
LineToCleanCarryTaskErrorCodeAnalysis(info, 1); | LineToCleanCarryTaskErrorCodeAnalysis(info, 1); | ||||
globalVar.rollerLineOne.IsEpmtyBefore = true; | globalVar.rollerLineOne.IsEpmtyBefore = true; | ||||
//globalVar.rollerLineOne.CanRun = false; | |||||
AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处 | |||||
// AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处 | |||||
} | } | ||||
} | } | ||||
else | else | ||||
@@ -2192,8 +2192,8 @@ namespace FryPot_DosingSystem.Control | |||||
Thread.Sleep(500); | Thread.Sleep(500); | ||||
LineToCleanCarryTaskErrorCodeAnalysis(info, 2); | LineToCleanCarryTaskErrorCodeAnalysis(info, 2); | ||||
globalVar.rollerLineTwo.IsEpmtyBefore = true; | globalVar.rollerLineTwo.IsEpmtyBefore = true; | ||||
// globalVar.rollerLineTwo.CanRun = false; | |||||
AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处 | |||||
//AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处 | |||||
} | } | ||||
} | } | ||||
else | else | ||||
@@ -2227,8 +2227,8 @@ namespace FryPot_DosingSystem.Control | |||||
Thread.Sleep(500); | Thread.Sleep(500); | ||||
LineToCleanCarryTaskErrorCodeAnalysis(info, 3); | LineToCleanCarryTaskErrorCodeAnalysis(info, 3); | ||||
globalVar.rollerLineThree.IsEpmtyBefore = true; | globalVar.rollerLineThree.IsEpmtyBefore = true; | ||||
//globalVar.rollerLineThree.CanRun = false; | |||||
AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处 | |||||
//AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处 | |||||
} | } | ||||
} | } | ||||
else | else | ||||
@@ -2247,11 +2247,23 @@ namespace FryPot_DosingSystem.Control | |||||
{ | { | ||||
globalVar.rollerLineOne.agvArriveCleanUnLoad = false; | globalVar.rollerLineOne.agvArriveCleanUnLoad = false; | ||||
MessageLog.GetInstance.ShowRunLog("空桶从线体1到达清洗位置,准备卸桶"); | MessageLog.GetInstance.ShowRunLog("空桶从线体1到达清洗位置,准备卸桶"); | ||||
//plc交互 | |||||
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC | |||||
if (globalVar.CleadBarrelEnterSingle == 0) | |||||
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 0) | |||||
{ | { | ||||
MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!"); | |||||
//plc交互 | |||||
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC | |||||
} | |||||
else//有故障 | |||||
{ | |||||
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1) | |||||
{ | |||||
Thread.Sleep(5); | |||||
if (globalVar.ExitLineOneTask) | |||||
return; | |||||
} | |||||
MessageLog.GetInstance.ShowRunLog("清洗台空桶进桶滚筒重新运行!!"); | |||||
goto erp; | |||||
} | } | ||||
} | } | ||||
@@ -2268,11 +2280,22 @@ namespace FryPot_DosingSystem.Control | |||||
globalVar.rollerLineTwo.agvArriveCleanUnLoad = false; | globalVar.rollerLineTwo.agvArriveCleanUnLoad = false; | ||||
MessageLog.GetInstance.ShowRunLog("空桶从线体2到达清洗位置,准备卸桶"); | MessageLog.GetInstance.ShowRunLog("空桶从线体2到达清洗位置,准备卸桶"); | ||||
//plc交互 | |||||
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC | |||||
if (globalVar.CleadBarrelEnterSingle == 0) | |||||
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 0) | |||||
{ | |||||
//plc交互 | |||||
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC | |||||
} | |||||
else//有故障 | |||||
{ | { | ||||
MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!"); | |||||
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1) | |||||
{ | |||||
Thread.Sleep(5); | |||||
if (globalVar.ExitLineOneTask) | |||||
return; | |||||
} | |||||
MessageLog.GetInstance.ShowRunLog("清洗台空桶进桶滚筒重新运行!!"); | |||||
goto erp; | |||||
} | } | ||||
} | } | ||||
@@ -2288,13 +2311,30 @@ namespace FryPot_DosingSystem.Control | |||||
{ | { | ||||
globalVar.rollerLineThree.agvArriveCleanUnLoad = false; | globalVar.rollerLineThree.agvArriveCleanUnLoad = false; | ||||
MessageLog.GetInstance.ShowRunLog("空桶从线体3到达清洗位置,准备卸桶"); | MessageLog.GetInstance.ShowRunLog("空桶从线体3到达清洗位置,准备卸桶"); | ||||
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 0) | |||||
{ | |||||
//plc交互 | |||||
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC | |||||
//plc交互 | |||||
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC | |||||
if (globalVar.CleadBarrelEnterSingle == 0) | |||||
} | |||||
else//有故障 | |||||
{ | { | ||||
MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!"); | |||||
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1) | |||||
{ | |||||
Thread.Sleep(5); | |||||
if (globalVar.ExitLineOneTask) | |||||
return; | |||||
} | |||||
MessageLog.GetInstance.ShowRunLog("清洗台空桶进桶滚筒重新运行!!"); | |||||
goto erp; | |||||
} | } | ||||
////plc交互 | |||||
//WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC | |||||
//if (globalVar.CleadBarrelEnterSingle == 0) | |||||
//{ | |||||
// MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!"); | |||||
//} | |||||
} | } | ||||
} | } | ||||
@@ -2813,7 +2853,7 @@ namespace FryPot_DosingSystem.Control | |||||
// Sqlite<PotFourStatus>.GetInstance.Save();//保存数据 | // Sqlite<PotFourStatus>.GetInstance.Save();//保存数据 | ||||
//} | //} | ||||
//FryPotOneRollerTroubleCheck(); | //FryPotOneRollerTroubleCheck(); | ||||
if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//炒锅滚筒无故障 | |||||
if ((FryPotAlarm == 1 && globalVar.LOneFryPotSerial == 1 )|| (FryPotFourAlarm == 1&& globalVar.LOneFryPotSerial == 4))//炒锅滚筒无故障 | |||||
{ | { | ||||
if (globalVar.LOneFryPotSerial == 1) | if (globalVar.LOneFryPotSerial == 1) | ||||
{ | { | ||||
@@ -2854,6 +2894,7 @@ namespace FryPot_DosingSystem.Control | |||||
AgvArriveFryPotTwoOrFiveSingleSetDown(); | AgvArriveFryPotTwoOrFiveSingleSetDown(); | ||||
globalVar.LTwoagvArriveUnLoad = false; | globalVar.LTwoagvArriveUnLoad = false; | ||||
globalVar.LTwoPotInputMaterialArrive = true; | globalVar.LTwoPotInputMaterialArrive = true; | ||||
FryPotTwoRollerTroubleCheck(); | |||||
} | } | ||||
} | } | ||||
public void LTwoFallMaterial() | public void LTwoFallMaterial() | ||||
@@ -2870,8 +2911,8 @@ namespace FryPot_DosingSystem.Control | |||||
// Sqlite<PotFiveStatus>.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 | // Sqlite<PotFiveStatus>.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 | ||||
// Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据 | // Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据 | ||||
//} | //} | ||||
FryPotTwoRollerTroubleCheck(); | |||||
if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//炒锅滚筒无故障 | |||||
if ((FryPotTwoAlarm == 1&& globalVar.LTwoFryPotSerial == 2) ||( FryPotFiveAlarm == 1&& globalVar.LTwoFryPotSerial == 5))//炒锅滚筒无故障 | |||||
{ | { | ||||
if (globalVar.LTwoFryPotSerial == 2) | if (globalVar.LTwoFryPotSerial == 2) | ||||
{ | { | ||||
@@ -2906,6 +2947,7 @@ namespace FryPot_DosingSystem.Control | |||||
AgvArriveFryPotThreeSingleSetDown(); | AgvArriveFryPotThreeSingleSetDown(); | ||||
globalVar.LThreeagvArriveUnLoad = false; | globalVar.LThreeagvArriveUnLoad = false; | ||||
globalVar.LThreePotInputMaterialArrive = true; | globalVar.LThreePotInputMaterialArrive = true; | ||||
FryPotThreeRollerTroubleCheck(); | |||||
} | } | ||||
} | } | ||||
@@ -2915,7 +2957,7 @@ namespace FryPot_DosingSystem.Control | |||||
{ | { | ||||
//Sqlite<PotThreeStatus>.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 | //Sqlite<PotThreeStatus>.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 | ||||
//Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据 | //Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据 | ||||
FryPotThreeRollerTroubleCheck(); | |||||
if (FryPotThreeAlarm == 1)//炒锅滚筒无故障 | if (FryPotThreeAlarm == 1)//炒锅滚筒无故障 | ||||
{ | { | ||||
@@ -1,4 +1,6 @@ | |||||
using BPASmartClient.CustomResource.Pages.Model; | using BPASmartClient.CustomResource.Pages.Model; | ||||
using BPASmartClient.CustomResource.UserControls; | |||||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using FryPot_DosingSystem.Model; | using FryPot_DosingSystem.Model; | ||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | using Microsoft.Toolkit.Mvvm.ComponentModel; | ||||
@@ -96,7 +98,7 @@ namespace FryPot_DosingSystem.ViewModel | |||||
if (name == null) | if (name == null) | ||||
{ | { | ||||
if (RecipeRollerNum != 0) | |||||
if (materials.Count<=8&& materials.Count> 0) | |||||
{ | { | ||||
prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改 | prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改 | ||||
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID); | var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID); | ||||
@@ -112,7 +114,8 @@ namespace FryPot_DosingSystem.ViewModel | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
MessageLog.GetInstance.ShowUserLog($"新建配方【{RecipeName}】无效【配方中没有添加原料】"); | |||||
MessageLog.GetInstance.ShowUserLog($"新建配方【{RecipeName}】无效:【配方中原料桶数异常】"); | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"新建配方【{RecipeName}】无效"); | |||||
} | } | ||||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | ActionManage.GetInstance.Send("CloseNewRecipeView"); | ||||
} | } | ||||
@@ -124,11 +127,21 @@ namespace FryPot_DosingSystem.ViewModel | |||||
} | } | ||||
else //已有配方,用于编辑 | else //已有配方,用于编辑 | ||||
{ | { | ||||
bom.materialCollection = materials; | |||||
bom.RecipeName = RecipeName; | |||||
bom.UpdateTime = DateTime.Now.ToShortDateString(); | |||||
Json<RecipeManage>.Save(); | |||||
if (materials.Count > 0 && materials.Count <= 8) | |||||
{ | |||||
bom.materialCollection = materials; | |||||
bom.RecipeName = RecipeName; | |||||
bom.UpdateTime = DateTime.Now.ToShortDateString(); | |||||
Json<RecipeManage>.Save(); | |||||
MessageLog.GetInstance.ShowUserLog($"配方【{RecipeName}】修改成功"); | |||||
} | |||||
else | |||||
{ | |||||
MessageLog.GetInstance.ShowUserLog($"修改配方【{RecipeName}】无效:【配方中原料桶数异常】"); | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"修改配方【{RecipeName}】无效"); | |||||
} | |||||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | ActionManage.GetInstance.Send("CloseNewRecipeView"); | ||||
} | } | ||||
}); | }); | ||||
SaveAs = new RelayCommand(() => | SaveAs = new RelayCommand(() => | ||||
@@ -137,7 +150,7 @@ namespace FryPot_DosingSystem.ViewModel | |||||
var rec = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeId); | var rec = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeId); | ||||
if (bom == null && rec != null)//配方名称更改 | if (bom == null && rec != null)//配方名称更改 | ||||
{ | { | ||||
if (RecipeRollerNum != 0) | |||||
if (materials.Count>0&& materials.Count<=8)//验证配方中原料桶数 | |||||
{ | { | ||||
prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改 | prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改 | ||||
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID); | var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID); | ||||
@@ -149,11 +162,12 @@ namespace FryPot_DosingSystem.ViewModel | |||||
{ | { | ||||
goto prop; | goto prop; | ||||
} | } | ||||
MessageLog.GetInstance.ShowUserLog("新建配方成功"); | |||||
MessageLog.GetInstance.ShowUserLog("另存配方成功"); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
MessageLog.GetInstance.ShowUserLog("新建配方无效【配方中没有添加原料】"); | |||||
MessageLog.GetInstance.ShowUserLog($"另存配方【{rec.RecipeName}】无效:【配方中原料桶数异常】"); | |||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"另存配方【{rec.RecipeName}】无效"); | |||||
} | } | ||||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | ActionManage.GetInstance.Send("CloseNewRecipeView"); | ||||
} | } | ||||
@@ -178,6 +178,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeDesignerSCADA", "BeDesign | |||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.RecipeManagement", "BPASmart.RecipeManagement\BPASmart.RecipeManagement.csproj", "{28EBFC11-184A-4B88-A7B3-84F3FD768520}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.RecipeManagement", "BPASmart.RecipeManagement\BPASmart.RecipeManagement.csproj", "{28EBFC11-184A-4B88-A7B3-84F3FD768520}" | ||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.SmallBatchingSystem", "BPASmart.SmallBatchingSystem\BPASmart.SmallBatchingSystem.csproj", "{DB6DC970-859C-4C63-AE9B-BA415D56CECD}" | |||||
EndProject | |||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmart.ConfigurationSoftware", "BPASmart.ConfigurationSoftware\BPASmart.ConfigurationSoftware.csproj", "{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}" | |||||
EndProject | |||||
Global | Global | ||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
Debug|Any CPU = Debug|Any CPU | Debug|Any CPU = Debug|Any CPU | ||||
@@ -1612,6 +1616,46 @@ Global | |||||
{28EBFC11-184A-4B88-A7B3-84F3FD768520}.Release|x64.Build.0 = Release|Any CPU | {28EBFC11-184A-4B88-A7B3-84F3FD768520}.Release|x64.Build.0 = Release|Any CPU | ||||
{28EBFC11-184A-4B88-A7B3-84F3FD768520}.Release|x86.ActiveCfg = Release|Any CPU | {28EBFC11-184A-4B88-A7B3-84F3FD768520}.Release|x86.ActiveCfg = Release|Any CPU | ||||
{28EBFC11-184A-4B88-A7B3-84F3FD768520}.Release|x86.Build.0 = Release|Any CPU | {28EBFC11-184A-4B88-A7B3-84F3FD768520}.Release|x86.Build.0 = Release|Any CPU | ||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|ARM.Build.0 = Debug|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|ARM64.Build.0 = Debug|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|x64.ActiveCfg = Debug|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|x64.Build.0 = Debug|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|x86.ActiveCfg = Debug|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|x86.Build.0 = Debug|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|ARM.ActiveCfg = Release|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|ARM.Build.0 = Release|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|ARM64.ActiveCfg = Release|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|ARM64.Build.0 = Release|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|x64.ActiveCfg = Release|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|x64.Build.0 = Release|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|x86.ActiveCfg = Release|Any CPU | |||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|x86.Build.0 = Release|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|ARM.Build.0 = Debug|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|ARM64.Build.0 = Debug|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|x64.ActiveCfg = Debug|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|x64.Build.0 = Debug|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|x86.ActiveCfg = Debug|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|x86.Build.0 = Debug|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Release|ARM.ActiveCfg = Release|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Release|ARM.Build.0 = Release|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Release|ARM64.ActiveCfg = Release|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Release|ARM64.Build.0 = Release|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Release|x64.ActiveCfg = Release|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Release|x64.Build.0 = Release|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Release|x86.ActiveCfg = Release|Any CPU | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Release|x86.Build.0 = Release|Any CPU | |||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(SolutionProperties) = preSolution | GlobalSection(SolutionProperties) = preSolution | ||||
HideSolutionNode = FALSE | HideSolutionNode = FALSE | ||||
@@ -1694,6 +1738,8 @@ Global | |||||
{06F0B369-0483-46DD-82D2-70431FB505C1} = {7B0175AD-BB74-4A98-B9A7-1E289032485E} | {06F0B369-0483-46DD-82D2-70431FB505C1} = {7B0175AD-BB74-4A98-B9A7-1E289032485E} | ||||
{DF8B4C38-39DE-4220-AB60-885CAE6D1E47} = {06F0B369-0483-46DD-82D2-70431FB505C1} | {DF8B4C38-39DE-4220-AB60-885CAE6D1E47} = {06F0B369-0483-46DD-82D2-70431FB505C1} | ||||
{28EBFC11-184A-4B88-A7B3-84F3FD768520} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} | {28EBFC11-184A-4B88-A7B3-84F3FD768520} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} | ||||
{DB6DC970-859C-4C63-AE9B-BA415D56CECD} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} | |||||
{897F8379-3301-4CBE-9BCA-AF7FD2F963A9} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} | |||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(ExtensibilityGlobals) = postSolution | GlobalSection(ExtensibilityGlobals) = postSolution | ||||
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC} | SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC} | ||||
@@ -20,6 +20,7 @@ | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\BeDesignerSCADA\BeDesignerSCADA.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | <ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||