mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-08-05 21:01:12 +00:00
add print example
svn path=/trunk/gtk-sharp/; revision=20348
This commit is contained in:
parent
f537b79614
commit
fd18887c61
|
@ -1,3 +1,7 @@
|
||||||
|
2003-11-22 John Luke <jluke@cfl.rr.com>
|
||||||
|
|
||||||
|
* en/Gnome/Print.xml: add example
|
||||||
|
|
||||||
2003-11-18 John Luke <jluke@cfl.rr.com>
|
2003-11-18 John Luke <jluke@cfl.rr.com>
|
||||||
|
|
||||||
* en/Gnome/CanvasPixbuf.xml: correct HeightInPixels from Sebastian <scut@nb.in-berlin.de>
|
* en/Gnome/CanvasPixbuf.xml: correct HeightInPixels from Sebastian <scut@nb.in-berlin.de>
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
<TypeSignature Language="C#" Value="public class Print" Maintainer="auto" />
|
<TypeSignature Language="C#" Value="public class Print" Maintainer="auto" />
|
||||||
<AssemblyInfo>
|
<AssemblyInfo>
|
||||||
<AssemblyName>gnome-sharp</AssemblyName>
|
<AssemblyName>gnome-sharp</AssemblyName>
|
||||||
<AssemblyPublicKey></AssemblyPublicKey>
|
<AssemblyPublicKey>
|
||||||
|
</AssemblyPublicKey>
|
||||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||||
<AssemblyCulture>neutral</AssemblyCulture>
|
<AssemblyCulture>neutral</AssemblyCulture>
|
||||||
<Attributes />
|
<Attributes />
|
||||||
|
@ -11,6 +12,91 @@
|
||||||
<Docs>
|
<Docs>
|
||||||
<summary>To be added</summary>
|
<summary>To be added</summary>
|
||||||
<remarks>To be added</remarks>
|
<remarks>To be added</remarks>
|
||||||
|
<example>
|
||||||
|
<code language="C#">
|
||||||
|
using System;
|
||||||
|
using Gtk;
|
||||||
|
using GtkSharp;
|
||||||
|
using Gnome;
|
||||||
|
|
||||||
|
class PrintSample
|
||||||
|
{
|
||||||
|
TextView tv;
|
||||||
|
|
||||||
|
static void Main ()
|
||||||
|
{
|
||||||
|
new PrintSample ();
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintSample ()
|
||||||
|
{
|
||||||
|
Application.Init ();
|
||||||
|
Gtk.Window win = new Gtk.Window ("Print sample");
|
||||||
|
win.SetDefaultSize (400, 300);
|
||||||
|
win.DeleteEvent += new DeleteEventHandler (OnWinDelete);
|
||||||
|
|
||||||
|
VBox vbox = new VBox (false, 0);
|
||||||
|
win.Add (vbox);
|
||||||
|
|
||||||
|
tv = new TextView ();
|
||||||
|
tv.Buffer.Text = "Hello World";
|
||||||
|
vbox.PackStart (tv, true, true, 0);
|
||||||
|
|
||||||
|
Button print = new Button (Gtk.Stock.Print);
|
||||||
|
print.Clicked += new EventHandler (OnPrintClicked);
|
||||||
|
vbox.PackStart (print, false, true, 0);
|
||||||
|
|
||||||
|
win.ShowAll ();
|
||||||
|
Application.Run ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyPrint (PrintContext gpc)
|
||||||
|
{
|
||||||
|
Print.Beginpage (gpc, "demo");
|
||||||
|
Print.Moveto (gpc, 1, 700);
|
||||||
|
Print.Show (gpc, tv.Buffer.Text);
|
||||||
|
Print.Showpage (gpc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnPrintClicked (object o, EventArgs args)
|
||||||
|
{
|
||||||
|
PrintJob pj = new PrintJob (PrintConfig.Default ());
|
||||||
|
PrintDialog dialog = new PrintDialog (pj, "Print Test", 0);
|
||||||
|
int response = dialog.Run ();
|
||||||
|
Console.WriteLine ("response: " + response);
|
||||||
|
|
||||||
|
if (response == (int) PrintButtons.Cancel) {
|
||||||
|
Console.WriteLine ("Canceled");
|
||||||
|
dialog.Hide ();
|
||||||
|
dialog.Dispose ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintContext ctx = pj.Context;
|
||||||
|
MyPrint (ctx);
|
||||||
|
|
||||||
|
pj.Close ();
|
||||||
|
|
||||||
|
switch (response) {
|
||||||
|
case (int) PrintButtons.Print:
|
||||||
|
pj.Print ();
|
||||||
|
break;
|
||||||
|
case (int) PrintButtons.Preview:
|
||||||
|
new PrintJobPreview (pj, "Print Test").Show ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.Hide ();
|
||||||
|
dialog.Dispose ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnWinDelete (object o, DeleteEventArgs args)
|
||||||
|
{
|
||||||
|
Application.Quit ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</example>
|
||||||
</Docs>
|
</Docs>
|
||||||
<Base>
|
<Base>
|
||||||
<BaseTypeName>System.Object</BaseTypeName>
|
<BaseTypeName>System.Object</BaseTypeName>
|
||||||
|
|
Loading…
Reference in a new issue