/// <summary> /// Creates the Sciter window and returns the native handle /// </summary> /// <param name="frame">Rectangle of the window</param> /// <param name="creationFlags">Flags for the window creation, defaults to SW_MAIN | SW_TITLEBAR | SW_RESIZEABLE | SW_CONTROLS</param> /// <param name="parent"></param> public IntPtr CreateWindow(SciterRectangle frame = new SciterRectangle(), CreateWindowFlags creationFlags = DefaultCreateFlags, IntPtr?parent = null) { #if DEBUG // Force Sciter SW_ENABLE_DEBUG in Debug build. creationFlags |= CreateWindowFlags.EnableDebug; #endif var result = SciterApi.SciterCreateWindow( creationFlags, frame, null, IntPtr.Zero, parent ?? IntPtr.Zero ); Debug.Assert(result != IntPtr.Zero); if (result == IntPtr.Zero) { throw new Exception("CreateWindow() failed"); } return(result); }
public CustomWindow() { var creationFlags = //SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_MAIN | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ENABLE_DEBUG | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_POPUP | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_TITLEBAR | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_RESIZEABLE | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_CONTROLS | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_GLASSY; var frame = new SciterRectangle(800, 600); CreateWindow(frame: frame, creationFlags: creationFlags, parent: IntPtr.Zero); //CreateWindow(800, 600) // .CenterTopLevelWindow() // .SetTitle("SciterCore::NetCore::Playground"); }
private void DrawDefaultClock( SciterGraphics graphics, SciterRectangle area, float scale, DateTime timeInfo) { var markColor = SciterColor.White; var hourColor = SciterColor.White; var minuteColor = SciterColor.White; var secondColor = SciterColor.Create(0xF3, 0x7F, 0x14); graphics .SaveState() .Translate(area.Left + area.Width / 2.0f, area.Top + area.Height / 2.0f) .Scale(scale, scale) .Rotate(-Pi / 2) .SetLineColor(SciterColor.Transparent) .SetLineCap(LineCapType.Round); // Hour marks graphics .SaveState() .SetLineWidth(10f) .SetLineColor(markColor); for (int i1 = 0; i1 < 12; ++i1) { graphics.Rotate(Pi / 6, 0, 0); graphics.DrawLine(125f, 0, 140f, 0); } graphics.RestoreState(); // Minute marks graphics .SaveState() .SetLineWidth(2f) .SetLineColor(markColor); for (int i = 0; i < 60; ++i) { if (i % 5 != 0) { graphics.DrawLine(134f, 0, 144f, 0); } graphics.Rotate(Pi / 30f); } graphics.RestoreState(); int sec = timeInfo.Second; int min = timeInfo.Minute; int hr = timeInfo.Hour; hr = hr >= 12 ? hr - 12 : hr; // draw Hours graphics.SaveState() .Rotate(hr * (Pi / 6) + (Pi / 360) * min + (Pi / 21600) * sec) .SetLineWidth(10f) .SetLineColor(hourColor) .DrawLine(-20, 0, 50, 0) .RestoreState(); // draw Minutes graphics .SaveState() .Rotate((Pi / 30) * min + (Pi / 1800) * sec) .SetLineWidth(10f) .SetLineColor(minuteColor) .DrawLine(-20, 0, 100, 0) .RestoreState(); graphics .SaveState() .Rotate(sec * Pi / 30) .SetLineColor(secondColor) .SetFillColor(secondColor) .SetLineWidth(6f) .DrawLine(-20f, 0, 80, 0) .DrawEllipse(0, 0, 10, 10) .SetFillColor(SciterColor.Transparent) .DrawEllipse(90, 0, 8, 8) .SetLineWidth(1f) .SetLineColor(SciterColor.Goldenrod) .SetFillColor(SciterColor.Gold) .DrawEllipse(0, 0, 2, 2) .RestoreState(); graphics.RestoreState(); //graphics.DrawText( // SciterText.CreateForElementAndStyle($"{timeinfo.Hour:00}:{timeinfo.Second:00}", se, // $"font-size:24pt;color:{secondColorHex}"), area.Left + area.Width / 2.0f, // area.Top + area.Height / 4.0f, 5); }
private void DrawCirclesClock( SciterGraphics graphics, SciterRectangle area, float scale, DateTime timeInfo) { var markColor = SciterColor.Parse("#969696"); var hourColor = SciterColor.Parse("#969696"); var minuteColor = SciterColor.Parse("#969696"); var secondColor = SciterColor.Parse("#64C439"); graphics .SaveState() .Translate(area.Left + area.Width / 2.0f, area.Top + area.Height / 2.0f) .Scale(scale, scale) .Rotate(-Pi / 2) .SetLineColor(SciterColor.Transparent) .SetLineCap(LineCapType.Square); int sec = timeInfo.Second; int min = timeInfo.Minute; int hr = timeInfo.Hour; hr = hr >= 12 ? hr - 12 : hr; // Background graphics .SaveState() .Translate(0, 0) .SetLineColor(SciterColor.Transparent) .SetFillGradientLinear(0f, 75f, 150f, 75f, SciterColorStop.Create(0f, SciterColor.Parse("#242424")), SciterColorStop.Create(1f, SciterColor.Parse("#545454"))) .DrawEllipse(0, 0, 150, 150) .SetFillColor(SciterColor.Transparent) .SetLineColor(minuteColor) .DrawEllipse(0, 0, 150, 150) .RestoreState(); graphics .SaveState() .Translate(-(area.Height / 3.0f), 0) .SetLineWidth(2f) .SetLineColor(SciterColor.Black) .SetFillColor(SciterColor.Parse("#222222")) .DrawEllipse(0, 0, 50, 50) .SetLineColor(markColor) .Using(@ref => { for (var i = 0; i < 12; ++i) { @ref .Rotate(Pi / 6, 0, 0) .DrawLine(34, 0, 44f, 0); } }) .RestoreState(); graphics .SaveState() .Translate(-(area.Height / 3.0f), 0) .SetLineColor(secondColor) .Using(@ref => { @ref .SetLineWidth(2f) .SetLineColor(markColor); for (var i = 0; i < 60; ++i) { if (i % 5 != 0) { @ref.DrawLine(40f, 0, 44f, 0); } @ref.Rotate(Pi / 30f); } }) .RestoreState(); graphics .SaveState() .Translate(-(area.Height / 3.0f), 0) .Rotate(sec * Pi / 30) .SetLineColor(secondColor) .SetFillColor(secondColor) .SetLineWidth(2f) .DrawLine(0, 0, 44, 0) .DrawEllipse(0, 0, 3, 3) .RestoreState(); // Hour marks graphics .SaveState() .SetLineColor(markColor) .Using(@ref => { for (var i = 0; i < 12; ++i) { @ref.Rotate(Pi / 6, 0, 0); if (new [] { 2, 5, 8, 11 }.Contains(i)) { @ref .SetLineWidth(8f) .DrawLine(125f, 0, 142f, 0); } else { @ref .SetLineWidth(2f) .DrawLine(125f, 0, 145f, 0); } } }) .RestoreState(); // Minute marks graphics .SaveState() .SetLineWidth(2f) .SetLineColor(markColor) .Using(@ref => { for (var i = 0; i < 60; ++i) { if (i % 5 != 0) { @ref.DrawLine(138f, 0, 144f, 0); } @ref.Rotate(Pi / 30f); } }) .SetLineColor(minuteColor) .DrawEllipse(0, 0, 150, 150) .RestoreState(); // draw Hours graphics.SaveState() .Rotate(hr * (Pi / 6) + (Pi / 360) * min + (Pi / 21600) * sec) .SetLineWidth(1f) .SetFillGradientLinear(50f, -3f, 50f, 3f, SciterColorStop.Create(0f, SciterColor.Parse("#c4c4c4")), SciterColorStop.Create(1f, SciterColor.Parse("#B2B2B2"))) .DrawPolygon(() => new List <PolygonPoint>() { PolygonPoint.Create(0f, -3f), PolygonPoint.Create(90f, -3f), PolygonPoint.Create(100f, 0f), PolygonPoint.Create(90f, 3f), PolygonPoint.Create(0f, 3f), }) //.SetLineWidth(0f) //.DrawEllipse(0, 0, 10, 10) .RestoreState(); // draw Minutes graphics .SaveState() .Rotate((Pi / 30) * min + (Pi / 1800) * sec) //.SetLineColor(SciterColor.Transparent) //.SetLineWidth(0f) //.SetFillColor(SciterColor.Create(0, 0, 0, .5f)) //.DrawEllipse(0, 0, 10, 10) .SetLineWidth(1f) .SetLineColor(minuteColor) .SetFillColor(minuteColor) .SetFillGradientLinear(65, -3f, 65f, 3f, SciterColorStop.Create(0f, SciterColor.Parse("#c4c4c4")), SciterColorStop.Create(1f, SciterColor.Parse("#B2B2B2"))) .DrawPolygon(() => new List <PolygonPoint>() { PolygonPoint.Create(0, -3), PolygonPoint.Create(120, -3), PolygonPoint.Create(130, 0), PolygonPoint.Create(120, 3), PolygonPoint.Create(0, 3), }) .DrawEllipse(0, 0, 8, 8) .SetLineColor(SciterColor.Parse("#686868")) .SetFillColor(SciterColor.Parse("#2E2E2E")) .SetLineWidth(2f) .DrawEllipse(0, 0, 4, 4) //.SetLineWidth(1f) .RestoreState(); // Outer ring graphics .SaveState() .SetLineColor(minuteColor) .DrawEllipse(0, 0, 150, 150) .RestoreState(); graphics.RestoreState(); }
private void DrawSwissClock( SciterGraphics graphics, SciterRectangle area, float scale, DateTime timeInfo) { var markColor = SciterColor.Black; var hourColor = SciterColor.Black; var minuteColor = SciterColor.Black; var secondColor = SciterColor.Create(0xA9, 0x33, 0x2A); graphics .SaveState() .Translate(area.Left + area.Width / 2.0f, area.Top + area.Height / 2.0f) .Scale(scale, scale) .Rotate(-Pi / 2) .SetLineColor(SciterColor.Transparent) .SetLineCap(LineCapType.Square); // Hour marks graphics .SaveState() .SetLineWidth(10f) .SetLineColor(markColor); for (int i1 = 0; i1 < 12; ++i1) { graphics.Rotate(Pi / 6, 0, 0); graphics.DrawLine(125f, 0, 140f, 0); } graphics.RestoreState(); // Minute marks graphics .SaveState() .SetLineWidth(2f) .SetLineColor(markColor); for (int i = 0; i < 60; ++i) { if (i % 5 != 0) { graphics.DrawLine(134f, 0, 144f, 0); } graphics.Rotate(Pi / 30f); } graphics.RestoreState(); int sec = timeInfo.Second; int min = timeInfo.Minute; int hr = timeInfo.Hour; hr = hr >= 12 ? hr - 12 : hr; // draw Hours graphics.SaveState() .Rotate(hr * (Pi / 6) + (Pi / 360) * min + (Pi / 21600) * sec) .SetLineWidth(10f) .SetLineColor(hourColor) .DrawLine(-40, 0, 80, 0) .RestoreState(); // draw Minutes graphics .SaveState() .Rotate((Pi / 30) * min + (Pi / 1800) * sec) .SetLineWidth(10f) .SetLineColor(minuteColor) .DrawLine(-40, 0, 130, 0) .RestoreState(); graphics .SaveState() .Rotate(sec * Pi / 30) .SetLineColor(secondColor) .SetFillColor(secondColor) .SetLineWidth(4) .DrawLine(-40, 0, 110, 0) .DrawEllipse(0, 0, 3, 3) .SetFillColor(SciterColor.Gold) .SetLineWidth(1f) .DrawEllipse(0, 0, 2, 2) .SetFillColor(secondColor) .DrawEllipse(105, 0, 10, 10) .RestoreState(); graphics.RestoreState(); }
internal static PInvokeUtils.RECT ToRect(this SciterRectangle rectangle) => new PInvokeUtils.RECT(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom);
internal static SciterSize ToSize(this SciterRectangle rectangle) => new SciterSize(rectangle.Width, rectangle.Height);