Inheritance: FileDialog
Example #1
1
		private void OnProcessFileDialog(Object sender, FileDialogEventArgs e)
		{
			switch (e.Mode)
			{
				case FileDialogMode.Save:
					using (var saveDialog = new SaveFileDialog())
					{
						saveDialog.Title = e.Title;
						saveDialog.Filter = e.Filter;
						saveDialog.FileName = e.DefaultFileName;
						if (saveDialog.ShowDialog() != DialogResult.Cancel)
						{
							FormProgress.ShowProgress();
							FormProgress.SetTitle("Downloading…", true);
							FormProgress.SetDetails(Path.GetFileName(saveDialog.FileName));
							TabControl.Enabled = false;
							Application.DoEvents();
							e.Continue(saveDialog.FileName);
						}
						else
							e.Cancel();
					}
					break;
			}
			e.Handled = true;
		}
Example #2
0
        private void btn_save_Click(object sender, System.EventArgs e)
        {
            var saveFileDialog = new SaveFileDialog
            {
                Filter = @"Bitmap files (*.bmp)|*.bmp|Image files (*.jpg)|*.jpg|PNG files (*.png)|*.png|" +
                         @"ICO files (*.ico)|*.ico|GIF files (*.gif)|*.gif|TIFF files (*.tiff)|*.tiff|" +
                         @"XPS files (*.xps)|*.xps|PDF files (*.pdf)|*.pdf|PSD files (*.psd)|*.psd"
            };
            if (saveFileDialog.ShowDialog() == DialogResult.Cancel) return;

            // Switch
            //FactorySwitch.ChooseFormat(saveFileDialog.FilterIndex).Save(saveFileDialog.FileName, pctbx_canvas.Image);

            // LinkedList
            //var factory = new FactoryLinked();
            //factory.GetFormat(saveFileDialog.FilterIndex).Save(saveFileDialog.FileName, pctbx_canvas.Image);

            // Loop
            var factory = new FactoryLoop();
            var formats = factory.GetValidFormats(saveFileDialog.FilterIndex);
            foreach (var item in formats)
            {
                item.Save(saveFileDialog.FileName, pctbx_canvas.Image);
            }
        }
Example #3
0
 private void button4_Click(object sender, EventArgs e)
 {
     SaveFileDialog sd = new SaveFileDialog();
     sd.Filter = "FlexFile (*.flx)|*.flx";
     sd.FilterIndex = 0;
     sd.DefaultExt = ".flx";
     sd.AddExtension = true;
     if (sd.ShowDialog() == DialogResult.OK)
     {
         BinaryWriter wr = new BinaryWriter(new FileStream(sd.FileName, FileMode.Create));
         wr.Write(header);
         for (int i = 0; i < cnt * 256; i++)
         {
             wr.Write((int)0);
             wr.Write((int)0);
         }
         foreach (Section s in sex)
         {
             int ofs = (int)wr.BaseStream.Position;
             int sz = s.data.Length;
             wr.BaseStream.Position = 0x80 + 8 * s.id;
             wr.Write(ofs);
             wr.Write(sz);
             wr.BaseStream.Position = ofs;
             wr.Write(s.data);
         }
         wr.Close();
     }
 }
Example #4
0
 internal void SaveToFile()
 {
     SaveFileDialog sfd = new SaveFileDialog();
     sfd.AddExtension = true;
     //sfd.CheckFileExists = true;
     //sfd.CheckPathExists = true;
     sfd.CreatePrompt = true;
     sfd.DefaultExt = "rtf";
     sfd.Filter = "リッチテキストフォーマット|*.rtf";
     if (sfd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
     {
         Stream write = null;
         try
         {
             write = sfd.OpenFile();
             rtb_thread_main.SaveFile(write, RichTextBoxStreamType.RichText);
             MessageBox.Show("セーブ成功しました。");
         }
         catch (System.IO.IOException)
         {
             MessageBox.Show("セーブ失敗ました。");
         }
         finally
         {
             if (write != null)
             {
                 write.Close();
             }
         }
     }
 }
Example #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Title = "图象另存为";
            sfd.OverwritePrompt = true;
            sfd.CheckPathExists = true;
            sfd.Filter = cmbSaveFiletype.Text + "|" + cmbSaveFiletype.Text;
            sfd.ShowHelp = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                string strFileName = sfd.FileName;
                switch (cmbSaveFiletype.Text)
                {
                    case "*.bmp":
                        m_bitmap.Save(strFileName, ImageFormat.Bmp);
                        break;

                    case "*.jpg":
                        m_bitmap.Save(strFileName, ImageFormat.Jpeg);
                        break;

                    case "*.gif":
                        m_bitmap.Save(strFileName, ImageFormat.Gif);
                        break;

                    case "*.tif":
                        m_bitmap.Save(strFileName, ImageFormat.Tiff);
                        break;
                }
                MessageBox.Show("图象文件格式转换成功!", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #6
0
        public static bool SaveDIBAs(string picname, IntPtr bminfo, IntPtr pixdat)
        {
            SaveFileDialog sd = new SaveFileDialog();

            sd.FileName = picname;
            sd.Title = "Save bitmap as...";
            sd.Filter = "Bitmap file (*.bmp)|*.bmp|TIFF file (*.tif)|*.tif|JPEG file (*.jpg)|*.jpg|PNG file (*.png)|*.png|GIF file (*.gif)|*.gif|All files (*.*)|*.*";
            sd.FilterIndex = 1;
            if (sd.ShowDialog() != DialogResult.OK)
                return false;

            Guid clsid;
            if (!GetCodecClsid(sd.FileName, out clsid))
            {
                MessageBox.Show("Unknown picture format for extension " + Path.GetExtension(sd.FileName),
                                "Image Codec", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }

            IntPtr img = IntPtr.Zero;
            int st = GdipCreateBitmapFromGdiDib(bminfo, pixdat, ref img);
            if ((st != 0) || (img == IntPtr.Zero))
                return false;

            st = GdipSaveImageToFile(img, sd.FileName, ref clsid, IntPtr.Zero);
            GdipDisposeImage(img);
            return st == 0;
        }
        public void CommandExport(object param)
        {
            if (!TilePoolExists(param))
                return;

            Guid uid = (Guid)param;
            TilePool tilePool = Editor.Project.TilePoolManager.Pools[uid];

            using (System.Drawing.Bitmap export = tilePool.TileSource.CreateBitmap()) {
                using (SaveFileDialog ofd = new SaveFileDialog()) {
                    ofd.Title = "Export Raw Tileset";
                    ofd.Filter = "Portable Network Graphics (*.png)|*.png|Windows Bitmap (*.bmp)|*.bmp|All Files|*";
                    ofd.OverwritePrompt = true;
                    ofd.RestoreDirectory = false;

                    if (ofd.ShowDialog() == DialogResult.OK) {
                        try {
                            export.Save(ofd.FileName);
                        }
                        catch {
                            MessageBox.Show("Could not save image file.", "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
            }
        }
Example #8
0
        private void btnSaveSetList_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog dlgSave = new SaveFileDialog())
            {
                dlgSave.Title = "Select where to save the training set to...";
                dlgSave.Filter = "ENFORM Set File (*.eset)|*.eset|Text File (*.txt) |*.txt|Any file (*.*)|*.*";

                if (dlgSave.ShowDialog() == DialogResult.OK)
                {
                    using (StreamWriter w = new StreamWriter(dlgSave.FileName, false))
                    {
                        foreach (selectedSet.SelectedIndexRow row in selectedTable.Rows)
                        {

                            if (row.testingset || row.trainingset)
                            {
                                w.WriteLine(row.subjectid.ToString() + "," + Convert.ToInt32(row.trainingset).ToString() + "," + Convert.ToInt32(row.testingset).ToString() + "," + feretDataSet.faces.Select("subjectid=" +row.subjectid.ToString())[0]["filename"].ToString() );
                            }

                        }

                    }
                }

            }
        }
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
		{
			if (context == null || provider == null || context.Instance == null)
			{
				return base.EditValue(provider, value);
			}
			
			FileDialog fileDlg;
			if (context.PropertyDescriptor.Attributes[typeof(SaveFileAttribute)] == null)
			{
				fileDlg = new OpenFileDialog();
			}
			else
			{
				fileDlg = new SaveFileDialog();
			}
			fileDlg.Title = "Select " + context.PropertyDescriptor.DisplayName;
			fileDlg.FileName =  (string) value;
			
			FileDialogFilterAttribute filterAtt =  (FileDialogFilterAttribute) context.PropertyDescriptor.Attributes[typeof(FileDialogFilterAttribute)];
			if (filterAtt != null)
			{
				fileDlg.Filter = filterAtt.Filter;
			}
			if (fileDlg.ShowDialog() == DialogResult.OK)
			{
				value = fileDlg.FileName;
			}
			fileDlg.Dispose();
			return value;
		}
        private void buttonExtract_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txtCompiledFile.Text))
            {
                MessageBox.Show(this, "Please select a compiled ArchAngel template file.", "Missing File", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultExt = ".stz";
            dialog.Filter = "ArchAngel templates (*.stz)|*.stz";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (!Directory.Exists(Path.GetDirectoryName(dialog.FileName)))
                {
                    MessageBox.Show(this, "Please specify a valid save location.", "Invalid Folder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (File.Exists(dialog.FileName))
                {
                    Slyce.Common.Utility.DeleteFileBrute(dialog.FileName);
                }
                Project.ExtractTemplateFromCompiledTemplate(txtCompiledFile.Text, dialog.FileName);
                this.FileName = dialog.FileName;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Example #11
0
        public Form1()
        {
            InitializeComponent();
            cd = new ColorDialog();
            ld = new SHMUP.Screens.Levels.LevelManager.LevelData();
            sfd = new SaveFileDialog();
            sfd.Filter = "SHMUP Level File (*.lvl)|*.lvl";
            ofd = new OpenFileDialog();
            ofd.Filter = "SHMUP Level File (*.lvl)|*.lvl";

            //for (int i = 0; i < (int)SHMUP.Screens.Levels.LevelManager.bosses.ZZZEndOfList; i++)
            //{
            //    comBossType.Items.Add((SHMUP.Screens.Levels.LevelManager.bosses)i);
            //}

            string appPath = Application.ExecutablePath.Remove(Application.ExecutablePath.LastIndexOf(Path.DirectorySeparatorChar));

            String[] bosses = Directory.GetFiles(Path.Combine(Path.Combine(appPath, "Content"), "Bosses"), "*.bos");

            for (int i = 0; i < bosses.Length; i++)
            {
                bosses[i] = bosses[i].Remove(0, Path.Combine(Path.Combine(appPath, "Content"), "Bosses").Length + 1);
                bosses[i] = bosses[i].Remove(bosses[i].LastIndexOf(".bos"));
                comBossType.Items.Add(bosses[i]);
            }

            for (int i = 0; i < (int)SHMUP.Screens.Levels.LevelManager.enemies.ZZZEndOfList; i++)
            {
                comEnemyType.Items.Add((SHMUP.Screens.Levels.LevelManager.enemies)i);
            }

            ClearAll();
        }
Example #12
0
        public static int dialSaveFile(ref string dir,
                                      string filter,
                                      string title,
                                      int filterIndex,   
                                      out string path)
        {
            path = "";

            SaveFileDialog dlg = new SaveFileDialog();

            if (Directory.Exists(dir))
                dlg.InitialDirectory = dir;

            dlg.Title = title;
            dlg.Filter = filter;
            dlg.RestoreDirectory = true;
            dlg.FilterIndex = filterIndex;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                path = dlg.FileName;
                dir = Path.GetDirectoryName(path);
                return dlg.FilterIndex;
            }

            return -1;
        }
        private void yesButton_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog save = new SaveFileDialog())
              {
            save.DefaultExt = "sql";
            save.OverwritePrompt = true;
            save.Filter = "SQL Script Files (*.sql)|*.sql|All Files (*.*)|*.*";
            save.FileName = String.Format("{0}.sql", _tableName);
            save.Title = "Save SQLite Change Script";

            DialogResult = save.ShowDialog(this);

            if (DialogResult == DialogResult.OK)
            {
              _defaultSave = _saveOrig.Checked;

              using (System.IO.StreamWriter writer = new System.IO.StreamWriter(save.FileName, false, Encoding.UTF8))
              {
            if ((_show.Visible == true && _saveOrig.Checked == true) || (_show.Visible == false && _splitter.Panel2Collapsed == true))
            {
              if (_show.Visible == true) writer.WriteLine("/*");
              writer.WriteLine(_original.Text.Replace("\r", "").TrimEnd('\n').Replace("\n", "\r\n"));
              if (_show.Visible == true) writer.WriteLine("*/");
            }
            if (_show.Visible == true || _splitter.Panel2Collapsed == false)
              writer.WriteLine(_script.Text.Replace("\r", "").TrimEnd('\n').Replace("\n", "\r\n"));
              }
            }
              }
              Close();
        }
        private void barra1_click_imprimir_button()
        {
            SaveFileDialog sfDialog = new SaveFileDialog();
                sfDialog.AddExtension = true;
                sfDialog.Filter = "PDF Files (*.pdf)|*.PDF";
                sfDialog.DefaultExt = ".pdf";
                DialogResult drResult = sfDialog.ShowDialog();
                if (drResult.Equals(DialogResult.OK))
                {
                    switch (tabControl1.SelectedIndex)
                    {
                        case 0:
                            convertidor.ExportGrid(dgv_Tab0_Historial, sfDialog.FileName,"BODEGA");
                            break;
                        case 1:
                            convertidor.ExportGrid(dgv_Tab1_Historial, sfDialog.FileName,"UBICACION");
                            break;
                        case 2:
                            convertidor.ExportGrid(dgv_Tab2_Historial, sfDialog.FileName,"TIPO PRODUCTO");
                            break;
                        case 3:
                            convertidor.ExportGrid(dataGridView1, sfDialog.FileName, "Verificacion Inventario");
                            break;
                    }

                }
        }
Example #15
0
        public bool export()
        {
            checkStuff();

            SaveFileDialog ofd = new SaveFileDialog();
            ofd.Filter = LanguageManager.Get("Filters", "png");
            if (ofd.ShowDialog(win) == DialogResult.Cancel) return false;
            calcSizes();

            Bitmap b = new Bitmap(tx, ty);
            Graphics bgfx = Graphics.FromImage(b);
            int x = 0;
            foreach (PixelPalettedImage img in imgs)
            {
                int y = 0;
                foreach (Palette pal in pals)
                {
                    Bitmap bb = img.render(pal);
                    bgfx.DrawImage(bb, x, y, bb.Width, bb.Height);
                    bb.Dispose();
                    y += tys;
                }
                x += img.getWidth();
            }

            b.Save(ofd.FileName);
            b.Dispose();
            return true;
        }
Example #16
0
 public static void SaveRadTree(RadTreeView view, IWin32Window frm = null, string filename = "")
 {
     var saveFileDialogCsv = new SaveFileDialog();
     saveFileDialogCsv.Title = "Save data to Comma Separated File";
     saveFileDialogCsv.Filter = "CSV or Excel|*.csv";
     saveFileDialogCsv.CheckPathExists = true;
     saveFileDialogCsv.DefaultExt = "csv";
     saveFileDialogCsv.AddExtension = true;
     saveFileDialogCsv.OverwritePrompt = true;
     saveFileDialogCsv.InitialDirectory = Repository.DataFolder;
     saveFileDialogCsv.FileName = filename;
     if (saveFileDialogCsv.ShowDialog(frm) == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             sb = new StringBuilder();
             foreach (var node in view.Nodes)
             {
                 sb.AppendLine(node.Text.Replace("<=", ","));
                 ListNodes(node);
             }
             System.IO.File.WriteAllText(saveFileDialogCsv.FileName, sb.ToString(),Encoding.UTF8);
         }
         catch (Exception exc)
         {
             MessageBox.Show(exc.Message, "Unexpected Error");
         }
     }
 }
Example #17
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            var saveFileDlg = new SaveFileDialog {Filter = Resources.SaveFileFilter};

            if (DialogResult.OK.Equals(saveFileDlg.ShowDialog()))
            {
                var workbookParameterContainer = new WorkbookParameterContainer();
                workbookParameterContainer.Load(@"Template\Template.xml");
                SheetParameterContainer sheetParameterContainer = workbookParameterContainer["重复单元格式化器"];

                ExportHelper.ExportToLocal(@"Template\Template.xls", saveFileDlg.FileName,
                    new SheetFormatter("重复单元格式化器",
                        new RepeaterFormatter<StudentInfo>(sheetParameterContainer["rptStudentInfo_Start"],
                            sheetParameterContainer["rptStudentInfo_End"], StudentLogic.GetList(),
                            new CellFormatter<StudentInfo>(sheetParameterContainer["Name"], t => t.Name),
                            new CellFormatter<StudentInfo>(sheetParameterContainer["Gender"], t => t.Gender ? "男" : "女"),
                            new CellFormatter<StudentInfo>(sheetParameterContainer["Class"], t => t.Class),
                            new CellFormatter<StudentInfo>(sheetParameterContainer["RecordNo"], t => t.RecordNo),
                            new CellFormatter<StudentInfo>(sheetParameterContainer["Phone"], t => t.Phone),
                            new CellFormatter<StudentInfo>(sheetParameterContainer["Email"], t => t.Email)
                            )
                        )
                    );
            }
        }
Example #18
0
        /// <summary>
        /// Displays a save file dialog.
        /// </summary>
        /// <param name="title">Dialog title.</param>
        /// <param name="startPath">Initial path.</param>
        /// <param name="extension">File extension filter.</param>
        /// <param name="callback">Callback that is executed after the dialog completes.</param>
        /// <returns>True if succeeded.</returns>
        public static bool FileSave(String title, String startPath, String extension, Action<String> callback)
        {
            var dialog = new SaveFileDialog
            {
                Title = title,
                InitialDirectory = startPath,
                DefaultExt = @"*.*",
                Filter = extension,
                CheckPathExists = true,
                OverwritePrompt = true
            };
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (callback != null)
                {
                    callback(dialog.FileName);
                }
            }
            else
            {
                if (callback != null)
                {
                    callback(String.Empty);
                }
                return false;
            }

            return true;
        }
        private void init()
        {
            saveFileDialog = new SaveFileDialog();
            applyFilterOptions();
            string initialDirectory = null;
            try
            {
                initialDirectory = Path.GetDirectoryName(conf.OutputFileAsFullpath);
            }
            catch
            {
                LOG.WarnFormat("OutputFileAsFullpath was set to {0}, ignoring due to problem in path.", conf.OutputFileAsFullpath);
            }

            if (!string.IsNullOrEmpty(initialDirectory) && Directory.Exists(initialDirectory))
            {
                saveFileDialog.InitialDirectory = initialDirectory;
            }
            else if (Directory.Exists(conf.OutputFilePath))
            {
                saveFileDialog.InitialDirectory = conf.OutputFilePath;
            }
            // The following property fixes a problem that the directory where we save is locked (bug #2899790)
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.OverwritePrompt = true;
            saveFileDialog.CheckPathExists = false;
            saveFileDialog.AddExtension = true;
            ApplySuggestedValues();
        }
Example #20
0
 public static void ExportGridEx(Janus.Windows.GridEX.GridEX gridEx )
 {
     Stream sw = null;
     try
     {
         var sd = new SaveFileDialog { Filter = "Excel File (*.xml)|*.xml" };
         if (sd.ShowDialog() == DialogResult.OK)
         {
             //sw = new FileStream(sd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
             sw = new FileStream(sd.FileName, FileMode.Create);
             GridEXExporter grdListExporter = new GridEXExporter();
             grdListExporter.IncludeExcelProcessingInstruction = true;
             grdListExporter.IncludeFormatStyle = true;
             grdListExporter.IncludeHeaders = true;
             grdListExporter.GridEX = gridEx;
             grdListExporter.Export(sw);
             Utility.ShowMsg("Xuất dữ liệu thành công");
         }
     }
     catch (Exception ex)
     {
         Utility.ShowMsg(ex.Message);
     }
     finally
     {
         if (sw != null)
         {
             sw.Flush();
             sw.Close();
             sw.Dispose();
         }
     }
 }
Example #21
0
        /// <summary>
        /// 
        /// </summary>
        public static void SaveScene(bool saveAs)
        {
            if (SceneManager.ActiveScene == null) return;

            if (!File.Exists(SceneManager.ActiveScenePath))
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.InitialDirectory = SceneManager.GameProject.ProjectPath;
                sfd.Filter = "(*.scene)|*.scene";
                DialogResult dr = sfd.ShowDialog();

                if (dr == DialogResult.Yes || dr == DialogResult.OK)
                {
                    SceneManager.ActiveScenePath = sfd.FileName;
                }
                else
                {
                    return;
                }
            }

            if (saveAs)
            {
                // TODO: implement "Save As" funcionality

            }
            else
            {
                SceneManager.ActiveScene.SaveComponentValues();
                SceneManager.SaveActiveScene();
            }
        }
            public override void Invoke()
            {
                string value = HtmlSmartTag.Element.GetAttribute("ng-controller").Value;

                if (string.IsNullOrEmpty(value))
                    value = "myController";

                string folder = ProjectHelpers.GetProjectFolder(EditorExtensionsPackage.DTE.ActiveDocument.FullName);
                string file;

                using (var dialog = new SaveFileDialog())
                {
                    dialog.FileName = value + ".js";
                    dialog.DefaultExt = ".js";
                    dialog.Filter = "JS files | *.js";
                    dialog.InitialDirectory = folder;

                    if (dialog.ShowDialog() != DialogResult.OK)
                        return;

                    file = dialog.FileName;
                }

                EditorExtensionsPackage.DTE.UndoContext.Open(this.DisplayText);

                string script = GetScript(value);
                File.WriteAllText(file, script);

                ProjectHelpers.AddFileToActiveProject(file);
                EditorExtensionsPackage.DTE.ItemOperations.OpenFile(file);

                EditorExtensionsPackage.DTE.UndoContext.Close();
            }
 /// <summary>
 /// Function to take backup
 /// </summary>
 public void TakeBackUp()
 {
     try
     {
         if (MessageBox.Show("Do you want to take back up?", "OpenMiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             if (sqlcon.State == ConnectionState.Closed)
             {
                 sqlcon.Open();
             }
             string strPath = Application.StartupPath + "\\Data\\" + PublicVariables._decCurrentCompanyId + "\\DBOpenMiracle.mdf";
             SaveFileDialog saveBackupDialog = new SaveFileDialog();
             string strDestinationPath = string.Empty;
             string strFname = "DBOpenMiracle" + DateTime.Now.ToString("ddMMyyyhhmmss");
             saveBackupDialog.FileName = strFname;
             if (saveBackupDialog.ShowDialog() == DialogResult.OK)
             {
                 strDestinationPath = saveBackupDialog.FileName;
                 strDestinationPath = "'" + strDestinationPath + ".bak'";
                 SqlCommand sccmd = new SqlCommand("CompanyBackUpDb", sqlcon);
                 sccmd.CommandType = CommandType.StoredProcedure;
                 sccmd.Parameters.Add("@path", SqlDbType.VarChar).Value = strPath;
                 sccmd.Parameters.Add("@name", SqlDbType.VarChar).Value = strDestinationPath;
                 decimal decEffect = Convert.ToDecimal(sccmd.ExecuteNonQuery().ToString());
                 MessageBox.Show("The backup of database  completed successfully", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("BR 1 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
		bool RunDialog (OpenFileDialogData data)
		{			
			Application.EnableVisualStyles ();
			
			FileDialog fileDlg = null;
			if (data.Action == Gtk.FileChooserAction.Open)
				fileDlg = new OpenFileDialog ();
			else
				fileDlg = new SaveFileDialog ();
			
			var dlg = new CustomOpenFileDialog (fileDlg, data);
				
			SelectFileDialogHandler.SetCommonFormProperties (data, dlg.FileDialog);
			
			using (dlg) {
				rootForm = new WinFormsRoot ();
				if (dlg.ShowDialog (rootForm) == DialogResult.Cancel) {
					return false;
				}
	
				FilePath[] paths = new FilePath [fileDlg.FileNames.Length];
				for (int n = 0; n < fileDlg.FileNames.Length; n++)	
					paths [n] = fileDlg.FileNames [n];
				data.SelectedFiles = paths;
				
				if (dlg.SelectedEncodingId != null)
					data.Encoding = dlg.SelectedEncodingId > 0 ? Encoding.GetEncoding (dlg.SelectedEncodingId) : null;
				if (dlg.SelectedViewer != null)
					data.SelectedViewer = dlg.SelectedViewer;
				
				data.CloseCurrentWorkspace = dlg.CloseCurrentWorkspace;
			}
			
			return true;
		}
 public void ExportPDF(DateTime dateFrom, DateTime dateTo)
 {
     Cursor current = this.Cursor;
     this.Cursor = Cursors.WaitCursor;
     if (organizationSumBindingSource.DataSource == null)
         GenerateReportGrid(dateFrom, dateTo);
     try
     {
         SaveFileDialog openFileDialog1 = new SaveFileDialog();
         openFileDialog1.Filter = "Pdf files (*.Pdf)|*.Pdf";
         if (openFileDialog1.ShowDialog() == DialogResult.OK)
         {
             chartControlAnalizeCount.Dock = DockStyle.None;
             chartControlAnalizeCount.Width = 600;
             chartControlAnalizeCount.ExportToPdf(openFileDialog1.FileName);
             chartControlAnalizeCount.Dock = DockStyle.Top;
             System.Diagnostics.Process.Start(openFileDialog1.FileName);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Возможно файл открыт.", "Ошибка сохранения.",
       MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Cursor = current;
     }
     this.Cursor = current;
 }
Example #26
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
              SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname = "";
            saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls";


            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                fname = saveFileDialog1.FileName;
                try
                {
                    dsoFramerControl1.FileSave(saveFileDialog1.FileName, true);
                    
                    if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK)
                    {
                       
                        ExcelAccess ex = new ExcelAccess();
                        ex.Open(fname);
                        //此处写填充内容代码
                        ex.ShowExcel();
                        return;
                    }
                }
                catch
                {
                    MsgBox.ShowSuccessfulMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。");
                    return;
                }
            }
        }
        private void btnExportGrid_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (selection.SelectedCount <= FrmLogin.MAXROWCOUNT)
            {
                SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.Filter = "XLS文件|*.xls";
                saveDialog.Title = "导出Excel文件";
                saveDialog.DefaultExt = "xls";
                if (saveDialog.ShowDialog() == DialogResult.OK)
                {
                    gridView1.Columns["CheckMarkSelection"].Visible = false;

                    gridView1.SelectAll();
                    gridView1.ExportToXls(saveDialog.FileName);

                    gridView1.Columns["CheckMarkSelection"].Visible = true;
                    gridView1.Columns["CheckMarkSelection"].VisibleIndex = 0;

                    MessageBox.Show("导出成功!");

                }
            }
            else
            {
                MessageBox.Show("记录数超过50000条,请缩小查找范围后再导出!");
            }
        }
Example #28
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            //string filename = "Azure_Pass_Account" +/* datePicker.ToString() + */inputApplicant.Text;
            Excel.Application excel = new Excel.Application();
            excel.Visible = true;
            Excel.Workbook wb = excel.Workbooks.Add(1);
            Excel.Worksheet sh = wb.Sheets.Add();
            datePicker.Format = DateTimePickerFormat.Custom;
            datePicker.CustomFormat = "yyMMdd";

            sh.Name = "Azure Account";

            sh.Cells[1, "A"].Value2 = "Index";
            sh.Cells[1, "B"].Value2 = "Account";
            sh.Cells[1, "C"].Value2 = "Password";
            sh.Cells[1, "D"].Value2 = "Applicant";

            for(int index = 1; index <= Int32.Parse( inputAmount.Text); index   ++)
            {
                sh.Cells[index + 1 ,"A"].Value2 = index;
                sh.Cells[index + 1, "B"].Value2 = "MS" + datePicker.Text + index.ToString("000") + "@outlook.com";
                sh.Cells[index + 1, "C"].Value2 = "MS" + datePicker.Text;
                sh.Cells[index + 1, "D"].Value2 = inputApplicant.Text;
            }

            string filename = "Azure_Pass_Account_" + datePicker.Text + "_" + inputApplicant.Text + "_Auto_Generate";
            SaveFileDialog mySaveFileDialog = new SaveFileDialog();
            mySaveFileDialog.FileName = filename;
            mySaveFileDialog.Filter = "Excel files (*.xlsx)|*.xlsx";
            mySaveFileDialog.ShowDialog();

            excel.Quit();
        }
Example #29
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.textBox1.Text.Trim()))
            {
                MessageBox.Show("请输入需要转换的信息!");
            }

            string content = this.textBox1.Text;
            SaveFileDialog sFD = new SaveFileDialog();
            sFD.DefaultExt = "*.png|*.png";
            sFD.AddExtension = true;            
            
            try
            {
                if (sFD.ShowDialog() == DialogResult.OK)
                {
                    //string content = @"url:http://writeblog.csdn.net/PostEdit.aspx; name:nickwar";
                    COMMON.ByteMatrix byteMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, 350, 350);
                    writeToFile(byteMatrix, System.Drawing.Imaging.ImageFormat.Png, sFD.FileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #30
0
        private void lnkBrowseTo_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            SaveFileDialog diag = new SaveFileDialog();

            if (!String.IsNullOrEmpty(txtFromDir.Text) || !String.IsNullOrWhiteSpace(txtFromDir.Text))
            {

                if (!String.IsNullOrEmpty(fname) || !String.IsNullOrWhiteSpace(fname))
                {
                    diag.FileName = fname;
                }
                else
                {
                    h.alert("The source file name is empty.\nYou must first select a source file above and then select the destination.", "File Location Error");
                    txtFromDir.Focus();
                    fname = null;
                    return;
                }

            }
            else
            {
                h.alert("The source file name is empty.\nYou must first select a source file above and then select the destination.", "File Location Error");
                txtFromDir.Focus();
                fname = null;
                return;
            }

            if (diag.ShowDialog() == DialogResult.OK)
            {
               txtToDir.Text = diag.FileName.ToString();
            }
        }