终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

94 linhas
3.0 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using BPASmart.Model;
  7. using Microsoft.Toolkit.Mvvm.Input;
  8. using System.Collections.ObjectModel;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using BPA.Helper;
  12. using System.Diagnostics;
  13. using BeDesignerSCADA;
  14. namespace BPASmart.ConfigurationSoftware
  15. {
  16. public class MainWindowViewModel : NoticeBase
  17. {
  18. string LayoutPath
  19. {
  20. get
  21. {
  22. Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\Layouts"));
  23. return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\Layouts\\";
  24. }
  25. }
  26. public MainWindowViewModel()
  27. {
  28. ActionManage.GetInstance.Register(new Action<object>((o) =>
  29. {
  30. Pages.Add(o.ToString());
  31. File.WriteAllText(LayoutPath + o.ToString(), null, Encoding.Unicode);
  32. }), "PageName");
  33. NewCommand = new RelayCommand(() =>
  34. {
  35. NewProjectView newProjectView = new NewProjectView();
  36. bool? result = newProjectView.ShowDialog();
  37. if (result != null && result == true)
  38. {
  39. if (newProjectView.Tag != null && newProjectView.Tag is NewDataModel objModel)
  40. {
  41. Directory.CreateDirectory(Path.Combine(objModel.ProjectPath, objModel.ProjectName));
  42. Head = objModel.ProjectName;
  43. }
  44. }
  45. });
  46. NewPageCommand = new RelayCommand(() =>
  47. {
  48. NewPageView newPageView = new NewPageView();
  49. newPageView.ShowDialog();
  50. });
  51. OpenVarManagerCommand = new RelayCommand(() =>
  52. {
  53. string path = $"{AppDomain.CurrentDomain.BaseDirectory}BPASmart.VariableManager.exe";
  54. if (File.Exists(path))
  55. {
  56. Process[] pro = Process.GetProcesses();
  57. if (pro?.ToList().FirstOrDefault(p => p.ProcessName.Contains("BPASmart.VariableManager")) == null)
  58. {
  59. Process.Start(path);
  60. }
  61. }
  62. });
  63. SelectedCommand = new RelayCommand<object>((o) =>
  64. {
  65. });
  66. }
  67. public RelayCommand NewCommand { get; set; }
  68. public RelayCommand OpenVarManagerCommand { get; set; }
  69. public RelayCommand<object> SelectedCommand { get; set; }
  70. public RelayCommand SaveCommand { get; set; }
  71. public RelayCommand NewPageCommand { get; set; }
  72. public string Head { get { return _mHead; } set { _mHead = value; OnPropertyChanged(); } }
  73. private string _mHead;
  74. //public ObservableCollection<MainCanvasPanel>
  75. public ObservableCollection<string> Pages { get; set; } = new ObservableCollection<string>();
  76. }
  77. }