2023-05-11 10:12:41 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using MECF.Framework.Common.DataCenter;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
|
2023-05-11 10:12:41 +08:00
|
|
|
|
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using OpenSEMI.ClientBase;
|
2023-05-11 10:12:41 +08:00
|
|
|
|
using static MECF.Framework.UI.Client.CenterViews.Editors.ProcessTypeFileItem;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
|
|
|
|
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
|
|
|
|
|
{
|
|
|
|
|
public class RecipeSelectDialogViewModel : DialogViewModel<string>
|
|
|
|
|
{
|
2023-05-11 10:12:41 +08:00
|
|
|
|
|
|
|
|
|
#region Variables
|
|
|
|
|
|
2023-08-22 16:48:45 +08:00
|
|
|
|
private readonly RecipeType _fileTypes;
|
2023-05-11 10:12:41 +08:00
|
|
|
|
private readonly bool _isFolderOnly;
|
|
|
|
|
private readonly bool _isShowRootNode;
|
|
|
|
|
private FileNode _currentFileNode;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
public RecipeSelectDialogViewModel()
|
|
|
|
|
{
|
2023-08-22 16:48:45 +08:00
|
|
|
|
_fileTypes = RecipeType.Process | RecipeType.Routine | RecipeType.Clean;
|
2023-05-11 10:12:41 +08:00
|
|
|
|
_isFolderOnly = false;
|
|
|
|
|
_isShowRootNode = false;
|
|
|
|
|
|
|
|
|
|
BuildFileTree(_isShowRootNode, _isFolderOnly, _fileTypes);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 16:48:45 +08:00
|
|
|
|
public RecipeSelectDialogViewModel(bool isShowRootNode, bool isFolderOnly, RecipeType fileType)
|
2023-05-11 10:12:41 +08:00
|
|
|
|
{
|
|
|
|
|
_fileTypes = fileType;
|
|
|
|
|
_isFolderOnly = isFolderOnly;
|
|
|
|
|
_isShowRootNode = isShowRootNode;
|
|
|
|
|
|
|
|
|
|
BuildFileTree(isShowRootNode, isFolderOnly, fileType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
|
|
|
|
public List<ProcessTypeFileItem> ProcessTypeFileList { get; set; }
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
|
|
|
|
public FileNode CurrentFileNode { get; set; }
|
|
|
|
|
|
|
|
|
|
public int ProcessTypeIndexSelection { get; set; }
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<FileNode> Files { get; set; }
|
2023-05-11 10:12:41 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Private Methods
|
|
|
|
|
|
2023-08-22 16:48:45 +08:00
|
|
|
|
private void BuildFileTree(bool isShowRootNode, bool isFolderOnly, RecipeType fileType)
|
2023-05-11 10:12:41 +08:00
|
|
|
|
{
|
|
|
|
|
var recipeProvider = new RecipeProvider();
|
2023-08-22 16:48:45 +08:00
|
|
|
|
var scProcessType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType").ToString();
|
|
|
|
|
var supportedRecipeType = new List<RecipeType>(new[] { RecipeType.Process, RecipeType.Routine });
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(scProcessType))
|
2023-05-11 10:12:41 +08:00
|
|
|
|
{
|
2023-08-22 16:48:45 +08:00
|
|
|
|
supportedRecipeType.Clear();
|
2023-05-11 10:12:41 +08:00
|
|
|
|
|
2023-08-22 16:48:45 +08:00
|
|
|
|
if (fileType.HasFlag(RecipeType.Process) && scProcessType.Contains(RecipeType.Process.ToString()))
|
|
|
|
|
supportedRecipeType.Add(RecipeType.Process);
|
2023-05-11 10:12:41 +08:00
|
|
|
|
|
2023-08-22 16:48:45 +08:00
|
|
|
|
if (fileType.HasFlag(RecipeType.Routine) && scProcessType.Contains(RecipeType.Routine.ToString()))
|
|
|
|
|
supportedRecipeType.Add(RecipeType.Routine);
|
2023-05-11 10:12:41 +08:00
|
|
|
|
|
2023-08-22 16:48:45 +08:00
|
|
|
|
if (fileType.HasFlag(RecipeType.Clean) && scProcessType.Contains(RecipeType.Clean.ToString()))
|
|
|
|
|
supportedRecipeType.Add(RecipeType.Clean);
|
2023-05-11 10:12:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var processTypeFileList = new List<ProcessTypeFileItem>();
|
|
|
|
|
|
2023-08-22 16:48:45 +08:00
|
|
|
|
for (var i = 0; i < supportedRecipeType.Count; i++)
|
2023-05-11 10:12:41 +08:00
|
|
|
|
{
|
|
|
|
|
var type = new ProcessTypeFileItem
|
|
|
|
|
{
|
2023-08-22 16:48:45 +08:00
|
|
|
|
ProcessType = supportedRecipeType[i]
|
2023-05-11 10:12:41 +08:00
|
|
|
|
};
|
2023-08-22 16:48:45 +08:00
|
|
|
|
var prefix = $"Sic\\{supportedRecipeType[i]}";
|
2023-05-11 10:12:41 +08:00
|
|
|
|
var recipes = recipeProvider.GetXmlRecipeList(prefix);
|
|
|
|
|
type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipes, isFolderOnly, isShowRootNode)[0].Files;
|
|
|
|
|
processTypeFileList.Add(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ProcessTypeFileList = processTypeFileList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
|
|
|
|
public void TreeSelectChanged(FileNode file)
|
|
|
|
|
{
|
2023-05-11 10:12:41 +08:00
|
|
|
|
_currentFileNode = file;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void TreeMouseDoubleClick(FileNode file)
|
|
|
|
|
{
|
2023-05-11 10:12:41 +08:00
|
|
|
|
_currentFileNode = file;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
OK();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OK()
|
|
|
|
|
{
|
2023-05-11 10:12:41 +08:00
|
|
|
|
if (this._currentFileNode == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (_isFolderOnly)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-05-11 10:12:41 +08:00
|
|
|
|
if (this._currentFileNode.IsFile)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this.DialogResult = _currentFileNode.PrefixPath + "\\" + _currentFileNode.FullPath;
|
|
|
|
|
IsCancel = false;
|
|
|
|
|
TryClose(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!this._currentFileNode.IsFile)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this.DialogResult = _currentFileNode.PrefixPath + "\\" + _currentFileNode.FullPath;
|
|
|
|
|
IsCancel = false;
|
|
|
|
|
TryClose(true);
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Cancel()
|
|
|
|
|
{
|
|
|
|
|
IsCancel = true;
|
|
|
|
|
TryClose(false);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-11 10:12:41 +08:00
|
|
|
|
#endregion
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|