public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm) { var flValue = pm.GetValue(FileListKey); IFileListViewModel flvm = flValue is IExplorerViewModel ? (flValue as IExplorerViewModel).FileList : flValue as IFileListViewModel; if (flvm == null) { return(ResultCommand.Error(new KeyNotFoundException(FileListKey))); } IEntryModel[] value = new IEntryModel[] { }; switch (AssignType) { case FileListAssignType.All: value = flvm.ProcessedEntries.EntriesHelper.AllNonBindable .Select(evm => evm.EntryModel).ToArray(); break; case FileListAssignType.Selected: value = flvm.Selection.SelectedItems.Select(evm => evm.EntryModel).ToArray(); break; default: return(ResultCommand.Error(new NotSupportedException("AssignType"))); } return(ScriptCommands.Assign(DestinationKey, value, false, NextCommand)); }
/// <summary> /// Not Serializable, create a folder by specified parameter. /// </summary> /// <param name="parentFolder"></param> /// <param name="folderName"></param> /// <param name="destVariable"></param> /// <param name="nameGenerationMode"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand DiskCreateFolder(IEntryModel parentFolder, string folderName, string destVariable = "{Entry}", NameGenerationMode nameGenerationMode = NameGenerationMode.Rename, IScriptCommand nextCommand = null) { return(ScriptCommands.Assign("{DiskCreateFolder-Profile}", parentFolder, false, ScriptCommands.Assign("{DiskCreateFolder-Path}", parentFolder.Profile.Path.Combine(parentFolder.FullPath, folderName), false, DiskCreateFolder("{DiskCreateFolder-Profile}", "{DiskCreateFolder-Path}", destVariable, nameGenerationMode, nextCommand)))); }
/// <summary> /// Set Control.Commands(CommandManager).Commands(DynamicDictionary[IScriptCommand]) /// </summary> /// <param name="?"></param> /// <returns></returns> public static IScriptCommand SetScriptCommand(string controlVariable = "{FileList}", string target = "Open", IScriptCommand valueCommand = null, IScriptCommand nextCommand = null) { string valueVarable = ParameterDic.CombineVariable(controlVariable, "Value"); return(ScriptCommands.Assign(valueVarable, valueCommand, false, SetScriptCommand(controlVariable, target, valueVarable, nextCommand))); }
public static IScriptCommand IfArrayLength(ComparsionOperator op = ComparsionOperator.GreaterThanOrEqual, string arrayVariable = "{array}", int value = 1, IScriptCommand trueCommand = null, IScriptCommand otherwiseCommand = null) { return (ScriptCommands.Assign("{ArrayLengthValue}", value, false, IfArrayLength(op, arrayVariable, "{ArrayLengthValue}", trueCommand, otherwiseCommand))); }
public static IScriptCommand NotifyRootDeleted(IEntryModel[] directories, IScriptCommand nextCommand = null) { string directoryVariable = "{Notify-RootDirs}"; return(ScriptCommands.Assign(directoryVariable, directories, false, NotifyRootDeleted(directoryVariable, nextCommand))); }
public static IScriptCommand DiskTransferChild(IEntryModel[] srcModels, IEntryModel destDirModel, bool removeOriginal = false, bool allowCustomImplementation = true, IScriptCommand nextCommand = null) { return(ScriptCommands.Assign("{SourceDiskTransferEntry}", srcModels, false, ScriptCommands.Assign("{DestinationDiskTransferEntry}", destDirModel, false, DiskTransferChild("{SourceDiskTransferEntry}", "{DestinationDiskTransferEntry}", removeOriginal, allowCustomImplementation, nextCommand)))); }
/// <summary> /// Not Serializable, transfer source entry to destentry. /// For transfer to ISzsItemModel only, if unsure destination use DiskTransfer with allowCustom on. /// </summary> /// <param name="srcModel"></param> /// <param name="destDirModel"></param> /// <param name="removeOriginal"></param> /// <param name="allowCustomImplementation"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand SzsDiskTransfer(IEntryModel[] srcModels, ISzsItemModel destDirModel, bool removeOriginal = false, IScriptCommand nextCommand = null) { return(ScriptCommands.Assign("{SourceDiskTransferEntry}", srcModels, false, ScriptCommands.Assign("{DestinationDiskTransferEntry}", destDirModel, false, SzsDiskTransfer("{SourceDiskTransferEntry}", "{DestinationDiskTransferEntry}", removeOriginal, nextCommand)))); }
public static IScriptCommand RunICommand(ICommand command, string parameterVariable, bool throwIfError = false, IScriptCommand nextCommand = null) { string commandVariable = "{" + string.Format("Command{0}", new Random().Next()) + "}"; return(ScriptCommands.Assign(commandVariable, command, false, ScriptCommands.RunICommand(commandVariable, parameterVariable, throwIfError, nextCommand))); }
public static IScriptCommand IfEquals <T>(string variable = "{variable}", T value = default(T), IScriptCommand trueCommand = null, IScriptCommand otherwiseCommand = null) { string ifEqualValueProperty = "{IfEquals-Value}"; return (ScriptCommands.Assign(ifEqualValueProperty, value, false, IfValue(ComparsionOperator.Equals, variable, ifEqualValueProperty, trueCommand, otherwiseCommand))); }
public static IScriptCommand List(IEntryModel directoryEntry, string destVariable = "{Destination}", string maskVariable = "*", ListOptions options = ListOptions.File | ListOptions.Folder, IScriptCommand nextCommand = null) { return(ScriptCommands.Assign("{List-DirectoryEntry}", directoryEntry, false, List("{List-DirectoryEntry}", destVariable, maskVariable, options, ScriptCommands.Reset(nextCommand, "{List-DirectoryEntry}")))); }
/// <summary> /// Not serializable, Copy contents from srcFile to destFile. /// </summary> /// <param name="srcFile"></param> /// <param name="destFile"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand DiskCopyFile(IEntryModel srcFile, IEntryModel destFile, IScriptCommand nextCommand = null) { return(ScriptCommands.Assign("{DiskCopyFile-Source}", srcFile, false, ScriptCommands.Assign("{DiskCopyFile-Dest}", destFile, false, CoreScriptCommands.DiskOpenStream(dcSourceVariable, "{SourceStream}", FileExplorer.Defines.FileAccess.Read, CoreScriptCommands.DiskOpenStream(dcDestVariable, "{DestinationStream}", FileExplorer.Defines.FileAccess.Write, CoreScriptCommands.CopyStream("{CopyStream-Source}", "{CopyStream-Dest}", CoreScriptCommands.NotifyEntryChanged(ChangeType.Created, null, dcSourceVariable, null, dcDestVariable, ScriptCommands.Reset(nextCommand, dcSourceVariable, dcDestVariable)))))))); }
public static IScriptCommand AddValue <T>(string value1Variable = "{Value1}", T[] value2 = null, string destinationVariable = "{Destination}", IScriptCommand nextCommand = null) { value2 = value2 ?? new T[] {}; string value2Variable = ParameterDic.RandomVariable(); return(ScriptCommands.Assign(value2Variable, value2, false, Add(value1Variable, value2Variable, destinationVariable, nextCommand))); }
public static IScriptCommand NotifyEntryChangedPath( ChangeType changeType, IProfile sourceProfile, string[] sourceEntryPaths, IProfile destinationProfile, string[] destinationEntryPaths, IScriptCommand nextCommand = null) { string sourceEntriesKey = "{SourceEntriesKey}"; string destinationEntriesKey = "{DestinationEntriesKey}"; return(ScriptCommands.Assign(sourceEntriesKey, sourceEntryPaths, false, ScriptCommands.Assign(destinationEntriesKey, destinationEntryPaths, false, NotifyEntryChangedProfile(changeType, sourceProfile, sourceEntriesKey, destinationProfile, destinationEntriesKey, nextCommand)))); }
public override IScriptCommand Execute(ParameterDic pm) { return(ScriptCommands.Assign(new Dictionary <string, object>() { { "{ColumnList}", IOInitializeHelpers.FileList_ColumList_For_DiskBased_Items }, { "{ColumnFilters}", IOInitializeHelpers.FileList_ColumnFilter_For_DiskBased_Items }, { "{FileListOpenCommand}", IOInitializeHelpers.FileList_Open_For_DiskBased_Items }, { "{FileListDeleteCommand}", IOInitializeHelpers.FileList_Delete }, { "{FileListNewFolderCommand}", IOInitializeHelpers.FileList_NewFolder }, { "{FileListCutCommand}", IOInitializeHelpers.FileList_Cut_For_DiskBased_Items }, { "{FileListCopyCommand}", IOInitializeHelpers.FileList_Copy_For_DiskBased_Items }, { "{FileListPasteCommand}", IOInitializeHelpers.FileList_Paste_For_DiskBased_Items }, { "{FileListNewWindowCommand}", IOInitializeHelpers.FileList_NewWindow }, { "{DirectoryTreeMapCommand}", IOInitializeHelpers.DirectoryTree_Map_From_Profiles }, { "{DirectoryTreeUnmapCommand}", IOInitializeHelpers.DirectoryTree_Unmap }, { "{DirectoryTreeNewWindowCommand}", IOInitializeHelpers.DirectoryTree_NewWindow }, }, true, ScriptCommands.RunSequence(NextCommand, UIScriptCommands.ExplorerAssignScriptParameters(ExplorerKey, "{Profiles}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.RootModels, "{RootDirectories}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.FileName, "{FileName}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.EnableContextMenu, "{EnableContextMenu}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.EnableDrag, "{EnableDrag}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.EnableDrop, "{EnableDrop}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.EnableMultiSelect, "{EnableMultiSelect}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.ColumnList, "{ColumnList}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.ColumnFilters, "{ColumnFilters}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.FilterString, "{FilterString}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.ViewMode, "{ViewMode}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.ItemSize, "{ItemSize}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.ShowToolbar, "{ShowToolbar}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.ShowSidebar, "{ShowSidebar}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.ShowGridHeader, "{ShowGridHeader}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.ExplorerWidth, "{ExplorerWidth}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.ExplorerHeight, "{ExplorerHeight}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.ExplorerPosition, "{ExplorerPosition}"), UIScriptCommands.ExplorerSetParameter(ExplorerKey, ExplorerParameterType.EnableBookmark, "{EnableBookmark}"), UIScriptCommands.SetScriptCommand(FileListKey, "Open", "{FileListOpenCommand}"), UIScriptCommands.SetScriptCommand(FileListKey, "Delete", "{FileListDeleteCommand}"), UIScriptCommands.SetScriptCommand(FileListKey, "NewFolder", "{FileListNewFolderCommand}"), UIScriptCommands.SetScriptCommand(FileListKey, "OpenTab", "{FileListOpenTabCommand}"), UIScriptCommands.SetScriptCommand(FileListKey, "Cut", "{FileListCutCommand}"), UIScriptCommands.SetScriptCommand(FileListKey, "Copy", "{FileListCopyCommand}"), UIScriptCommands.SetScriptCommand(FileListKey, "Paste", "{FileListPasteCommand}"), UIScriptCommands.SetScriptCommand(FileListKey, "NewWindow", "{FileListNewWindowCommand}"), UIScriptCommands.SetScriptCommand(DirectoryTreeKey, "OpenTab", "{DirectoryTreeOpenTabCommand}"), UIScriptCommands.SetScriptCommand(DirectoryTreeKey, "NewWindow", "{DirectoryTreeNewWindowCommand}"), UIScriptCommands.SetScriptCommand(DirectoryTreeKey, "Map", "{DirectoryTreeMapCommand}"), UIScriptCommands.SetScriptCommand(DirectoryTreeKey, "Unmap", "{DirectoryTreeUnmapCommand}") ) )); }
public static IScriptCommand ExplorerNewWindow(IProfile[] profiles, IEntryModel[] rootDirectories, string explorerVariable = "{Explorer}", IScriptCommand nextCommand = null) { return(ScriptCommands.Assign(new Dictionary <string, object>() { { "{Profiles}", profiles }, { "{RootDirectories}", rootDirectories }, { "{OnModelCreated}", IOInitializeHelpers.Explorer_Initialize_Default }, { "{OnViewAttached}", UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot() } }, false, UIScriptCommands.ExplorerNewWindow("{OnModelCreated}", "{OnViewAttached}", "{WindowManager}", "{GlobalEvents}", explorerVariable, nextCommand))); }
private async Task <IScriptCommand> transferScriptCommandAsync(ParameterDic pm, IEntryModel[] srcEntries, IEntryModel destEntry, string destinationKey) { var progress = pm.GetProgress() ?? NullTransferProgress.Instance; var srcProfile = srcEntries.First().Profile as IDiskProfile; var destProfile = destEntry.Profile as IDiskProfile; var srcMapper = srcProfile.DiskIO.Mapper; var destMapping = destProfile.DiskIO.Mapper[destEntry]; List <IScriptCommand> notifyChangeCommands = new List <IScriptCommand>(); List <string> changedPath = new List <string>(); progress.Report(TransferProgress.IncrementTotalEntries(srcEntries.Count())); foreach (var srcEntry in srcEntries) { var srcMapping = srcMapper[srcEntry]; string destName = PathFE.GetFileName(srcMapping.IOPath); string destFullName = destProfile.Path.Combine(destEntry.FullPath, destName); progress.Report(TransferProgress.From(srcEntry.FullPath, destEntry.FullPath)); if (srcEntry.IsDirectory) { await ScriptRunner.RunScriptAsync(pm, ScriptCommands.Assign("{DT-SrcDirectory}", srcEntry, false, ScriptCommands.Assign("{DT-DestProfile}", destEntry.Profile, false, CoreScriptCommands.DiskParseOrCreateFolder("{DT-DestProfile}", destFullName, "{DT-DestDirectory}", IOScriptCommands.DiskTransferChild("{DT-SrcDirectory}", "{DT-DestDirectory}", RemoveOriginal, AllowCustomImplementation, ScriptCommands.Reset(ResultCommand.NoError, "{DT-DestDirectory}", "{DT-SrcDirectory}")))))); } else { await ScriptRunner.RunScriptAsync(pm, ScriptCommands.Assign("{DT-SrcFile}", srcEntry, false, ScriptCommands.Assign("{DT-SrcProfile}", srcEntry.Profile, false, ScriptCommands.Assign("{DT-DestProfile}", destEntry.Profile, false, CoreScriptCommands.DiskParseOrCreateFile("{DT-DestProfile}", destFullName, "{DT-DestFile}", CoreScriptCommands.DiskCopyFile("{DT-SrcProfile}", "{DT-SrcFile}", "{DT-DestProfile}", "{DT-DestFile}", ScriptCommands.Reset(ResultCommand.NoError, "{DT-SrcFile}", "{DT-DestFile}"))))))); } progress.Report(TransferProgress.IncrementProcessedEntries()); } logger.Info(String.Format("{0} {1} -> {2} using ScriptCommand", RemoveOriginal ? "Move" : "Copy", srcEntries.GetDescription(), destEntry.Name)); return(await GetAssignDestinationCommandAsync(pm, srcEntries, destEntry, destinationKey, NextCommand)); }
public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm) { var flValue = pm.GetValue(FileListKey); IFileListViewModel flvm = flValue is IExplorerViewModel ? (flValue as IExplorerViewModel).FileList : flValue as IFileListViewModel; if (flvm == null) { return(ResultCommand.Error(new KeyNotFoundException(FileListKey))); } return(ScriptCommands.Assign(DestinationKey, flvm.Selection.SelectedItems.Select(evm => evm.EntryModel).ToArray(), false, NextCommand)); }
public static IScriptCommand FileSave( string filterString = "All files (*.*)|*.*", string selectionPathsVariable = "{Selection}", IScriptCommand nextCommand = null, IScriptCommand cancelCommand = null) { return(ScriptCommands.Assign(new Dictionary <string, object>() { { "{EnableDrag}", false }, { "{EnableDrop}", false }, { "{FilterString}", filterString }, { "{EnableMultiSelect}", false }, { "{FileListNewWindowCommand}", NullScriptCommand.Instance }, { "{OnModelCreated}", IOInitializeHelpers.Explorer_Initialize_Default }, { "{OnViewAttached}", UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot() } }, false, UIScriptCommands.ExplorerPick(ExplorerMode.FileSave, "{OnModelCreated}", "{OnViewAttached}", "{WindowManager}", "{GlobalEvents}", null, selectionPathsVariable, nextCommand, cancelCommand))); }
public static IScriptCommand DirectoryPick(IProfile[] profiles, IEntryModel[] rootDirectories, string selectionVariable = "{Selection}", string selectionPathVariable = "{SelectionPaths}", IScriptCommand nextCommand = null, IScriptCommand cancelCommand = null) { return(ScriptCommands.Assign(new Dictionary <string, object>() { { "{Profiles}", profiles }, { "{RootDirectories}", rootDirectories }, { "{EnableDrag}", false }, { "{EnableDrop}", false }, { "{EnableMultiSelect}", false }, { "{FileListNewWindowCommand}", NullScriptCommand.Instance }, { "{OnModelCreated}", IOInitializeHelpers.Explorer_Initialize_Default }, { "{OnViewAttached}", UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot() } }, false, UIScriptCommands.ExplorerPick(ExplorerMode.DirectoryOpen, "{OnModelCreated}", "{OnViewAttached}", "{WindowManager}", "{GlobalEvents}", selectionVariable, selectionPathVariable, nextCommand, cancelCommand))); }
private async Task <IScriptCommand> GetAssignDestinationCommandAsync(ParameterDic pm, IEntryModel[] srcEntries, IEntryModel destEntry, string destinationKey, IScriptCommand nextCommand) { if (DestinationKey != null) { string[] srcEntryNames = srcEntries.Select(e => e.Name).ToArray(); IEntryModel[] destinationEntries = (await destEntry.Profile.ListAsync(destEntry, pm.CancellationToken, e => srcEntryNames.Contains(e.Name, StringComparer.CurrentCultureIgnoreCase), true)).ToArray(); if (destinationEntries.Length != srcEntries.Length) { logger.Warn(String.Format("Transfer count different : sorce = {0}, actual = {1}", srcEntries.Length, destinationEntries.Length)); } return(ScriptCommands.Assign(DestinationKey, destinationEntries, false, nextCommand)); } else { return(nextCommand); } }
public override IScriptCommand Execute(ParameterDic pm) { object value = Value; if (ValueFunc != null) { value = ValueFunc(); } if (!(value is string)) { value = value.ToString(); } else { value = pm.ReplaceVariableInsideBracketed((string)value); } return(ScriptCommands.Assign(VariableKey, value, SkipIfExists, NextCommand)); }
public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm) { switch (Operation) { case ClipboardOperation.Copy: case ClipboardOperation.Cut: var _srcModels = await pm.GetValueAsEntryModelArrayAsync(EntriesKey); var da = _srcModels.First().Profile.DragDrop.GetDataObject(_srcModels); byte[] moveEffect = Operation == ClipboardOperation.Cut ? preferCut : preferCopy; MemoryStream dropEffect = new MemoryStream(); dropEffect.Write(moveEffect, 0, moveEffect.Length); da.SetData("Preferred DropEffect", dropEffect); Clipboard.Clear(); Clipboard.SetDataObject(da, true); break; case ClipboardOperation.Paste: var currentDirectory = await pm.GetValueAsEntryModelAsync(CurrentDirectoryEntryKey); if (currentDirectory != null) { IDataObject da1 = Clipboard.GetDataObject(); if (da1 != null) { IEntryModel[] srcModels = currentDirectory.Profile.DragDrop.GetEntryModels(da1).ToArray(); string sourceModelKey = "{Clipboard-SourceModels}"; return(ScriptCommands.Assign(sourceModelKey, srcModels, false, IOScriptCommands.DiskTransfer(sourceModelKey, CurrentDirectoryEntryKey, DestinationKey, false, true, NextCommand))); } } break; } return(NextCommand); }
public static IScriptCommand Reset(string variable, IScriptCommand nextCommand) { return(ScriptCommands.Assign(variable, null)); }
/// <summary> /// Serializable, remove a variable from ParameterDic. /// </summary> /// <param name="nextCommand"></param> /// <param name="variables"></param> /// <returns></returns> public static IScriptCommand Reset(IScriptCommand nextCommand = null, params string[] variables) { return(ScriptCommands.Run(RunMode.Parallel, nextCommand, variables.Select(v => ScriptCommands.Assign(v, null)).ToArray())); }
/// <summary> /// Not serializable, goto the specified directory. /// </summary> /// <param name="explorerVariable"></param> /// <param name="directory"></param> /// <param name="nextCommand"></param> /// <returns></returns> public static IScriptCommand ExplorerGoToValue(string explorerVariable = "{Explorer}", IEntryModel directory = null, IScriptCommand nextCommand = null) { return(ScriptCommands.Assign("{Goto-Directory}", directory, false, ExplorerGoTo(explorerVariable, "{Goto-Directory}", nextCommand))); }