private void open_Clicked(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog("Select a file"); dlg.InitialFileName = "Some file"; dlg.Multiselect = false; dlg.Filters.Add(new FileDialogFilter("Report files", "*.rdl")); dlg.Filters.Add(new FileDialogFilter("All files", "*.*")); if (dlg.Run()) { rv.LoadReport(new Uri(dlg.FileName), this.parameters); } }
public void OpenClicked(object sender, EventArgs e) { var ofdialog = new OpenFileDialog(); ofdialog.Multiselect = false; ofdialog.Filters.Add(_spritefontFileFilter); ofdialog.Filters.Add(_anyFilesFilter); var result = ofdialog.Run (this); if (result) sfwidget1.Open(ofdialog.FileName); ofdialog.Dispose (); ReloadTitle(); }
static void Main(string[] args) { string dataFolderPath = Directory.GetCurrentDirectory(); string database = String.Format("{0}\\data.db", dataFolderPath); dataSource = "data source=" + database; tableName = "product"; tableName = "product"; PlotHelper.createTable(dataSource,tableName); PlotHelper.TestConnection(dataSource); // TODO: add Xwt.WPF.dll to vendor directory Application.Initialize(ToolkitType.Gtk); Window MainWindow = new Window() { Title = "Xwt Demo Application", Width = 500, Height = 400 }; MainWindow.CloseRequested += (o, e) => { Application.Exit(); }; Menu MainMenu = new Menu(); RichTextView TextView = new RichTextView(); MenuItem FileOpenMenuItem = new MenuItem("???????"); Menu FileMenu = new Menu(); FileOpenMenuItem.Clicked += (o, e) => { OpenFileDialog Dialog = new OpenFileDialog("??????? ????"); if (Dialog.Run(MainWindow)) { TextView.LoadFile(Dialog.FileName, Xwt.Formats.TextFormat.Markdown); } }; MenuItem FileMenuItem = new MenuItem("????") { SubMenu = FileMenu }; FileMenu.Items.Add(FileOpenMenuItem); MainMenu.Items.Add(FileMenuItem); MainWindow.MainMenu = MainMenu; var n = new NotebookSample(); MainWindow.Content = n; MainWindow.Show(); Application.Run(); }
public static string OpenFileDialog(this IWindow window, string folder, string title, string extension = null) { window.Sensitive = false; FileDialog dialog = new OpenFileDialog (I18N._ (title)); dialog.CurrentFolder = folder; if (extension != null) { dialog.Filters.Add (new FileDialogFilter ("." + extension, "*." + extension)); dialog.Filters.Add (new FileDialogFilter (I18N._("all"), "*")); } if (dialog.Run ()) { window.Sensitive = true; return Path.Combine (dialog.CurrentFolder, dialog.FileName); } window.Sensitive = true; return null; }
private void Open() { var ofdialog = new OpenFileDialog(); ofdialog.Filters.Add(_urmFileFilter); ofdialog.Filters.Add(_txtFileFilter); ofdialog.Filters.Add(_anyFilesFilter); if (ofdialog.Run(this)) { fileName = ofdialog.FileName; te1.Document.Text = File.ReadAllText(fileName); te1.ClearUndoRedoStack(); savedContent = te1.Document.Text; ReloadMenuAndTitle(); } }
public MarkDownSample() { var openFileDialog = new OpenFileDialog ("Select File"); var markdown = new MarkdownView() { Markdown = MarkDownText }; var scrolled = new ScrollView (markdown) { MinHeight = 400 }; var button = new Button ("Open File"); button.Clicked += delegate { if (openFileDialog.Run (ParentWindow)) { markdown.Markdown = File.ReadAllText (openFileDialog.FileName); } }; PackStart (button, BoxMode.FillAndExpand); PackStart (scrolled, BoxMode.FillAndExpand); }
private void ButtonAddImageClicked(object sender, EventArgs e) { var dialog = new OpenFileDialog { Title = "Select an image", Multiselect = true, }; dialog.Filters.Add(new FileDialogFilter("Image files", "*.png", "*.bmp", "*.jpeg", "*.jpg")); if (!dialog.Run(View.ParentWindow)) return; foreach (var filename in dialog.FileNames) { Card.AddImage(new Deblocus.Entities.Image { Data = System.IO.File.ReadAllBytes(filename) }); } View.UpdateView(); }
static void ShowFileDialog(object sender, EventArgs eventArgs) { TextEntry entry = sender as TextEntry; if (entry == null) { return; } string filePath = entry.Text; string directory = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFiles); string fileName = ""; if (!string.IsNullOrEmpty (filePath)) { FileInfo info = new FileInfo (filePath); directory = info.DirectoryName; fileName = info.Name; } FileDialog dialog = new OpenFileDialog { CurrentFolder = directory, InitialFileName = fileName }; if (dialog.Run ()) { entry.Text = Path.Combine (dialog.CurrentFolder, dialog.FileName); } }
/// <summary> /// Open new scenario. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OpenNewServer(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(Director.Properties.Resources.DialogOpenScenario); dlg.Multiselect = false; dlg.Filters.Add(new FileDialogFilter("Director files", "*.adfe")); if (dlg.Run()) { try { UServer = Deserialization.DeserializeAll(dlg.FileNames[0]); String messageType = Director.Properties.Resources.ImportResult; if (UServer == null) { MessageDialog.ShowMessage(messageType, Deserialization.errorMessage); return; } } catch { MessageDialog.ShowError(Director.Properties.Resources.DialogInvalidFile); return; } // Refresh tree RefreshServerTreeView(); // Enable close sceanrio EnableServerButtons(); } }
public Windows() { Button b = new Button ("Show borderless window"); PackStart (b); b.Clicked += delegate { Window w = new Window (); w.Decorated = false; Button c = new Button ("This is a window"); // c.Margin.SetAll (10); w.Content = c; c.Clicked += delegate { w.Dispose (); }; var bpos = b.ScreenBounds; w.ScreenBounds = new Rectangle (bpos.X, bpos.Y + b.Size.Height, w.Width, w.Height); w.Show (); }; b = new Button ("Show message dialog"); PackStart (b); b.Clicked += delegate { MessageDialog.ShowMessage (ParentWindow, "Hi there!"); }; Button db = new Button ("Show custom dialog"); PackStart (db); db.Clicked += delegate { Dialog d = new Dialog (); d.Title = "This is a dialog"; Table t = new Table (); t.Attach (new Label ("Some field:"), 0, 1, 0, 1); t.Attach (new TextEntry (), 1, 2, 0, 1); t.Attach (new Label ("Another field:"), 0, 1, 1, 2); t.Attach (new TextEntry (), 1, 2, 1, 2); d.Content = t; Command custom = new Command ("Custom"); d.Buttons.Add (new DialogButton (custom)); d.Buttons.Add (new DialogButton ("Custom OK", Command.Ok)); d.Buttons.Add (new DialogButton (Command.Cancel)); d.Buttons.Add (new DialogButton (Command.Ok)); var r = d.Run (this.ParentWindow); db.Label = "Result: " + r.Label; d.Dispose (); }; b = new Button ("Show Open File dialog"); PackStart (b); b.Clicked += delegate { OpenFileDialog dlg = new OpenFileDialog ("Select a file"); dlg.InitialFileName = "Some file"; dlg.Multiselect = true; dlg.Filters.Add (new FileDialogFilter ("Xwt files", "*.xwt")); dlg.Filters.Add (new FileDialogFilter ("All files", "*.*")); if (dlg.Run ()) MessageDialog.ShowMessage ("Files have been selected!", string.Join ("\n", dlg.FileNames)); }; b = new Button ("Show Save File dialog"); PackStart (b); b.Clicked += delegate { SaveFileDialog dlg = new SaveFileDialog ("Select a file"); dlg.InitialFileName = "Some file"; dlg.Multiselect = true; dlg.Filters.Add (new FileDialogFilter ("Xwt files", "*.xwt")); dlg.Filters.Add (new FileDialogFilter ("All files", "*.*")); if (dlg.Run ()) MessageDialog.ShowMessage ("Files have been selected!", string.Join ("\n", dlg.FileNames)); }; b = new Button ("Show Select Folder dialog (Multi select)"); PackStart (b); b.Clicked += delegate { SelectFolderDialog dlg = new SelectFolderDialog ("Select some folder"); dlg.Multiselect = true; if (dlg.Run ()) MessageDialog.ShowMessage ("Folders have been selected!", string.Join ("\n", dlg.Folders)); }; b = new Button ("Show Select Folder dialog (Single select)"); PackStart (b); b.Clicked += delegate { SelectFolderDialog dlg = new SelectFolderDialog ("Select a folder"); dlg.Multiselect = false; if (dlg.Run ()) MessageDialog.ShowMessage ("Folders have been selected!", string.Join ("\n", dlg.Folders)); }; b = new Button ("Show Select Color dialog"); PackStart (b); b.Clicked += delegate { SelectColorDialog dlg = new SelectColorDialog ("Select a color"); dlg.SupportsAlpha = true; dlg.Color = Xwt.Drawing.Colors.AliceBlue; if (dlg.Run (ParentWindow)) MessageDialog.ShowMessage ("A color has been selected!", dlg.Color.ToString ()); }; b = new Button("Show window shown event"); PackStart(b); b.Clicked += delegate { Window w = new Window(); w.Decorated = false; Button c = new Button("This is a window with events on"); w.Content = c; c.Clicked += delegate { w.Dispose(); }; w.Shown += (sender, args) => MessageDialog.ShowMessage("My Parent has been shown"); w.Hidden += (sender, args) => MessageDialog.ShowMessage("My Parent has been hidden"); w.Show(); }; }
private void SelectCommand() { using (var fileSelect = new OpenFileDialog("Choose executable")) { fileSelect.Multiselect = false; if (fileSelect.Run(this)) { commandNameEntry.TooltipText = commandNameEntry.Text = fileSelect.FileName; } } }
/// <summary> /// Select file. /// </summary> private void SelectFile_Clicked(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(Director.Properties.Resources.DialogOpenScenario); dlg.Multiselect = false; dlg.Filters.Add(new FileDialogFilter("All files", "*.*")); if (dlg.Run()) FilePath.Text = dlg.FileName; }
/// <summary> /// Add a new glade file in the datastore /// </summary> /// <param name='sender'> /// Sender. /// </param> /// <param name='e'> /// E. /// </param> void HandleBtnAddClicked(object sender, EventArgs e) { OpenFileDialog fc = new OpenFileDialog("select a glade file"); fc.Filters.Add(new FileDialogFilter("Glade","*.glade")); if (fc.Run()) { GladeFile gf = new GladeFile(fc.FileName); gf.WindowName = "window1"; gf.Namespace = "window1"; gf.ClassName = "window1"; gf.CreateImplementation = true; gf.OutputPath = new FileInfo(fc.FileName).Directory.FullName; TsData.AddNode().SetValue(dfFilename,gf.Filename).SetValue(dfGladefile,gf); } }
public Windows() { Button bp = new Button ("Show borderless window"); PackStart (bp); bp.Clicked += delegate { Window w = new Window (); w.Decorated = false; Button c = new Button ("This is a window"); // c.Margin.SetAll (10); w.Content = c; c.Clicked += delegate { w.Dispose (); }; var bpos = bp.ScreenBounds; w.ScreenBounds = new Rectangle (bpos.X, bpos.Y + bp.Size.Height, w.Width, w.Height); w.Show (); }; Button b = new Button ("Show message dialog"); PackStart (b); b.Clicked += delegate { MessageDialog.ShowMessage (ParentWindow, "Hi there!"); }; Button db = new Button ("Show custom dialog"); PackStart (db); db.Clicked += delegate { Dialog d = new Dialog (); d.Title = "This is a dialog"; Table t = new Table (); t.Add (new Label ("Some field:"), 0, 0); t.Add (new TextEntry (), 1, 0); t.Add (new Label ("Another field:"), 0, 1); t.Add (new TextEntry (), 1, 1); d.Content = t; d.CloseRequested += delegate(object sender, CloseRequestedEventArgs args) { args.AllowClose = MessageDialog.Confirm ("Really close?", Command.Close); }; Command custom = new Command ("Custom"); d.Buttons.Add (new DialogButton (custom)); d.Buttons.Add (new DialogButton ("Custom OK", Command.Ok)); d.Buttons.Add (new DialogButton (Command.Cancel)); d.Buttons.Add (new DialogButton (Command.Ok)); var r = d.Run (this.ParentWindow); db.Label = "Result: " + (r != null ? r.Label : "(Closed)"); d.Dispose (); }; b = new Button ("Show Open File dialog"); PackStart (b); b.Clicked += delegate { OpenFileDialog dlg = new OpenFileDialog ("Select a file"); dlg.InitialFileName = "Some file"; dlg.Multiselect = true; dlg.Filters.Add (new FileDialogFilter ("Xwt files", "*.xwt")); dlg.Filters.Add (new FileDialogFilter ("All files", "*.*")); if (dlg.Run ()) MessageDialog.ShowMessage ("Files have been selected!", string.Join ("\n", dlg.FileNames)); }; b = new Button ("Show Save File dialog"); PackStart (b); b.Clicked += delegate { SaveFileDialog dlg = new SaveFileDialog ("Select a file"); dlg.InitialFileName = "Some file"; dlg.Multiselect = true; dlg.Filters.Add (new FileDialogFilter ("Xwt files", "*.xwt")); dlg.Filters.Add (new FileDialogFilter ("All files", "*.*")); if (dlg.Run ()) MessageDialog.ShowMessage ("Files have been selected!", string.Join ("\n", dlg.FileNames)); }; b = new Button ("Show Select Folder dialog (Multi select)"); PackStart (b); b.Clicked += delegate { SelectFolderDialog dlg = new SelectFolderDialog ("Select some folder"); dlg.Multiselect = true; if (dlg.Run ()) MessageDialog.ShowMessage ("Folders have been selected!", string.Join ("\n", dlg.Folders)); }; b = new Button ("Show Select Folder dialog (Single select)"); PackStart (b); b.Clicked += delegate { SelectFolderDialog dlg = new SelectFolderDialog ("Select a folder"); dlg.Multiselect = false; if (dlg.Run ()) MessageDialog.ShowMessage ("Folders have been selected!", string.Join ("\n", dlg.Folders)); }; b = new Button ("Show Select Folder dialog (Single select, allow creation)"); PackStart (b); b.Clicked += delegate { SelectFolderDialog dlg = new SelectFolderDialog ("Select or create a folder"); dlg.Multiselect = false; dlg.CanCreateFolders = true; if (dlg.Run ()) MessageDialog.ShowMessage ("Folders have been selected/created!", string.Join ("\n", dlg.Folders)); }; b = new Button ("Show Select Color dialog"); PackStart (b); b.Clicked += delegate { SelectColorDialog dlg = new SelectColorDialog ("Select a color"); dlg.SupportsAlpha = true; dlg.Color = Xwt.Drawing.Colors.AliceBlue; if (dlg.Run (ParentWindow)) MessageDialog.ShowMessage ("A color has been selected!", dlg.Color.ToString ()); }; b = new Button("Show window shown event"); PackStart(b); b.Clicked += delegate { Window w = new Window(); w.Decorated = false; Button c = new Button("This is a window with events on"); w.Content = c; c.Clicked += delegate { w.Dispose(); }; w.Shown += (sender, args) => MessageDialog.ShowMessage("My Parent has been shown"); w.Hidden += (sender, args) => MessageDialog.ShowMessage("My Parent has been hidden"); w.Show(); }; b = new Button("Show dialog with dynamically updating content"); PackStart(b); b.Clicked += delegate { var dialog = new Dialog (); dialog.Content = new Label ("Hello World"); Xwt.Application.TimeoutInvoke (TimeSpan.FromSeconds (2), () => { dialog.Content = new Label ("Goodbye World"); return false; }); dialog.Run (); }; }
/// <summary> /// Start apiary import. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ApiaryImport_Clicked(object sender, EventArgs e) { // Info MessageDialog.ShowMessage(Director.Properties.Resources.InfoApiarySnowcrash); // Show open file dialog OpenFileDialog of = new OpenFileDialog(Director.Properties.Resources.SelectJsonFile); of.Multiselect = false; of.Filters.Add(new FileDialogFilter("Json files", "*.json")); if (of.Run()) { Server tmp = UServer; if (tmp == null) { tmp = new Server(); } // Process result Boolean result = Apiary.ProcessApiaryFile(tmp, of.FileName); // Set again UServer = tmp; if (result) { // Refresh tree RefreshServerTreeView(); // Enable close sceanrio EnableServerButtons(); } } }
public bool OpenDialog() { OpenFileDialog openDialog = new OpenFileDialog("Open Project"); openDialog.Filters.Add(new FileDialogFilter("BAIMP Project file", "*.baimp")); if (openDialog.Run()) { if (string.IsNullOrEmpty(openDialog.FileName)) { return false; } if (!Open(openDialog.FileName)) { return false; } return scanCollection != null && scanCollection.Count > 0; } return false; }
void HandleOpenFileClicked(object sender, EventArgs e) { OpenFileDialog fc = new OpenFileDialog("select a gladebuilder file"); fc.Filters.Add(new FileDialogFilter("Gladebuilder","*.gladebuilder")); if (fc.Run()) { loadData(fc.FileName); } }