本文整理汇总了C#中System.Windows.Forms.SaveFileDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# SaveFileDialog.ShowDialog方法的具体用法?C# SaveFileDialog.ShowDialog怎么用?C# SaveFileDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.SaveFileDialog
的用法示例。
在下文中一共展示了SaveFileDialog.ShowDialog方法的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: btnExport_Click
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);
}
}
}
}
示例3: FileSelectFile
// 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;
}
}
示例4: SaveFileDialog
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);
}
}
示例5: callSaveFileDialog
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);
}
}
示例6: Browse
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;
}
}
}
示例7: ShowDialog
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;
}
示例8: 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;
}
示例9: 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);
}
}
}
}
}
示例10: 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;
}
示例11: btnExport_Click
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)
)
)
);
}
}
示例12: 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();
}
示例13: btnGenerate_Click
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();
}
示例14: mergeTiffToolStripMenuItem_Click
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);
}
}
}
示例15: TakeBackUp
/// <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);
}
}