本文整理汇总了C#中Gtk.FileChooserDialog.Show方法的典型用法代码示例。如果您正苦于以下问题:C# FileChooserDialog.Show方法的具体用法?C# FileChooserDialog.Show怎么用?C# FileChooserDialog.Show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.FileChooserDialog
的用法示例。
在下文中一共展示了FileChooserDialog.Show方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnButtonFileChooserClicked
protected void OnButtonFileChooserClicked(object sender, EventArgs e)
{
FileChooserDialog fc =
new FileChooserDialog ("Укажите файл резервной копии",
this,
FileChooserAction.Save,
"Отмена", ResponseType.Cancel,
"Сохранить", ResponseType.Accept);
fc.SetFilename (entryFileName.Text);
fc.Show ();
if (fc.Run () == (int)ResponseType.Accept) {
entryFileName.Text = fc.Filename;
}
fc.Destroy ();
}
示例2: OnSaveAsActionActivated
protected void OnSaveAsActionActivated(object sender, EventArgs e)
{
if(DocTemplate == null)
return;
FileChooserDialog fc=
new FileChooserDialog("Укажите файл для сохранения шаблона...",
this,
FileChooserAction.Save,
"Отмена",ResponseType.Cancel,
"Сохранить",ResponseType.Accept);
//FileFilter filter = new FileFilter();
fc.CurrentName = DocTemplate.Name + ".xml";
fc.Show();
if(fc.Run() == (int) ResponseType.Accept)
{
fc.Hide();
FileStream fs = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write);
DocTemplate.SaveToStream(fs);
fs.Close();
}
fc.Destroy();
}
示例3: LoadFile
private void LoadFile(object sender, EventArgs e)
{
//show the file browser
FileChooserDialog dialogBox = new FileChooserDialog ("Choose the file to open",
this,
FileChooserAction.Open,
"Cancel",ResponseType.Cancel,
"Open",ResponseType.Accept);
dialogBox.Show ();
if (dialogBox.Run() == (int)ResponseType.Accept)
{
Console.WriteLine ("accept response from dialog box");
//check to make sure the file is valid
//if it is not notify the user to try again
if (!FileParser.FileParser.ParseFileGrammar (dialogBox.Filename, true)) {
Console.WriteLine ("bad file grammar");
InvalidFilePopup badFilePrompt = new InvalidFilePopup ();
badFilePrompt.makeAppear ();
}
//else all is well
else {
Console.WriteLine ("We will repaint the home window with the" +
"new data given.");
parentWindow.Repaint ();
}
dialogBox.Destroy();
this.Destroy ();
}
}
示例4: OnButtonSavePhotoClicked
protected void OnButtonSavePhotoClicked(object sender, EventArgs e)
{
FileChooserDialog fc =
new FileChooserDialog ("Укажите файл для сохранения фотографии",
(Window)this.Toplevel,
FileChooserAction.Save,
"Отмена", ResponseType.Cancel,
"Сохранить", ResponseType.Accept);
fc.CurrentName = (GetSaveFileName != null ? GetSaveFileName() : "фото") + ".jpg";
fc.Show ();
if (fc.Run () == (int)ResponseType.Accept) {
fc.Hide ();
FileStream fs = new FileStream (fc.Filename, FileMode.Create, FileAccess.Write);
fs.Write (ImageFile, 0, ImageFile.Length);
fs.Close ();
}
fc.Destroy ();
}
示例5: ShowDialog
public DialogResult ShowDialog(IWin32Window owner)
{
var oldDirectory = Directory.GetCurrentDirectory();
try
{
m_dlg = CreateFileChooserDialog();
m_dlg.Show();
Gtk.Application.Run();
return DialogResult;
}
finally
{
if (RestoreDirectory)
Directory.SetCurrentDirectory(oldDirectory);
}
}
示例6: OnButtonSaveClicked
protected void OnButtonSaveClicked(object sender, EventArgs e)
{
TreePath sel = iconviewFiles.SelectedItems [0];
TreeIter iter;
FilesStore.GetIter (out iter, sel);
FileChooserDialog fc =
new FileChooserDialog ("Укажите путь для сохранения файла",
(Gtk.Window)this.Toplevel,
FileChooserAction.Save,
"Отмена", ResponseType.Cancel,
"Сохранить", ResponseType.Accept);
fc.CurrentName = (string)FilesStore.GetValue (iter, (int)FilesCol.name);
fc.Show ();
if (fc.Run () == (int)ResponseType.Accept) {
fc.Hide ();
logger.Info ("Сохраняем файл на диск...");
byte[] file = (byte[])FilesStore.GetValue (iter, (int)FilesCol.file);
if (file == null) {
file = LoadFileFromDB ((int)FilesStore.GetValue (iter, (int)FilesCol.id));
}
System.IO.File.WriteAllBytes (fc.Filename, file);
}
fc.Destroy ();
logger.Info ("Ок");
}
示例7: Save
void Save(System.Action after)
{
if (_lang == null)
{
return;
}
if (string.IsNullOrWhiteSpace(_lang.Filename))
{
var sf = new FileChooserDialog("Save As", this, FileChooserAction.Save);
sf.AddFilter(langFileFilter);
sf.AddButton("Save", ResponseType.Accept);
sf.AddButton("Cancel", ResponseType.Cancel);
sf.Response += (o, args) =>
{
switch (args.ResponseId)
{
case ResponseType.Yes:
case ResponseType.Accept:
case ResponseType.Apply:
case ResponseType.Ok:
_lang.Filename = sf.Filename;
Save(after);
break;
default:
break;
}
sf.Destroy();
};
sf.Show();
}
else
{
if (string.IsNullOrWhiteSpace(_lang.Name))
{
_lang.Name = System.IO.Path.GetFileNameWithoutExtension(_lang.Filename);
}
string json = JsonConvert.SerializeObject(_lang, Formatting.Indented);
File.WriteAllText(_lang.Filename, json);
_dirty = false;
statusbar1.Push(0, string.Format("Saved as {0}", _lang.Filename));
if (after != null)
{
after();
}
}
}
示例8: OnOpenActionActivated
protected void OnOpenActionActivated(object sender, EventArgs e)
{
SaveIfDirtyThen(() =>
{
var fd = new FileChooserDialog("Open language", this, FileChooserAction.Open);
fd.AddButton("Open", ResponseType.Accept);
fd.AddButton("Cancel", ResponseType.Cancel);
fd.AddFilter(langFileFilter);
fd.Response += (o, args) =>
{
var filename = fd.Filename;
fd.Destroy();
if (args.ResponseId == ResponseType.Accept)
{
OpenLang(filename);
}
};
fd.Show();
});
}
示例9: btnRunClicked
private void btnRunClicked (object o, EventArgs args)
{
const string sampleText = "Lorem ipsum dolor sit amet";
string cmd = txtCommand.Text;
if (cmd == "click button1")
button1.Activate ();
else if (cmd == "set textbox3 text")
textBox3.Buffer.Text = sampleText;
else if (cmd == "set textBox3 long text")
textBox3.Buffer.Text = "very very very very very very very very long text to enable the horizontal scroll bar";
else if (cmd.StartsWith ("set textbox3 to "))
textBox3.Buffer.Text = cmd.Substring (16).
Replace ("\\n", "\n").
Replace ("\\r", "\r");
else if (cmd == "select textbox3") {
if (textBox3.Buffer.Text.Length < 4)
textBox3.Buffer.Text = sampleText;
Gtk.TextIter startIter, endIter;
textBox3.Buffer.GetSelectionBounds (out startIter, out endIter);
int start, end;
start = startIter.Offset;
end = endIter.Offset;
end = (end-start == 3? 4: 3);
start = 0;
startIter = textBox3.Buffer.GetIterAtOffset (start);
endIter = textBox3.Buffer.GetIterAtOffset (end);
textBox3.Buffer.MoveMark ("selection_bound", startIter);
textBox3.Buffer.MoveMark ("insert", endIter);
} else if (cmd == "add table row") {
Gtk.TreeIter iter;
iter = tableStore.AppendNode ();
tableStore.SetValues (iter, "true", "Mallory", "40");
} else if (cmd == "add table column")
AddTreeViewColumn (treeView2, 3, "more");
else if (cmd == "enable multiselect")
listView1.Selection.Mode = Gtk.SelectionMode.Multiple;
else if (cmd == "disable multiselect")
listView1.Selection.Mode = Gtk.SelectionMode.Single;
else if (cmd == "change button3 name")
button3.Accessible.Name = "xyzzy";
else if (cmd == "change button3 helptext")
button3.Accessible.Description = "plugh";
else if (cmd == "enable button3")
button3.Sensitive = true;
else if (cmd == "disable button3")
button3.Sensitive = false;
else if (cmd == "focus textBox3")
textBox3.GrabFocus ();
else if (cmd == "focus button2")
button2.GrabFocus ();
else if (cmd.StartsWith ("change title:"))
window.Title = cmd.Substring (cmd.IndexOf (':') + 1);
else if (cmd == "open FileChooser" && chooser == null) {
chooser = new Gtk.FileChooserDialog ("FileChooser", window, FileChooserAction.Open, "data", 0);
chooser.Show ();
}
else if (cmd == "close FileChooser" && chooser != null) {
chooser.Destroy ();
chooser = null;
}
}
示例10: OpenFileTree
/**
* Wil open a file browser to locate a file on the system
* */
private void OpenFileTree(object sender, EventArgs e)
{
bool openedSuccessfully = false;
Console.WriteLine ("Opening a file tree");
//show the file browser
dialogBox = new FileChooserDialog ("Choose the file to open",
this,
FileChooserAction.Open,
"Cancel",ResponseType.Cancel,
"Open",ResponseType.Accept);
dialogBox.Show ();
if (dialogBox.Run () == (int)ResponseType.Accept) {
Console.WriteLine ("accept response from dialog box");
//check to make sure the file is valid
//if it is not notify the user to try again
if (!FileParser.FileParser.ParseFileGrammar (dialogBox.Filename, false)) {
Console.WriteLine ("bad file grammar");
InvalidFilePopup badFilePrompt = new InvalidFilePopup ();
badFilePrompt.makeAppear ();
}
//else all is well
else {
Console.WriteLine ("going to main window");
MainWindow homeScreen = new MainWindow ();
homeScreen.makeAppear ();
openedSuccessfully = true;
}
dialogBox.Destroy ();
if (openedSuccessfully)
this.Destroy ();
} else
dialogBox.Destroy ();
}
示例11: OnImagePopupSave
protected void OnImagePopupSave(object sender, EventArgs Arg)
{
FileChooserDialog fc=
new FileChooserDialog("Укажите файл для сохранения картинки",
this,
FileChooserAction.Save,
"Отмена",ResponseType.Cancel,
"Сохранить",ResponseType.Accept);
//FileFilter filter = new FileFilter();
fc.CurrentName = DocInfo.TypeName + " " + entryNumber.Text + ".jpg";
fc.Show();
if(fc.Run() == (int) ResponseType.Accept)
{
fc.Hide();
foreach(DocumentImage img in Images)
{
if(img.id == PopupImageId)
{
FileStream fs = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write);
fs.Write(img.file, 0, (int)img.size);
fs.Close();
}
}
}
fc.Destroy();
}
示例12: OnButtonPDFClicked
protected void OnButtonPDFClicked(object sender, EventArgs e)
{
FileChooserDialog fc=
new FileChooserDialog("Укажите файл для сохранения документа",
this,
FileChooserAction.Save,
"Отмена",ResponseType.Cancel,
"Сохранить",ResponseType.Accept);
fc.CurrentName = DocInfo.TypeName + " " + entryNumber.Text + ".pdf";
fc.Show();
if(fc.Run() == (int) ResponseType.Accept)
{
fc.Hide();
iTextSharp.text.Document document = new iTextSharp.text.Document();
using (var stream = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write, FileShare.None))
{
iTextSharp.text.pdf.PdfWriter.GetInstance(document, stream);
document.Open();
foreach(DocumentImage img in Images)
{
if(img.Image.Width > img.Image.Height)
document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
else
document.SetPageSize(iTextSharp.text.PageSize.A4);
document.NewPage();
var image = iTextSharp.text.Image.GetInstance(img.file);
image.SetAbsolutePosition(0,0);
image.ScaleToFit(document.PageSize.Width, document.PageSize.Height);
document.Add(image);
}
document.Close();
}
}
fc.Destroy();
}