public void ShowChooseDialog(bool closeOnEscape)
        {
            var dialog = new OpenFileDialog
            {
                Filter          = string.Format("{0} (*.{1})|*.{1}", Res.BackupFiles, NpgExImHelper.BackupFileExt),
                CheckFileExists = true,
                Multiselect     = false
            };
            var stringKeeper = new Settings("ProjectImEx");
            var lastFile     = stringKeeper.GetString("LastFile");

            if (!string.IsNullOrEmpty(lastFile) && File.Exists(lastFile))
            {
                dialog.InitialDirectory = Path.GetDirectoryName(lastFile);
                dialog.FileName         = lastFile;
            }
            if (dialog.ShowDialog(View as Window) == true)
            {
                stringKeeper.SetString("LastFile", dialog.FileName);
                stringKeeper.Save();
                FileName = dialog.FileName;
                if (string.IsNullOrEmpty(ConnectionParameters.Database))
                {
                    ConnectionParameters.Database = Path.GetFileNameWithoutExtension(FileName);
                }
            }
            else if (closeOnEscape)
            {
                View.DialogResult = false;
            }
        }
Ejemplo n.º 2
0
        public void Export()
        {
            var dialog = new SaveFileDialog
            {
                Filter          = string.Format("{0} (*.{1})|*.{1}", Res.BackupFiles, NpgExImHelper.BackupFileExt),
                CheckFileExists = false,
                OverwritePrompt = true
            };
            var stringKeeper = new Settings("ProjectImEx");
            var lastFile     = stringKeeper.GetString("LastFile");

            if (!string.IsNullOrEmpty(lastFile) && File.Exists(lastFile))
            {
                dialog.InitialDirectory = Path.GetDirectoryName(lastFile);
                dialog.FileName         = lastFile;
            }
            if (dialog.ShowDialog(View as Window) != true)
            {
                View.DialogResult = false;
                return;
            }
            stringKeeper.SetString("LastFile", dialog.FileName);
            stringKeeper.Save();
            var fileName = dialog.FileName;

            _service.ActionHelper.Async(() => Export(fileName));
        }
Ejemplo n.º 3
0
 public void ShowChooseDialog(bool closeOnEscape)
 {
     var dialog = new OpenFileDialog
         {
             Filter = string.Format("{0} (*.{1})|*.{1}", Res.BackupFiles, NpgExImHelper.BackupFileExt),
             CheckFileExists = true,
             Multiselect = false
         };
     var stringKeeper = new Settings("ProjectImEx");
     var lastFile = stringKeeper.GetString("LastFile");
     if (!string.IsNullOrEmpty(lastFile) && File.Exists(lastFile))
     {
         dialog.InitialDirectory = Path.GetDirectoryName(lastFile);
         dialog.FileName = lastFile;
     }
     if (dialog.ShowDialog(View as Window) == true)
     {
         stringKeeper.SetString("LastFile", dialog.FileName);
         stringKeeper.Save();
         FileName = dialog.FileName;
         if (string.IsNullOrEmpty(ConnectionParameters.Database))
         {
             ConnectionParameters.Database = Path.GetFileNameWithoutExtension(FileName);
         }
     }
     else if (closeOnEscape)
     {
         View.DialogResult = false;
     }
 }