private void deletePicture()
        {
            if (listview_Dropbox_uploads.SelectedItems != null && listview_Dropbox_uploads.SelectedItems.Count > 0)
            {
                for (int i = 0; i < listview_Dropbox_uploads.SelectedItems.Count; i++)
                {
                    DropboxInfo  imgurInfo = (DropboxInfo)listview_Dropbox_uploads.SelectedItems[i].Tag;
                    DialogResult result    = MessageBox.Show(lang.GetFormattedString(LangKey.delete_question, imgurInfo.Title), lang.GetFormattedString(LangKey.delete_title, imgurInfo.ID), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(DropboxPlugin.Attributes.Name, lang.GetString(LangKey.communication_wait));
                        try
                        {
                            DropboxUtils.DeleteDropboxImage(imgurInfo);
                        }
                        catch (Exception ex)
                        {
                            LOG.Warn("Problem communicating with Dropbox: ", ex);
                        }
                        finally
                        {
                            backgroundForm.CloseDialog();
                        }

                        imgurInfo.Dispose();
                    }
                }
            }
            redraw();
        }
예제 #2
0
        public void HandleChooseFolderLocation(ApiRequest request)
        {
            try
            {
                string sharedFolder;
                // One of the few places that knows we're using a particular implementation
                // of TeamRepo. But we have to know that to create it. And of course the user
                // has to chose a folder to get things started.
                // We'll need a different API or something similar if we ever want to create
                // some other kind of repo.
                using (var dlg = new FolderBrowserDialog())
                {
                    // Default to the Dropbox folder if one is found.
                    var dropboxFolder = DropboxUtils.GetDropboxFolderPath();
                    if (!String.IsNullOrEmpty(dropboxFolder))
                    {
                        dlg.SelectedPath = dropboxFolder;
                    }
                    dlg.ShowNewFolderButton = true;
                    dlg.Description         = LocalizationManager.GetString("TeamCollection.SelectFolder",
                                                                            "Select or create the folder where this collection will be shared");
                    if (DialogResult.OK != dlg.ShowDialog())
                    {
                        request.Failed();
                        return;
                    }

                    sharedFolder = dlg.SelectedPath;
                }
                // We send the result through a websocket rather than simply returning it because
                // if the user is very slow (one site said FF times out after 90s) the browser may
                // abandon the request before it completes. The POST result is ignored and the
                // browser simply listens to the socket.
                // We'd prefer this request to return immediately and set a callback to run
                // when the dialog closes and handle the results, but FolderBrowserDialog
                // does not offer such an API. Instead, we just ignore any timeout
                // in our Javascript code.
                dynamic messageBundle = new DynamicJson();
                messageBundle.repoFolderPath = sharedFolder;
                messageBundle.problem        = ProblemsWithLocation(sharedFolder);
                // This clientContext must match what is being listened for in CreateTeamCollection.tsx
                _socketServer.SendBundle("teamCollectionCreate", "shared-folder-path", messageBundle);

                request.PostSucceeded();
            }
            catch (Exception e)
            {
                // Not sure what to do here: choosing the collection folder should never crash.
                Logger.WriteError("TeamCollectionApi.HandleChooseFolderLocation() crashed", e);
                NonFatalProblem.ReportSentryOnly(e, $"Something went wrong for {request.LocalPath()}");
                request.Failed("choose folder location failed");
            }
        }
예제 #3
0
 private void HandleShowCreateTeamCollectionDialog(ApiRequest request)
 {
     ReactDialog.ShowOnIdle("createTeamCollectionDialogBundle", new { defaultRepoFolder = DropboxUtils.GetDropboxFolderPath() }, 600, 580, null, null, "Create Team Collection");
     request.PostSucceeded();
 }