@@ -0,0 +1,8 @@ | |||||
<Application x:Class="BPASmart.MenuLoad.App" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:local="clr-namespace:BPASmart.MenuLoad"> | |||||
<Application.Resources> | |||||
</Application.Resources> | |||||
</Application> |
@@ -0,0 +1,67 @@ | |||||
using BeDesignerSCADA.Helper; | |||||
using BeDesignerSCADA.View; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Configuration; | |||||
using System.Data; | |||||
using System.Diagnostics; | |||||
using System.IO; | |||||
using System.Linq; | |||||
using System.Runtime.InteropServices; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
using System.Windows; | |||||
namespace BPASmart.MenuLoad | |||||
{ | |||||
/// <summary> | |||||
/// Interaction logic for App.xaml | |||||
/// </summary> | |||||
public partial class App : Application | |||||
{ | |||||
bool isShow = false; | |||||
[DllImport("kernel32.dll")] | |||||
private static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max); | |||||
string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf"; | |||||
private void FlushMemory() | |||||
{ | |||||
GC.Collect(); | |||||
GC.WaitForPendingFinalizers(); | |||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT) | |||||
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); | |||||
} | |||||
protected override void OnStartup(StartupEventArgs e) | |||||
{ | |||||
base.OnStartup(e); | |||||
RunWindows run = new RunWindows(); | |||||
_ = Task.Factory.StartNew(delegate | |||||
{ | |||||
while (true) | |||||
{ | |||||
try | |||||
{ | |||||
if (!isShow) | |||||
{ | |||||
this.Dispatcher.Invoke(() => { | |||||
if (File.Exists(_path)) | |||||
{ | |||||
SystemHelperNew.GetInstance.CreateDesktopShortcut(); | |||||
run.LoadingData(_path); | |||||
run.Show(); | |||||
isShow = true; | |||||
} | |||||
}); | |||||
} | |||||
FlushMemory(); | |||||
Thread.Sleep(TimeSpan.FromSeconds((double)1000)); | |||||
} | |||||
catch { } | |||||
} | |||||
}); | |||||
} | |||||
} | |||||
} |
@@ -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,28 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>WinExe</OutputType> | |||||
<TargetFramework>net6.0-windows</TargetFramework> | |||||
<Nullable>enable</Nullable> | |||||
<UseWPF>true</UseWPF> | |||||
<AssemblyName>可视化应用</AssemblyName> | |||||
<ApplicationIcon>fyf.ico</ApplicationIcon> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<None Remove="fyf.ico" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<Content Include="fyf.ico" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\BeDesignerSCADA\BeDesignerSCADA.csproj" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<Resource Include="fyf.ico" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -0,0 +1,12 @@ | |||||
<Window x:Class="BPASmart.MenuLoad.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:local="clr-namespace:BPASmart.MenuLoad" | |||||
mc:Ignorable="d" | |||||
Title="MainWindow" Height="450" Width="800"> | |||||
<Grid> | |||||
</Grid> | |||||
</Window> |
@@ -0,0 +1,28 @@ | |||||
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.MenuLoad | |||||
{ | |||||
/// <summary> | |||||
/// Interaction logic for MainWindow.xaml | |||||
/// </summary> | |||||
public partial class MainWindow : Window | |||||
{ | |||||
public MainWindow() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -9,6 +9,16 @@ | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<COMReference Include="IWshRuntimeLibrary"> | |||||
<WrapperTool>tlbimp</WrapperTool> | |||||
<VersionMinor>0</VersionMinor> | |||||
<VersionMajor>1</VersionMajor> | |||||
<Guid>f935dc20-1cf0-11d0-adb9-00c04fd58a0b</Guid> | |||||
<Lcid>0</Lcid> | |||||
<Isolated>false</Isolated> | |||||
<EmbedInteropTypes>true</EmbedInteropTypes> | |||||
<UseWindowsForms>true</UseWindowsForms> | |||||
</COMReference> | |||||
<Compile Remove="Adorners\**" /> | <Compile Remove="Adorners\**" /> | ||||
<Compile Remove="CustomerControls\**" /> | <Compile Remove="CustomerControls\**" /> | ||||
<EmbeddedResource Remove="Adorners\**" /> | <EmbeddedResource Remove="Adorners\**" /> | ||||
@@ -119,8 +129,4 @@ | |||||
</Reference> | </Reference> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | |||||
<Folder Include="Helper\" /> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -78,6 +78,11 @@ | |||||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Save" /> | <icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Save" /> | ||||
</MenuItem.Icon> | </MenuItem.Icon> | ||||
</MenuItem> | </MenuItem> | ||||
<MenuItem Header="(另存)页面" Command="{Binding LWSaveAllPageCommand}"> | |||||
<MenuItem.Icon> | |||||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Save" /> | |||||
</MenuItem.Icon> | |||||
</MenuItem> | |||||
<MenuItem Header="变量管理器" Command="{Binding LoadValuesCommand}"> | <MenuItem Header="变量管理器" Command="{Binding LoadValuesCommand}"> | ||||
<MenuItem.Icon> | <MenuItem.Icon> | ||||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="DiskDownload" /> | <icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="DiskDownload" /> | ||||
@@ -44,7 +44,6 @@ namespace BeDesignerSCADA.Controls | |||||
viewModel.LayoutsPath = _Path; | viewModel.LayoutsPath = _Path; | ||||
this.DataContext = viewModel; | this.DataContext = viewModel; | ||||
viewModel.Loaded(cav, runCanvas); | viewModel.Loaded(cav, runCanvas); | ||||
//控件加载 | //控件加载 | ||||
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); | Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); | ||||
CtlList.ItemsSource = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name)?.ToList(); | CtlList.ItemsSource = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name)?.ToList(); | ||||
@@ -139,10 +138,10 @@ namespace BeDesignerSCADA.Controls | |||||
/// </summary> | /// </summary> | ||||
public void FileSave() | public void FileSave() | ||||
{ | { | ||||
SaveBtn_Click(null, null); | |||||
viewModel.SaveAllPageHeaderPath(viewModel.LayoutsPath); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 读取文件 | |||||
/// 读取文件,加载布局 | |||||
/// </summary> | /// </summary> | ||||
/// <param name="path"></param> | /// <param name="path"></param> | ||||
public void FileRead(string path) | public void FileRead(string path) | ||||
@@ -151,59 +150,14 @@ namespace BeDesignerSCADA.Controls | |||||
{ | { | ||||
if (File.Exists(path)) | 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); | |||||
viewModel.LoadAllPageHeaderPath(path); | |||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 根据流加载数据 | |||||
/// </summary> | |||||
public void LoadFrameworkElement(UIElementCollection frameworks) | |||||
{ | |||||
try | |||||
{ | |||||
cav.Children.Clear(); | |||||
foreach (FrameworkElement element in frameworks) | |||||
{ | |||||
string xamlText = XamlWriter.Save(element); | |||||
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; | |||||
cav.Children.Add(item); | |||||
} | |||||
cav.SelectedItems?.Clear(); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 获取所有控件 | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
public List<FrameworkElement> GetChildren() | |||||
{ | |||||
List<FrameworkElement> frameworks = new List<FrameworkElement>(); | |||||
foreach (FrameworkElement child in cav.Children) | |||||
{ | |||||
string xamlText = XamlWriter.Save(child); | |||||
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; | |||||
frameworks.Add(item); | |||||
} | |||||
return frameworks; | |||||
} | |||||
/// <summary> | |||||
/// 运行程序 | /// 运行程序 | ||||
/// </summary> | /// </summary> | ||||
public void Run() | public void Run() | ||||
@@ -303,21 +257,13 @@ namespace BeDesignerSCADA.Controls | |||||
/// <param name="e"></param> | /// <param name="e"></param> | ||||
private void SaveBtn_Click(object sender, RoutedEventArgs e) | private void SaveBtn_Click(object sender, RoutedEventArgs e) | ||||
{ | { | ||||
if (File.Exists(viewModel.LayoutsPath)) | |||||
SaveFileDialog sfd = new SaveFileDialog(); | |||||
sfd.Filter = "布局文件|*.lay"; | |||||
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) | |||||
{ | { | ||||
string str = cav.Save(); | string str = cav.Save(); | ||||
File.WriteAllText(viewModel.LayoutsPath, str, Encoding.Unicode); | |||||
} | |||||
else | |||||
{ | |||||
SaveFileDialog sfd = new SaveFileDialog(); | |||||
sfd.Filter = "布局文件|*.lay"; | |||||
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) | |||||
{ | |||||
string str = cav.Save(); | |||||
File.WriteAllText(sfd.FileName, str, Encoding.Unicode); | |||||
} | |||||
File.WriteAllText(sfd.FileName, str, Encoding.Unicode); | |||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -0,0 +1,232 @@ | |||||
using IWshRuntimeLibrary; | |||||
using Microsoft.Win32; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Diagnostics; | |||||
using System.Linq; | |||||
using System.Runtime.InteropServices; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BeDesignerSCADA.Helper | |||||
{ | |||||
/// <summary> | |||||
/// 系统操作类 | |||||
/// </summary> | |||||
public class SystemHelperNew | |||||
{ | |||||
private volatile static SystemHelperNew _Instance; | |||||
public static SystemHelperNew GetInstance => _Instance ?? (_Instance = new SystemHelperNew()); | |||||
private SystemHelperNew() { } | |||||
/// <summary> | |||||
/// 获取当前应用程序名称,包括后缀名 | |||||
/// </summary> | |||||
public string GetApplicationName => $"{AppDomain.CurrentDomain.FriendlyName}.exe"; | |||||
/// <summary> | |||||
/// 获取当前应用程序完整路径 | |||||
/// </summary> | |||||
public string GetApplicationPath => $"{AppDomain.CurrentDomain.BaseDirectory}{GetApplicationName}"; | |||||
/// <summary> | |||||
/// 创建桌面快捷方式 | |||||
/// </summary> | |||||
/// <returns>成功或失败</returns> | |||||
public bool CreateDesktopShortcut() | |||||
{ | |||||
//1、在COM对象中找到 Windows Script Host Object Model | |||||
//2、添加引用 using IWshRuntimeLibrary; | |||||
string deskTop = string.Empty; | |||||
try | |||||
{ | |||||
deskTop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\"; | |||||
if (System.IO.File.Exists(deskTop + GetApplicationName + ".lnk")) // | |||||
{ | |||||
return true; | |||||
//System.IO.File.Delete(deskTop + FileName + ".lnk");//删除原来的桌面快捷键方式 | |||||
} | |||||
WshShell shell = new WshShell(); | |||||
//快捷键方式创建的位置、名称 | |||||
IWshShortcut shortcut = shell.CreateShortcut(deskTop + GetApplicationName + ".lnk") as IWshShortcut; | |||||
shortcut.TargetPath = GetApplicationPath; //目标文件 | |||||
//该属性指定应用程序的工作目录,当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。 | |||||
shortcut.WorkingDirectory = System.Environment.CurrentDirectory; | |||||
shortcut.WindowStyle = 1; //目标应用程序的窗口状态分为普通、最大化、最小化【1,3,7】 | |||||
shortcut.Description = GetApplicationName; //描述 | |||||
//shortcut.IconLocation = exePath + "\\logo.ico"; //快捷方式图标 | |||||
shortcut.Arguments = ""; | |||||
//shortcut.Hotkey = "CTRL+ALT+F11"; // 快捷键 | |||||
shortcut.Save(); //必须调用保存快捷才成创建成功 | |||||
return true; | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
return false; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 设置开机自启动 | |||||
/// </summary> | |||||
/// <param name="isAuto">true:开机启动,false:不开机自启</param> | |||||
public void AutoStart(bool isAuto = true) | |||||
{ | |||||
if (isAuto == true) | |||||
{ | |||||
RegistryKey R_local = Registry.CurrentUser; | |||||
RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); | |||||
R_run.SetValue(GetApplicationName, GetApplicationPath); | |||||
R_run.Close(); | |||||
R_local.Close(); | |||||
} | |||||
else | |||||
{ | |||||
RegistryKey R_local = Registry.CurrentUser; | |||||
RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); | |||||
R_run.DeleteValue(GetApplicationName, false); | |||||
R_run.Close(); | |||||
R_local.Close(); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 判断是否是自动启动 | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
public bool IsAutoStart() | |||||
{ | |||||
RegistryKey R_local = Registry.CurrentUser; | |||||
RegistryKey R_run = R_local.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); | |||||
bool res = R_run.GetValueNames().Contains(GetApplicationName); | |||||
R_run.Close(); | |||||
R_local.Close(); | |||||
return res; | |||||
} | |||||
#region U盘,串口插拔信息 | |||||
private const int WM_DEVICECHANGE = 0x219; //设备改变 | |||||
private const int DBT_DEVICEARRIVAL = 0x8000; //检测到新设备 | |||||
private const int DBT_DEVICEREMOVECOMPLETE = 0x8004; //移除设备 | |||||
public const int DBT_DEVTYP_PORT = 0x00000003; | |||||
public const int DBT_DEVTYP_VOLUME = 0x00000002; | |||||
public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) | |||||
{ | |||||
if (msg == WM_DEVICECHANGE) | |||||
{ | |||||
//插入 | |||||
if (wParam.ToInt32() == DBT_DEVICEARRIVAL) | |||||
{ | |||||
var volume = (DEV_BROADCAST_HDR)Marshal.PtrToStructure(lParam, typeof(DEV_BROADCAST_HDR)); | |||||
switch (volume.dbch_devicetype) | |||||
{ | |||||
case DBT_DEVTYP_PORT://串口设备 | |||||
string portName = Marshal.PtrToStringUni(lParam + Marshal.SizeOf(typeof(DEV_BROADCAST_PORT))); | |||||
break; | |||||
case DBT_DEVTYP_VOLUME: | |||||
var drive = GetDrive(lParam); | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
//拔出 | |||||
if (wParam.ToInt32() == DBT_DEVICEREMOVECOMPLETE) | |||||
{ | |||||
var volume = (DEV_BROADCAST_HDR)Marshal.PtrToStructure(lParam, typeof(DEV_BROADCAST_HDR)); | |||||
switch (volume.dbch_devicetype) | |||||
{ | |||||
case DBT_DEVTYP_PORT://串口设备 | |||||
string portName = Marshal.PtrToStringUni(lParam + Marshal.SizeOf(typeof(DEV_BROADCAST_PORT))); | |||||
break; | |||||
case DBT_DEVTYP_VOLUME: | |||||
var drive = GetDrive(lParam); | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
return IntPtr.Zero; | |||||
} | |||||
private static string GetDrive(IntPtr lParam) | |||||
{ | |||||
var volume = (DEV_BROADCAST_VOLUME)Marshal.PtrToStructure(lParam, typeof(DEV_BROADCAST_VOLUME)); | |||||
var letter = GetLetter(volume.dbcv_unitmask); | |||||
return string.Format("{0}:\\", letter); | |||||
} | |||||
/// <summary> | |||||
/// 获得盘符 | |||||
/// </summary> | |||||
/// <param name="dbcvUnitmask"> | |||||
/// 1 = A | |||||
/// 2 = B | |||||
/// 4 = C... | |||||
/// </param> | |||||
/// <returns>结果是A~Z的任意一个字符或者为'?'</returns> | |||||
private static char GetLetter(uint dbcvUnitmask) | |||||
{ | |||||
const char nona = '?'; | |||||
const string drives = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |||||
if (dbcvUnitmask == 0) return nona; | |||||
var i = 0; | |||||
var pom = dbcvUnitmask >> 1; | |||||
while (pom != 0) | |||||
{ | |||||
pom = pom >> 1; | |||||
i++; | |||||
} | |||||
if (i < drives.Length) | |||||
return drives[i]; | |||||
return nona; | |||||
} | |||||
#endregion | |||||
} | |||||
[StructLayout(LayoutKind.Sequential)] | |||||
struct DEV_BROADCAST_HDR | |||||
{ | |||||
public UInt32 dbch_size; | |||||
public UInt32 dbch_devicetype; | |||||
public UInt32 dbch_reserved; | |||||
} | |||||
[StructLayout(LayoutKind.Sequential)] | |||||
struct DEV_BROADCAST_PORT | |||||
{ | |||||
public uint dbcp_size; | |||||
public uint dbcp_devicetype; | |||||
public uint dbcp_reserved; | |||||
} | |||||
[StructLayout(LayoutKind.Sequential)] | |||||
struct DEV_BROADCAST_PORT_A | |||||
{ | |||||
public uint dbcp_size; | |||||
public uint dbcp_devicetype; | |||||
public uint dbcp_reserved; | |||||
//public string dbcp_name; | |||||
} | |||||
[StructLayout(LayoutKind.Sequential)] | |||||
struct DEV_BROADCAST_VOLUME | |||||
{ | |||||
/// DWORD->unsigned int | |||||
public uint dbcv_size; | |||||
/// DWORD->unsigned int | |||||
public uint dbcv_devicetype; | |||||
/// DWORD->unsigned int | |||||
public uint dbcv_reserved; | |||||
/// DWORD->unsigned int | |||||
public uint dbcv_unitmask; | |||||
/// WORD->unsigned short | |||||
public ushort dbcv_flags; | |||||
} | |||||
} |
@@ -384,6 +384,10 @@ namespace BeDesignerSCADA.ViewModel | |||||
/// </summary> | /// </summary> | ||||
public RelayCommand SaveAllPageCommand { get; set; } | public RelayCommand SaveAllPageCommand { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 另存页面文件 | |||||
/// </summary> | |||||
public RelayCommand LWSaveAllPageCommand { get; set; } | |||||
/// <summary> | |||||
/// 加载页面文件 | /// 加载页面文件 | ||||
/// </summary> | /// </summary> | ||||
public RelayCommand LoadAllPageCommand { get; set; } | public RelayCommand LoadAllPageCommand { get; set; } | ||||
@@ -403,6 +407,7 @@ namespace BeDesignerSCADA.ViewModel | |||||
DeletePageCommand = new RelayCommand<object>(new Action<object?>(DeletePageHeader)); | DeletePageCommand = new RelayCommand<object>(new Action<object?>(DeletePageHeader)); | ||||
SelectPageCommand = new RelayCommand<object>(new Action<object?>(SelectPageHeader)); | SelectPageCommand = new RelayCommand<object>(new Action<object?>(SelectPageHeader)); | ||||
SaveAllPageCommand = new RelayCommand(new Action(SaveAllPageHeader)); | SaveAllPageCommand = new RelayCommand(new Action(SaveAllPageHeader)); | ||||
LWSaveAllPageCommand=new RelayCommand(new Action(LWSaveAllPageHeader)); | |||||
LoadAllPageCommand = new RelayCommand(new Action(LoadAllPageHeader)); | LoadAllPageCommand = new RelayCommand(new Action(LoadAllPageHeader)); | ||||
LoadValuesCommand = new RelayCommand(new Action(LoadValuesHeader)); | LoadValuesCommand = new RelayCommand(new Action(LoadValuesHeader)); | ||||
@@ -412,7 +417,6 @@ namespace BeDesignerSCADA.ViewModel | |||||
MenuModel.SelectPageModels = MenuModel.pageModels[0]; | MenuModel.SelectPageModels = MenuModel.pageModels[0]; | ||||
GxSortTarget(); | GxSortTarget(); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 刷新排序 | /// 刷新排序 | ||||
/// </summary> | /// </summary> | ||||
@@ -573,15 +577,37 @@ namespace BeDesignerSCADA.ViewModel | |||||
/// 导出页面文件 | /// 导出页面文件 | ||||
/// </summary> | /// </summary> | ||||
public void SaveAllPageHeader() | public void SaveAllPageHeader() | ||||
{ | |||||
try | |||||
{ | |||||
string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf"; | |||||
if (!Directory.Exists($"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts")) // 返回bool类型,存在返回true,不存在返回false | |||||
{ | |||||
Directory.CreateDirectory($"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts"); //不存在则创建路径 | |||||
} | |||||
if (File.Exists(_path)) // 返回bool类型,存在返回true,不存在返回false | |||||
{ | |||||
File.Delete(_path); | |||||
} | |||||
SaveAllPageHeaderPath(_path); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 另存文件 | |||||
/// </summary> | |||||
public void LWSaveAllPageHeader() | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
SaveFileDialog sfd = new SaveFileDialog(); | SaveFileDialog sfd = new SaveFileDialog(); | ||||
sfd.Filter = "页面布局|*.yf"; | sfd.Filter = "页面布局|*.yf"; | ||||
if (sfd.ShowDialog() == true) | if (sfd.ShowDialog() == true) | ||||
{ | { | ||||
BinaryFile.SaveBinary(MenuModel, sfd.FileName); | |||||
SaveAllPageHeaderPath(sfd.FileName); | |||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -589,6 +615,22 @@ namespace BeDesignerSCADA.ViewModel | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 根据路径保存菜单布局 | |||||
/// </summary> | |||||
/// <param name="path"></param> | |||||
public void SaveAllPageHeaderPath(string path) | |||||
{ | |||||
try | |||||
{ | |||||
BinaryFile.SaveBinary(MenuModel, path); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 加载页面文件 | /// 加载页面文件 | ||||
/// </summary> | /// </summary> | ||||
@@ -600,20 +642,35 @@ namespace BeDesignerSCADA.ViewModel | |||||
ofd.Filter = "页面布局|*.yf"; | ofd.Filter = "页面布局|*.yf"; | ||||
if (ofd.ShowDialog() == true) | if (ofd.ShowDialog() == true) | ||||
{ | { | ||||
MenuModel = BinaryFile.ReadBinary<MenuModel>(ofd.FileName) as MenuModel; | |||||
MenuModel?.pageModels?.ToList().ForEach(par => | |||||
LoadAllPageHeaderPath(ofd.FileName); | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 根据路径加载菜单布局 | |||||
/// </summary> | |||||
/// <param name="path"></param> | |||||
public void LoadAllPageHeaderPath(string path) | |||||
{ | |||||
try | |||||
{ | |||||
MenuModel = BinaryFile.ReadBinary<MenuModel>(path) as MenuModel; | |||||
MenuModel?.pageModels?.ToList().ForEach(par => | |||||
{ | |||||
par.visual = new CanvasPanel(); | |||||
par?.ChildrenStr?.ForEach(k => | |||||
{ | { | ||||
par.visual = new CanvasPanel(); | |||||
par?.ChildrenStr?.ForEach(k => | |||||
{ | |||||
FrameworkElement item = XamlReader.Parse(k) as FrameworkElement; | |||||
par.visual.Children.Add(item); | |||||
}); | |||||
FrameworkElement item = XamlReader.Parse(k) as FrameworkElement; | |||||
par.visual.Children.Add(item); | |||||
}); | }); | ||||
if (MenuModel.pageModels != null && MenuModel.pageModels.Count > 0) | |||||
{ | |||||
SelectPageHeader(MenuModel.pageModels?.ToList()?[0]); | |||||
} | |||||
}); | |||||
if (MenuModel.pageModels != null && MenuModel.pageModels.Count > 0) | |||||
{ | |||||
SelectPageHeader(MenuModel.pageModels?.ToList()?[0]); | |||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -180,6 +180,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkMOC", "B | |||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.DosingHKProject", "BPASmartClient.DosingProject\BPASmartClient.DosingHKProject.csproj", "{6763F73A-555C-41E2-91F7-ADF26C59A946}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.DosingHKProject", "BPASmartClient.DosingProject\BPASmartClient.DosingHKProject.csproj", "{6763F73A-555C-41E2-91F7-ADF26C59A946}" | ||||
EndProject | EndProject | ||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmart.MenuLoad", "BPASmart.MenuLoad\BPASmart.MenuLoad.csproj", "{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}" | |||||
EndProject | |||||
Global | Global | ||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
Debug|Any CPU = Debug|Any CPU | Debug|Any CPU = Debug|Any CPU | ||||
@@ -1694,6 +1696,26 @@ Global | |||||
{6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x64.Build.0 = Release|Any CPU | {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x64.Build.0 = Release|Any CPU | ||||
{6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.ActiveCfg = Release|Any CPU | {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.ActiveCfg = Release|Any CPU | ||||
{6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.Build.0 = Release|Any CPU | {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.Build.0 = Release|Any CPU | ||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM.Build.0 = Debug|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM64.Build.0 = Debug|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x64.ActiveCfg = Debug|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x64.Build.0 = Debug|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x86.ActiveCfg = Debug|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x86.Build.0 = Debug|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM.ActiveCfg = Release|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM.Build.0 = Release|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM64.ActiveCfg = Release|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM64.Build.0 = Release|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x64.ActiveCfg = Release|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x64.Build.0 = Release|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x86.ActiveCfg = Release|Any CPU | |||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x86.Build.0 = Release|Any CPU | |||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(SolutionProperties) = preSolution | GlobalSection(SolutionProperties) = preSolution | ||||
HideSolutionNode = FALSE | HideSolutionNode = FALSE | ||||
@@ -1777,6 +1799,7 @@ Global | |||||
{BA588F22-87FB-4124-AF62-CA8DC492ED7D} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} | {BA588F22-87FB-4124-AF62-CA8DC492ED7D} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} | ||||
{D5081D7B-3EBB-42C7-8FB9-A889870D08C2} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | {D5081D7B-3EBB-42C7-8FB9-A889870D08C2} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | ||||
{6763F73A-555C-41E2-91F7-ADF26C59A946} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} | {6763F73A-555C-41E2-91F7-ADF26C59A946} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} | ||||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B} = {06F0B369-0483-46DD-82D2-70431FB505C1} | |||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(ExtensibilityGlobals) = postSolution | GlobalSection(ExtensibilityGlobals) = postSolution | ||||
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC} | SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC} | ||||