diff options
author | Marc-André Moreau <marcandre.moreau@gmail.com> | 2011-03-24 20:51:56 +0300 |
---|---|---|
committer | Marc-André Moreau <marcandre.moreau@gmail.com> | 2011-03-24 20:51:56 +0300 |
commit | 4c242d34d15bd2e7a5efacdb4905c401cb114831 (patch) | |
tree | f8223a3f573763f1d9adff95142396d7b74cec6a | |
parent | 0bd8143f6e324d48413caf1998a524629c6e7828 (diff) |
moved LineDrawingArea to its own class
-rw-r--r-- | GdiTest/GdiTest.csproj | 1 | ||||
-rw-r--r-- | GdiTest/LineDrawingArea.cs | 44 | ||||
-rw-r--r-- | GdiTest/Main.cs | 40 | ||||
-rw-r--r-- | GdiTest/bin/Debug/.gitignore | 2 |
4 files changed, 51 insertions, 36 deletions
diff --git a/GdiTest/GdiTest.csproj b/GdiTest/GdiTest.csproj index c820a4b..38f9068 100644 --- a/GdiTest/GdiTest.csproj +++ b/GdiTest/GdiTest.csproj @@ -53,6 +53,7 @@ <Compile Include="gtk-gui\MainWindow.cs" /> <Compile Include="Main.cs" /> <Compile Include="AssemblyInfo.cs" /> + <Compile Include="LineDrawingArea.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/GdiTest/LineDrawingArea.cs b/GdiTest/LineDrawingArea.cs new file mode 100644 index 0000000..0fc00d3 --- /dev/null +++ b/GdiTest/LineDrawingArea.cs @@ -0,0 +1,44 @@ +using System; +using Cairo; +using Gtk; + +namespace GdiTest +{ + public class LineDrawingArea : DrawingArea + { + public LineDrawingArea () + { + } + + protected override bool OnExposeEvent (Gdk.EventExpose args) + { + using (Context g = Gdk.CairoHelper.Create (args.Window)) + { + g.Antialias = Antialias.None; + g.LineWidth = 4; + + g.Color = new Color(1,0,0); + g.MoveTo (10, 10); + g.LineTo (110, 10); + g.Stroke (); + + g.Color = new Color(0,1,0); + g.MoveTo (10, 10); + g.LineTo (10, 110); + g.Stroke (); + + g.Color = new Color(0,0,1); + g.MoveTo (10, 10); + g.LineTo (110, 110); + g.Stroke (); + + g.Color = new Color(0,0,0); + Rectangle rect = new Rectangle(210, 10, 260, 110); + g.Rectangle(rect); + g.Stroke (); + } + return true; + } + } +} + diff --git a/GdiTest/Main.cs b/GdiTest/Main.cs index 17cd08e..232dd72 100644 --- a/GdiTest/Main.cs +++ b/GdiTest/Main.cs @@ -1,6 +1,6 @@ using System; -using Gtk; using Cairo; +using Gtk; namespace GdiTest { @@ -11,10 +11,11 @@ namespace GdiTest Application.Init (); MainWindow w = new MainWindow (); - DrawingArea a = new CairoGraphic (); + DrawingArea lineDrawingArea = new LineDrawingArea (); Box box = new HBox (true, 0); - box.Add (a); + box.Add (lineDrawingArea); + w.Add (box); w.Resize (500, 500); w.ShowAll (); @@ -23,36 +24,3 @@ namespace GdiTest } } } - -public class CairoGraphic : DrawingArea -{ - protected override bool OnExposeEvent (Gdk.EventExpose args) - { - using (Context g = Gdk.CairoHelper.Create (args.Window)) - { - g.Antialias = Antialias.None; - g.LineWidth = 4; - - g.Color = new Color(1,0,0); - g.MoveTo (10, 10); - g.LineTo (110, 10); - g.Stroke (); - - g.Color = new Color(0,1,0); - g.MoveTo (10, 10); - g.LineTo (10, 110); - g.Stroke (); - - g.Color = new Color(0,0,1); - g.MoveTo (10, 10); - g.LineTo (110, 110); - g.Stroke (); - - g.Color = new Color(0,0,0); - Rectangle rect = new Rectangle(210, 10, 260, 110); - g.Rectangle(rect); - g.Stroke (); - } - return true; - } -} diff --git a/GdiTest/bin/Debug/.gitignore b/GdiTest/bin/Debug/.gitignore new file mode 100644 index 0000000..3ecd083 --- /dev/null +++ b/GdiTest/bin/Debug/.gitignore @@ -0,0 +1,2 @@ +/*.exe.mdb +/*.exe |