ComparisonInfo RequestComparisonInfo() { uint cid = statusbar.GetContextId("assemblies"); statusbar.Pop(cid); statusbar.Push(cid, "Choosing Base Assembly"); FileChooserDialog d = new FileChooserDialog("Choose Base Assembly", this, FileChooserAction.Open, Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Accept); FileFilter filter = new FileFilter(); filter.AddPattern("*.dll"); d.Filter = filter; if ((ResponseType)d.Run() == ResponseType.Cancel) { d.Destroy(); return(null); } d.Hide(); string base_path = d.Filename; statusbar.Pop(cid); statusbar.Push(cid, "Choosing Target Assembly"); d.Title = "Choose Target Assembly"; if ((ResponseType)d.Run() == ResponseType.Cancel) { d.Destroy(); return(null); } string target_path = d.Filename; d.Hide(); d.Destroy(); return(new ComparisonInfo(base_path, target_path)); }
private void ShowOpenDBDialog() { try { FileChooserDialog dlg = new FileChooserDialog(Catalog.GetString("Open Database"), null, FileChooserAction.Open, Catalog.GetString("Cancel"), ResponseType.Cancel, Catalog.GetString("Open"), ResponseType.Accept); dlg.SetCurrentFolder(AppConfig.DataDirectory); FileFilter filter = new FileFilter(); filter.Name = "OCM Databases"; filter.AddPattern("*.ocm"); dlg.AddFilter(filter); if (dlg.Run() == (int)ResponseType.Accept) { dlg.Hide(); AppConfig.DBFile = dlg.Filename; m_Store = new FileStore(dlg.Filename); } else { dlg.Hide(); } } catch (Exception) { return; } }
protected virtual void OnOpenButtonClicked(object sender, System.EventArgs e) { FileChooserDialog dlg = null; try { dlg = new FileChooserDialog(Catalog.GetString("Open Map Description File"), null, FileChooserAction.Open, Catalog.GetString("Cancel"), ResponseType.Cancel, Catalog.GetString("Open"), ResponseType.Accept); //dlg.SetCurrentFolder (m_conf.DataDirectory); FileFilter filter = new FileFilter(); filter.Name = Catalog.GetString("OCM Map Files"); filter.AddPattern("*.xml"); dlg.AddFilter(filter); if (dlg.Run() == (int)ResponseType.Accept) { dlg.Hide(); m_maps.AddRange(MapManager.GetMapsFromFile(dlg.Filename)); ReloadMaps(); dlg.Destroy(); } else { dlg.Hide(); dlg.Destroy(); } } catch (Exception exception) { OCMApp.ShowException(exception); if (dlg != null) { dlg.Hide(); dlg.Destroy(); } } }
protected void LoadTextFile(ref string FileName, string title, TextView view, Entry entry, bool isTraining = false, SpinButton counter = null) { TextLoader.Title = title; // Add most recent directory if (!string.IsNullOrEmpty(TextLoader.Filename)) { var directory = System.IO.Path.GetDirectoryName(TextLoader.Filename); if (Directory.Exists(directory)) { TextLoader.SetCurrentFolder(directory); } } if (TextLoader.Run() == (int)ResponseType.Accept) { if (!string.IsNullOrEmpty(TextLoader.Filename)) { FileName = TextLoader.Filename; ReloadTextFile(FileName, view, isTraining, counter); if (entry != null) { entry.Text = FileName; } } } TextLoader.Hide(); }
public static bool SaveProjectAs() { FileChooserDialog dialog = new FileChooserDialog(Catalog.GetString("Save Stetic File As"), null, FileChooserAction.Save, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Save, Gtk.ResponseType.Ok); if (Project.FileName != null) { dialog.CurrentName = Project.FileName; } int response = dialog.Run(); if (response == (int)Gtk.ResponseType.Ok) { string name = dialog.Filename; if (System.IO.Path.GetExtension(name) == "") { name = name + ".stetic"; } try { Project.Save(name); Project.Modified = false; SteticMain.UIManager.AddRecentFile(name); } catch (Exception ex) { ReportError(Catalog.GetString("The project could not be saved."), ex); return(false); } } dialog.Hide(); return(true); }
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.Name + " " + 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(); }
private void Generate(object sender, EventArgs a) { if (meetingNotes == null) { return; } var saveFileDialog = new FileChooserDialog("Save report as ...", this, FileChooserAction.Save, "OK", ResponseType.Ok, "Cancel", ResponseType.Cancel); saveFileDialog.SetFilename("report.docx"); var dialogResult = saveFileDialog.Run(); saveFileDialog.Hide(); if (dialogResult != (int)ResponseType.Ok) { return; } var filename = saveFileDialog.Filename; GenerationHelper.GenerateAndOpen(filename, meetingNotes); }
protected void OnOpenActionActivated(object sender, EventArgs e) { FileChooserDialog Chooser = new FileChooserDialog("Выберите файл шаблона распознования...", this, FileChooserAction.Open, "Отмена", ResponseType.Cancel, "Открыть", ResponseType.Accept); FileFilter Filter = new FileFilter(); Filter.AddMimeType("text/xml"); Filter.AddPattern("*.xml"); Filter.Name = "xml"; Chooser.AddFilter(Filter); if ((ResponseType)Chooser.Run() == ResponseType.Accept) { Chooser.Hide(); FileStream fs = new FileStream(Chooser.Filename, FileMode.Open, FileAccess.Read); //FIXME Обработать ошибки загрузки. DocTemplate = RecognizeTemplate.Load(fs); fs.Close(); labelTemplateName.LabelProp = DocTemplate.Name; DocTemplate.DocTypeId = TypeId; } Chooser.Destroy(); }
protected void OnButtonLoadPhotoClicked(object sender, EventArgs e) { FileChooserDialog Chooser = new FileChooserDialog("Выберите фото для загрузки...", (Window)this.Toplevel, FileChooserAction.Open, "Отмена", ResponseType.Cancel, "Загрузить", ResponseType.Accept); FileFilter Filter = new FileFilter(); Filter.AddPixbufFormats(); Filter.Name = "Все изображения"; Chooser.AddFilter(Filter); if ((ResponseType)Chooser.Run() == ResponseType.Accept) { Chooser.Hide(); logger.Info("Загрузка фотографии..."); ImageFile = ImageHelper.LoadImageToJpgBytes(Chooser.Filename); buttonSavePhoto.Sensitive = true; logger.Info("Ok"); } Chooser.Destroy(); }
// File Menu protected virtual void OnOpenActivated(object sender, System.EventArgs e) { BuildFilters(); using (FileChooserDialog fcd = new FileChooserDialog("Open Assembly...", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept)) { if (current_directory != null) { fcd.SetCurrentFolder(current_directory); } fcd.SelectMultiple = true; fcd.AddFilter(dotnet_filter); fcd.AddFilter(list_filter); fcd.AddFilter(all_filter); bool ok = (fcd.Run() == (int)ResponseType.Accept); fcd.Hide(); if (ok) { Load(fcd.Filenames); current_directory = fcd.CurrentFolder; } } }
static void openButton_Clicked(object sender, EventArgs e) { FileChooserDialog fcd = new FileChooserDialog("Open page...", (Window)((Widget)sender).Toplevel, FileChooserAction.Open); fcd.AddButton(Stock.Cancel, ResponseType.Cancel); fcd.AddButton(Stock.Open, ResponseType.Ok); fcd.DefaultResponse = ResponseType.Ok; fcd.Filter = new FileFilter(); fcd.Filter.AddPattern("*.aspx"); fcd.SelectMultiple = false; ResponseType response = (ResponseType)fcd.Run( ); fcd.Hide(); if (response == ResponseType.Ok && fcd.Filename != null) { using (FileStream fileStream = new FileStream(fcd.Filename, FileMode.Open)) { if (fileStream == null) { return; } host.Reset(); host.Load(fileStream, fcd.Filename); host.Activate(); } } fcd.Destroy(); }
static void toolboxAddButton_Clicked(object sender, EventArgs e) { FileChooserDialog fcd = new FileChooserDialog("Add custom controls...", (Window)((Widget)sender).Toplevel, FileChooserAction.Open); fcd.AddButton(Stock.Cancel, ResponseType.Cancel); fcd.AddButton(Stock.Open, ResponseType.Ok); fcd.DefaultResponse = ResponseType.Ok; fcd.Filter = new FileFilter(); fcd.Filter.AddPattern("*.dll"); fcd.SelectMultiple = false; ResponseType response = (ResponseType)fcd.Run( ); fcd.Hide(); if (response == ResponseType.Ok && fcd.Filename != null) { try{ System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom(fcd.Filename); toolboxService.PopulateFromAssembly(a); } catch (Exception ex) { //TODO: handle this better! System.Diagnostics.Trace.WriteLine("Could not load assembly \"" + fcd.Filename + "\"."); } } fcd.Destroy(); }
protected void SaveImage(FileChooserDialog dialog, string title, Pixbuf pixbuf) { dialog.Title = title; if (!string.IsNullOrEmpty(dialog.Filename)) { var directory = System.IO.Path.GetDirectoryName(dialog.Filename); if (Directory.Exists(directory)) { dialog.SetCurrentFolder(directory); } } if (dialog.Run() == Convert.ToInt32(ResponseType.Accept)) { if (!string.IsNullOrEmpty(dialog.Filename)) { var FileName = dialog.Filename; if (!FileName.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) { FileName += ".png"; } pixbuf.Save(FileName, "png"); } } dialog.Hide(); }
static void saveButton_Clicked(object sender, EventArgs e) { FileChooserDialog fcd = new FileChooserDialog("Save page as...", (Window)((Widget)sender).Toplevel, FileChooserAction.Save); fcd.AddButton(Stock.Cancel, ResponseType.Cancel); fcd.AddButton(Stock.Save, ResponseType.Ok); fcd.DefaultResponse = ResponseType.Ok; fcd.Filter = new FileFilter(); fcd.Filter.AddPattern("*.aspx"); fcd.SelectMultiple = false; fcd.SetFilename(((System.Web.UI.Control)host.RootComponent).ID + ".aspx"); ResponseType response = (ResponseType)fcd.Run(); fcd.Hide(); if (response == ResponseType.Ok && fcd.Filename != null) { using (FileStream fileStream = new FileStream(fcd.Filename, FileMode.Create)) { if (fileStream == null) { return; } host.SaveDocument(fileStream); } } fcd.Destroy(); }
/// <summary> /// Raises the button clicked event. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> protected void OnBtnClicked(object sender, EventArgs e) { this.Log().Info("Button clicked"); FileChooserDialog chooser = new FileChooserDialog( "Please select an image", null, FileChooserAction.Open, new object[] { "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept }); int result = chooser.Run(); this.Log().Info("Dialog result: " + result.ToString()); if (result == ( int )ResponseType.Accept) { this.Log().Info("Dialog accepted, filename picked: " + chooser.Filename); filename = chooser.Filename; ValidateImage(); } UpdateImage(); chooser.Hide(); }
protected void OnButtonAddImageClicked(object sender, EventArgs e) { FileChooserDialog Chooser = new FileChooserDialog("Выберите изображение...", (Window)this.Toplevel, FileChooserAction.Open, "Отмена", ResponseType.Cancel, "Загрузить", ResponseType.Accept); FileFilter Filter = new FileFilter(); Filter.AddPixbufFormats(); Filter.Name = "Все изображения"; Chooser.AddFilter(Filter); if ((ResponseType)Chooser.Run() == ResponseType.Accept) { Chooser.Hide(); logger.Info("Загрузка изображения..."); var imageFile = ImageHelper.LoadImageToJpgBytes(Chooser.Filename); Entity.Images.Add(new NomenclatureImage(Entity, imageFile)); ReloadImages(); logger.Info("Ok"); } Chooser.Destroy(); }
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(); }
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("Ок"); }
// File -> Save transcript void OnSaveTranscript(object sender, EventArgs args) { FileChooserDialog dlg = new FileChooserDialog("Save transcript", null, FileChooserAction.Save, new object[] { Stock.Cancel, ResponseType.Cancel, Stock.Ok, ResponseType.Ok }); dlg.DefaultResponse = ResponseType.Ok; for (;;) { if ((ResponseType)dlg.Run() == ResponseType.Ok) { if (DoSaveTranscript(dlg.Filename)) { break; } } else { break; } } dlg.Hide(); }
protected void OnSaveProcessedImageButtonClicked(object o, EventArgs e) { if (ControlsActive) { if (GtkSelection.Selection.Count() > 0) { ImageSaver.Title = "Save Processed Image"; if (!string.IsNullOrEmpty(ImageSaver.Filename)) { var directory = System.IO.Path.GetDirectoryName(ImageSaver.Filename); if (Directory.Exists(directory)) { ImageSaver.SetCurrentFolder(directory); } } if (ImageSaver.Run() == Convert.ToInt32(ResponseType.Accept)) { if (!string.IsNullOrEmpty(ImageSaver.Filename)) { var FileName = ImageSaver.Filename; if (!FileName.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) { FileName += ".png"; } var ScaleX = Convert.ToDouble(OriginalImage.Width) / cameraImage.WidthRequest; var ScaleY = Convert.ToDouble(OriginalImage.Height) / cameraImage.HeightRequest; using (Pixbuf pb = GtkSelection.Render(OriginalImage, opencv, GtkSelection.MarkerColor, GtkSelection.Selected, GtkSelection.SelectedColor, false, true, ScaleX, ScaleY)) { if (cameraImage.Pixbuf != null && pb != null) { pb.Save(FileName, "png"); } } } } ImageSaver.Hide(); } } }
protected void OnOpenActionActivated(object sender, EventArgs e) { TreeIter iter; FileChooserDialog Chooser = new FileChooserDialog( "Выберите изображения для загрузки...", this, FileChooserAction.Open, "Отмена", ResponseType.Cancel, "Открыть", ResponseType.Accept ) { SelectMultiple = true }; FileFilter Filter = new FileFilter(); Filter.AddPixbufFormats(); Filter.Name = "Все изображения"; Chooser.AddFilter(Filter); if ((ResponseType)Chooser.Run() == ResponseType.Accept) { Chooser.Hide(); progresswork.Text = "Загрузка изображений..."; progresswork.Adjustment.Upper = Chooser.Filenames.Length; foreach (string File in Chooser.Filenames) { logger.Debug(File); iter = ImageListNewDoc(); FileStream fs = new FileStream(File, FileMode.Open, FileAccess.Read); Pixbuf image = new Pixbuf(fs); double ratio = 150f / Math.Max(image.Height, image.Width); Pixbuf thumb = image.ScaleSimple((int)(image.Width * ratio), (int)(image.Height * ratio), InterpType.Bilinear); fs.Close(); ImageList.AppendValues(iter, 0, System.IO.Path.GetFileName(File), File, null, thumb, image, true, "", ""); progresswork.Adjustment.Value++; MainClass.WaitRedraw(); } treeviewImages.ExpandAll(); progresswork.Text = "Ок"; progresswork.Fraction = 0; } Chooser.Destroy(); }
private void ChooserOnFileActivated(object sender, EventArgs e) { Callback(_chooserDialog.Filename); if (e != null) { _chooserDialog.Hide(); } }
protected void OnSaveBlobsButtonClicked(object o, EventArgs e) { // Add most recent directory if (!string.IsNullOrEmpty(FolderChooser.CurrentFolder)) { if (Directory.Exists(FolderChooser.CurrentFolder)) { FolderChooser.SetCurrentFolder(FolderChooser.CurrentFolder); } } else if (!string.IsNullOrEmpty(ImageLoader.Filename)) { var directory = System.IO.Path.GetDirectoryName(ImageLoader.Filename); if (Directory.Exists(directory)) { FolderChooser.SetCurrentFolder(directory); } } if (FolderChooser.Run() == Convert.ToInt32(ResponseType.Accept)) { var blobs = GtkSelection.Selection.BoundingBoxes(); if (!string.IsNullOrEmpty(FolderChooser.CurrentFolder) && !string.IsNullOrEmpty(ImageLoader.Filename) && blobs.Count > 0) { var basefile = System.IO.Path.GetFileNameWithoutExtension(ImageLoader.Filename); var index = 1; foreach (var rectangle in blobs) { var ScaleX = Convert.ToDouble(OriginalImage.Width) / imageBox.WidthRequest; var ScaleY = Convert.ToDouble(OriginalImage.Height) / imageBox.HeightRequest; var width = Convert.ToInt32(Math.Abs(rectangle.X1 - rectangle.X0) * ScaleX); var height = Convert.ToInt32(Math.Abs(rectangle.Y1 - rectangle.Y0) * ScaleY); var top = Convert.ToInt32(Math.Min(rectangle.Y0, rectangle.Y1) * ScaleY); var left = Convert.ToInt32(Math.Min(rectangle.X0, rectangle.X1) * ScaleX); var area = new Pixbuf(Colorspace.Rgb, false, 8, width, height); if (OriginalImage != null) { OriginalImage.CopyArea(left, top, width, height, area, 0, 0); area.Save(String.Format("{0}/{1}-blob-{2}.png", FolderChooser.CurrentFolder, basefile, index.ToString("D4")), "png"); } area.Dispose(); index++; } } } FolderChooser.Hide(); }
protected void OnImportImage(object o, EventArgs e) { FileChooserDialog fileChooser = new FileChooserDialog("Select ImageFile", MainWindow, FileChooserAction.Open, new object[] {}); fileChooser.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel); fileChooser.AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok); fileChooser.DefaultResponse = Gtk.ResponseType.Ok; Gtk.FileFilter all = new Gtk.FileFilter(); all.Name = "All Files"; all.AddPattern("*"); fileChooser.AddFilter(all); int result = fileChooser.Run(); fileChooser.Hide(); if (result != (int)ResponseType.Ok) { return; } string file = fileChooser.Filename; string trim = tilesetdir + "/"; if (!file.StartsWith(trim)) { Console.WriteLine( "Imported file must be located inside tileset directory"); return; } ChangeImage(file.TrimStart(trim.ToCharArray())); int startid = tileset.Tiles.Count; for (int y = 0; y < TilesY; ++y) { for (int x = 0; x < TilesX; ++x) { int i = y * TilesX + x; Tile tile = new Tile(); tile.ID = startid + i; ImageRegion region = new ImageRegion(); region.ImageFile = currentimage; region.Region = new System.Drawing.Rectangle(x * TileSet.TILE_WIDTH, y * TileSet.TILE_HEIGHT, TileSet.TILE_WIDTH, TileSet.TILE_HEIGHT); tile.Images.Add(region); if (Tiles[i] != null) { Console.WriteLine( "Warning Tile in this region already existed..."); } Tiles[i] = tile; tileset.Tiles.Add(tile); } } FillTileList(); }
protected async void OnYbuttonSaveClicked(object sender, EventArgs e) { var extension = ".xlsx"; var filechooser = new FileChooserDialog("Сохранить отчет...", null, FileChooserAction.Save, "Отменить", ResponseType.Cancel, "Сохранить", ResponseType.Accept) { DoOverwriteConfirmation = true, CurrentName = $"{Tab.TabName} {ViewModel.Report.CreationDate:yyyy-MM-dd-HH-mm}{extension}" }; var excelFilter = new FileFilter { Name = $"Документ Microsoft Excel ({extension})" }; excelFilter.AddMimeType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); excelFilter.AddPattern($"*{extension}"); filechooser.AddFilter(excelFilter); if (filechooser.Run() == (int)ResponseType.Accept) { var path = filechooser.Filename; if (!path.Contains(extension)) { path += extension; } filechooser.Hide(); ViewModel.IsSaving = true; await Task.Run(() => { try { ybuttonSave.Label = "Отчет сохраняется..."; ViewModel.ExportReport(path); } finally { Application.Invoke((s, eventArgs) => { ViewModel.IsSaving = false; ybuttonSave.Label = "Сохранить"; }); } }); } filechooser.Destroy(); }
protected void SaveTextFile(ref string FileName, string title, Entry entry, ManagedArray data) { TextSaver.Title = title; TextSaver.SelectFilename(FileName); string directory; // Add most recent directory if (!string.IsNullOrEmpty(TextSaver.Filename)) { directory = System.IO.Path.GetDirectoryName(TextSaver.Filename); if (Directory.Exists(directory)) { TextSaver.SetCurrentFolder(directory); } } if (TextSaver.Run() == (int)ResponseType.Accept) { if (!string.IsNullOrEmpty(TextSaver.Filename)) { FileName = TextSaver.Filename; directory = GetDirectory(FileName); var ext = TextSaver.Filter.Name; FileName = String.Format("{0}.{1}", GetBaseFileName(FileName), ext); if (data != null) { var current = DelimiterBox.Active; var delimiter = current >= 0 && current < Delimiters.Count ? Delimiters[current].Character : '\t'; var fullpath = String.Format("{0}/{1}", directory, FileName); try { ManagedFile.Save2D(fullpath, data, delimiter); FileName = fullpath; entry.Text = FileName; } catch (Exception ex) { Console.WriteLine("Error saving {0}: {1}", FileName, ex.Message); } } } } TextSaver.Hide(); }
protected async void OnYbuttonSaveClicked(object sender, EventArgs e) { var extension = ".xlsx"; var filechooser = new FileChooserDialog("Сохранить отчет...", null, FileChooserAction.Save, "Отменить", ResponseType.Cancel, "Сохранить", ResponseType.Accept) { DoOverwriteConfirmation = true, CurrentName = $"{ViewModel.Title} {DateTime.Now:yyyy-MM-dd-HH-mm}{extension}" }; var excelFilter = new FileFilter { Name = $"Документ Microsoft Excel ({extension})" }; excelFilter.AddMimeType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); excelFilter.AddPattern($"*{extension}"); filechooser.AddFilter(excelFilter); if (filechooser.Run() == (int)ResponseType.Accept) { var path = filechooser.Filename; if (!path.Contains(extension)) { path += extension; } filechooser.Hide(); await Task.Run(() => { try { datatreeviewDocuments.SetItemsSource(ViewModel.Report.Rows); string templatePath = @".\Reports\Cars\ReportOnTheCostsOfOperatingCars.xlsx"; var template = new XLTemplate(templatePath); template.AddVariable(ViewModel.Report); template.Generate(); template.SaveAs(path); } catch (Exception ex) { Application.Invoke((s, eventArgs) => { throw ex; }); } }); } filechooser.Destroy(); }
private void OpenDocButton_Clicked(object sender, EventArgs e) { var response = chooserDialog.Run(); if ((ResponseType)response == ResponseType.Ok) { filePathEntry.Text = chooserDialog.File.Path; } chooserDialog.Hide(); }
void OnChoose(object sender, EventArgs args) { chooseDialog.SetFilename(sMSPDebugPath.Text); ResponseType r = (ResponseType)chooseDialog.Run(); chooseDialog.Hide(); if (r == ResponseType.Ok) { sMSPDebugPath.Text = chooseDialog.Filename; } }
protected void OnOpen(object o, EventArgs e) { if (!ChangeConfirm("load a new level")) { return; } fileChooser.Title = "Choose a Level"; fileChooser.Action = FileChooserAction.Open; fileChooser.SetCurrentFolder(Settings.Instance.LastDirectoryName); fileChooser.Filter = fileChooser.Filters[0]; int result = fileChooser.Run(); fileChooser.Hide(); if (result != (int)ResponseType.Ok) { return; } Settings.Instance.LastDirectoryName = fileChooser.CurrentFolder; Settings.Instance.Save(); Load(fileChooser.Filename); }