123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.IO;
- using System.Linq;
- using System.Net.Sockets;
- using System.Windows;
- using System.Windows.Input;
- using Aitex.Common.Util;
- using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
- using OpenSEMI.ClientBase;
- namespace MECF.Framework.UI.Client.CenterViews.Editors
- {
- public class InputFileNameDialogViewModel : DialogViewModel<string>
- {
- public InputFileNameDialogViewModel(string dialogName = "", ObservableCollection<FileNode> filepath = null, string comment = "", Visibility commentvisible = Visibility.Visible, Visibility folderVisibility = Visibility.Visible)
- {
- this.DisplayName = dialogName;
- this.fileNodes = filepath;
- this.Comment = comment;
- CommentVisiblility = commentvisible;
- FolderVisibility = folderVisibility;
- }
- public ObservableCollection<FileNode> fileNodes;
- public Dictionary<string, FileNode> FilePaths { get; set; } = new Dictionary<string, FileNode>();
- public string FilePath { get; set; }
- public string FileName { get; set; }
- public FileNode SelectNode { get; set; }
- public string Comment { get; set; }
- public int SelectIndex { get; set; } = -1;
- private Visibility _commentVisibility;
- public Visibility CommentVisiblility
- {
- get
- {
- return _commentVisibility;
- }
- set
- {
- _commentVisibility = value;
- NotifyOfPropertyChange(nameof(CommentVisiblility));
- }
- }
- #region
- #region 选择框 是否可见
- /// <summary>
- /// 是否可见
- /// </summary>
- public Visibility FolderVisibility
- {
- get { return __folderVisibility; }
- set
- {
- __folderVisibility = value;
- NotifyOfPropertyChange(nameof(FolderVisibility));
- }
- }
- private Visibility __folderVisibility= Visibility.Visible;
- #endregion
- #endregion
- public void Cancel()
- {
- IsCancel = true;
- TryClose(false);
- }
- protected override void OnViewLoaded(object view)
- {
- base.OnViewLoaded(view);
- InputFileNameDialogView v = (InputFileNameDialogView)view;
- FocusManager.SetFocusedElement(v, v.tbName);
- FilePaths.Clear();
- foreach (var item in fileNodes)
- {
- GetFilePathByNode(item);
- }
- }
- void GetFilePathByNode(FileNode node)
- {
- if (!node.IsFile)
- {
- if (FilePaths.ContainsKey(node.FullPath))
- {
- FilePaths[node.FullPath] = node;
- }
- else
- {
- FilePaths.Add(node.FullPath, node);
- }
- }
- foreach (var item in node.Files)
- {
- GetFilePathByNode(item);
- }
- }
- public void OK()
- {
- this.DialogResult = FileName;
- InputFileNameDialogView v = ((Window)GetView()).Content as InputFileNameDialogView;
- FilePath = v.cbFolder.Text;
- if (!string.IsNullOrEmpty(v.cbFolder.Text))
- {
- SelectNode = FilePaths[v.cbFolder.Text];
- }
- IsCancel = false;
- TryClose(true);
- }
- }
- }
|