本文整理汇总了C#中Gtk.FileChooserDialog.SetUri方法的典型用法代码示例。如果您正苦于以下问题:C# FileChooserDialog.SetUri方法的具体用法?C# FileChooserDialog.SetUri怎么用?C# FileChooserDialog.SetUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.FileChooserDialog
的用法示例。
在下文中一共展示了FileChooserDialog.SetUri方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnAddWallpapersClicked
// Add more wallpapers
private void OnAddWallpapersClicked(object sender, EventArgs args)
{
FileChooserDialog fc = new FileChooserDialog(Catalog.GetString("Add wallpaper"), winPref, FileChooserAction.Open);
// Settings
fc.LocalOnly = true; // Only local files
fc.SelectMultiple = true; // Users can select multiple images at a time
fc.Filter = new FileFilter(); // Filter
fc.Filter.AddPixbufFormats(); // Add pixmaps
// Add buttons
fc.AddButton(Stock.Cancel, ResponseType.Cancel);
fc.AddButton(Stock.Open , ResponseType.Ok);
// Try to goto the monitor dir if monitoring is enabled, else goto documents
if (DrapesApp.Cfg.MonitorEnabled == true)
fc.SetUri(DrapesApp.Cfg.MonitorDirectory);
else
fc.SetUri(Environment.GetEnvironmentVariable("HOME") + "/Documents");
ListStore FileOptions = new ListStore(typeof(string), typeof(string));
FileOptions.AppendValues(Catalog.GetString("Images"), Stock.File);
FileOptions.AppendValues(Catalog.GetString("Directory"), Stock.Directory);
ComboBox ChooserType = new ComboBox(FileOptions);
ChooserType.Active = 0;
CellRendererPixbuf fTypeImage = new CellRendererPixbuf();
CellRendererText fTypeText = new CellRendererText();
ChooserType.PackStart(fTypeImage, false);
ChooserType.PackStart(fTypeText, true);
CellLayoutDataFunc renderer = delegate (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter)
{
if (cell == fTypeText) {
(cell as CellRendererText).Text = (string) model.GetValue(iter, 0);
} else if (cell == fTypeImage) {
if (model.GetValue(iter, 1) != null) {
(cell as CellRendererPixbuf).StockId = (string) model.GetValue(iter, 1);
} else
(cell as CellRendererPixbuf).StockId = null;
}
};
ChooserType.SetCellDataFunc(fTypeText, renderer);
ChooserType.SetCellDataFunc(fTypeImage, renderer);
// changed event is just going to be anonymous method
ChooserType.Changed += delegate (object dSender, EventArgs dArgs)
{
ComboBox cb = (ComboBox) dSender;
if (cb.Active == 0) {
fc.SelectMultiple = true;
fc.Action = FileChooserAction.Open;
} else {
fc.SelectMultiple = false;
fc.Action = FileChooserAction.SelectFolder;
}
};
fc.ExtraWidget = new HBox(false, 10);
(fc.ExtraWidget as HBox).PackEnd(ChooserType, false, false, 0);
(fc.ExtraWidget as HBox).PackEnd(new Label(Catalog.GetString("Import type:")), false, false, 0);
fc.ExtraWidget.ShowAll();
// Show the dialog
int r = fc.Run();
if ((ResponseType) r == ResponseType.Ok) {
if (fc.Action == FileChooserAction.SelectFolder)
DrapesApp.WpList.AddDirectory(fc.Filename);
else
DrapesApp.WpList.AddFiles(fc.Filenames);
}
// Get rid of the window
fc.Destroy();
}
示例2: Open
private void Open(FileChooserAction action)
{
string title = Catalog.GetString ("Open");
if (action == FileChooserAction.SelectFolder)
title = Catalog.GetString ("Select Folder");
FileChooserDialog chooser = new FileChooserDialog (title,
Window,
action);
chooser.AddButton (Stock.Cancel, ResponseType.Cancel);
chooser.AddButton (Stock.Open, ResponseType.Ok);
chooser.SetUri (uri.ToString ());
int response = chooser.Run ();
if ((ResponseType) response == ResponseType.Ok)
CurrentUri = new SafeUri (chooser.Uri, true);
chooser.Destroy ();
}
示例3: OnBtnSettingsBrowseClick
private void OnBtnSettingsBrowseClick(object o, EventArgs e)
{
string _server_subfolder = null;
string _server_string = null;
string _server_protocol = null;
int _server_string_length = 0;
int _dlg_uri_length = 0;
int _url_diff = 0;
int _response = -1;
FileChooserDialog dlg = new FileChooserDialog (
"Device Sub Folder",
this,
FileChooserAction.SelectFolder,
"Cancel", ResponseType.Cancel,
"Choose", ResponseType.Accept
);
c_current_server = csql.CSQL_GetServer (c_current_device.DeviceServer );
_server_string = c_current_server.ServerAddr + c_current_server.ServerBaseDir;
_server_string_length = _server_string.Length;
_server_protocol = c_current_server.ServerProtocol;
if (_server_protocol == "file://") {
dlg.LocalOnly = false;
_response = dlg.Run ();
if (_response == (int)ResponseType.Accept) {
if (dlg.Uri.StartsWith("file://")) {
entDeviceServerSubDir.Text = dlg.Uri.Substring("file://".Length);
if (entDeviceServerSubDir.Text.EndsWith (System.IO.Path.DirectorySeparatorChar.ToString()) == false )
entDeviceServerSubDir.Text += System.IO.Path.DirectorySeparatorChar.ToString();
c_current_device.DeviceServerSubDir = entDeviceServerSubDir.Text;
} else {
entDeviceServerSubDir.Text = dlg.Uri + System.IO.Path.DirectorySeparatorChar;
c_current_device.DeviceServerSubDir = dlg.Uri + System.IO.Path.DirectorySeparatorChar;
}
} else {
}
} else {
dlg.LocalOnly = false;
dlg.SetUri (_server_string);
_response = dlg.Run ();
if (_response == (int)ResponseType.Accept) {
string s = dlg.Uri;
_dlg_uri_length = s.Length;
_url_diff = _dlg_uri_length - _server_string_length;
if (_url_diff > 0) {
_server_subfolder = s.Substring (_server_string_length, _dlg_uri_length - _server_string_length);
if (_server_subfolder.EndsWith ("/") != true)
_server_subfolder += "/";
} else {
}
entDeviceServerSubDir.Text = _server_subfolder;
c_current_device.DeviceServerSubDir = _server_subfolder;
} else {
}
}
dlg.Destroy ();
}
示例4: HandleFileOpen
// XXX: never called
private void HandleFileOpen(object sender, System.EventArgs args)
{
FileChooserDialog file_selector =
new FileChooserDialog ("Open", this.Window,
FileChooserAction.Open);
file_selector.SetUri (uri.ToString ());
int response = file_selector.Run ();
if ((Gtk.ResponseType) response == Gtk.ResponseType.Ok) {
var l = new List<SafeUri> ();
foreach (var s in file_selector.Uris)
l.Add (new SafeUri (s));
new FSpot.SingleView (l.ToArray ());
}
file_selector.Destroy ();
}
示例5: HandleFileOpen
private void HandleFileOpen (object sender, System.EventArgs args)
{
string open = null;
FileChooserDialog file_selector =
new FileChooserDialog ("Open", this.Window,
FileChooserAction.Open);
file_selector.SetUri (uri.ToString ());
int response = file_selector.Run ();
if ((Gtk.ResponseType) response == Gtk.ResponseType.Ok) {
open = file_selector.Filename;
new FSpot.SingleView (open);
}
file_selector.Destroy ();
}