Пример #1
0
        public Host(SciterWindow window)
            : base(window : window)
        {
            this.RegisterBehaviorHandler(typeof(ImgDrawBehavior))
            .AttachEventHandler(new HostEventHandler());

#if DEBUG
            string location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            location += "\\..\\..\\..\\..\\..";

            string path = Path.Combine(location, "res", "index.html");

            Uri uri = new Uri(path, UriKind.Absolute);

            Debug.Assert(uri.IsFile);

            Debug.Assert(File.Exists(uri.AbsolutePath));
#else
            Uri uri = new Uri("file:///Users/midiway/Documents/SciterSharp/Tests/SciterTest.Mac/res/index.html", UriKind.Absolute);
#endif

            window.LoadPage(uri: uri);
            window.CenterWindow()
            .Show();
        }
Пример #2
0
 public AppHost(SciterWindow window)
 {
     _archive.Open(ArchiveResource.resources);
     _window = window;
     SetupWindow(_window);
     window.Show();
 }
Пример #3
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();
        }
Пример #4
0
        public AppHost(SciterWindow window)
            : base()
        {
            _window = window;

            var assembly = Assembly.Load("SciterCore.SciterSharp.Utilities");

            var attributes = assembly.GetCustomAttributes <SciterCoreArchiveAttribute>();

            foreach (var attribute in attributes)
            {
                var archive = new SciterArchive(attribute.Uri)
                              .Open(assembly: assembly, attribute.ResourceName);

                AttachedArchives.TryAdd(archive.Uri.Scheme, archive);

                if (attribute.InitScripts?.Any() != true)
                {
                    continue;
                }

                foreach (var initScript in attribute.InitScripts)
                {
                    var byteArray   = Encoding.UTF8.GetBytes($"include \"{initScript}\";");
                    var pinnedArray = GCHandle.Alloc(byteArray, GCHandleType.Pinned);
                    var pointer     = pinnedArray.AddrOfPinnedObject();
                    Sciter.SciterApi.SciterSetOption(IntPtr.Zero, SciterXDef.SCITER_RT_OPTIONS.SCITER_SET_INIT_SCRIPT,
                                                     pointer);
                    pinnedArray.Free();
                }
            }
        }
Пример #5
0
        public DlgLicenseHost(SciterWindow wnd)
        {
            Setup(wnd);
            AttachEvh(new DlgLicenseEVH());

            SetupPage("licensing.html");
        }
Пример #6
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();
        }
Пример #7
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);
        }
Пример #8
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();
        }
Пример #9
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);
        }
Пример #10
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            SciterApi.SciterSetOption(IntPtr.Zero, SciterXDef.SCITER_RT_OPTIONS.SCITER_SET_DEBUG_MODE, new IntPtr(1));

            SciterWindow = SciterWindow
                           .CreateChildWindow(Handle);

            Host.SetupWindow(SciterWindow)
            .AttachEventHandler(HostEventHandler);

            if (LoadUri != null)
            {
                var loadUriEventArgs = new LoadUriEventArgs();

                LoadUri?.Invoke(this, loadUriEventArgs);
                Host.Window.TryLoadPage(loadUriEventArgs.Uri);
            }
            else
            {
                var loadHtmlEventArgs = new LoadHtmlEventArgs()
                {
                    Html = Html
                };

                LoadHtml?.Invoke(this, loadHtmlEventArgs);
                Host.Window.LoadHtml(loadHtmlEventArgs?.Html ?? this.Html ?? string.Format(DEFAULT_HTML, Name));
            }

            OnClientSizeChanged(EventArgs.Empty);
            Host.Window.Show();
            //Host.ConnectToInspector();
        }
Пример #11
0
        public BaseArchiveHost(SciterWindow window)
            : base(window: window)
        {
            _window = window;
//#if !DEBUG
            _archive.Open();
//#endif
        }
Пример #12
0
        public Host(SciterWindow wnd)
        {
            var host = this;

            host.Setup(wnd);
            host.AttachEvh(new HostEvh());
            host.RegisterBehaviorHandler(typeof(IconsSource));
        }
Пример #13
0
 public void Setup()
 {
     _sciterWindow =
         new SciterWindow()
         .CreateMainWindow(320, 240)
         //.CenterTopLevelWindow()
         .SetTitle(nameof(SciterGraphicsTests));
 }
Пример #14
0
        protected override HandleRef BuildWindowCore(HandleRef hwndParent)
        {
            _wnd = new SciterWindow();
            _wnd.CreateChildWindow(hwndParent.Handle);
            _wnd.LoadHtml("<style>html { background: silver; }</style> <h1>Hello world!</h1>");

            return(new HandleRef(this, _wnd._hwnd));
        }
Пример #15
0
        public Host(SciterWindow wnd)
        {
            var host = this;

            host.Setup(wnd);
            host.AttachEvh(new HostEvh());
            host.SetupPage("index.html");
            wnd.Show();
        }
Пример #16
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();
        }
Пример #17
0
 public void SetupWindow_More_Than_Once_Throws_InvalidOperationException()
 {
     using (var sciterHost = new TestableSciterHost())
         using (var window = new SciterWindow(_fakePointer))
         {
             sciterHost.SetupWindow(window);
             Assert.Throws <InvalidOperationException>(() => sciterHost.SetupWindow(window));
         }
 }
Пример #18
0
 public void Destroy()
 {
     if (_wnd != null)
     {
         _wnd.Destroy();
         _wnd  = null;
         _host = null;
     }
 }
Пример #19
0
        public void Setup()
        {
            _sciterWindow =
                new SciterWindow()
                .CreateMainWindow(320, 240)
                .SetTitle(nameof(SciterGraphicsTests));

            _currentVm = Sciter.ScriptApi.GetCurrentVM();
        }
Пример #20
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();
        }
Пример #21
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();
        }
Пример #22
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();
        }
Пример #23
0
        public void Setup(SciterWindow wnd)
        {
            _wnd = wnd;
            SetupWindow(wnd._hwnd);

#if DEBUG
            wnd.SetMediaVars(SciterValue.FromDictionary(new Dictionary <string, string> {
                { "debug", "true" }
            }));
#endif
        }
Пример #24
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();
        }
Пример #25
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();
        }
Пример #26
0
        public void TestThings()
        {
            SciterWindow window =
                new SciterWindow()
                .CreateMainWindow(640, 480)
                .SetTitle("Wtf");

            _ = new TestableSciterHost(window);
            window.LoadHtml("<html></html>");

            var sv = window.EvalScript("Utils.readStreamToEnd");

            Assert.IsTrue(!sv.IsUndefined);
        }
Пример #27
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();
        }
Пример #28
0
        static void Main(string[] args)
        {
            var list = new List <int> {
                123
            };

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

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

            // 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
            AppWnd = new SciterWindow();

            var rc = new PInvokeUtils.RECT();

            rc.right  = 800;
            rc.bottom = 600;

            var wnd = AppWnd;

            //wnd.CreateWindow(rc, SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_POPUP | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_MAIN | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_RESIZEABLE);
            wnd.CreateMainWindow(1500, 800);
            wnd.CenterTopLevelWindow();
            wnd.Title = "TestCore";
            wnd.Icon  = Properties.Resources.IconMain;

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

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

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

            // Show window and Run message loop
            wnd.Show();
            PInvokeUtils.RunMsgLoop();
        }
Пример #29
0
        public void TestThings()
        {
            SciterWindow wnd = new SciterWindow();

            wnd.CreateMainWindow(1500, 800);
            wnd.Title = "Wtf";

            SciterHost host = new SciterHost(wnd);

            wnd.LoadHtml("<html></html>");

            var sv = wnd.EvalScript("Utils.readStreamToEnd");

            Assert.IsTrue(!sv.IsUndefined);
        }
Пример #30
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();
        }
Пример #31
0
 public SciterControl()
 {
     SciterWnd = new SciterWindow();
 }