private void setVMProperty <T>(ExplorerParameterType property, T value) { ParameterDic pd = new ParameterDic(); pd.SetValue("{PropertyValue}", value, false); _evm.Commands.Execute(UIScriptCommands.ExplorerSetParameter(property, "{PropertyValue}"), pd); }
public MdiWindow(IWindowManager wm, IEventAggregator events, IEntryModel[] rootModels) { InitializeComponent(); _rootDirectories = rootModels; _initializer = new ScriptCommandInitializer() { WindowManager = wm, Events = events, OnModelCreated = IOInitializeHelpers.Explorer_Initialize_Default, OnViewAttached = UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot(), RootModels = rootModels, StartupParameters = new ParameterDic() { { "MdiWindow", this } } }; //_initializer = AppViewModel.getInitializer(_windowManager, _events, _root, // new ColumnInitializers(), // new ScriptCommandsInitializers(_windowManager, _events), // new ToolbarCommandsInitializers(_windowManager)); //_initializer.Initializers.Add(new MdiWindowInitializers(_initializer, Container)); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); //FileExplorer.WPF.UserControls.Explorer exp = explorer as FileExplorer.WPF.UserControls.Explorer; explorer.ViewModel.Initializer = new ScriptCommandInitializer() { OnModelCreated = IOInitializeHelpers.Explorer_Initialize_Default, OnViewAttached = UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot(), RootModels = _rootDirs, StartupParameters = new ParameterDic() { { "Profiles", _profiles }, { "RootDirectories", _rootDirs }, { "StartupPath", _selectedPath }, { "FilterString", _filterStr }, { "ViewMode", "List" }, { "ItemSize", 4 }, { "EnableDrag", true }, { "EnableDrop", true }, { "FileListNewWindowCommand", NullScriptCommand.Instance }, //Disable NewWindow Command. { "EnableMultiSelect", true }, { "ShowToolbar", false }, { "ShowGridHeader", false } } }; explorer.ViewModel.FileList.EnableContextMenu = false; explorer.ViewModel.DirectoryTree.EnableContextMenu = false; explorer.ViewModel.FileList.PropertyChanged += CurrentDirectory_PropertyChanged; //this.WatchSystem(explorer.ViewModel.CurrentDirectory.ToString()); }
private void Encrypt_Button_Click(object sender, RoutedEventArgs e) { var _fileList = explorer.ViewModel.FileList.Selection.SelectedItems; List <string> encryptedFileNames = new List <string>(); Boolean isCancelEncryptionProcess = false; foreach (var el in _fileList) { if (System.IO.Path.GetExtension(el.EntryModel.FullPath) == Securebox.secureboxExtension) { //System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("File is already encrypted, press \"Cancel\" to skip remaining selected file(s), press \"Ok\" to continue", "File is already encrypted by Securebox", MessageBoxButtons.OKCancel); //isCancelEncryptionProcess = dialogResult == System.Windows.Forms.DialogResult.Cancel; } else { Guid g; // Create and display the value of two GUIDs. g = Guid.NewGuid(); Securebox.EncryptFile(el.EntryModel.FullPath, el.EntryModel.FullPath + ".tmp", g); isCancelEncryptionProcess = Securebox.PostProcessEncryptFile(el.EntryModel.FullPath + ".tmp", el.EntryModel.FullPath + ".box", g); encryptedFileNames.Add(System.IO.Path.GetFileName(el.EntryModel.FullPath)); } if (isCancelEncryptionProcess) { break; } } var report = String.Join("\n", encryptedFileNames.ToArray()); IScriptCommand cmd = UIScriptCommands.FileListRefresh(true, UIScriptCommands.MessageBoxOK("Report", report)); explorer.ViewModel.Commands.ExecuteAsync(cmd); }
public void PickFiles() { ScriptRunner.RunScriptAsync( new ParameterDic() { { "WindowManager", _windowManager }, { "GlobalEvents", _events }, { "Header", "OpenFile(s)" }, { "StartupPath", OpenPath } }, IOScriptCommands.FileOpen(_profiles, RootModels.ToArray(), true, FileFilter, "{Selection}", UIScriptCommands.MessageBoxOK("{Header}", "{Selection[0]} Selected"), UIScriptCommands.MessageBoxOK("{Header}", "User Cancelled")) ); #region Obsoluted - 1 (Use WPFScriptCommands.OpenFileDialog() IScriptCommand) //ScriptRunner.RunScriptAsync( // new ParameterDic() { { "WindowManager", _windowManager } }, // WPFScriptCommands.OpenFileDialog(_windowManager, _events, RootModels.ToArray(), FileFilter, "demo.txt", // (fpvm) => WPFScriptCommands.MessageBox("Open", fpvm.FileName), ResultCommand.OK)); #endregion #region Obsoluted - 0 (Create FilePickerViewModel Manually) //var filePicker = new FilePickerViewModel(_events, _windowManager, FileFilter, FilePickerMode.Open, RootModels.ToArray()); //updateExplorerModel(initExplorerModel(filePicker)); //if (_windowManager.ShowDialog(filePicker).Value) //{ // MessageBox.Show(String.Join(",", filePicker.SelectedFiles.Select(em => em.FullPath))); //} #endregion }
public void Handle(RootChangedEvent message) { Queue <IScriptCommand> cmds = new Queue <IScriptCommand>(); cmds.Enqueue(Explorer.ChangeRoot(message.ChangeType, message.AppliedRootDirectories)); if (message.Sender != null && message.Sender != this) { cmds.Enqueue(UIScriptCommands.ExplorerGoToValue(CurrentDirectory.EntryModel)); } else { switch (message.ChangeType) { case ChangeType.Changed: cmds.Enqueue(UIScriptCommands.ExplorerGoToValue(message.AppliedRootDirectories.First())); break; case ChangeType.Deleted: cmds.Enqueue(UIScriptCommands.ExplorerGoToValue(RootModels.FirstOrDefault())); break; } } Commands.ExecuteAsync(cmds.ToArray()); }
private async Task <IEntryModel> showDirectoryPicker(IEntryModel[] rootModels) { IProfile[] profiles = rootModels.Select(rm => rm.Profile).Distinct().ToArray(); return(await ScriptRunner.RunScriptAsync <IEntryModel>( "{OutputDirectory}", new ParameterDic() { { "WindowManager", _windowManager }, { "GlobalEvents", _events }, { "Header", "DirectoryPick" } }, IOScriptCommands.DirectoryPick(profiles, rootModels, "{OutputDirectory}", null, UIScriptCommands.MessageBoxOKCancel("{Header}", "Add {OutputDIrectory}?", null, ScriptCommands.Assign("{OutputDirectory}", null))))); //var directoryPicker = new DirectoryPickerViewModel( // AppViewModel.getInitializer(_windowManager, _events, rootModels, // new BasicParamInitalizers(true, false, false, false), // new ColumnInitializers())); //if (_windowManager.ShowDialog(directoryPicker).Value) // return directoryPicker.SelectedDirectory; //return null; }
private T getVMProperty <T>(ExplorerParameterType property) { ParameterDic pd = new ParameterDic(); _evm.Commands.Execute(UIScriptCommands.ExplorerGetParameter(property, "{OutputValue}"), pd); return(pd.GetValue <T>("{OutputValue}")); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); cbExplorerMode.ItemsSource = Enum.GetValues(typeof(FileExplorer.WPF.UserControls.Explorer.ExplorerMode)); cbExplorerMode.SelectedValue = FileExplorer.WPF.UserControls.Explorer.ExplorerMode.ToolWindow; //For use in ToolWindow2 mode. //explorer.ViewModel.Parameters.NavigationSize = 25; //explorer.ViewModel.Parameters.DirectoryTreeSize = "2*"; //explorer.ViewModel.Parameters.FileListSize = "*"; explorer.ViewModel.Initializer = new ScriptCommandInitializer() { OnModelCreated = IOInitializeHelpers.Explorer_Initialize_Default, OnViewAttached = UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot(), RootModels = _rootDirs, StartupParameters = new ParameterDic() { { "Profiles", _profiles }, { "RootDirectories", _rootDirs }, { "StartupPath", _selectedPath }, { "FilterString", _filterStr }, { "ViewMode", "List" }, { "ItemSize", 16 }, { "EnableDrag", true }, { "EnableDrop", true }, { "FileListNewWindowCommand", NullScriptCommand.Instance }, //Disable NewWindow Command. { "EnableMultiSelect", true }, { "ShowToolbar", false }, { "ShowGridHeader", false } } }; testDroppable.DataContext = new TestDroppableViewModel(); #region Obsoluted //exp.RootDirectories = _rootDirs; //exp.ViewModel.FileList.ShowToolbar = false; //exp.ViewModel.FileList.ShowGridHeader = false; //exp.ViewModel.FileList.Parameters.ViewMode = "List"; //exp.ViewModel.FileList.Parameters.ItemSize = 16; //exp.ViewModel.FileList.EnableDrag = true; //exp.ViewModel.FileList.EnableDrop = false; //exp.ViewModel.FileList.EnableMultiSelect = false; //exp.ViewModel.FilterStr = _mask; //if (_selectedPath != null) // exp.ViewModel.GoAsync(_selectedPath); //FileSystemInfoExProfile profile = new FileSystemInfoExProfile(exp.ViewModel.Events, exp.ViewModel.WindowManager); //var rootModel = AsyncUtils.RunSync(() => profile.ParseAsync("")); //or exp.ViewModel.Commands.ExecuteAsync(new IScriptCommand[] { Explorer.GoTo("C:\\") }); #endregion }
public void SaveFile() { ScriptRunner.RunScriptAsync( new ParameterDic() { { "WindowManager", _windowManager }, { "GlobalEvents", _events }, { "Header", "SaveFile" }, { "FileName", "OpenFile.txt" }, { "StartupPath", OpenPath } }, IOScriptCommands.FileSave(_profiles, RootModels.ToArray(), FileFilter, "{Selection}", UIScriptCommands.MessageBoxOK("{Header}", "{Selection[0]} Selected"), UIScriptCommands.MessageBoxOK("{Header}", "User Cancelled")) ); #region Obsolute - 2 (Use UIScriptCommands.FileSave) //ScriptRunner.RunScriptAsync( // new ParameterDic() // { // { "WindowManager", _windowManager }, // { "RootModels", RootModels.ToArray() }, // { "FilterStr", FileFilter }, // { "ProfileEx", _profileEx } // }, // UIScriptCommands.FileSave( // ScriptCommands.RunCommandsInQueue(null, // UIScriptCommands.ExplorerSetParameters(ExplorerParameterType.RootModels, "{RootModels}", // UIScriptCommands.ExplorerSetParameters(ExplorerParameterType.FilterStr, "{FilterStr}")) // ), // UIScriptCommands.ExplorerParseAndGoTo("{Explorer}", "{ProfileEx}", ""), // "{WindowsManager}", "{Events}", "{DialogResult}", "{SelectionPaths}", // ScriptCommands.IfTrue("{DialogResult}", // UIScriptCommands.MessageBoxOK("SaveFile", "{SelectionPaths}"), // UIScriptCommands.MessageBoxOK("SaveFile", "Cancelled")) // )); #endregion #region Obsolute - 1 (Use WPFScriptCommands.SaveFilePicker() IScriptCommand) //ScriptRunner.RunScriptAsync( // new ParameterDic() { { "WindowManager", _windowManager } }, // WPFScriptCommands.SaveFilePicker(_windowManager, null, RootModels.ToArray(), FileFilter, "demo.txt", // (fpvm) => WPFScriptCommands.MessageBox("Save", fpvm.FileName), ResultCommand.OK)); #endregion #region Obsolute - 0 (Create FilePickerViewModel manually) //var filePicker = new FilePickerViewModel(_events, _windowManager, FileFilter, FilePickerMode.Save, RootModels.ToArray()); //updateExplorerModel(initExplorerModel(filePicker)); //if (_windowManager.ShowDialog(filePicker).Value) //{ // MessageBox.Show(filePicker.FileName); //} #endregion }
public IExplorerViewModel OpenTab(IEntryModel model = null) { var initializer = _initializer.Clone(); if (initializer is ExplorerInitializer) { ExplorerInitializer eInit = initializer as ExplorerInitializer; if (model != null) { eInit.Initializers.Add(ExplorerInitializers.StartupDirectory(model)); } } else if (initializer is ScriptCommandInitializer) { ScriptCommandInitializer sInit = initializer as ScriptCommandInitializer; sInit.OnViewAttached = (model != null) ? ScriptCommands.Assign("{StartupPath}", model.FullPath, false, UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot()) : UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot(); sInit.OnModelCreated = ScriptCommands.Assign("{TabbedExplorer}", this, false, UIScriptCommands.ExplorerAssignScriptParameters("{Explorer}", "{TabbedExplorer}", sInit.OnModelCreated)); } ExplorerViewModel expvm = new ExplorerViewModel(_windowManager, _events) { Initializer = initializer }; //expvm.Commands.ParameterDicConverter.AddAdditionalParameters(new ParameterDic() // { // {"TabbedExplorer", this } // }); expvm.DropHelper = new TabDropHelper <IExplorerViewModel>(expvm, this); //expvm.FileList.Commands.CommandDictionary.CloseTab = // UIScriptCommands.TabExplorerCloseTab("{TabbedExplorer}", "{Explorer}"); ////ScriptCommands.ReassignToParameter("{Explorer}", TabbedExplorer.CloseTab(this)); expvm.FileList.Commands.CommandDictionary.OpenTab = ScriptCommands.Assign("{TabbedExplorer}", this, false, FileList.AssignSelectionToParameter( UIScriptCommands.TabExplorerNewTab("{TabbedExplorer}", "{Parameter}", null))); expvm.DirectoryTree.Commands.CommandDictionary.OpenTab = ScriptCommands.Assign("{TabbedExplorer}", this, false, DirectoryTree.AssignSelectionToParameter( UIScriptCommands.TabExplorerNewTab("{TabbedExplorer}", "{Parameter}", null))); ActivateItem(expvm); checkTabs(); return(expvm); }
public static IScriptCommand ExplorerNewMdiWindow(string mdiContainerVariable = "{MdiContainer}", string windowManagerVariable = "{WindowManager}", string eventsVariable = "{GlobalEvents}", string explorerVariable = "{Explorer}", IScriptCommand nextCommand = null) { return (UIScriptCommands.ExplorerCreate(ExplorerMode.Normal, "{OnModelCreated}", "{OnViewAttached}", windowManagerVariable, eventsVariable, explorerVariable, TestAppCommands.ExplorerShowMdi(mdiContainerVariable, windowManagerVariable, explorerVariable, nextCommand))); }
public static void OnPropertiesChanged(object sender, DependencyPropertyChangedEventArgs args) { Explorer exp = sender as Explorer; switch (args.Property.Name) { case "RootDirectories": IEntryModel[] newRootDirs = args.NewValue as IEntryModel[]; if (newRootDirs != null && newRootDirs.Length > 0) { exp._evm.Commands.Execute( UIScriptCommands.NotifyRootChanged(newRootDirs) ); } break; case "Mode": switch ((ExplorerMode)args.NewValue) { case ExplorerMode.Normal: exp.Content = new ExplorerView(); break; case ExplorerMode.ToolWindow: exp.Content = new ToolWindow(); break; case ExplorerMode.ToolWindow2: exp.Content = new ToolWindow2(); break; case ExplorerMode.DirectoryPicker: exp.Content = new DirectoryPicker(); break; case ExplorerMode.DirectoryPickerCombo: exp.Content = new DirectoryPickerCombo(); break; default: exp.Content = null; break; } if (exp.Content != null) { Caliburn.Micro.Bind.SetModel(exp.Content as DependencyObject, exp._evm); } break; case "EnableContextMenu": case "EnableDrag": case "EnableDrop": case "EnableBookmark": case "EnableMultiSelect": ExplorerParameterType prop; if (Enum.TryParse <ExplorerParameterType>(args.Property.Name, true, out prop)) { exp.setVMProperty(prop, (bool)args.NewValue); } break; } }
public TabbedExplorerViewModel(IWindowManager windowManager, IEventAggregator events) { DragHelper = new TabControlDragHelper <IExplorerViewModel>(this); _events = events; _windowManager = windowManager; events.Subscribe(this); Commands = new TabbedExplorerCommandManager(this, _events); Commands.SetCommandToDictionary(OnTabExplorerAttachedKey, UIScriptCommands.TabExplorerNewTab()); }
public DiskProfileBase(IEventAggregator events, params IConverterProfile[] converters) : base(events, converters) { MetadataProvider = new MetadataProviderBase(new BasicMetadataProvider(), new FileBasedMetadataProvider()); CommandProviders.Add(new FileBasedCommandProvider()); //Open, Cut, Copy, Paste etc DeleteCommand = ScriptCommands.AssignProperty("{DeleteEntries}", "Length", "{DeleteEntries-Length}", //Assign DeleteEntries Length ScriptCommands.IfValue <int>(ComparsionOperator.GreaterThanOrEqual, "{DeleteEntries.Length}", 1, //If DeleteEntries Length >= 1 UIScriptCommands.MessageBoxYesNo("FileExplorer", "Delete {DeleteEntries[0]} and {DeleteEntries-Length} Item(s)?", //IfTrue CoreScriptCommands.DiskDeleteMultiple("{DeleteEntries}", true)))); CreateFolderCommand = CoreScriptCommands.DiskCreateFolder("{BaseFolder.Profile}", "{BaseFolder.FullPath}\\{FolderName}", "{CreatedFolder}", NameGenerationMode.Rename); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); var vm = DataContext as AddBookmarksViewModel; var rootDir = new IEntryModel[] { vm.Profile.RootModel }; expFolderPicker.ViewModel.Initializer = new ScriptCommandInitializer() { OnModelCreated = UIScriptCommands.ExplorerDefault(), OnViewAttached = ScriptCommands.Assign("{StartupDir}", vm.CurrentBookmarkDirectory, false, ScriptCommands.Assign("{StartupPath}", "{StartupDir.FullPath}", false, UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot())), RootModels = rootDir, StartupParameters = new ParameterDic() { { "Profiles", vm.Profile }, { "RootDirectories", rootDir }, //{ "StartupPath", vm.CurrentBookmarkDirectory.FullPath }, //{ "StartupPath", _selectedPath }, //{ "FilterString", _filterStr }, { "ViewMode", "List" }, { "ItemSize", 16 }, { "EnableDrag", true }, { "EnableDrop", true }, { "EnableMap", false }, { "FileListNewWindowCommand", NullScriptCommand.Instance }, //Disable NewWindow Command. { "EnableMultiSelect", true }, { "ShowToolbar", false }, { "ShowGridHeader", false } } }; expFolderPicker.ViewModel.FileList.PropertyChanged += (o, e) => { if (e.PropertyName == "CurrentDirectory") { vm.CurrentBookmarkDirectory = expFolderPicker.ViewModel.FileList.CurrentDirectory; } }; vm.PropertyChanged += (o, e) => { if (e.PropertyName == "CurrentBookmarkDirectory") { expFolderPicker.ViewModel.FileList.CurrentDirectory = vm.CurrentBookmarkDirectory; } }; }
private void Decrypt_Button_Click(object sender, RoutedEventArgs e) { //FileExplorer.WPF.UserControls.Explorer exp = explorer as FileExplorer.WPF.UserControls.Explorer; var _fileList = explorer.ViewModel.FileList.Selection.SelectedItems; foreach (var el in _fileList) { //Debug.WriteLine(el.EntryModel.FullPath); Securebox.DecryptPreprocess(el.EntryModel.FullPath); //Helper.DecryptFile(el.EntryModel.FullPath, el.EntryModel.FullPath + ".sbox", g.ToString()); // Debug.WriteLine(el.ToString()); } IScriptCommand cmd = UIScriptCommands.FileListRefresh(true, UIScriptCommands.MessageBoxOK("Refresh", "File(s) Decrypted")); explorer.ViewModel.Commands.ExecuteAsync(cmd); }
public static IScriptCommand ExplorerNewMdiWindow(WPF.MDI.MdiContainer container, IProfile[] profiles, IEntryModel[] rootDirectories, string explorerVariable = "{Explorer}", IScriptCommand nextCommand = null) { return(ScriptCommands.Assign(new Dictionary <string, object>() { { "{MdiContainer}", container }, { "{Profiles}", profiles }, { "{RootDirectories}", rootDirectories }, { "{OnModelCreated}", ScriptCommands.RunSequence(null, TestAppCommands.MdiExplorer_Initialize_Default, UIScriptCommands.ExplorerAssignScriptParameters("{Explorer}", "{MdiContainer},{RootDirectories}")) }, { "{OnViewAttached}", UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot() } }, false, TestAppCommands.ExplorerNewMdiWindow("{MdiContainer}", "{WindowManager}", "{GlobalEvents}", "{Explorer}", nextCommand))); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); IEventAggregator _events = new EventAggregator(); IWindowManager _windowManager = new AppWindowManager(); IProfile _exProfile = new FileSystemInfoExProfile(_events, _windowManager); IProfile _ioProfile = new FileSystemInfoProfile(_events); IProfile[] _profiles = new IProfile[] { _exProfile, _ioProfile }; IEntryModel[] _rootDirs = new IEntryModel[] { AsyncUtils.RunSync(() => _exProfile.ParseAsync("")) }; explorer.WindowManager = _windowManager; explorer.ViewModel.Initializer = new ScriptCommandInitializer() { OnModelCreated = ScriptCommands.Run("{OnModelCreated}"), OnViewAttached = ScriptCommands.Run("{OnViewAttached}"), RootModels = _rootDirs, WindowManager = _windowManager, StartupParameters = new ParameterDic() { { "Profiles", _profiles }, { "RootDirectories", _rootDirs }, { "GlobalEvents", _events }, { "WindowManager", _windowManager }, { "StartupPath", "" }, { "ViewMode", "List" }, { "ItemSize", 16 }, { "EnableDrag", true }, { "EnableDrop", true }, { "FileListNewWindowCommand", NullScriptCommand.Instance }, //Disable NewWindow Command. { "EnableMultiSelect", true }, { "ShowToolbar", true }, { "ShowGridHeader", true }, { "OnModelCreated", IOInitializeHelpers.Explorer_Initialize_Default }, { "OnViewAttached", UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot() } } }; cbCommand.ItemsSource = ScriptCommandDictionary.CommandList; }
public override IScriptCommand Execute(ParameterDic pm) { var viewModel = new ExplorerViewModel(_initializer); pm["Explorer"] = viewModel; var view = new ExplorerView(); Caliburn.Micro.Bind.SetModel(view, viewModel); //Set the ViewModel using this command. var mdiChild = new MdiChild { DataContext = viewModel, ShowIcon = true, Content = view, Width = 500, Height = 334, Position = new Point(0, 0) }; mdiChild.SetBinding(MdiChild.TitleProperty, new Binding("DisplayName") { Mode = BindingMode.OneWay }); mdiChild.SetBinding(MdiChild.IconProperty, new Binding("CurrentDirectory.Icon") { Mode = BindingMode.OneWay }); _container.Children.Add(mdiChild); var selection = _getSelectionFunc == null ? null : _getSelectionFunc(pm); if (selection != null && selection.Count() > 0) { return(UIScriptCommands.ExplorerGoToValue(selection.First())); } return(ResultCommand.NoError); }
private void ExportButton_Click(object sender, RoutedEventArgs e) { //export db // Displays a SaveFileDialog so the user can save the Image // assigned to Button2. Microsoft.Win32.SaveFileDialog saveFileDialog1 = new Microsoft.Win32.SaveFileDialog(); saveFileDialog1.Filter = "Securebox key file (.sbox)|*.sbox"; // Filter files by extension saveFileDialog1.Title = "Export and save Securebox key file"; saveFileDialog1.ShowDialog(); // If the file name is not an empty string open it for saving. if (saveFileDialog1.FileName != "") { // Saves the Image via a FileStream created by the OpenFile method. //System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile(); // Saves the Image in the appropriate ImageFormat based upon the // File type selected in the dialog box. // NOTE that the FilterIndex property is one-based. File.Copy(DatabaseManagement.GetDBFullPath(), saveFileDialog1.FileName, true); IScriptCommand cmd = UIScriptCommands.FileListRefresh(true, UIScriptCommands.MessageBoxOK("Refresh", "Securebox key file exported")); explorer.ViewModel.Commands.ExecuteAsync(cmd); //fs.Close(); } }
public ScriptCommandInitializer() { RootModels = new FileExplorer.Models.IEntryModel[] { }; OnModelCreated = UIScriptCommands.ExplorerDefault(); }
private void RefreshView() { IScriptCommand cmd = UIScriptCommands.FileListRefresh(true); explorer.ViewModel.Commands.ExecuteAsync(cmd); }
protected override void setupScriptCommands(dynamic commandDictionary) { commandDictionary.NewTab = UIScriptCommands.TabExplorerNewTab("{TabbedExplorer}", null); commandDictionary.CloseTab = UIScriptCommands.TabExplorerCloseTab("{TabbedExplorer}"); }
public override void NotifySelectionChanged(IEntryModel[] appliedModels) { List <ICommandModel> subCommands = new List <ICommandModel>(); if (appliedModels.Length >= 1 && !(appliedModels.Any(em => em.FullPath.StartsWith("::")))) { #region Decompress - When selected archive. if (appliedModels.All(em => em is ISzsItemModel)) { bool isRoot = appliedModels.All(em => em is SzsRootModel); Func <IEntryModel, IScriptCommand, IScriptCommand> transferCommandFunc = (destModel, thenCommand) => isRoot? IOScriptCommands.DiskTransferChild(appliedModels, destModel, false, true, thenCommand) : IOScriptCommands.DiskTransfer(appliedModels, destModel, false, true, thenCommand); //Extract to ... subCommands.Add(new CommandModel( WPFScriptCommands.ShowDirectoryPicker(_initializer, null, dm => WPFScriptCommands.ShowProgress("Extract", transferCommandFunc(dm, WPFScriptCommands.HideProgress())), ResultCommand.NoError)) { Header = "Extract to ...", IsEnabled = true, IsVisibleOnMenu = true }); if (isRoot) { SzsRootModel firstRoot = appliedModels[0] as SzsRootModel; IPathHelper path = firstRoot.Profile.Path; Header = path.GetExtension(firstRoot.Name).TrimStart('.').FirstCharToUppercase(); string parentPath = path.GetDirectoryName(firstRoot.FullPath); //Extract Here subCommands.Add(new CommandModel( WPFScriptCommands.ShowProgress("Extract", transferCommandFunc(firstRoot.Parent, WPFScriptCommands.HideProgress()))) { Header = "Extract Here", IsEnabled = true, IsVisibleOnMenu = true }); if (appliedModels.Length == 1) { //Extract to \\ArchiveName subCommands.Add(new CommandModel( WPFScriptCommands.ParseOrCreatePath(firstRoot.Parent.Profile as IDiskProfile, path.Combine(parentPath, path.RemoveExtension(appliedModels[0].Name)), true, destFolder => transferCommandFunc(destFolder, WPFScriptCommands.HideProgress()))) { Header = "Extract to \\" + path.RemoveExtension(appliedModels[0].Name), IsEnabled = true, IsVisibleOnMenu = true }); } else { subCommands.Add(new CommandModel( WPFScriptCommands.ShowProgress("Extract", ScriptCommands.ForEach(appliedModels, am => WPFScriptCommands.ParseOrCreatePath(firstRoot.Parent.Profile as IDiskProfile, path.Combine(parentPath, path.RemoveExtension(am.Name)), true, destFolder => transferCommandFunc(destFolder, WPFScriptCommands.HideProgress()))))) { Header = "Extract to {ArchiveName}\\", IsEnabled = true, IsVisibleOnMenu = true }); } } } //if (appliedModels.All(em => em is SzsRootModel)) //{ // SzsRootModel firstRoot = appliedModels[0] as SzsRootModel; // IPathHelper path = firstRoot.Profile.Path; // Header = path.GetExtension(firstRoot.Name).TrimStart('.').FirstCharToUppercase(); // string parentPath = path.GetDirectoryName(firstRoot.FullPath); // //Extract to ... // subCommands.Add(new CommandModel( // ScriptCommands.ShowDirectoryPicker(_initializer, null, // dm => // ScriptCommands.ShowProgress("Extract", // ScriptCommands.ForEach(appliedModels, am => // IOScriptCommands.TransferChild(am, dm, null, false), // ScriptCommands.HideProgress())), // ResultCommand.NoError)) { Header = "Extract to ...", IsEnabled = true, IsVisibleOnMenu = true }); // //Extract Here // subCommands.Add(new CommandModel( // ScriptCommands.ShowProgress("Extract", // ScriptCommands.ForEach(appliedModels, am => // IOScriptCommands.TransferChild(am, firstRoot.Parent, null, false), // ScriptCommands.HideProgress()))) { Header = "Extract Here", IsEnabled = true, IsVisibleOnMenu = true }); // if (appliedModels.Length == 1) // { // //Extract to \\ArchiveName // subCommands.Add(new CommandModel( // ScriptCommands.ParseOrCreatePath(firstRoot.Parent.Profile as IDiskProfile, // path.Combine(parentPath, path.RemoveExtension(appliedModels[0].Name)), true, // destFolder => // ScriptCommands.ShowProgress("Extract", // IOScriptCommands.TransferChild(appliedModels[0], destFolder, null, false, // ScriptCommands.HideProgress())))) // { // Header = "Extract to \\" + path.RemoveExtension(appliedModels[0].Name), // IsEnabled = true, // IsVisibleOnMenu = true // }); // } // else // subCommands.Add(new CommandModel( // ScriptCommands.ShowProgress("Extract", // ScriptCommands.ForEach(appliedModels, am => // ScriptCommands.ParseOrCreatePath(firstRoot.Parent.Profile as IDiskProfile, // path.Combine(parentPath, path.RemoveExtension(am.Name)), true, // destFolder => // IOScriptCommands.TransferChild(am, destFolder, null, false)), // ScriptCommands.HideProgress()))) { Header = "Extract to {ArchiveName}\\", IsEnabled = true, IsVisibleOnMenu = true }); //} #endregion #region Compress if (!appliedModels.Any(em => em is SzsChildModel) && !(appliedModels.Length == 1 && appliedModels[0] is SzsRootModel)) { Header = "Compress"; IEntryModel firstEntry = appliedModels[0]; IDiskProfile firstProfile = firstEntry.Profile as IDiskProfile; if (firstProfile != null && !firstEntry.FullPath.StartsWith("::{") && firstEntry.Parent != null) { IPathHelper path = firstEntry.Profile.Path; //Header = path.GetExtension(firstEntry.Name).TrimStart('.').FirstCharToUppercase(); string parentPath = path.GetDirectoryName(firstEntry.FullPath); //e.g. C:\temp\abc.txt => C:\temp\temp.zip string parentArchiveName = path.ChangeExtension(firstEntry.Parent.Name, ".zip"); string parentArchivePath = path.Combine(firstEntry.Parent.FullPath, parentArchiveName); string firstArchiveName = path.ChangeExtension(firstEntry.Name, ".zip"); string firstArchivePath = path.Combine(firstEntry.Parent.FullPath, firstArchiveName); subCommands.Add(new CommandModel( ScriptCommands.Assign(new Dictionary <string, object>() { { "{Profile}", firstEntry.Parent.Profile }, { "{Header}", "Compress" }, { "{CompressFiles}", appliedModels }, { "{StartupPath}", firstEntry.Parent.FullPath }, { "{FileName}", firstArchiveName } }, false, IOScriptCommands.FileSave("Zip archives (.zip)|*.zip|7z archives (.7z)|*.7z", "{ArchivePath}", WPFScriptCommands.ShowProgress("Compress", IOScriptCommands.DiskParseOrCreateArchive("{Profile}", "{ArchivePath}", "{Archive}", IOScriptCommands.SzsDiskTransfer("{CompressFiles}", "{Archive}", false))), UIScriptCommands.MessageBoxOK("Compress", "Compress is canceled.")))) { Header = "Compress to ...", IsEnabled = true, IsVisibleOnMenu = true }); Action <string, string> addCompressToPath = (destName, destPath) => { subCommands.Add(new CommandModel( WPFScriptCommands.ShowProgress("Compress", IOScriptCommands.ParseOrCreateArchive(firstProfile, destPath, pm => IOScriptCommands.DiskTransfer(appliedModels, pm, false, true, null)))) { Header = "Compress to " + destName, IsEnabled = true, IsVisibleOnMenu = true }); }; addCompressToPath(firstArchiveName, firstArchivePath); addCompressToPath(parentArchiveName, parentArchivePath); } } #endregion } SubCommands = subCommands; IsVisibleOnMenu = SubCommands.Count() > 0; }