Example #1
0
        static void Main(string[] args)
        {
            // Sciter needs this for drag'n'drop support; STAThread is required for OleInitialize succeess
            int oleres = PInvokeWindows.OleInitialize(IntPtr.Zero);

            Debug.Assert(oleres == 0);

            // Create the window
            var wnd = new SciterWindow();

            wnd.CreateMainWindow(1500, 800);
            wnd.CenterTopLevelWindow();
            wnd.Title = "SciterBootstrap";
            wnd.Icon  = Properties.Resources.IconMain;

            // Prepares SciterHost and then load the page
            var host = new Host();

            host.Setup(wnd);
            host.AttachEvh(new HostEvh());
            host.SetupPage("index.html");

            // Show window and Run message loop
            wnd.Show();
            PInvokeUtils.RunMsgLoop();
        }
Example #2
0
        public Host(SciterWindow window)
            : base(window)
        {
            this.RegisterBehaviorHandler <CheckeredBackgroundBitmapBehavior>()

            .RegisterBehaviorHandler <InfoBitmapBehavior>()

            .RegisterBehaviorHandler <SolidBitmapBehavior>()
            .RegisterBehaviorHandler <SolidForegroundBitmapBehavior>()

            .RegisterBehaviorHandler <LinearBitmapBehavior>()
            .RegisterBehaviorHandler <LinearForegroundBitmapBehavior>()

            .RegisterBehaviorHandler <RadialBitmapBehavior>()
            .RegisterBehaviorHandler <RadialForegroundBitmapBehavior>()

            .RegisterBehaviorHandler <DrawTextBehavior>()
            .RegisterBehaviorHandler <DrawGeometryBehavior>()

            .AttachEventHandler(new HostEventHandler());

            SetupPage("index.html");

            window.Show();
        }
Example #3
0
        public void TestODH()
        {
            TestableDOH odh = new TestableDOH();

            SciterWindow wnd = new SciterWindow();

            wnd.CreateMainWindow(1500, 800);
            wnd.Title = "Wtf";
            bool res = wnd.LoadHtml(@"
<html>
<style>
	body { wtf: 123; }
</style>

<script type='text/tiscript'>
</script>
</html>
");

            Assert.IsTrue(res);

            PInvokeWindows.MSG msg;
            while (PInvokeWindows.GetMessage(out msg, IntPtr.Zero, 0, 0) != 0)
            {
                wnd.Show();
                PInvokeWindows.TranslateMessage(ref msg);
                PInvokeWindows.DispatchMessage(ref msg);
            }

            Assert.IsTrue(odh.msgs.Count == 1);
        }
Example #4
0
 public AppHost(SciterWindow window)
 {
     _archive.Open(ArchiveResource.resources);
     _window = window;
     SetupWindow(_window);
     window.Show();
 }
Example #5
0
        static void Main(string[] args)
        {
#if WINDOWS
            // Sciter needs this for drag'n'drop support; STAThread is required for OleInitialize succeess
            int oleres = PInvokeWindows.OleInitialize(IntPtr.Zero);
            Debug.Assert(oleres == 0);
#endif

            Console.WriteLine("Sciter: " + SciterX.Version);

            // Create the window
            var wnd = new SciterWindow();
            wnd.CreateMainWindow(1500, 800);
            wnd.CenterTopLevelWindow();
            wnd.Title = "Sciter Bootstrap";
#if WINDOWS
            wnd.Icon = Properties.Resources.IconMain;
#endif

            // Prepares SciterHost and then load the page
            var host = new Host();
            host.SetupWindow(wnd);
            host.RegisterBehaviorHandler(typeof(DrawBitmapBehavior), "DrawBitmap");
            host.RegisterBehaviorHandler(typeof(DrawTextBehavior), "DrawText");
            host.RegisterBehaviorHandler(typeof(DrawGeometryBehavior), "DrawGeometry");
            host.AttachEvh(new HostEvh());
            host.SetupPage("index.html");

            // Show window and Run message loop
            wnd.Show();
            PInvokeUtils.RunMsgLoop();

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Example #6
0
        protected override void OnHandleCreated(EventArgs e)
        {
            if (this.DesignMode)
            {
                this.DoubleBuffered = true;
                return;
            }

            SciterWindow = SciterWindow
                           .CreateChildWindow(Handle);

            this.WindowCreated?.Invoke(this, new WindowCreatedEventArgs(SciterWindow));

            if (SciterWindow != null && SciterWindow?.Handle != IntPtr.Zero)
            {
                //var loadHtmlEventArgs = new LoadHtmlEventArgs()
                //{
                //	Html = this.Html
                //};

                //LoadHtml?.Invoke(this, loadHtmlEventArgs);
                //
                //SciterWnd.LoadHtml(loadHtmlEventArgs?.Html ?? this.Html ?? DEFAULT_HTML);

                SciterWindow?.Show(this.Visible);
            }

            base.OnHandleCreated(e);
        }
Example #7
0
        public Host(SciterWindow wnd)
        {
            var host = this;

            host.Setup(wnd);
            host.AttachEvh(new HostEvh());
            host.SetupPage("index.html");
            wnd.Show();
        }
Example #8
0
        public Host(SciterWindow wnd)
            : base(wnd)
        {
            RegisterBehaviorHandler(typeof(ImgDrawBehavior));

            wnd.LoadPage("file:///Users/midiway/Documents/SciterSharp/Tests/TestOSX/res/index.html");
            wnd.CenterTopLevelWindow();
            wnd.Show();
        }
Example #9
0
        public Host(SciterWindow wnd)
        {
            var host = this;

            host.Setup(wnd);
            host.AttachEvh(new HostEvh());
            host.SetupPage("views/index/mainLayout.html");
            //host.SetupPage("utils/virtualList/vlist.htm");
            wnd.Show();
        }
Example #10
0
        public Host(SciterWindow wnd)
        {
            // Prepares SciterHost and then load the page
            var host = this;

            host.Setup(wnd);
            host.AttachEvh(new HostEvh());
            host.SetupPage("index.html");
            //host.DebugInspect();// >-- call it after SetupPage(), dont forget to run inspector.exe
            wnd.Show();
        }
Example #11
0
        public Host(SciterWindow window)
            : base(window: window)
        {
            var host = this;

            host.RegisterBehaviorHandler(typeof(DrawGeometryBehavior))
            .AttachEventHandler(new HostEventHandler());

            host.SetupPage(page: "index.html");
            window.Show();
        }
Example #12
0
        public Host(SciterWindow wnd)
        {
            var host = this;

            host.Setup(wnd);
            host.AttachEvh(new HostEvh());
            host.RegisterBehaviorHandler(typeof(LineChartGraphics));
            host.RegisterBehaviorHandler(typeof(LineChartPNG));
            host.SetupPage("index.html");
            wnd.Show();
        }
Example #13
0
        public Host(SciterWindow wnd)
        {
            SetupWindow(wnd);
            RegisterBehaviorHandler(typeof(ImgDrawBehavior));

            wnd.LoadPage("/Users/midiway/Documents/SciterSharp/Tests/TestOSX/res/index.html");
            wnd.CallFunction("CallMe", new SciterValue((args) =>
            {
                return(new SciterValue(123));
            }));
            wnd.CenterTopLevelWindow();
            wnd.Show();
        }
Example #14
0
        public static void Run()
        {
#if X64
            SciterX.Use3264DLLNaming = true;
#endif
            PInvokeWindows.OleInitialize(IntPtr.Zero);
            var window = new SciterWindow();
            window.CreateMainWindow(500, 500);
            window.CenterTopLevelWindow();
            var host = new AppHost(window);
            window.LoadPage("archive://app/acrylic-window/acrylic-window-sketch.htm");
            window.Show();
            PInvokeUtils.RunMsgLoop();
        }
Example #15
0
        public override void FinishedLaunching(MonoMac.Foundation.NSObject notification)
        {
            wnd = new SciterWindow();
            wnd.CreateMainWindow(500, 500);
            wnd.CenterTopLevelWindow();
            wnd.Title = "SciterSharp from OSX";

            host = new Host();
            host.SetupWindow(wnd);
            host.AttachEvh(new HostEvh());
            host.SetupPage("index.html");
            host.DebugInspect();

            wnd.Show();
        }
Example #16
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            wnd = new SciterWindow();
            wnd.CreateMainWindow(800, 500);
            wnd.CenterTopLevelWindow();
            wnd.Title = "SciterSharp from OSX";

            host = new Host();
            host.SetupWindow(wnd);
            host.AttachEvh(new HostEvh());
            host.SetupPage("index.html");
            //host.DebugInspect();

            wnd.Show();
        }
Example #17
0
        public Host(SciterWindow window)
        {
            Setup(window);
            AttachEvh(new HostEvh(this));
            SetupPage("index.html");

            #if DEBUG
            try {
                DebugInspect();
            } catch {
                // ignore
            }
            #endif

            window.Show();
        }
Example #18
0
        static void Main(string[] args)
        {
            // TODO: think Andrew corrected child window creation
            PInvokeWindows.OleInitialize(IntPtr.Zero);

            // Create the window
            var wnd = new SciterWindow();

            wnd.CreateMainWindow(1500, 800);
            var r = wnd.RootElement;

            wnd.Icon = Properties.Resources.Icon1;
            //wnd.EnableDwmClientArea();


            //wnd.CenterTopLevelWindow();
            //wnd.AfterWindowCreate();
            //wnd.Title = "Sciter Bootstrap";

            // Prepares SciterHost and then load the page
            var host = new Host();

            host.SetupWindow(wnd);
            host.AttachEvh(new HostEvh());
            host.SetupPage("index.html");
            //host.DebugInspect();

            // get the page <body>
            var se_body = wnd.RootElement.SelectFirst("body");

            // append a <h1> header to it
            se_body.TransformHTML("<h1>Wow, this header was created natively!</h1>", SciterXDom.SET_ELEMENT_HTML.SIH_INSERT_AT_START);

            // set <h1> color to blue
            se_body[0].SetStyle("color", "#00F");


            /*SciterWindow wnd_popup = new SciterWindow();
             * wnd_popup.CreatePopupAlphaWindow(400, 400, wnd._hwnd);
             * wnd_popup.LoadHtml("<html><body><style>html { background: red; }</style></body></html>");
             * wnd_popup.Show();*/

            // Show window and Run message loop
            wnd.Show();
            PInvokeUtils.RunMsgLoop();
        }
Example #19
0
        static void Main(string[] args)
        {
            var list = new List <int> {
                123
            };

            var ss = SciterValue.Create(new { aa = list });

            Console.WriteLine($@"Sciter: {Sciter.SciterApi.SciterVersion()}");
            Console.WriteLine("Bitness: " + IntPtr.Size);

            // Platform specific (required for GTK)
            SciterPlatform.Initialize();
            // SciterCore needs this for drag 'n drop support (on Windows)
            SciterPlatform.EnableDragAndDrop();

            // Create the window
            AppWindow = new SciterWindow()
                        .CreateMainWindow(800, 600)
                        .CenterWindow()
                        .SetTitle("SciterCore.Windows::Core")
                        .SetIcon(SciterTest.Core.Properties.Resources.IconMain);

            // Prepares SciterHost and then load the page
            AppHost = new AppHost(AppWindow);

            AppHost
            .SetupWindow(AppWindow)
            .AttachEventHandler(new AppEventHandler());

            AppHost.SetupPage("index.html");

            //AppHost.ConnectToInspector();

            //byte[] css_bytes = File.ReadAllBytes(@"D:\ProjetosSciter\AssetsDrop\AssetsDrop\res\css\global.css");
            //SciterX.API.SciterAppendMasterCSS(css_bytes, (uint) css_bytes.Length);
            Debug.Assert(!AppHost.EvalScript("Utils").IsUndefined);

            // Show window and Run message loop
            AppWindow.Show();
            SciterPlatform.RunMessageLoop();
        }
Example #20
0
        public void DrawLine_with_lineCap_and_lineJoin(string behaviorName, LineCapType lineCap, LineJoinType lineJoin)
        {
            var random = new Random();

            _mockBehaviorResolver.Setup(resolver => resolver.GetBehaviorHandler(behaviorName))
            .Returns(() =>
            {
                return(new DrawContentBehavior(_sciterWindow, (element, args) =>
                {
                    if (args.DrawEvent != DrawEvent.Content)
                    {
                        return false;
                    }

                    using (var graphics = SciterGraphics.Create(args.Handle))
                    {
                        for (var i = 0; i < byte.MaxValue; i++)
                        {
                            graphics.SaveState()
                            .Translate(args.Area.Left, args.Area.Top)
                            .SetLineColor(
                                (byte)random.Next(byte.MinValue, byte.MaxValue),
                                (byte)random.Next(byte.MinValue, byte.MaxValue),
                                (byte)random.Next(byte.MinValue, byte.MaxValue),
                                (byte)random.Next(byte.MinValue, byte.MaxValue))
                            .SetFillColor(
                                (byte)random.Next(byte.MinValue, byte.MaxValue),
                                (byte)random.Next(byte.MinValue, byte.MaxValue),
                                (byte)random.Next(byte.MinValue, byte.MaxValue),
                                (byte)random.Next(byte.MinValue, byte.MaxValue))
                            .SetLineWidth(random.Next(2, 10))
                            .SetLineCap(lineCap)
                            .SetLineJoin(lineJoin)
                            .DrawLine(random.Next(byte.MinValue, args.Area.Width),
                                      random.Next(byte.MinValue, args.Area.Height),
                                      random.Next(byte.MinValue, args.Area.Width),
                                      random.Next(byte.MinValue, args.Area.Height))
                            .SetLineGradientLinear(
                                0f,
                                0f,
                                args.Area.Width / 2f,
                                args.Area.Height,
                                SciterColorStop.Create(0f,
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue),
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue),
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue),
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue)),
                                SciterColorStop.Create(.5f,
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue),
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue),
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue),
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue)),
                                SciterColorStop.Create(1f,
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue),
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue),
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue),
                                                       (byte)random.Next(byte.MinValue, byte.MaxValue)))
                            .DrawLine(random.Next(byte.MinValue, args.Area.Width),
                                      random.Next(byte.MinValue, args.Area.Height),
                                      random.Next(byte.MinValue, args.Area.Width),
                                      random.Next(byte.MinValue, args.Area.Height))
                            .RestoreState();
                        }
                    }

                    element?.Window?.Close();

                    return true;
                }));
            });

            _ = new TestableSciterHost(_sciterWindow)
                .SetBehaviorResolver(_mockBehaviorResolver.Object);

            _sciterWindow.Show();

            _sciterWindow.RootElement.AppendElement("body", elm => elm)
            .SetStyleValue("background", $"rgb({random.Next(byte.MinValue, byte.MaxValue)}, {random.Next(byte.MinValue, byte.MaxValue)}, {random.Next(byte.MinValue, byte.MaxValue)})")
            .SetStyleValue("behavior", behaviorName);

            SciterPlatform.RunMessageLoop();

            //Assert.NotNull(_sciterGraphics);
        }