|
10 | 10 | var host = new SciterAPIHost ( Path.Combine ( pathToSciter, "bin/windows/x64" ), true, true ); |
11 | 11 | var path = "file://" + Path.Combine ( pathToSciter, "samples/html/details-summary.htm" ); |
12 | 12 | host.Callbacks.AddAttachBehaviourFactory ( "testbehaviour", ( element ) => new TestGraphicsEventHandler ( element, host ) ); |
13 | | -host.CreateMainWindow ( 0, 0, enableDebug: true, enableFeature: true ); |
| 13 | +host.CreateMainWindow ( 300, 300, enableDebug: true, enableFeature: true ); |
14 | 14 | host.AddWindowEventHandler ( new MyWindowEventHandler ( host.MainWindow, host ) ); |
15 | 15 | host.LoadFile ( path ); |
16 | 16 | host.Process (); |
@@ -39,20 +39,27 @@ public class TestGraphicsEventHandler : ElementEventHandler { |
39 | 39 | public TestGraphicsEventHandler ( nint element, SciterAPIHost host ) : base ( element, host ) { |
40 | 40 | Text = Host.GraphicsCreateTextForElement ( element, "test text!!!111", "test-class" ); |
41 | 41 | Text2 = Host.GraphicsCreateTextForElementWithStyle ( element, "test text!!!111", "font-size: 18px;color: green;" ); |
| 42 | + Color1 = Host.GraphicsGetColor ( 0, 204, 0 ); |
| 43 | + Color2 = Host.GraphicsGetColor ( 0, 0, 255 ); |
42 | 44 | } |
43 | 45 |
|
| 46 | + public uint Color1 { get; set; } |
| 47 | + |
| 48 | + public uint Color2 { get; set; } |
| 49 | + |
44 | 50 | public GraphicsTextModel Text { get; set; } |
45 | 51 |
|
46 | 52 | public GraphicsTextModel Text2 { get; set; } |
47 | 53 |
|
48 | 54 | public override void DrawEvent ( DrawEvents command, nint gfx, SciterRectangle area, uint reserved ) { |
49 | | - var color = Host.Graphics.RGBA ( 0, 204, 0, 255 ); |
50 | | - var blue = Host.Graphics.RGBA ( 0, 0, 255, 255 ); |
| 55 | + var (position, size) = Host.GetMainWindowPositionAndSize (); |
| 56 | + Console.WriteLine ( $"Position: {position.X} - {position.Y}" ); |
| 57 | + |
51 | 58 | if ( command == DrawEvents.DRAW_CONTENT ) { |
52 | 59 | Host.GraphicsSaveState ( gfx ); |
53 | | - Host.GraphicsFillColor ( gfx, color ); |
| 60 | + Host.GraphicsFillColor ( gfx, Color1 ); |
54 | 61 | Host.GraphicsDrawRectangle ( gfx, area.Left, area.Top, area.Left + area.Width, area.Top + area.Height ); |
55 | | - Host.GraphicsDrawLine ( gfx, area.LeftTopCorner, area.RightBottomCorner, blue, 10 ); |
| 62 | + Host.GraphicsDrawLine ( gfx, area.LeftTopCorner, area.RightBottomCorner, Color2, 10 ); |
56 | 63 | Host.GraphicsDrawText ( gfx, Text, new Vector2 ( area.Left, area.Top ), SciterTextPosition.TopLeft ); |
57 | 64 | Host.GraphicsDrawText ( gfx, Text2, new Vector2 ( area.Left, area.Top + 30 ), SciterTextPosition.TopLeft ); |
58 | 65 | Host.GraphicsRestoreState ( gfx ); |
|
0 commit comments