Пример #1
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                sfd.DefaultExt = "sxb";
                sfd.FileName   = "ShareX_backup.sxb";
                sfd.Filter     = "ShareX backup (*.sxb)|*.sxb|All files (*.*)|*.*";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    btnExport.Enabled      = false;
                    btnImport.Enabled      = false;
                    pbExportImport.Visible = true;

                    TaskEx.Run(() =>
                    {
                        Program.SaveAllSettings();
                        ExportImportManager.Export(sfd.FileName);
                    },
                               () =>
                    {
                        pbExportImport.Visible = false;
                        btnExport.Enabled      = true;
                        btnImport.Enabled      = true;
                    });
                }
            }
        }
Пример #2
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                sfd.DefaultExt = "sxb";
                sfd.FileName   = $"ShareX-{Application.ProductVersion}-backup.sxb";
                sfd.Filter     = "ShareX backup (*.sxb)|*.sxb|All files (*.*)|*.*";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    btnExport.Enabled      = false;
                    btnImport.Enabled      = false;
                    pbExportImport.Visible = true;

                    string exportPath = sfd.FileName;

                    DebugHelper.WriteLine("Export started: " + exportPath);

                    TaskEx.Run(() =>
                    {
                        Program.SaveAllSettings();

                        ExportImportManager.Export(exportPath);
                    },
                               () =>
                    {
                        if (!IsDisposed)
                        {
                            pbExportImport.Visible = false;
                            btnExport.Enabled      = true;
                            btnImport.Enabled      = true;
                        }

                        DebugHelper.WriteLine("Export completed: " + exportPath);
                    });
                }
            }
        }