diff options
author | Marc-André Moreau <marcandre.moreau@gmail.com> | 2011-03-26 03:08:58 +0300 |
---|---|---|
committer | Marc-André Moreau <marcandre.moreau@gmail.com> | 2011-03-26 03:08:58 +0300 |
commit | 547f19bdfc234390a07269b83f4c1fb859ee0260 (patch) | |
tree | b9aa261d7c0e4bb2ad6207c7ed7c945e539e532b | |
parent | 4c242d34d15bd2e7a5efacdb4905c401cb114831 (diff) |
Importing native BitBlt function from gdi32.dll, should now be Win32 dependent.
-rw-r--r-- | GdiTest.userprefs | 6 | ||||
-rw-r--r-- | GdiTest/BitBltDrawingArea.cs | 60 | ||||
-rw-r--r-- | GdiTest/GdiTest.csproj | 3 | ||||
-rw-r--r-- | GdiTest/GdiTest.pidb | bin | 6597 -> 7093 bytes | |||
-rw-r--r-- | GdiTest/Main.cs | 2 | ||||
-rw-r--r-- | GdiTest/bin/Debug/.gitignore | 1 | ||||
-rw-r--r-- | GdiTest/gtk-gui/gui.stetic | 2 |
7 files changed, 69 insertions, 5 deletions
diff --git a/GdiTest.userprefs b/GdiTest.userprefs index b190e39..e820017 100644 --- a/GdiTest.userprefs +++ b/GdiTest.userprefs @@ -1,9 +1,9 @@ <Properties> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" /> - <MonoDevelop.Ide.Workbench ActiveDocument="GdiTest/Main.cs"> + <MonoDevelop.Ide.Workbench ActiveDocument="GdiTest\MainWindow.cs"> <Files> - <File FileName="GdiTest/Main.cs" Line="37" Column="22" /> - <File FileName="GdiTest/MainWindow.cs" Line="18" Column="1" /> + <File FileName="GdiTest\Main.cs" Line="27" Column="1" /> + <File FileName="GdiTest\MainWindow.cs" Line="18" Column="1" /> </Files> </MonoDevelop.Ide.Workbench> <MonoDevelop.Ide.DebuggingService.Breakpoints> diff --git a/GdiTest/BitBltDrawingArea.cs b/GdiTest/BitBltDrawingArea.cs new file mode 100644 index 0000000..a5b8dab --- /dev/null +++ b/GdiTest/BitBltDrawingArea.cs @@ -0,0 +1,60 @@ +using Gtk; +using Cairo; +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace GdiTest +{ + public class BitBltDrawingArea : DrawingArea + { + [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")] + + private static extern int BitBlt( + IntPtr hdcDest, + int nXDest, + int nYDest, + int nWidth, + int nHeight, + IntPtr hdcSrc, + int nXSrc, + int nYSrc, + System.Int32 dwRop + ); + + public BitBltDrawingArea () + { + } + + protected override bool OnExposeEvent (Gdk.EventExpose args) + { + using (Context cg = Gdk.CairoHelper.Create (args.Window)) + { + cg.Antialias = Antialias.None; + cg.LineWidth = 4; + + cg.Color = new Cairo.Color(1,0,0); + cg.MoveTo (10, 10); + cg.LineTo (110, 10); + cg.Stroke (); + + cg.Color = new Cairo.Color(0,1,0); + cg.MoveTo (10, 10); + cg.LineTo (10, 110); + cg.Stroke (); + + cg.Color = new Cairo.Color(0,0,1); + cg.MoveTo (10, 10); + cg.LineTo (110, 110); + cg.Stroke (); + + System.Drawing.Graphics wg = Gtk.DotNet.Graphics.FromDrawable(this.GdkWindow, true); + IntPtr dc = wg.GetHdc(); + + BitBlt(dc, 70, 0, 60, 60, dc, 0, 0, 0xCC0020); + } + return true; + } + } +} + diff --git a/GdiTest/GdiTest.csproj b/GdiTest/GdiTest.csproj index 38f9068..fda40e2 100644 --- a/GdiTest/GdiTest.csproj +++ b/GdiTest/GdiTest.csproj @@ -41,6 +41,8 @@ <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> <Reference Include="Mono.Cairo" /> + <Reference Include="System.Drawing" /> + <Reference Include="gtk-dotnet, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="gtk-gui\gui.stetic"> @@ -54,6 +56,7 @@ <Compile Include="Main.cs" /> <Compile Include="AssemblyInfo.cs" /> <Compile Include="LineDrawingArea.cs" /> + <Compile Include="BitBltDrawingArea.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/GdiTest/GdiTest.pidb b/GdiTest/GdiTest.pidb Binary files differindex 5638050..46e69f3 100644 --- a/GdiTest/GdiTest.pidb +++ b/GdiTest/GdiTest.pidb diff --git a/GdiTest/Main.cs b/GdiTest/Main.cs index 232dd72..7e1b01e 100644 --- a/GdiTest/Main.cs +++ b/GdiTest/Main.cs @@ -11,7 +11,7 @@ namespace GdiTest Application.Init (); MainWindow w = new MainWindow (); - DrawingArea lineDrawingArea = new LineDrawingArea (); + DrawingArea lineDrawingArea = new BitBltDrawingArea (); Box box = new HBox (true, 0); box.Add (lineDrawingArea); diff --git a/GdiTest/bin/Debug/.gitignore b/GdiTest/bin/Debug/.gitignore index 3ecd083..0b2585b 100644 --- a/GdiTest/bin/Debug/.gitignore +++ b/GdiTest/bin/Debug/.gitignore @@ -1,2 +1,3 @@ /*.exe.mdb /*.exe +/*.pdb diff --git a/GdiTest/gtk-gui/gui.stetic b/GdiTest/gtk-gui/gui.stetic index faedde8..e081656 100644 --- a/GdiTest/gtk-gui/gui.stetic +++ b/GdiTest/gtk-gui/gui.stetic @@ -6,7 +6,7 @@ </configuration> <import> <widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> - <widget-library name="../bin/Debug/GdiTest.exe" internal="true" /> + <widget-library name="..\bin\Debug\GdiTest.exe" internal="true" /> </import> <widget class="Gtk.Window" id="MainWindow" design-size="400 300"> <property name="MemberName" /> |