playing around with printing stuff - nothing production ready yet
This commit is contained in:
parent
844dc18392
commit
6f6488fb8e
@ -0,0 +1,69 @@
|
||||
//
|
||||
// PrintDialogOptionsTab.cs
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2021 Mike Becker's Software
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
using MBS.Framework.UserInterface;
|
||||
using MBS.Framework.UserInterface.Controls;
|
||||
using UniversalEditor.Printing;
|
||||
|
||||
namespace UniversalEditor.UserInterface.Controls
|
||||
{
|
||||
[ContainerLayout(typeof(PrintDialogOptionsTabPage), "UniversalEditor.UserInterface.Controls.PrintDialogOptionsTabPage.glade")]
|
||||
public class PrintDialogOptionsTabPage : TabPage
|
||||
{
|
||||
private GroupBox fraCustomOptions;
|
||||
private ComboBox cboPrintHandler;
|
||||
|
||||
public PrintHandlerReference[] PrintHandlers { get; set; } = null;
|
||||
public PrintHandlerReference SelectedPrintHandler { get; set; } = null;
|
||||
|
||||
public PrintDialogOptionsTabPage()
|
||||
{
|
||||
Text = "Options";
|
||||
}
|
||||
|
||||
[EventHandler(nameof(cboPrintHandler), "Changed")]
|
||||
private void cboPrintHandler_Changed(object sender, EventArgs e)
|
||||
{
|
||||
fraCustomOptions.Controls.Clear();
|
||||
}
|
||||
|
||||
protected override void OnCreated(EventArgs e)
|
||||
{
|
||||
base.OnCreated(e);
|
||||
|
||||
if (PrintHandlers != null)
|
||||
{
|
||||
for (int i = 0; i < PrintHandlers.Length; i++)
|
||||
{
|
||||
(cboPrintHandler.Model as DefaultTreeModel).Rows.Add(new TreeModelRow(new TreeModelRowColumn[]
|
||||
{
|
||||
new TreeModelRowColumn(cboPrintHandler.Model.Columns[0], PrintHandlers[i].TypeName)
|
||||
}));
|
||||
}
|
||||
|
||||
if (SelectedPrintHandler != null)
|
||||
{
|
||||
cboPrintHandler.SelectedItem = (cboPrintHandler.Model as DefaultTreeModel).Rows[Array.IndexOf<PrintHandlerReference>(PrintHandlers, SelectedPrintHandler)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkListStore" id="tmPrintHandler">
|
||||
<columns>
|
||||
<!-- column-name colPrintHandlerTitle -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Print _handler</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="cboPrintHandler">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="model">tmPrintHandler</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="fraCustomOptions">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<object class="GtkAlignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Custom options</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
@ -31,6 +31,8 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using MBS.Framework.UserInterface.Controls.ListView;
|
||||
using MBS.Framework;
|
||||
using UniversalEditor.UserInterface.Controls;
|
||||
using UniversalEditor.ObjectModels.PropertyList;
|
||||
|
||||
namespace UniversalEditor.UserInterface
|
||||
{
|
||||
@ -1317,7 +1319,52 @@ namespace UniversalEditor.UserInterface
|
||||
if (phrs.Length > 0)
|
||||
{
|
||||
PrintDialog dlg = new PrintDialog();
|
||||
if (dlg.ShowDialog(this) == DialogResult.OK)
|
||||
dlg.EnablePreview = true;
|
||||
|
||||
PrintDialogOptionsTabPage tab1 = new PrintDialogOptionsTabPage();
|
||||
tab1.SelectedPrintHandler = phrs[0];
|
||||
tab1.PrintHandlers = phrs;
|
||||
|
||||
dlg.TabPages.Add(tab1);
|
||||
|
||||
DialogResult result = dlg.ShowDialog(this);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case DialogResult.Apply:
|
||||
{
|
||||
// do print preview
|
||||
|
||||
FileAccessor faINI = new FileAccessor(TemporaryFileManager.GetTemporaryFileName(), true, true, true);
|
||||
PropertyListObjectModel omINI = new PropertyListObjectModel();
|
||||
DataFormats.PropertyList.WindowsConfigurationDataFormat dfINI = new DataFormats.PropertyList.WindowsConfigurationDataFormat();
|
||||
|
||||
omINI.Items.Add(new Group("Print Settings", new PropertyListItem[]
|
||||
{
|
||||
}));
|
||||
omINI.Items.Add(new Group("Page Setup", new PropertyListItem[]
|
||||
{
|
||||
new Property("PPDName", "Letter")
|
||||
}));
|
||||
omINI.Items.Add(new Group("Print Job", new PropertyListItem[]
|
||||
{
|
||||
new Property("title", "Universal Editor Print Preview Test")
|
||||
}));
|
||||
|
||||
// we do not need to quote property values here
|
||||
dfINI.PropertyValuePrefix = String.Empty;
|
||||
dfINI.PropertyValueSuffix = String.Empty;
|
||||
|
||||
Document.Save(omINI, dfINI, faINI);
|
||||
|
||||
string pdfFileName = TemporaryFileManager.GetTemporaryFileName();
|
||||
System.IO.File.Copy("/tmp/1940.pdf", pdfFileName);
|
||||
|
||||
(Application.Instance as UIApplication).Launch("evince-previewer", String.Format("--print-settings {0} --unlink-tempfile {1}", faINI.FileName, pdfFileName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
PrintHandler ph = phrs[0].Create();
|
||||
if (ph != null)
|
||||
@ -1339,6 +1386,11 @@ namespace UniversalEditor.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
void Job_Preview(object sender, PrintPreviewEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
void Job_DrawPage(object sender, PrintEventArgs e)
|
||||
{
|
||||
PrintJob job = (sender as PrintJob);
|
||||
|
||||
@ -134,6 +134,7 @@
|
||||
<Compile Include="IDocumentPropertiesProvider.cs" />
|
||||
<Compile Include="EditorApplication.cs" />
|
||||
<Compile Include="IHostApplication.cs" />
|
||||
<Compile Include="Controls\PrintDialogOptionsTabPage.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
@ -197,6 +198,7 @@
|
||||
<EmbeddedResource Include="SettingsProviders\DefaultSettingsProvider.xml" />
|
||||
<EmbeddedResource Include="Editors\FileSystem\FileSystemEditorSettingsProvider.xml" />
|
||||
<EmbeddedResource Include="Editors\Text\Plain\PlainTextEditorSettingsProvider.xml" />
|
||||
<EmbeddedResource Include="Controls\PrintDialogOptionsTabPage.glade" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user