You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- 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.Windows;
- using BPA.Helper;
- using System.Windows.Forms;
- using System.IO;
-
- namespace BPASmart.ConfigurationSoftware
- {
- public class NewProjectViewModel : NoticeBase
- {
- public NewProjectViewModel()
- {
- Json<BasicInformation>.Read();
- NewData.ProjectPath = Json<BasicInformation>.Data.ProjectDefaultPath;
- OpenBrowserDialogCommand = new RelayCommand(() =>
- {
- FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
- if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
- {
- NewData.ProjectPath = folderBrowserDialog.SelectedPath;
- Json<BasicInformation>.Data.ProjectDefaultPath = NewData.ProjectPath;
- Json<BasicInformation>.Save();
- }
- });
-
- CreateCommand = new RelayCommand(() =>
- {
- if (NewData.ProjectName == null || NewData.ProjectName?.Length <= 0)
- {
- ErrorInfo = "项目名不能为空";
- return;
- }
-
- if (NewData.ProjectPath == null || NewData.ProjectPath?.Length <= 0)
- {
- ErrorInfo = "项目路径不合法";
- return;
- }
- var res = Directory.GetDirectories(NewData.ProjectPath);
- if (res?.ToList()?.FirstOrDefault(p => p.Contains(NewData.ProjectName)) == null)
- {
- ActionManage.GetInstance.Send("CreateCommand", NewData);
- }
- else
- {
- ErrorInfo = "该项目已经存在";
- return;
- }
-
- });
-
- CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("CancelCommand"); });
-
- }
-
- public NewDataModel NewData { get { return _mNewData; } set { _mNewData = value; OnPropertyChanged(); } }
- private NewDataModel _mNewData = new NewDataModel();
-
-
- public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
- private string _mErrorInfo;
-
-
- public RelayCommand CreateCommand { get; set; }
-
- public RelayCommand OpenBrowserDialogCommand { get; set; }
-
- public RelayCommand CancelCommand { get; set; }
-
- }
- }
|