Browse Source

页面加载

样式分支
pry 2 years ago
parent
commit
4c62a9fc44
15 changed files with 186 additions and 43 deletions
  1. +1
    -1
      BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj
  2. +12
    -3
      BPASmart.ConfigurationSoftware/MainWindow.xaml
  3. +9
    -1
      BPASmart.ConfigurationSoftware/MainWindowViewModel.cs
  4. +5
    -3
      BPASmart.ConfigurationSoftware/NewProjectView.xaml
  5. +57
    -1
      BPASmart.ConfigurationSoftware/ServiceCenter.cs
  6. +17
    -0
      BPASmart.Model/BinConfigFile.cs
  7. +29
    -0
      BPASmart.Model/FileConfigModel.cs
  8. +4
    -1
      BPASmart.PageLoad/BPASmart.PageLoad.csproj
  9. +17
    -17
      BPASmart.PageLoad/FControl/RunCanvas.xaml.cs
  10. +20
    -0
      BPASmart.PageLoad/MainWindow.xaml.cs
  11. +2
    -2
      BPASmart.Server/BPASmart.Server.csproj
  12. +1
    -2
      BPASmart.Server/CommunicationServer.cs
  13. +2
    -2
      BPASmart.VariableManager/BPASmart.VariableManager.csproj
  14. +8
    -8
      BPASmart.VariableManager/Views/NewDeviceView.xaml
  15. +2
    -2
      ComputerTestDemo/ComputerTestDemo.csproj

+ 1
- 1
BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj View File

@@ -20,7 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.9" />
<PackageReference Include="BPA.Helper" Version="1.0.11" />
</ItemGroup>

<ItemGroup>


+ 12
- 3
BPASmart.ConfigurationSoftware/MainWindow.xaml View File

@@ -191,9 +191,18 @@
Style="{StaticResource RadioMiniButtonStyle}">
<RadioButton.ContextMenu>
<ContextMenu>
<MenuItem Header="删除页面" />
<MenuItem Header="设为启动界面" />
<MenuItem Header="重命名" />
<MenuItem
Command="{Binding DataContext.RemovePageCommand, RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=4, Mode=FindAncestor}}"
CommandParameter="{Binding}"
Header="删除页面" />
<MenuItem
Command="{Binding DataContext.SetStartPageCommand, RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=4, Mode=FindAncestor}}"
CommandParameter="{Binding}"
Header="设为启动界面" />
<MenuItem
Command="{Binding DataContext.ReNameCommand, RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=4, Mode=FindAncestor}}"
CommandParameter="{Binding}"
Header="重命名" />
</ContextMenu>
</RadioButton.ContextMenu>
</RadioButton>


+ 9
- 1
BPASmart.ConfigurationSoftware/MainWindowViewModel.cs View File

@@ -32,13 +32,15 @@ namespace BPASmart.ConfigurationSoftware
SelectedPageCommand = new RelayCommand<object>((o) => { ServiceCenter.GetInstance.SelectedPage(o); });
SaveProjectCommand = new RelayCommand(() => { ServiceCenter.GetInstance.ProjectSave(); });
GengrateCommand = new RelayCommand(() => { ServiceCenter.GetInstance.ApplicationBale(); });
RemovePageCommand = new RelayCommand<object>((o) => { ServiceCenter.GetInstance.RemovePageCommand(o); });
ReNameCommand = new RelayCommand<object>((o) => { ServiceCenter.GetInstance.ReNameCommand(o); });
SetStartPageCommand = new RelayCommand<object>((o) => { ServiceCenter.GetInstance.SetStartPageCommand(o); });
ServiceCenter.GetInstance.PageChange = new Action<FrameworkElement>((f) => { MainContent = f; });
ServiceCenter.GetInstance.ProjectNameChange = new Action<string>((s) => { Head = s; });
mainCanvasPanels = ServiceCenter.GetInstance.mainCanvasPanels;
Pages = ServiceCenter.GetInstance.Pages;
Message = ServiceCenter.GetInstance.Message;
ServiceCenter.GetInstance.Init();

}

public RelayCommand NewProjectCommand { get; set; }
@@ -53,6 +55,12 @@ namespace BPASmart.ConfigurationSoftware

public RelayCommand GengrateCommand { get; set; }

public RelayCommand<object> RemovePageCommand { get; set; }

public RelayCommand<object> SetStartPageCommand { get; set; }

public RelayCommand<object> ReNameCommand { get; set; }

public string Head { get { return _mHead; } set { _mHead = value; OnPropertyChanged(); } }
private string _mHead;



+ 5
- 3
BPASmart.ConfigurationSoftware/NewProjectView.xaml View File

@@ -6,8 +6,8 @@
xmlns:local="clr-namespace:BPASmart.ConfigurationSoftware"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="创建新项目"
Width="300"
Height="180"
Width="330"
Height="220"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">

@@ -30,6 +30,7 @@
<TextBox
Grid.Row="1"
VerticalAlignment="Center"
FontSize="20"
Text="{Binding NewData.ProjectName}" />

<TextBlock
@@ -53,7 +54,8 @@
Grid.Row="4"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding ErrorInfo}" Foreground="Red"/>
Foreground="Red"
Text="{Binding ErrorInfo}" />

<Grid Grid.Row="5">
<Grid.ColumnDefinitions>


+ 57
- 1
BPASmart.ConfigurationSoftware/ServiceCenter.cs View File

@@ -135,6 +135,11 @@ namespace BPASmart.ConfigurationSoftware
{
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (Pages.Count <= 0)
{
Serialization<BinConfigFile>.Data.StartPageName = o.ToString();
Serialization<BinConfigFile>.Save($"{FileConfigModel.GetBinConfigPath}");
}
Pages.Add(o.ToString());
string path = $"{ Json<ProjectModel>.Data.ProjectPath}\\{FileConfigModel.PageDirName}";
Directory.CreateDirectory(path);
@@ -217,6 +222,50 @@ namespace BPASmart.ConfigurationSoftware
}
}

/// <summary>
/// 删除指定界面
/// </summary>
/// <param name="o"></param>
public void RemovePageCommand(object o)
{
if (!string.IsNullOrEmpty(o?.ToString()))
{
if (Pages.FirstOrDefault(p => p == o.ToString()) != null)
{
Pages.Remove(o.ToString());
string path = $"{FileConfigModel.ConstPath}\\{FileConfigModel.PageDirName}\\{o.ToString()}.lay";
if (File.Exists(path)) File.Delete(path);
if (!File.Exists(path)) MessageLog.GetInstance.Show($"页面 {o.ToString()} 删除成功");
else MessageLog.GetInstance.Show($"页面 {o.ToString()} 删除失败");
}
}
}

/// <summary>
/// 设置界面为启动界面
/// </summary>
/// <param name="o"></param>
public void SetStartPageCommand(object o)
{
if (!string.IsNullOrEmpty(o?.ToString()))
{
Serialization<BinConfigFile>.Data.StartPageName = o.ToString();
Serialization<BinConfigFile>.Save($"{FileConfigModel.GetBinConfigPath}");
}
}

/// <summary>
/// 重命名界面名称
/// </summary>
/// <param name="o"></param>
public void ReNameCommand(object o)
{
if (!string.IsNullOrEmpty(o?.ToString()))
{

}
}

/// <summary>
/// 项目保存
/// </summary>
@@ -257,6 +306,9 @@ namespace BPASmart.ConfigurationSoftware
string pageFilePath = $"{FileConfigModel.ConstPath}\\{FileConfigModel.PageDirName}";
if (Directory.Exists(pageFilePath)) CopyFolder(pageFilePath, $"{path}\\{FileConfigModel.PageDirName}");

//生成启动快捷方式
//string createPath = $"{FileConfigModel.ConstPath}\\Publish\\{Json<ProjectModel>.Data.ProjectName}\\";
//CreateShortcut($"{Json<ProjectModel>.Data.ProjectName}.exe", createPath);
MessageLog.GetInstance.Show("打包完成");
}

@@ -277,6 +329,10 @@ namespace BPASmart.ConfigurationSoftware
foreach (string file in files)
{
string name = Path.GetFileName(file);
if (name.Contains("BPASmart.PageLoad.exe"))
{
name = $"{Json<ProjectModel>.Data.ProjectName}.exe";
}
string dest = Path.Combine(destFolder, name);
File.Copy(file, dest);//复制文件
}
@@ -320,7 +376,7 @@ namespace BPASmart.ConfigurationSoftware
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
IWshRuntimeLibrary.IWshShortcut shortcut = shell.CreateShortcut($"{path}{name}.lnk") as IWshRuntimeLibrary.IWshShortcut;
shortcut.TargetPath = path; //目标文件
//该属性指定应用程序的工作目录,当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
//该属性指定应用程序的工作目录,当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
shortcut.WorkingDirectory = System.Environment.CurrentDirectory;
shortcut.WindowStyle = 1; //目标应用程序的窗口状态分为普通、最大化、最小化【1,3,7】
shortcut.Description = name; //描述


+ 17
- 0
BPASmart.Model/BinConfigFile.cs View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.Model
{
[Serializable]
public class BinConfigFile
{
/// <summary>
/// 启动页面名称
/// </summary>
public string StartPageName { get; set; }
}
}

+ 29
- 0
BPASmart.Model/FileConfigModel.cs View File

@@ -29,6 +29,25 @@ namespace BPASmart.Model
}
}

/// <summary>
/// 获取二进制文件配置路径
/// </summary>
/// <returns></returns>
public static string GetBinConfigPath
{
get
{
string ReturnValue = null;
if (Directory.Exists(ConstPath))
{
string path = $"{ConstPath}\\{ConfigDirName}\\{BaseConfig}";
Directory.CreateDirectory(path);
ReturnValue = $"{ConstPath}\\{ConfigDirName}\\{BaseConfig}\\{BinConfigFileName}";
}
return ReturnValue;
}
}

/// <summary>
/// 变量管理器路径
/// </summary>
@@ -43,5 +62,15 @@ namespace BPASmart.Model
/// 配置文件文件夹名称
/// </summary>
public const string ConfigDirName = "AccessFile";

/// <summary>
/// 基本配置文件夹名称
/// </summary>
public const string BaseConfig = "Bin";

/// <summary>
/// 二进制配置文件名
/// </summary>
public const string BinConfigFileName = "BinConfigFile.ser";
}
}

+ 4
- 1
BPASmart.PageLoad/BPASmart.PageLoad.csproj View File

@@ -16,9 +16,12 @@
<None Remove="Images\椭圆 22 副本 2.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.11" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmart.Model\BPASmart.Model.csproj" />
<ProjectReference Include="..\BPASmartClient.Compiler\BPASmartClient.Compiler.csproj" />
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" />
<ProjectReference Include="..\BPASmartClient.MessageName\BPASmartClient.MessageName.csproj" />
<ProjectReference Include="..\BPASmartClient.SCADAControl\BPASmartClient.SCADAControl.csproj" />


+ 17
- 17
BPASmart.PageLoad/FControl/RunCanvas.xaml.cs View File

@@ -1,4 +1,4 @@
using BPASmartClient.Compiler;
//using BPASmartClient.Compiler;
using BPASmartClient.MessageName.接收消息Model;
using System;
using System.Collections.Generic;
@@ -20,12 +20,12 @@ namespace BPASmart.PageLoad.FControl
/// <summary>
/// RunCanvas.xaml 的交互逻辑
/// </summary>
public partial class RunCanvas :UserControl
public partial class RunCanvas : UserControl
{
public RunCanvas()
{
InitializeComponent();
Unloaded += (s,e) => Destory();
Unloaded += (s, e) => Destory();
}

/// <summary>
@@ -48,14 +48,14 @@ namespace BPASmart.PageLoad.FControl
RootCanvas.Children.Clear();
foreach (FrameworkElement element in canvas)
{
if (element is IExecutable executable)
{
executable.IsExecuteState = true;
//if (executable.EventNameList != null && executable.EventNameList.Count > 0)
//{
// messages.AddRange(executable.EventNameList);
//}
}
//if (element is IExecutable executable)
//{
// executable.IsExecuteState = true;
// //if (executable.EventNameList != null && executable.EventNameList.Count > 0)
// //{
// // messages.AddRange(executable.EventNameList);
// //}
//}
RootCanvas.Children.Add(element);
RegisterJsName(element);
}
@@ -65,7 +65,7 @@ namespace BPASmart.PageLoad.FControl
// 注册名称到Js
static void RegisterJsName(FrameworkElement element)
{
Config.GetInstance().SetVariable(element.Name,element);
//Config.GetInstance().SetVariable(element.Name,element);
if (element is Panel panel)
{
foreach (var item in panel.Children)
@@ -76,7 +76,7 @@ namespace BPASmart.PageLoad.FControl
}

#region 拖动与缩放
private void RootCanvas_MouseMove(object sender,MouseEventArgs e)
private void RootCanvas_MouseMove(object sender, MouseEventArgs e)
{
if (DragEnable.IsChecked == false)
{
@@ -98,19 +98,19 @@ namespace BPASmart.PageLoad.FControl

bool isPressed = false;
Point last;//记录上次鼠标坐标位置
private void RootCanvas_MouseLeftButtoDown(object sender,MouseButtonEventArgs e)
private void RootCanvas_MouseLeftButtoDown(object sender, MouseButtonEventArgs e)
{
last = e.GetPosition(this);
isPressed = true;
}

private void RootCanvas_MouseLeftButtonUp(object sender,MouseButtonEventArgs e)
private void RootCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
isPressed = false;
}

// 缩放
private void RootCanvas_MouseWheel(object sender,MouseWheelEventArgs e)
private void RootCanvas_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (ZoomEnable.IsChecked == false)
{
@@ -125,7 +125,7 @@ namespace BPASmart.PageLoad.FControl
Scale.ScaleX = Scale.ScaleY = zoom;

Point mouse = e.GetPosition(RootCanvas);
Point newMouse = new Point(mouse.X * zoomS,mouse.Y * zoomS);
Point newMouse = new Point(mouse.X * zoomS, mouse.Y * zoomS);

Translate.X -= newMouse.X;
Translate.Y -= newMouse.Y;


+ 20
- 0
BPASmart.PageLoad/MainWindow.xaml.cs View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -12,6 +13,8 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BPA.Helper;
using BPASmart.Model;

namespace BPASmart.PageLoad
{
@@ -23,6 +26,23 @@ namespace BPASmart.PageLoad
public MainWindow()
{
InitializeComponent();
this.Loaded += MainWindow_Loaded;
}

List<FrameworkElement> frameworkElements = new List<FrameworkElement>();
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
Serialization<BinConfigFile>.Read();
if (!string.IsNullOrEmpty(Serialization<BinConfigFile>.Data.StartPageName))
{
string path = $"{AppDomain.CurrentDomain.BaseDirectory}{FileConfigModel.PageDirName}\\{Serialization<BinConfigFile>.Data.StartPageName}.lay";
if (File.Exists(path))
{
//MainCanvasPanel
}

runCanvas.Run();
}
}
}
}

+ 2
- 2
BPASmart.Server/BPASmart.Server.csproj View File

@@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.17" />
<PackageReference Include="BPA.Helper" Version="1.0.9" />
<PackageReference Include="BPA.Communication" Version="1.0.19" />
<PackageReference Include="BPA.Helper" Version="1.0.11" />
</ItemGroup>

<ItemGroup>


+ 1
- 2
BPASmart.Server/CommunicationServer.cs View File

@@ -2,7 +2,6 @@
using BPA.Helper;
using BPA.Communication;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Communication;
using System.Collections.Concurrent;
using Newtonsoft.Json;

@@ -15,7 +14,7 @@ namespace BPASmart.Server
public void Init()
{
BPASmartClient.Message.MessageLog.GetInstance.ShowDebugLog("通讯模块初始化");
RedisHelper.GetInstance.ConnectAsync();
RedisHelper.GetInstance.ConnectAsync("124.222.238.75", 16000, "123456", 1);
MqttInit();
Json<CommunicationPar>.Data.CommunicationDevices.ToList()?.ForEach(item =>
{


+ 2
- 2
BPASmart.VariableManager/BPASmart.VariableManager.csproj View File

@@ -29,8 +29,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.17" />
<PackageReference Include="BPA.Helper" Version="1.0.9" />
<PackageReference Include="BPA.Communication" Version="1.0.19" />
<PackageReference Include="BPA.Helper" Version="1.0.11" />
</ItemGroup>

<ItemGroup>


+ 8
- 8
BPASmart.VariableManager/Views/NewDeviceView.xaml View File

@@ -35,15 +35,15 @@
<ControlTemplate TargetType="Button">
<Grid x:Name="gr">
<ContentControl
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
<Polygon
x:Name="poly"
Points="0 0,80 0,100 30,20 30"
Stroke="#FF34F7F7"
StrokeThickness="2" />
x:Name="poly"
Points="0 0,80 0,100 30,20 30"
Stroke="#FF34F7F7"
StrokeThickness="2" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">


+ 2
- 2
ComputerTestDemo/ComputerTestDemo.csproj View File

@@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.17" />
<PackageReference Include="BPA.Helper" Version="1.0.9" />
<PackageReference Include="BPA.Communication" Version="1.0.19" />
<PackageReference Include="BPA.Helper" Version="1.0.11" />
</ItemGroup>

<ItemGroup>


Loading…
Cancel
Save