|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BPASmart.Model;
- using Microsoft.Toolkit.Mvvm.Input;
- using System.Collections.ObjectModel;
- using System.Windows.Forms;
- using System.IO;
- using BPA.Helper;
- using System.Diagnostics;
- using BeDesignerSCADA;
-
- namespace BPASmart.ConfigurationSoftware
- {
- public class MainWindowViewModel : NoticeBase
- {
- string LayoutPath
- {
- get
- {
- Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\Layouts"));
- return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\Layouts\\";
- }
- }
-
- public MainWindowViewModel()
- {
- ActionManage.GetInstance.Register(new Action<object>((o) =>
- {
- Pages.Add(o.ToString());
- File.WriteAllText(LayoutPath + o.ToString(), null, Encoding.Unicode);
- }), "PageName");
- NewCommand = new RelayCommand(() =>
- {
- NewProjectView newProjectView = new NewProjectView();
- bool? result = newProjectView.ShowDialog();
- if (result != null && result == true)
- {
- if (newProjectView.Tag != null && newProjectView.Tag is NewDataModel objModel)
- {
- Directory.CreateDirectory(Path.Combine(objModel.ProjectPath, objModel.ProjectName));
- Head = objModel.ProjectName;
- }
- }
- });
-
- NewPageCommand = new RelayCommand(() =>
- {
- NewPageView newPageView = new NewPageView();
- newPageView.ShowDialog();
- });
-
- OpenVarManagerCommand = new RelayCommand(() =>
- {
- string path = $"{AppDomain.CurrentDomain.BaseDirectory}BPASmart.VariableManager.exe";
- if (File.Exists(path))
- {
- Process[] pro = Process.GetProcesses();
- if (pro?.ToList().FirstOrDefault(p => p.ProcessName.Contains("BPASmart.VariableManager")) == null)
- {
- Process.Start(path);
- }
- }
- });
-
- SelectedCommand = new RelayCommand<object>((o) =>
- {
-
- });
- }
-
- public RelayCommand NewCommand { get; set; }
-
- public RelayCommand OpenVarManagerCommand { get; set; }
-
- public RelayCommand<object> SelectedCommand { get; set; }
-
- public RelayCommand SaveCommand { get; set; }
-
- public RelayCommand NewPageCommand { get; set; }
-
- public string Head { get { return _mHead; } set { _mHead = value; OnPropertyChanged(); } }
- private string _mHead;
-
- //public ObservableCollection<MainCanvasPanel>
-
- public ObservableCollection<string> Pages { get; set; } = new ObservableCollection<string>();
-
-
- }
- }
|