Пример #1
0
 public void UnregisterOnDemandSynchronizer()
 {
     if (IOUtilities.DirectoryExists(DataDirectoryPath))
     {
         OnDemandLocalFileSystem.Unregister(DataDirectoryPath, GetRegistration());
     }
 }
Пример #2
0
 private void OpenLogsPathToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (IOUtilities.DirectoryExists(Settings.LogsDirectoryPath))
     {
         WindowsUtilities.OpenExplorer(Settings.LogsDirectoryPath);
     }
 }
Пример #3
0
 private void OpenConfigurationBackupPathToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (IOUtilities.DirectoryExists(Settings.ConfigurationBackupDirectoryPath))
     {
         WindowsUtilities.OpenExplorer(Settings.ConfigurationBackupDirectoryPath);
     }
 }
Пример #4
0
        protected override void OnMenuInvoke(ShellMenuInvokeEventArgs e)
        {
            if (e.Verb != null)
            {
                // user is using "New ..." menu in the Explorer command bar
                // note if the user is using the "New..." menu in the folder's Context menu, it will not get there but be handled by WebShellFolderServer's notifier creation handling
                if (e.Verb.EqualsIgnoreCase("NewFolder") || e.Verb.EqualsIgnoreCase("NewLink") || e.Verb.StartsWith("."))
                {
                    // come up with a new file name
                    // since we're virtual we use a temp path

                    // here, we use the Shell itself to come up with a new file name (roundtrip api)
                    // note this can be costy in terms of performance (server call, etc.)
                    // so, we could choose arbitrary name instead, or ask the server for a new name
                    var files   = new List <string>();
                    var folders = new List <string>();
                    foreach (var item in ApiItem.EnumerateChildren())
                    {
                        if (item.IsFolder)
                        {
                            folders.Add(IOUtilities.PathToValidFileName(item.Name));
                        }
                        else
                        {
                            files.Add(IOUtilities.PathToValidFileName(item.Name));
                        }
                    }

                    // use ShellBoost's utility classes
                    var options = new CreateNewItemOptions();
                    options.ExistingFileNames   = files;
                    options.ExistingFolderNames = folders;
                    var path = Menu.CreateNewItem(e.Verb, options, false);
                    if (path != null)
                    {
                        var name = ApiItem.GetNewName(Path.GetFileName(path));
                        if (IOUtilities.DirectoryExists(path))
                        {
                            WebApi.CreateAsync(ApiItem.Id, null, name, FileAttributes.Directory);
                        }
                        else
                        {
                            WebApi.CreateAsync(ApiItem.Id, path, name);
                        }

                        // cleanup temp files
                        IOUtilities.DirectoryDelete(options.TargetPath, true, false);
                    }
                    return;
                }
            }

            // copy & cut support
            if (e.Command == DFM_CMD.DFM_CMD_COPY || e.Command == DFM_CMD.DFM_CMD_MOVE)
            {
                // make sure items are present locally
                // note if the past action is too fast, items may not be here yet (user will have to press "Retry")
                foreach (var si in e.Items)
                {
                    if (si is not IObjectWithApiItem apiItem)
                    {
                        continue;
                    }

                    Task.Run(() => apiItem.ApiItem.EnsureLocalAsync(si.FileSystemPath));
                }
                return;
            }

            // note DFM_CMD_DELETE is unhandled here so will fallback in OnOperate RecycleItem / RemoveItem
            base.OnMenuInvoke(e);
        }
Пример #5
0
 private void OpenDataDirectoryToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
 {
     openDataDirectoryToolStripMenuItem.Enabled = IOUtilities.DirectoryExists(Settings.DataDirectoryPath);
     openLogsPathToolStripMenuItem.Enabled      = IOUtilities.DirectoryExists(Settings.LogsDirectoryPath);
 }
Пример #6
0
 private void DiagnosticsToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
 {
     openConfigurationBackupPathToolStripMenuItem.Enabled = IOUtilities.DirectoryExists(Settings.ConfigurationBackupDirectoryPath);
     resetGoogleDriveStateToolStripMenuItem.Enabled       = OnDemandLocalFileSystem.IsSupported && Settings.HasSecretsFile && Settings.Current.Accounts.Any();
 }