本文整理汇总了C#中System.Windows.Forms.SaveFileDialog类的典型用法代码示例。如果您正苦于以下问题:C# SaveFileDialog类的具体用法?C# SaveFileDialog怎么用?C# SaveFileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SaveFileDialog类属于System.Windows.Forms命名空间,在下文中一共展示了SaveFileDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnProcessFileDialog
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;
}
示例2: btn_save_Click
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);
}
}
示例3: button4_Click
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();
}
}
示例4: SaveToFile
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();
}
}
}
}
示例5: btnSave_Click
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);
}
}
示例6: SaveDIBAs
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;
}
示例7: CommandExport
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);
}
}
}
}
}
示例8: btnSaveSetList_Click
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() );
}
}
}
}
}
}
示例9: EditValue
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;
}
示例10: buttonExtract_Click
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();
}
}
示例11: Form1
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();
}
示例12: dialSaveFile
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;
}
示例13: yesButton_Click
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();
}
示例14: barra1_click_imprimir_button
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;
}
}
}
示例15: export
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;
}