예제 #1
0
        internal static bool OpenFileFromDropbox(Form1 form1, Form form, String fileName, String directoryName)
        {
            XtraTabControl       pagesTabControl      = form1.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form1.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form1.toolStripProgressBar;

            try
            {
                Application.DoEvents();
                toolStripProgressBar.Value   = 0;
                toolStripProgressBar.Visible = true;
                toolStripProgressBar.PerformStep();

                bool   fileExists;
                String content = DropboxManager.GetFileFromDropbox(DropboxManager.GetDirectory(form1, directoryName), fileName, out fileExists);
                toolStripProgressBar.PerformStep();

                if (!fileExists)
                {
                    WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("openingFileNotExists", className), fileName, directoryName));
                    return(false);
                }
                if (String.IsNullOrEmpty(content))
                {
                    WindowManager.ShowInfoBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("openingFileEmpty", className), fileName));
                    return(false);
                }
                toolStripProgressBar.PerformStep();

                form1.LastDropboxFolder = directoryName;
                if (!String.IsNullOrEmpty(ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text))
                {
                    form1.TabIdentity = TabManager.AddNewPage(form1, form1.TabIdentity);
                }
                ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text = content;
                toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), fileName, LanguageUtil.GetCurrentLanguageString("OpenedFromDropbox", className));
                toolStripProgressBar.PerformStep();
            }
            catch (Exception exception)
            {
                WindowManager.ShowErrorBox(form, exception.Message, exception);
                return(false);
            }
            finally
            {
                toolStripProgressBar.Visible = false;
            }

            return(true);
        }
예제 #2
0
        internal static bool SaveFileOnDropbox(Form1 form1, Form form, String fileName, String directoryName)
        {
            XtraTabControl       pagesTabControl      = form1.pagesTabControl;
            ToolStripStatusLabel toolStripStatusLabel = form1.toolStripStatusLabel;
            ToolStripProgressBar toolStripProgressBar = form1.toolStripProgressBar;

            ICloudDirectoryEntry directory = DropboxManager.GetDirectory(form1, directoryName);

            try
            {
                Application.DoEvents();
                toolStripProgressBar.Value   = 0;
                toolStripProgressBar.Visible = true;
                toolStripProgressBar.PerformStep();

                if (DropboxManager.ExistsChildOnDropbox(directory, fileName))
                {
                    if (WindowManager.ShowQuestionBox(form, LanguageUtil.GetCurrentLanguageString("OverwriteFileOnDropbox", className)) != DialogResult.Yes)
                    {
                        return(false);
                    }
                }

                //Encoding fileEncoding = TabUtil.GetTabTextEncoding(pagesTabControl.SelectedTabPage);
                toolStripProgressBar.PerformStep();

                DropboxManager.SaveFileOnDropbox(form1, directory, fileName, ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text); //, fileEncoding);
                toolStripProgressBar.PerformStep();

                form1.LastDropboxFolder   = directoryName;
                toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), Path.GetFileName(fileName), LanguageUtil.GetCurrentLanguageString("SavedOnDropbox", className));
                toolStripProgressBar.PerformStep();

                toolStripProgressBar.Visible = false;
            }
            catch (Exception exception)
            {
                toolStripProgressBar.Visible = false;
                WindowManager.ShowErrorBox(form, exception.Message, exception);
                return(false);
            }

            return(true);
        }