public void InitSaveAs(string startDirectory = "C:\\", string defaultExtension = "", string searchPattern = "*", string title = "Select file") { InitCommon(startDirectory); explorerMode = ExplorerMode.Save; selectionMode = SelectionMode.File; this.searchPattern = searchPattern; this.title.text = title; this.multiSelect = false; answerButton.GetComponentInChildren <Text>().text = "Save As"; EventSystem.current.SetSelectedGameObject(filenameField.gameObject); if (!String.IsNullOrEmpty(defaultExtension)) { var rect = filenameField.GetComponent <RectTransform>(); rect.anchorMax = new Vector2(extension.GetComponent <RectTransform>().anchorMin.x, rect.anchorMax.y); extension.gameObject.SetActive(true); extension.text = defaultExtension; } UpdateDir(); }
public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm) { IWindowManager wm = pm.GetValue <IWindowManager>(WindowManagerKey) ?? new WindowManager(); IEventAggregator events = pm.GetValue <IEventAggregator>(EventAggregatorKey) ?? new EventAggregator(); IExplorerInitializer initializer = new ScriptCommandInitializer() { StartupParameters = pm, WindowManager = wm, Events = events, OnModelCreated = ScriptCommands.Run(OnModelCreatedKey), OnViewAttached = ScriptCommands.Run(OnViewAttachedKey) }; ExplorerViewModel evm = null; switch (ExplorerMode) { case Script.ExplorerMode.Normal: evm = new ExplorerViewModel(wm, events) { Initializer = initializer }; break; case Script.ExplorerMode.FileOpen: evm = new FilePickerViewModel(wm, events) { Initializer = initializer, PickerMode = FilePickerMode.Open }; break; case Script.ExplorerMode.FileSave: evm = new FilePickerViewModel(wm, events) { Initializer = initializer, PickerMode = FilePickerMode.Save }; break; case Script.ExplorerMode.DirectoryOpen: evm = new DirectoryPickerViewModel(wm, events) { Initializer = initializer }; break; default: return(ResultCommand.Error(new NotSupportedException(ExplorerMode.ToString()))); } logger.Info(String.Format("Creating {0}", evm)); pm.SetValue(DestinationKey, evm, false); return(NextCommand); }
private static void readMode() { if (File.Exists(configFilePath)) { ReadINI RI = new ReadINI(configFilePath); try { String tempStr = RI.GetValue("WindowData", "ExplorerMode"); if (tempStr == null || tempStr == "") { MessageBox.Show("缺少BaseUrl配置项!"); return; } // return explorerMode; if (tempStr == ExplorerMode.winMenu.ToString()) { explorerMode = ExplorerMode.winMenu; } else if (tempStr == ExplorerMode.winWeb.ToString()) { explorerMode = ExplorerMode.winWeb; } else { explorerMode = ExplorerMode.nodata; } } catch { MessageBox.Show("读取Config.ini文件错误!"); return; } try { contentMode = RI.GetValue("[WindowData]", "ContentMode"); if (contentMode == null || contentMode == "") { contentMode = "IE"; return; } // return explorerMode; } catch { // MessageBox.Show("读取Config.ini文件错误!"); return; } } else { MessageBox.Show("找不到Config.ini文件!"); return; } }
/// <summary> /// Serializable, Create a new directory or file picker explorer window (IExplorerViewModel), and show it. /// </summary> /// <param name="mode"></param> /// <param name="onModelCreatedVariable"></param> /// <param name="onViewAttachedVariable"></param> /// <param name="windowManagerVariable"></param> /// <param name="eventAggregatorVariable"></param> /// <param name="selectionVariable"></param> /// <param name="selectionPathsVariable"></param> /// <param name="nextCommand"></param> /// <param name="cancelCommand"></param> /// <returns></returns> public static IScriptCommand ExplorerPick(ExplorerMode mode = ExplorerMode.FileSave, string onModelCreatedVariable = "{OnModelCreated}", string onViewAttachedVariable = "{OnViewAttached}", string windowManagerVariable = "{WindowManager}", string eventAggregatorVariable = "{GlobalEvents}", string selectionVariable = null, string selectionPathsVariable = "{SelectionPaths}", IScriptCommand nextCommand = null, IScriptCommand cancelCommand = null) { string dialogResultVariable = "{ExplorerPick-DialogResult}"; string explorerVariable = "{ExplorerPick-Explorer}"; return(ExplorerCreate(mode, onModelCreatedVariable, onViewAttachedVariable, windowManagerVariable, eventAggregatorVariable, explorerVariable, UIScriptCommands.explorerShow(windowManagerVariable, explorerVariable, dialogResultVariable, selectionVariable, selectionPathsVariable, ScriptCommands.IfTrue(dialogResultVariable, nextCommand, cancelCommand)))); }
//NOTE(Simon): search pattern should be in default windows wildcard style: e.g. "*.zip" for zipfiles, "a.*" for all filetypes with name "a" //NOTE(Simon): If you provide "" as startDirectory, startDirectory will default to the last location from where a file was selected public void Init(string startDirectory = "C:\\", string searchPattern = "*", string title = "Select file", SelectionMode mode = SelectionMode.File, bool multiSelect = false) { InitCommon(startDirectory); explorerMode = ExplorerMode.Open; selectionMode = mode; this.searchPattern = searchPattern; this.title.text = title; this.multiSelect = multiSelect; answerButton.GetComponentInChildren <Text>().text = "Open"; UpdateDir(); HidePreview(); }
/// <summary> /// Serializable, Create a new Explorer IExplorerViewModel instance in ParameterDic, but does not show it. /// </summary> /// <param name="explorerMode"></param> /// <param name="onModelCreatedVariable"></param> /// <param name="onViewAttachedVariable"></param> /// <param name="windowManagerVariable"></param> /// <param name="eventAggregatorVariable"></param> /// <param name="destinationVariable"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand ExplorerCreate(ExplorerMode explorerMode, string onModelCreatedVariable = "{OnModelCreated}", string onViewAttachedVariable = "{OnViewAttached}", string windowManagerVariable = "{WindowManager}", string eventAggregatorVariable = "{GlobalEvents}", string destinationVariable = "{Explorer}", IScriptCommand nextCommand = null ) { return(new ExplorerCreate() { ExplorerMode = explorerMode, OnModelCreatedKey = onModelCreatedVariable, OnViewAttachedKey = onViewAttachedVariable, WindowManagerKey = windowManagerVariable, EventAggregatorKey = eventAggregatorVariable, DestinationKey = destinationVariable, NextCommand = (ScriptCommandBase)nextCommand }); }