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; }
private void btnExport_Click(object sender, EventArgs e) { SaveFileDialog o = new SaveFileDialog(); o.AddExtension = true; o.CheckPathExists = true; o.DefaultExt = "wav"; o.Filter = "WAVE audio (*.wav)|*.wav"; o.OverwritePrompt = true; if (o.ShowDialog() == DialogResult.OK) soundBase.Save_WAV(o.FileName, false); if (soundBase.CanLoop) { XElement xml = XElement.Load(Application.StartupPath + Path.DirectorySeparatorChar + "Plugins" + Path.DirectorySeparatorChar + "SoundLang.xml"); xml = xml.Element(pluginHost.Get_Language()).Element("SoundControl"); if (MessageBox.Show(xml.Element("S05").Value, "", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (o.ShowDialog() == DialogResult.OK) { string path = Path.GetDirectoryName(o.FileName) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(o.FileName) + "_loop.wav"; soundBase.Save_WAV(path, true); } } } }
// TODO: organise Dialogs.cs #region FileSelectFile /// <summary> /// Displays a standard dialog that allows the user to open or save files. /// </summary> /// <param name="OutputVar">The user selected files.</param> /// <param name="Options"> /// <list type="bullet"> /// <item><term>M</term>: <description>allow muliple files to be selected.</description></item> /// <item><term>S</term>: <description>show a save as dialog rather than a file open dialog.</description></item> /// <item><term>1</term>: <description>only allow existing file or directory paths.</description></item> /// <item><term>8</term>: <description>prompt to create files.</description></item> /// <item><term>16:</term>: <description>prompt to overwrite files.</description></item> /// <item><term>32</term>: <description>follow the target of a shortcut rather than using the shortcut file itself.</description></item> /// </list> /// </param> /// <param name="RootDir">The file path to initially select.</param> /// <param name="Prompt">Text displayed in the window to instruct the user what to do.</param> /// <param name="Filter">Indicates which types of files are shown by the dialog, e.g. <c>Audio (*.wav; *.mp2; *.mp3)</c>.</param> public static void FileSelectFile(out string OutputVar, string Options, string RootDir, string Prompt, string Filter) { bool save = false, multi = false, check = false, create = false, overwite = false, shortcuts = false; Options = Options.ToUpperInvariant(); if (Options.Contains("M")) { Options = Options.Replace("M", string.Empty); multi = true; } if (Options.Contains("S")) { Options = Options.Replace("S", string.Empty); save = true; } int result; if (int.TryParse(Options.Trim(), out result)) { if ((result & 1) == 1 || (result & 2) == 2) check = true; if ((result & 8) == 8) create = true; if ((result & 16) == 16) overwite = true; if ((result & 32) == 32) shortcuts = true; } ErrorLevel = 0; OutputVar = null; if (save) { var saveas = new SaveFileDialog { CheckPathExists = check, CreatePrompt = create, OverwritePrompt = overwite, DereferenceLinks = shortcuts, Filter = Filter }; var selected = dialogOwner == null ? saveas.ShowDialog() : saveas.ShowDialog(dialogOwner); if (selected == DialogResult.OK) OutputVar = saveas.FileName; else ErrorLevel = 1; } else { var open = new OpenFileDialog { Multiselect = multi, CheckFileExists = check, DereferenceLinks = shortcuts, Filter = Filter }; var selected = dialogOwner == null ? open.ShowDialog() : open.ShowDialog(dialogOwner); if (selected == DialogResult.OK) OutputVar = multi ? string.Join("\n", open.FileNames) : open.FileName; else ErrorLevel = 1; } }
private void сохранитьКакToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Title = "Сохранить"; saveFileDialog1.Filter = "Файлы блокнота|*.txt"; saveFileDialog1.ShowDialog(); if (saveFileDialog1.FileName != "") { saveFileDialog1.ShowDialog(); System.IO.File.WriteAllText(saveFileDialog1.FileName, textBox1.Text); } }
private static string callSaveFileDialog(string startFileName, string fileTypes, IWin32Window parentForm, ScriptEngine engine) { try { SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = startFileName; dlg.Filter = fileTypes; DialogResult result = parentForm == null ? dlg.ShowDialog() : dlg.ShowDialog(parentForm); return result == DialogResult.OK ? dlg.FileName : string.Empty; } catch (Exception ex) { throw ex.convertException(engine); } }
private void Browse(object sender, EventArgs e) { Button b = sender as Button; TextBox t = b.Tag as TextBox; OpenFileDialog ofd = new OpenFileDialog(); SaveFileDialog sfd = new SaveFileDialog(); if (t.Name == "txtInput") { // ofd ofd.Filter = "Bitmap Files (*.bmp)|*.bmp"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return; t.Text = ofd.FileName; } else if (t.Name == "txtOutput") { if (rdbHide.Checked) { // sfd sfd.Filter = "Bitmap Files (*.bmp)|*.bmp"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return; t.Text = sfd.FileName; } else { // ofd ofd.Filter = "Bitmap Files (*.bmp)|*.bmp"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return; t.Text = ofd.FileName; } } else if (t.Name == "txtData") { if (rdbHide.Checked) { // ofd if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return; t.Text = ofd.FileName; } else { // sfd if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return; t.Text = sfd.FileName; } } }
string ShowDialog() { DialogResult result = DialogResult.Ignore; SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = DialogFilter; dlg.InitialDirectory = Program.UserDataPath; dlg.CheckFileExists = false; if (CallerControl != null) CallerControl.Invoke(new Action(() => result = dlg.ShowDialog())); else result = dlg.ShowDialog(); if (result == DialogResult.OK) return dlg.FileName; return string.Empty; }
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); } } } } }
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; }
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) ) ) ); } }
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 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(); }
protected override void mergeTiffToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = imageFolder; openFileDialog1.Title = Properties.Resources.Select + " Input Images"; openFileDialog1.Filter = "Image Files (*.tif;*.tiff)|*.tif;*.tiff|Image Files (*.bmp)|*.bmp|Image Files (*.jpg;*.jpeg)|*.jpg;*.jpeg|Image Files (*.png)|*.png|All Image Files|*.tif;*.tiff;*.bmp;*.jpg;*.jpeg;*.png"; openFileDialog1.FilterIndex = filterIndex; openFileDialog1.RestoreDirectory = true; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { filterIndex = openFileDialog1.FilterIndex; imageFolder = Path.GetDirectoryName(openFileDialog1.FileName); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = imageFolder; saveFileDialog1.Title = Properties.Resources.Save + " Multi-page TIFF Image"; saveFileDialog1.Filter = "Image Files (*.tif;*.tiff)|*.tif;*.tiff"; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { File.Delete(saveFileDialog1.FileName); ImageIOHelper.MergeTiff(openFileDialog1.FileNames, saveFileDialog1.FileName); MessageBox.Show(this, Properties.Resources.Mergecompleted + Path.GetFileName(saveFileDialog1.FileName) + Properties.Resources.created, strProgName, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <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); } }
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"); } } }
/// <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 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() ); } } } } } }
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(); } }
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; }
/// <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 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; }
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(); } } } }
private void button1_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog { Title = "Program to crypt" }) { ofd.Filter = "Programs(*.exe)|*.exe"; if (ofd.ShowDialog() == DialogResult.OK) { textBox1.Text = ofd.FileName; textBox2.AppendText("Executable loaded!" + Environment.NewLine); using (SaveFileDialog sfd = new SaveFileDialog { Title = "Saves as" }) { sfd.Filter = "Programs(*.exe)|*.exe"; if (sfd.ShowDialog() == DialogResult.OK) { File.WriteAllBytes(sfd.FileName, Properties.Resources.dependency); Compress(ofd.FileName); byte[] bytes = File.ReadAllBytes(ofd.FileName.Replace(".exe", ".bin")); misc.WriteResource(sfd.FileName, bytes); textBox2.AppendText("Protection done!" + Environment.NewLine); File.Delete(CompressedFile); } } } } }
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); } }
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); } }
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(); } } }
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 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); } }
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(); }