Browse Source

配置修改

样式分支
pry 2 years ago
parent
commit
b2721dbd8f
13 changed files with 36 additions and 125 deletions
  1. +0
    -32
      BPASmart.ConfigurationSoftware/Global.cs
  2. +5
    -5
      BPASmart.ConfigurationSoftware/MainWindowViewModel.cs
  3. +0
    -0
      BPASmart.ConfigurationSoftware/Model/MainCanvasPageModel.cs
  4. +2
    -2
      BPASmart.ConfigurationSoftware/NewProjectViewModel.cs
  5. +0
    -40
      BPASmart.ConfigurationSoftware/ProjectDataServer.cs
  6. +0
    -35
      BPASmart.ConfigurationSoftware/ProjectModel.cs
  7. +16
    -3
      BPASmart.Model/FileConfigModel.cs
  8. +5
    -0
      BPASmart.Model/LocalPar.cs
  9. +2
    -2
      BPASmart.Model/NewProjectModel.cs
  10. +2
    -2
      BPASmart.VariableManager/App.xaml.cs
  11. +2
    -2
      BPASmart.VariableManager/ViewModels/CommunicationSetViewModel.cs
  12. +1
    -1
      BPASmart.VariableManager/Views/CommunicationSetView.xaml.cs
  13. +1
    -1
      BPASmart.VariableManager/Views/VariableConfig.xaml.cs

+ 0
- 32
BPASmart.ConfigurationSoftware/Global.cs View File

@@ -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";
}
}

+ 5
- 5
BPASmart.ConfigurationSoftware/MainWindowViewModel.cs View File

@@ -65,7 +65,7 @@ namespace BPASmart.ConfigurationSoftware
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
Pages.Add(o.ToString());
string path = $"{ Json<ProjectModel>.Data.ProjectPath}\\{Global.PageDirectoryName}";
string path = $"{ Json<ProjectModel>.Data.ProjectPath}\\{FileConfigModel.PageDirectoryName}";
Directory.CreateDirectory(path);
File.WriteAllText($"{path}\\{o.ToString()}.lay", null, Encoding.Unicode);
Json<ProjectModel>.Data.Pages.TryAdd(o.ToString(), $"{path}\\{o.ToString()}.lay");
@@ -77,7 +77,7 @@ namespace BPASmart.ConfigurationSoftware
bool? result = newProjectView.ShowDialog();
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}";
Directory.CreateDirectory(path);
@@ -100,19 +100,19 @@ namespace BPASmart.ConfigurationSoftware
{
Json<LocalPar>.Data.ProjectPath = Json<ProjectModel>.Data.ProjectPath;
Json<LocalPar>.Save();
if (File.Exists(Global.VarManagerPath))
if (File.Exists(FileConfigModel.VarManagerPath))
{
Process[] pro = Process.GetProcesses();
if (pro?.ToList().FirstOrDefault(p => p.ProcessName.Contains("BPASmart.VariableManager")) == null)
{
Process.Start(Global.VarManagerPath);
Process.Start(FileConfigModel.VarManagerPath);
}
}
});

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)
{
mainCanvasPanels.Add(new MainCanvasPageModel()


BPASmart.ConfigurationSoftware/MainCanvasPageModel.cs → BPASmart.ConfigurationSoftware/Model/MainCanvasPageModel.cs View File


+ 2
- 2
BPASmart.ConfigurationSoftware/NewProjectViewModel.cs View File

@@ -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(); } }


+ 0
- 40
BPASmart.ConfigurationSoftware/ProjectDataServer.cs View File

@@ -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();
}
}
}
}

+ 0
- 35
BPASmart.ConfigurationSoftware/ProjectModel.cs View File

@@ -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; }
// }
//}

BPASmart.VariableManager/FileConfigModel.cs → BPASmart.Model/FileConfigModel.cs View File

@@ -5,13 +5,16 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.VariableManager
namespace BPASmart.Model
{
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
{
@@ -25,5 +28,15 @@ namespace BPASmart.VariableManager
return ReturnValue;
}
}

/// <summary>
/// 变量管理器路径
/// </summary>
public static string VarManagerPath => $"{AppDomain.CurrentDomain.BaseDirectory}BPASmart.VariableManager.exe";

/// <summary>
/// 页面文件夹名称
/// </summary>
public static string PageDirectoryName { get; set; } = "Layouts";
}
}

+ 5
- 0
BPASmart.Model/LocalPar.cs View File

@@ -12,5 +12,10 @@ namespace BPASmart.Model
/// 项目路径
/// </summary>
public string ProjectPath { get; set; } = string.Empty;

/// <summary>
/// 项目上次保存的目录
/// </summary>
public string ProjectDefaultPath { get; set; } = string.Empty;
}
}

BPASmart.ConfigurationSoftware/Model/NewDataModel.cs → BPASmart.Model/NewProjectModel.cs View File

@@ -5,9 +5,9 @@ using System.Text;
using System.Threading.Tasks;
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(); } }
private string _mProjectName;

+ 2
- 2
BPASmart.VariableManager/App.xaml.cs View File

@@ -131,12 +131,12 @@ namespace BPASmart.VariableManager

private void DataSave()
{
Json<CommunicationPar>.Save(FileConfigModel.GetPath);
Json<CommunicationPar>.Save(FileConfigModel.JsonPath);
}

private void DataRead()
{
Json<CommunicationPar>.Read(FileConfigModel.GetPath);
Json<CommunicationPar>.Read(FileConfigModel.JsonPath);
}
}



+ 2
- 2
BPASmart.VariableManager/ViewModels/CommunicationSetViewModel.cs View File

@@ -20,12 +20,12 @@ namespace BPASmart.VariableManager.ViewModels
{
public CommunicationSetViewModel()
{
Json<CommunicationPar>.Read(FileConfigModel.GetPath);
Json<CommunicationPar>.Read(FileConfigModel.JsonPath);
communicationDevices = Json<CommunicationPar>.Data.CommunicationDevices;
DataListInit();
NewConnectCommand = new RelayCommand(() => { NewConnect(); });
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) =>
{


+ 1
- 1
BPASmart.VariableManager/Views/CommunicationSetView.xaml.cs View File

@@ -30,7 +30,7 @@ namespace BPASmart.VariableManager.Views

private void CommunicationSetView_Unloaded(object sender, RoutedEventArgs e)
{
Json<CommunicationPar>.Save(FileConfigModel.GetPath);
Json<CommunicationPar>.Save(FileConfigModel.JsonPath);
}
}
}

+ 1
- 1
BPASmart.VariableManager/Views/VariableConfig.xaml.cs View File

@@ -33,7 +33,7 @@ namespace BPASmart.VariableManager.Views

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)


Loading…
Cancel
Save