@@ -1,32 +0,0 @@ | |||||
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"; | |||||
} | |||||
} |
@@ -65,7 +65,7 @@ namespace BPASmart.ConfigurationSoftware | |||||
ActionManage.GetInstance.Register(new Action<object>((o) => | ActionManage.GetInstance.Register(new Action<object>((o) => | ||||
{ | { | ||||
Pages.Add(o.ToString()); | Pages.Add(o.ToString()); | ||||
string path = $"{ Json<ProjectModel>.Data.ProjectPath}\\{Global.PageDirectoryName}"; | |||||
string path = $"{ Json<ProjectModel>.Data.ProjectPath}\\{FileConfigModel.PageDirectoryName}"; | |||||
Directory.CreateDirectory(path); | Directory.CreateDirectory(path); | ||||
File.WriteAllText($"{path}\\{o.ToString()}.lay", null, Encoding.Unicode); | File.WriteAllText($"{path}\\{o.ToString()}.lay", null, Encoding.Unicode); | ||||
Json<ProjectModel>.Data.Pages.TryAdd(o.ToString(), $"{path}\\{o.ToString()}.lay"); | Json<ProjectModel>.Data.Pages.TryAdd(o.ToString(), $"{path}\\{o.ToString()}.lay"); | ||||
@@ -77,7 +77,7 @@ namespace BPASmart.ConfigurationSoftware | |||||
bool? result = newProjectView.ShowDialog(); | bool? result = newProjectView.ShowDialog(); | ||||
if (result != null && result == true) | if (result != null && result == true) | ||||
{ | { | ||||
if (newProjectView.Tag != null && newProjectView.Tag is NewDataModel objModel) | |||||
if (newProjectView.Tag != null && newProjectView.Tag is NewProjectModel objModel) | |||||
{ | { | ||||
string path = $"{objModel.ProjectPath}\\{objModel.ProjectName}"; | string path = $"{objModel.ProjectPath}\\{objModel.ProjectName}"; | ||||
Directory.CreateDirectory(path); | Directory.CreateDirectory(path); | ||||
@@ -100,19 +100,19 @@ namespace BPASmart.ConfigurationSoftware | |||||
{ | { | ||||
Json<LocalPar>.Data.ProjectPath = Json<ProjectModel>.Data.ProjectPath; | Json<LocalPar>.Data.ProjectPath = Json<ProjectModel>.Data.ProjectPath; | ||||
Json<LocalPar>.Save(); | Json<LocalPar>.Save(); | ||||
if (File.Exists(Global.VarManagerPath)) | |||||
if (File.Exists(FileConfigModel.VarManagerPath)) | |||||
{ | { | ||||
Process[] pro = Process.GetProcesses(); | Process[] pro = Process.GetProcesses(); | ||||
if (pro?.ToList().FirstOrDefault(p => p.ProcessName.Contains("BPASmart.VariableManager")) == null) | if (pro?.ToList().FirstOrDefault(p => p.ProcessName.Contains("BPASmart.VariableManager")) == null) | ||||
{ | { | ||||
Process.Start(Global.VarManagerPath); | |||||
Process.Start(FileConfigModel.VarManagerPath); | |||||
} | } | ||||
} | } | ||||
}); | }); | ||||
SelectedPageCommand = new RelayCommand<object>((o) => | SelectedPageCommand = new RelayCommand<object>((o) => | ||||
{ | { | ||||
string path = $"{Json<ProjectModel>.Data.ProjectPath}\\{Global.PageDirectoryName}\\{o.ToString()}.lay"; | |||||
string path = $"{Json<ProjectModel>.Data.ProjectPath}\\{FileConfigModel.PageDirectoryName}\\{o.ToString()}.lay"; | |||||
if (mainCanvasPanels.FirstOrDefault(p => p.PageName == o.ToString()) == null) | if (mainCanvasPanels.FirstOrDefault(p => p.PageName == o.ToString()) == null) | ||||
{ | { | ||||
mainCanvasPanels.Add(new MainCanvasPageModel() | mainCanvasPanels.Add(new MainCanvasPageModel() | ||||
@@ -59,8 +59,8 @@ namespace BPASmart.ConfigurationSoftware | |||||
} | } | ||||
public NewDataModel NewData { get { return _mNewData; } set { _mNewData = value; OnPropertyChanged(); } } | |||||
private NewDataModel _mNewData = new NewDataModel(); | |||||
public NewProjectModel NewData { get { return _mNewData; } set { _mNewData = value; OnPropertyChanged(); } } | |||||
private NewProjectModel _mNewData = new NewProjectModel(); | |||||
public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | ||||
@@ -1,40 +0,0 @@ | |||||
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(); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -1,35 +0,0 @@ | |||||
//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 Dictionary<string, string> Pages { get; set; } = new Dictionary<string, string>(); | |||||
// /// <summary> | |||||
// /// 变量表配置路径 | |||||
// /// </summary> | |||||
// public string VariableTabPath { get; set; } | |||||
// } | |||||
//} |
@@ -5,13 +5,16 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace BPASmart.VariableManager | |||||
namespace BPASmart.Model | |||||
{ | { | ||||
public class FileConfigModel | public class FileConfigModel | ||||
{ | { | ||||
public static string ConstPath = string.Empty; | |||||
public static string ConstPath { get; set; } = string.Empty; | |||||
public static string GetPath | |||||
/// <summary> | |||||
/// Json文件配置路径 | |||||
/// </summary> | |||||
public static string JsonPath | |||||
{ | { | ||||
get | get | ||||
{ | { | ||||
@@ -25,5 +28,15 @@ namespace BPASmart.VariableManager | |||||
return ReturnValue; | return ReturnValue; | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 变量管理器路径 | |||||
/// </summary> | |||||
public static string VarManagerPath => $"{AppDomain.CurrentDomain.BaseDirectory}BPASmart.VariableManager.exe"; | |||||
/// <summary> | |||||
/// 页面文件夹名称 | |||||
/// </summary> | |||||
public static string PageDirectoryName { get; set; } = "Layouts"; | |||||
} | } | ||||
} | } |
@@ -12,5 +12,10 @@ namespace BPASmart.Model | |||||
/// 项目路径 | /// 项目路径 | ||||
/// </summary> | /// </summary> | ||||
public string ProjectPath { get; set; } = string.Empty; | public string ProjectPath { get; set; } = string.Empty; | ||||
/// <summary> | |||||
/// 项目上次保存的目录 | |||||
/// </summary> | |||||
public string ProjectDefaultPath { get; set; } = string.Empty; | |||||
} | } | ||||
} | } |
@@ -5,9 +5,9 @@ using System.Text; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using BPASmart.Model; | using BPASmart.Model; | ||||
namespace BPASmart.ConfigurationSoftware | |||||
namespace BPASmart.Model | |||||
{ | { | ||||
public class NewDataModel : NoticeBase | |||||
public class NewProjectModel : NoticeBase | |||||
{ | { | ||||
public string ProjectName { get { return _mProjectName; } set { _mProjectName = value; OnPropertyChanged(); } } | public string ProjectName { get { return _mProjectName; } set { _mProjectName = value; OnPropertyChanged(); } } | ||||
private string _mProjectName; | private string _mProjectName; |
@@ -131,12 +131,12 @@ namespace BPASmart.VariableManager | |||||
private void DataSave() | private void DataSave() | ||||
{ | { | ||||
Json<CommunicationPar>.Save(FileConfigModel.GetPath); | |||||
Json<CommunicationPar>.Save(FileConfigModel.JsonPath); | |||||
} | } | ||||
private void DataRead() | private void DataRead() | ||||
{ | { | ||||
Json<CommunicationPar>.Read(FileConfigModel.GetPath); | |||||
Json<CommunicationPar>.Read(FileConfigModel.JsonPath); | |||||
} | } | ||||
} | } | ||||
@@ -20,12 +20,12 @@ namespace BPASmart.VariableManager.ViewModels | |||||
{ | { | ||||
public CommunicationSetViewModel() | public CommunicationSetViewModel() | ||||
{ | { | ||||
Json<CommunicationPar>.Read(FileConfigModel.GetPath); | |||||
Json<CommunicationPar>.Read(FileConfigModel.JsonPath); | |||||
communicationDevices = Json<CommunicationPar>.Data.CommunicationDevices; | communicationDevices = Json<CommunicationPar>.Data.CommunicationDevices; | ||||
DataListInit(); | DataListInit(); | ||||
NewConnectCommand = new RelayCommand(() => { NewConnect(); }); | NewConnectCommand = new RelayCommand(() => { NewConnect(); }); | ||||
RemoveDeviceCommand = new RelayCommand<object>(RemoveDevice); | RemoveDeviceCommand = new RelayCommand<object>(RemoveDevice); | ||||
SaveConnectSetCommand = new RelayCommand(() => { Json<CommunicationPar>.Save(FileConfigModel.GetPath); }); | |||||
SaveConnectSetCommand = new RelayCommand(() => { Json<CommunicationPar>.Save(FileConfigModel.JsonPath); }); | |||||
DelegationNotifi.GetInstance.AddDeviceVerify = new Func<DeviceManagermentResult, bool>((p) => | DelegationNotifi.GetInstance.AddDeviceVerify = new Func<DeviceManagermentResult, bool>((p) => | ||||
{ | { | ||||
@@ -30,7 +30,7 @@ namespace BPASmart.VariableManager.Views | |||||
private void CommunicationSetView_Unloaded(object sender, RoutedEventArgs e) | private void CommunicationSetView_Unloaded(object sender, RoutedEventArgs e) | ||||
{ | { | ||||
Json<CommunicationPar>.Save(FileConfigModel.GetPath); | |||||
Json<CommunicationPar>.Save(FileConfigModel.JsonPath); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -33,7 +33,7 @@ namespace BPASmart.VariableManager.Views | |||||
private void VariableConfig_Unloaded(object sender, RoutedEventArgs e) | private void VariableConfig_Unloaded(object sender, RoutedEventArgs e) | ||||
{ | { | ||||
Json<CommunicationPar>.Save(FileConfigModel.GetPath); | |||||
Json<CommunicationPar>.Save(FileConfigModel.JsonPath); | |||||
} | } | ||||
private void VariableConfig_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) | private void VariableConfig_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) | ||||