private bool OpenFontDialog() { FDialog.ShowApply = ShowApplyCheckBox.Checked; FDialog.ShowColor = ShowColorCheckBox.Checked; var result = FDialog.ShowDialog(); switch (result) { case DialogResult.OK: return(true); case DialogResult.Yes: return(true); case DialogResult.Retry: return(true); default: return(false); } }
public void InitPrint() { var printers = Print.PrinterSettings.InstalledPrinters.Cast <string>().ToArray(); using (doc = new Print.PrintDocument()) using (var form = new FDialog <string>()) using (var printerDropDown = new DropDown { DataStore = printers }) using (var paperDropDown = new DropDown()) using (var landscapeChk = new CheckBox { Text = "Querformat" }) using (var printButton = new Button { Text = "Drucken" }) using (var stack = new StackLayout(printerDropDown, paperDropDown, landscapeChk, printButton) { Orientation = Orientation.Horizontal, Padding = new Eto.Drawing.Padding(10), Spacing = 5 }) { form.Content = stack; form.DefaultButton = printButton; form.Title = "Bildfahrplan drucken"; printButton.Click += (s, e) => { form.Result = (string)printerDropDown.SelectedValue; form.Close(); }; printerDropDown.SelectedIndexChanged += (s, e) => { doc.PrinterSettings.PrinterName = (string)printerDropDown.SelectedValue; var paper = doc.PrinterSettings.PaperSizes.Cast <Print.PaperSize>().Select(p => p.PaperName).ToArray(); var a4Index = Array.IndexOf(paper, "A4"); paperDropDown.DataStore = paper; paperDropDown.SelectedIndex = (a4Index != -1) ? a4Index : 0; }; printerDropDown.SelectedIndex = 0; if (form.ShowModal() != null) { doc.PrintPage += Doc_PrintPage; doc.DocumentName = "Bildfahrplan generiert mit FPLedit"; doc.PrinterSettings.PrinterName = form.Result; doc.DefaultPageSettings.Margins = new Print.Margins(50, 50, 50, 50); // not working (turning page????) if (Eto.Platform.Instance.IsGtk) { var paperSize = doc.PrinterSettings.PaperSizes[paperDropDown.SelectedIndex]; //HACK: Do not use doc.DefaultPageSettings.Landscape on Linux, as it will lead to awkwardly turned rendering areas, ???) if (landscapeChk.Checked.Value) { doc.DefaultPageSettings.PaperSize = new Print.PaperSize(paperSize.PaperName, paperSize.Height, paperSize.Width); } else { doc.DefaultPageSettings.PaperSize = paperSize; } } else { doc.DefaultPageSettings.Landscape = landscapeChk.Checked.Value; } if (!doc.PrinterSettings.IsValid) { MessageBox.Show("Ungültige Druckereinstellungen!", "FPLedit", MessageBoxType.Error); } else { try { doc.Print(); } catch (Exception ex) { MessageBox.Show("Fehler beim Drucken! " + ex.Message, "FPLedit", MessageBoxType.Error); } } } } }
public void InitPrint() { var form = new FDialog <bool>(); var routesDropDown = new RoutesDropDown(); var routeStack = new StackLayout(routesDropDown) { Orientation = Orientation.Horizontal, Padding = new Eto.Drawing.Padding(10), Spacing = 5 }; var routeGroup = new GroupBox { Content = routeStack, Text = T._("Strecke auswählen") }; var widthLabel = new Label { Text = T._("Breite des Bildes (px)") }; var widthTextBox = new TextBox { Text = "1000" }; var exportButton = new Button { Text = T._("Exportieren") }; var printerStack = new StackLayout(widthLabel, widthTextBox, exportButton) { Orientation = Orientation.Horizontal, Padding = new Eto.Drawing.Padding(10), Spacing = 5 }; var printerGroup = new GroupBox { Content = printerStack, Text = T._("Exporteinstellungen") }; var stack = new StackLayout(routeGroup, printerGroup) { Orientation = Orientation.Vertical, Padding = new Eto.Drawing.Padding(10), Spacing = 5 }; routesDropDown.Initialize(pluginInterface); routesDropDown.EnableVirtualRoutes = true; form.Content = stack; form.DefaultButton = exportButton; form.Title = T._("Bildfahrplan drucken"); exportButton.Click += (s, e) => { form.Result = true; form.Close(); }; if (form.ShowModal()) { var width = 0; int.TryParse(widthTextBox.Text, out width); if (width == 0) { pluginInterface.Logger.Error("Ungültige Breite angegeben!"); return; } var exportFileDialog = new SaveFileDialog { Title = T._("Bildfahrplan exportieren") }; exportFileDialog.Filters.Add(new FileFilter("PNG-Datei", ".png")); if (exportFileDialog.ShowDialog(pluginInterface.RootForm) == DialogResult.Ok) { var filename = exportFileDialog.FileName; var export = new BitmapExport(routesDropDown.SelectedRoute, width, ImageFormat.Png); pluginInterface.Logger.Info(T._("Exportiere Bildfahrplan in Datei {0}", filename)); var tsk = export.GetAsyncSafeExport(tt.Clone(), filename, pluginInterface); tsk.ContinueWith((t, o) => { if (t.Result == false) { pluginInterface.Logger.Error(T._("Exportieren des Bildfahrplans fehlgeschlagen!")); } else { pluginInterface.Logger.Info(T._("Exportieren des Bildfahrplans erfolgreich abgeschlossen!")); } }, null, TaskScheduler.Default); tsk.Start(); // Non-blocking operation. } } }
public void InitPrint() { var printers = Print.PrinterSettings.InstalledPrinters.Cast <string>().ToArray(); doc = new Print.PrintDocument(); var form = new FDialog <string>(); var routesDropDown = new RoutesDropDown(); var routeStack = new StackLayout(routesDropDown) { Orientation = Orientation.Horizontal, Padding = new Eto.Drawing.Padding(10), Spacing = 5 }; var routeGroup = new GroupBox { Content = routeStack, Text = T._("Strecke auswählen") }; var printerDropDown = new DropDown { DataStore = printers }; var paperDropDown = new DropDown(); var landscapeChk = new CheckBox { Text = T._("Querformat") }; var printButton = new Button { Text = T._("Drucken") }; var printerStack = new StackLayout(printerDropDown, paperDropDown, landscapeChk, printButton) { Orientation = Orientation.Horizontal, Padding = new Eto.Drawing.Padding(10), Spacing = 5 }; var printerGroup = new GroupBox { Content = printerStack, Text = T._("Druckeinstellungen") }; var stack = new StackLayout(routeGroup, printerGroup) { Orientation = Orientation.Vertical, Padding = new Eto.Drawing.Padding(10), Spacing = 5 }; routesDropDown.Initialize(pluginInterface); routesDropDown.EnableVirtualRoutes = true; form.Content = stack; form.DefaultButton = printButton; form.Title = T._("Bildfahrplan drucken"); printButton.Click += (s, e) => { form.Result = (string)printerDropDown.SelectedValue; form.Close(); }; printerDropDown.SelectedIndexChanged += (s, e) => { doc.PrinterSettings.PrinterName = (string)printerDropDown.SelectedValue; var paper = doc.PrinterSettings.PaperSizes.Cast <Print.PaperSize>().Select(p => p.PaperName).ToArray(); var a4Index = Array.IndexOf(paper, "A4"); paperDropDown.DataStore = paper; paperDropDown.SelectedIndex = (a4Index != -1) ? a4Index : 0; }; printerDropDown.SelectedIndex = 0; if (form.ShowModal() != null) { if (routesDropDown.SelectedRoute > Timetable.UNASSIGNED_ROUTE_ID) { pd = Renderer.DefaultPathData(routesDropDown.SelectedRoute, pluginInterface.Timetable); } else { var virt = VirtualRoute.GetVRoute(pluginInterface.Timetable, routesDropDown.SelectedRoute); pd = virt !.GetPathData; } doc.PrintPage += Doc_PrintPage; doc.DocumentName = T._("Bildfahrplan generiert mit FPLedit"); doc.PrinterSettings.PrinterName = form.Result; doc.DefaultPageSettings.Margins = new Print.Margins(50, 50, 50, 50); // not working (turning page????) if (Eto.Platform.Instance.IsGtk) { var paperSize = doc.PrinterSettings.PaperSizes[paperDropDown.SelectedIndex]; //HACK: Do not use doc.DefaultPageSettings.Landscape on Linux, as it will lead to awkwardly turned rendering areas, ???) if (landscapeChk.Checked !.Value) { doc.DefaultPageSettings.PaperSize = new Print.PaperSize(paperSize.PaperName, paperSize.Height, paperSize.Width); } else { doc.DefaultPageSettings.PaperSize = paperSize; } } else { doc.DefaultPageSettings.Landscape = landscapeChk.Checked !.Value; } if (!doc.PrinterSettings.IsValid) { MessageBox.Show(T._("Ungültige Druckereinstellungen!"), "FPLedit", MessageBoxType.Error); } else { try { doc.Print(); } catch (Exception ex) { MessageBox.Show(T._("Fehler beim Drucken! {0}", ex.Message), "FPLedit", MessageBoxType.Error); } } }