Esempio n. 1
0
        public OpenFolderAction(string path, IFileExplorer fileExplorer)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (fileExplorer == null)
            {
                throw new ArgumentNullException(nameof(fileExplorer));
            }

            _fileExplorer = fileExplorer;

            _task = Task.Run(() =>
            {
                if (!FileEx.Exists(path, TimeSpan.FromSeconds(1)))
                {
                    FullFoldername = FileEx.FindClosestExistingFolder(path);
                    _fileExplorer.OpenFolder(FullFoldername);
                }
                else
                {
                    FullFoldername = path;
                    _fileExplorer.SelectFile(path);
                }
            })
                    .ContinueWith(OnFolderOpened);
        }
Esempio n. 2
0
 public SqLiteDatabaseBuilder(IDatabaseTableCreationQueries databaseTableCreationQueries, IFileExplorer fileExplorer, ISqLiteDatabaseFactory sqLiteDatabaseFactory, ISqLiteConnectionWrapperFactory sqLiteConnectionWrapperFactory)
 {
     _databaseTableCreationQueries = databaseTableCreationQueries;
     _fileExplorer                   = fileExplorer;
     _sqLiteDatabaseFactory          = sqLiteDatabaseFactory;
     _sqLiteConnectionWrapperFactory = sqLiteConnectionWrapperFactory;
 }
Esempio n. 3
0
        /// <summary>
        /// Attach control to local.
        /// </summary>
        public void AttachToMyComputer()
        {
            ExplorerHandler = new LocalFileExplorer();
            DriveInfo[] drives = DriveInfo.GetDrives();
            FolderTreeView.Nodes.Clear();

            TreeNode ptrNode = FolderTreeView.Nodes.Add("My Computer");

            ptrNode.ImageIndex         = (int)ImageIndexName.MyComputer;
            ptrNode.SelectedImageIndex = (int)ImageIndexName.MyComputer;
            TreeNode childNode;

            foreach (DriveInfo ptrDrive in drives)
            {
                if ((ptrDrive.DriveType == DriveType.Fixed) ||
                    (ptrDrive.DriveType == DriveType.Removable))
                {
                    childNode                    = ptrNode.Nodes.Add(ptrDrive.Name);
                    childNode.Tag                = ptrDrive.Name;
                    childNode.ImageIndex         = (int)ImageIndexName.HDD;
                    childNode.SelectedImageIndex = (int)ImageIndexName.HDD;
                    childNode.Nodes.Add(" ");
                }
            }
            ptrNode.Expand(); //Expand node to drive level.
            OnSourceChanged();
        }
Esempio n. 4
0
        public OpenFolderAction(string[] files, string folder, IFileExplorer fileExplorer)
        {
            if (files == null)
            {
                throw new ArgumentNullException(nameof(files));
            }

            if (string.IsNullOrEmpty(folder))
            {
                throw new ArgumentNullException(nameof(folder));
            }

            if (fileExplorer == null)
            {
                throw new ArgumentNullException(nameof(fileExplorer));
            }

            _fileExplorer = fileExplorer;

            _task = Task.Run(() =>
            {
                if (!Directory.Exists(folder))
                {
                    FullFoldername = FileEx.FindClosestExistingFolder(folder);
                    _fileExplorer.OpenFolder(FullFoldername);
                }
                else
                {
                    FullFoldername = folder;
                    _fileExplorer.SelectFiles(FullFoldername, files);
                }
            })
                    .ContinueWith(OnFolderOpened);
        }
Esempio n. 5
0
 /// <summary>
 /// Unsubscribe control from current source
 /// </summary>
 public void DetachSource()
 {
     FolderTreeView.Nodes.Clear();
     FileListView.Clear();
     ExplorerHandler = null;
     SelectedFolder  = string.Empty;
     _SelectedFiles  = null;
 }
    static FileExplorer()
    {
#if UNITY_EDITOR
        m_platformWrapper = new FileExplorerEditor();
#elif UNITY_STANDALONE_WIN
        m_platformWrapper = new FileExplorerWindows_gkngkc();
#endif
    }
Esempio n. 7
0
 public void Setup()
 {
     _databaseTableCreationQueries = A.Fake <IDatabaseTableCreationQueries>();
     _fileExplorer             = A.Fake <IFileExplorer>();
     _connectionWrapperFactory = A.Fake <ISqLiteConnectionWrapperFactory>();
     _sqLiteDatabaseFactory    = A.Fake <ISqLiteDatabaseFactory>();
     _sqLiteDatabase           = A.Fake <ISqLiteDatabase>();
     _databaseBuilder          = new SqLiteDatabaseBuilder(_databaseTableCreationQueries, _fileExplorer, _sqLiteDatabaseFactory, _connectionWrapperFactory);
 }
    static FileExplorer()
    {
#if UNITY_EDITOR
        m_platformWrapper = new FileExplorerEditor();
#elif UNITY_STANDALONE_WIN
        m_platformWrapper = new FileExplorerWindows_gkngkc();
#elif UNITY_STANDALONE_LINUX
#elif UNITY_STANDALONE_OSX
#endif

        UnityEngine.Debug.Assert(m_platformWrapper != null, "Platform wrapper needs implementation!");
    }
Esempio n. 9
0
        /// <summary>
        /// Attach control to object which implement IFileExplorer interface.
        /// </summary>
        /// <param name="source"></param>
        public void AttachSource(IFileExplorer source)
        {
            ExplorerHandler = source;
            FolderTreeView.Nodes.Clear();
            FileListView.Clear();

            TreeNode ptrNode = FolderTreeView.Nodes.Add(ExplorerHandler.Name);

            ptrNode.ImageIndex         = (int)ImageIndexName.Folder;
            ptrNode.Tag                = ExplorerHandler.Root;
            ptrNode.SelectedImageIndex = (int)ImageIndexName.Folder;
            ptrNode.Nodes.Add(" ");
            OnSourceChanged();
        }
Esempio n. 10
0
 public Scaffold(ILogger logger)
 {
     _logger       = logger;
     _fileExplorer = Services.Get <IFileExplorer>();
     _shell        = Services.Get <IShell>();
 }
 /// <summary>
 /// Unsubscribe control from current source
 /// </summary>
 public void DetachSource()
 {
     FolderTreeView.Nodes.Clear();
     FileListView.Clear();
     ExplorerHandler = null;
     SelectedFolder = string.Empty;
     _SelectedFiles = null;
 }
Esempio n. 12
0
 public FileRepository(IFileExplorer explorer)
 {
     _explorer = explorer;
 }
Esempio n. 13
0
        //private ICollectionView myVideoDataFilter;

        internal void GetFileExplorerInstance(IFileExplorer ifileExplorer)
        {
            this.ifileExplorer = ifileExplorer;
            (ifileExplorer as UserControl).Loaded += CollectionViewModel_Loaded;
        }
 public BrowseToDependencyInExplorerCommand(UnconfiguredProject project, IFileExplorer fileExplorer)
     : base(project)
 {
     _fileExplorer = fileExplorer;
 }
Esempio n. 15
0
 public void Setup()
 {
     _fileExplorer          = new FileExplorer();
     _sqLiteDatabaseBuilder = new SqLiteDatabaseBuilder(new DatabaseTableCreationQueries(), _fileExplorer,
                                                        new SqLiteDatabaseFactory(), new SqLiteConnectionWrapperFactory());
 }
        /// <summary>
        /// Attach control to object which implement IFileExplorer interface.
        /// </summary>
        /// <param name="source"></param>
        public void AttachSource(IFileExplorer source)
        {
            ExplorerHandler = source;
            FolderTreeView.Nodes.Clear();
            FileListView.Clear();

            TreeNode ptrNode = FolderTreeView.Nodes.Add(ExplorerHandler.Name);
            ptrNode.ImageIndex = (int)ImageIndexName.Folder;
            ptrNode.Tag = ExplorerHandler.Root;
            ptrNode.SelectedImageIndex = (int)ImageIndexName.Folder;
            ptrNode.Nodes.Add(" ");
            OnSourceChanged();
        }
 public ExploreDependencyFolderInWindowsCommand(UnconfiguredProject project, IFileExplorer fileExplorer)
     : base(project)
 {
     _fileExplorer = fileExplorer;
 }
Esempio n. 18
0
        public Software(IShell shell, INotify notify, IWindowManager windowManager, IVirtualDesktopManager virtualDesktopManager, IFileExplorer fileExplorer, IConfig <Config> config)
        {
            RegisterCommands();
            var software = config.CurrentValue.SoftwarePackage;
            var hotKeys  = software.Hotkeys;
            var swPaths  = software.SoftwarePaths;

            hotKeys.DoublePinyinSwitch.OnEvent(e =>
            {
                e.Handled              = true;
                const string keyName   = @"HKEY_CURRENT_USER\Software\Microsoft\InputMethod\Settings\CHS";
                const string valueName = "Enable Double Pinyin";
                var k = (int)Registry.GetValue(keyName, valueName, -1);
                if (k == 0 || k == -1)
                {
                    notify.ShowMessage("Double Pinyin Enabled");
                    Registry.SetValue(keyName, valueName, 1);
                }
                else if (k == 1)
                {
                    notify.ShowMessage("Full Pinyin Enabled");
                    Registry.SetValue(keyName, valueName, 0);
                }
            });

            //hotKeys.Find.OnEvent(async e =>
            //{
            //    e.Handled = true;
            //    var shiftDown = e.KeyboardState.IsDown(Shift);

            //    var c = windowManager.CurrentWindow.Class;
            //    var arg = shiftDown
            //        ? "-newwindow"
            //        : "-toggle-window";

            //    if ("CabinetWClass" == c)
            //    {
            //        var path = await fileExplorer.CurrentDirectory(windowManager.CurrentWindow.Handle);
            //        shell.RunWithCmd(shell.NormalizeCmd(swPaths.Everything, arg, "-path",
            //            path));
            //        return;
            //    }

            //    shell.RunWithCmd(shell.NormalizeCmd(swPaths.Everything, arg));
            //});

            //hotKeys.OpenTerminal.OnEvent(async e =>
            //{
            //    e.Handled = true;
            //    var    shiftDown = e.KeyboardState.IsDown(Shift);
            //    string path;
            //    var    c = windowManager.CurrentWindow.Class;
            //    if ("CabinetWClass" != c)
            //        path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            //    else
            //        path = await fileExplorer.CurrentDirectory(windowManager.CurrentWindow.Handle);
            //    // https://github.com/nt4f04uNd/wt-contextmenu
            //    if (shiftDown) shell.RunWithCmd(swPaths.Terminal, true); // powershell -Command "Start-Process shell:appsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App -Verb RunAs"
            //    else shell.RunWithExplorer(swPaths.Terminal);
            //});

            // hotKeys.OpenCodeEditor.OnEvent(async e =>
            // {
            //     e.Handled = true;
            //     if (!windowManager.CurrentWindow.IsExplorerOrOpenSaveDialog)
            //     {
            //         shell.RunWithExplorer(swPaths.Code);
            //         return;
            //     }
            //
            //     var paths = await fileExplorer.GetSelectedPaths(windowManager.CurrentWindow.Handle);
            //
            //     if (paths.Length == 0)
            //     {
            //         var path = await fileExplorer.Path(windowManager.CurrentWindow.Handle);
            //         shell.RunWithCmd(shell.NormalizeCmd(swPaths.Code, path));
            //         return;
            //     }
            //
            //     foreach (var path in paths)
            //     {
            //         shell.RunWithCmd(shell.NormalizeCmd(swPaths.Code, path));
            //     }
            // });

            //hotKeys.WebSearch.OnEvent(async e =>
            //{
            //    e.Handled = true;

            //    var altDown = e.KeyboardState.IsDown(Keys.Menu);
            //    var url = altDown
            //        ? swPaths.SearchEngineSecondary
            //        : swPaths.SearchEngine;

            //    var defaultPath = Browser.DefaultPath;
            //    var exeName     = Path.GetFileNameWithoutExtension(defaultPath);
            //    var process     = await virtualDesktopManager.GetFirstProcessOnCurrentVirtualDesktop(exeName);
            //    if (process == null)
            //    {
            //        shell.RunAsNormalUser(defaultPath, url, "--new-window", "--new-instance");
            //        return;
            //    }

            //    new Process
            //    {
            //        StartInfo =
            //        {
            //            UseShellExecute = true,
            //            FileName        = url
            //        }
            //    }.Start();
            //});
            // hotKeys.StartTaskExplorer.WithAliases(software.KeyAliases).OnEvent(e =>
            // {
            //     e.Handled = true;
            //     shell.RunWithCmd(swPaths.ProcessExplorer);
            // });
            //
            // hotKeys.OpenScreenRuler.WithAliases(software.KeyAliases).OnEvent(e =>
            // {
            //     e.Handled = true;
            //     shell.RunWithCmd(swPaths.Ruler);
            // });

            //hotKeys.OpenScreenRuler.WithAliases(software.KeyAliases).OnEvent(async e =>
            //{
            //    var exeName = "Inspect";

            //    var processes = await
            //        virtualDesktopManager.GetProcessesOnCurrentVirtualDesktop(exeName);

            //    var process = processes.FirstOrDefault();

            //    var hWnd = process?.MainWindowHandle;

            //    if (hWnd != null)
            //    {
            //        windowManager.Show(hWnd.Value);
            //        return;
            //    }

            //    shell.RunWithExplorer(swPaths.Inspect);
            //});

            //hotKeys.StartNotepad.WithAliases(software.KeyAliases).OnEvent(async e =>
            //{
            //    e.Handled = true;
            //    var exeName = "Notepad";

            //    var notePads = await
            //        virtualDesktopManager.GetProcessesOnCurrentVirtualDesktop(exeName,
            //            p => p.MainWindowTitle == "Untitled - Notepad");

            //    var notePad = notePads.FirstOrDefault();

            //    var hWnd = notePad?.MainWindowHandle;

            //    if (hWnd != null)
            //    {
            //        windowManager.Show(hWnd.Value);
            //        return;
            //    }

            //    shell.RunWithCmd("Notepad");
            //});

            hotKeys.StartVisualStudio.WithAliases(software.KeyAliases).OnEvent(async e =>
            {
                if (!windowManager.CurrentWindow.IsExplorerOrOpenSaveDialog)
                {
                    return;
                }

                e.Handled = true;

                var path = await fileExplorer.CurrentDirectory(windowManager.CurrentWindow.Handle);
                if (string.IsNullOrEmpty(path))
                {
                    shell.RunWithExplorer(swPaths.VisualStudio);
                    return;
                }

                Directory.CreateDirectory(path).EnumerateFiles("*.sln").Select(f => f.FullName).AsParallel().ForAll(s =>
                {
                    Process.Start(new ProcessStartInfo(swPaths.VisualStudio)
                    {
                        UseShellExecute = true, Arguments = s, WorkingDirectory = path
                    });
                });
            });

            // hotKeys.StartGifRecord.WithAliases(software.KeyAliases).OnEvent(e =>
            // {
            //     e.Handled = true;
            //     shell.RunWithCmd(swPaths.GifTool);
            // });

            hotKeys.ToggleDictionary.MapOnAllUp(Shift + LAlt + D);
        }
Esempio n. 19
0
        public FileExplorer(IWindowManager windowManager, IFileExplorer fileExplorer, IConfig <Config> config, INotify notify, IKeyboard keyboard)
        {
            RegisterCommands();
            var hotKeys = config.CurrentValue.FileExplorerPackage.Hotkeys;

            hotKeys.FocusItemsView.OnEvent(e =>
            {
                var listBoxEle   = windowManager.CurrentWindow?.FirstDescendant(c => c.ByClassName("UIItemsView"));
                var selectedItem = listBoxEle?.SelectedItems()?.FirstOrDefault();
                if (selectedItem != null)
                {
                    selectedItem.SetFocus();
                }
                else
                {
                    listBoxEle.FirstChild(c => c.ByClassName("UIItem"))?.Select();
                }
                e.Handled = true;
            }, _ => windowManager.CurrentWindow.IsExplorerOrOpenSaveDialog);

            hotKeys.FocusNavigationTreeView.OnEvent(e =>
            {
                var winEle       = windowManager.CurrentWindow?.FirstDescendant(cf => cf.ByClassName("SysTreeView32"));
                var selectedItem = winEle?.SelectedItems().FirstOrDefault();
                if (selectedItem != null)
                {
                    selectedItem.SetFocus();
                }
                else
                {
                    winEle?.FirstDecendent(c => c.ByControlType(ControlType.TreeItem))?.Select();
                }

                e.Handled = true;
            }, _ => windowManager.CurrentWindow.IsExplorerOrOpenSaveDialog);

            hotKeys.CopySelectedPath.OnEvent(async e =>
            {
                e.Handled  = true;
                var handle = windowManager.CurrentWindow.Handle;
                var paths  = await fileExplorer.GetSelectedPaths(handle);
                var r      = string.Join(';', paths);
                notify.ShowMessage($"Path Copied: {r}");
                System.Windows.Clipboard.SetText(r);
            }, _ => windowManager.CurrentWindow.IsExplorerOrOpenSaveDialog);

            hotKeys.NewFile.OnEvent(async e =>
            {
                e.Handled = true;
                const string newFileName = "NewFile";
                var handle   = windowManager.CurrentWindow.Handle;
                var fullPath = await fileExplorer.CurrentDirectory(handle);
                var fileName = newFileName;
                var i        = 1;
                while (File.Exists(fullPath + "\\" + fileName))
                {
                    fileName = newFileName + i++;
                }

                var file = File.Create(fullPath + "\\" + fileName);
                file.Close();
                var keyboard = Services.Get <IKeyboard>();
                fileExplorer.Select(handle, new[] { fileName });
                e.BeginInvoke(() => keyboard.Type(Key.F2));
            }, _ => windowManager.CurrentWindow.IsExplorer);

            hotKeys.ShowDesktopFolder.OnEvent(e =>
            {
                fileExplorer.Open(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                e.Handled = true;
            });

            (Ctrl + Back).OnDown(e =>
            {
                // fix ctrl+back is a box char in explorer
                e.DisableVirtualKeyHandlingInThisEvent();
                e.Handled = true;
                keyboard.Type(Ctrl + Shift + Left, Back); // Ctrl is up now
                keyboard.Down(Ctrl);                      //to trigger, if user hold ctrl and press back again
            }, e => windowManager.CurrentWindow.IsExplorerOrOpenSaveDialog);
        }
Esempio n. 20
0
 public DocumentExplorer(
     IFileExplorer fileExplorer)
 {
     _fileExplorer = fileExplorer;
 }
        /// <summary>
        /// Attach control to local.
        /// </summary>
        public void AttachToMyComputer()
        {
            ExplorerHandler = new LocalFileExplorer();
            DriveInfo[] drives = DriveInfo.GetDrives();
            FolderTreeView.Nodes.Clear();

            TreeNode ptrNode = FolderTreeView.Nodes.Add("My Computer");
            ptrNode.ImageIndex = (int)ImageIndexName.MyComputer;
            ptrNode.SelectedImageIndex = (int)ImageIndexName.MyComputer;
            TreeNode childNode;
            foreach (DriveInfo ptrDrive in drives)
            {
                if ((ptrDrive.DriveType == DriveType.Fixed) ||
                    (ptrDrive.DriveType == DriveType.Removable))
                {
                    childNode = ptrNode.Nodes.Add(ptrDrive.Name);
                    childNode.Tag = ptrDrive.Name;
                    childNode.ImageIndex = (int)ImageIndexName.HDD;
                    childNode.SelectedImageIndex = (int)ImageIndexName.HDD;
                    childNode.Nodes.Add(" ");
                }
            }
            ptrNode.Expand(); //Expand node to drive level.
            OnSourceChanged();
        }