Exemple #1
0
        /// <summary>
        /// Centers the window in the screen. You must call it after the window is created, but before it is shown to avoid flickering
        /// </summary>
        public void CenterTopLevelWindow()
        {
#if WINDOWS
            PInvokeUtils.RECT rectWindow;
            PInvokeWindows.GetWindowRect(_hwnd, out rectWindow);

            PInvokeUtils.RECT rectWorkArea = new PInvokeUtils.RECT();
            PInvokeWindows.SystemParametersInfo(PInvokeWindows.SPI_GETWORKAREA, 0, ref rectWorkArea, 0);

            int nX = (rectWorkArea.Width - rectWindow.Width) / 2 + rectWorkArea.left;
            int nY = (rectWorkArea.Height - rectWindow.Height) / 2 + rectWorkArea.top;

            PInvokeWindows.MoveWindow(_hwnd, nX, nY, rectWindow.Width, rectWindow.Height, false);
#elif GTKMONO
            int screen_width  = PInvokeGTK.gdk_screen_width();
            int screen_height = PInvokeGTK.gdk_screen_height();

            int window_width, window_height;
            PInvokeGTK.gtk_window_get_size(_gtkwindow, out window_width, out window_height);

            int nX = (screen_width - window_width) / 2;
            int nY = (screen_height - window_height) / 2;

            PInvokeGTK.gtk_window_move(_gtkwindow, nX, nY);
#elif OSX
            _nsview.Window.Center();
#endif
        }
Exemple #2
0
        public WindowSidebar()
        {
            PInvokeUtils.RECT rc = new PInvokeUtils.RECT();

            var flags = SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ALPHA |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_MAIN |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ENABLE_DEBUG |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_TOOL;
            var wnd = this;

            wnd.CreateWindow(rc, flags);
            wnd.Title = Consts.AppName;

            var deleg = new WindowDelegate();

            wnd._nsview.Window.Delegate  = deleg;
            wnd._nsview.Window.Level     = NSWindowLevel.Floating;
            wnd._nsview.Window.StyleMask = wnd._nsview.Window.StyleMask & ~NSWindowStyle.Resizable;

            // Create status bar item
            _sItem       = NSStatusBar.SystemStatusBar.CreateStatusItem(26);
            _sItem.Image = NSImage.FromStream(File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/drop.png"));
            //_sItem.AlternateImage = NSImage.FromStream(File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/icon_menubarX2.png"));
            _sItem.Image.Template = true;
            _sItem.Action         = new ObjCRuntime.Selector("OnIconClick");
            _sItem.Target         = deleg;
        }
Exemple #3
0
 public void CreateOwnedWindow(IntPtr owner, int width, int height, SciterXDef.SCITER_CREATE_WINDOW_FLAGS creationFlags = DefaultCreateFlags)
 {
     PInvokeUtils.RECT frame = new PInvokeUtils.RECT();
     frame.right  = width;
     frame.bottom = height;
     CreateWindow(frame, creationFlags, owner);
 }
Exemple #4
0
        public WindowSidebar()
        {
            var frm = NSScreen.MainScreen.VisibleFrame;

            PInvokeUtils.RECT rc = new PInvokeUtils.RECT()
            {
                right  = 670,
                bottom = (int)frm.Height - 50
            };

            var flags = SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ALPHA |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_MAIN |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ENABLE_DEBUG |
                        SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_TOOL;
            var wnd = this;

            wnd.CreateWindow(rc, flags);
            wnd.Title = Consts.AppName;

            var deleg = new WindowDelegate();

            wnd._nsview.Window.Delegate = deleg;
            wnd._nsview.Window.Level    = NSWindowLevel.Floating;

            // Create status bar item
            _sItem                = NSStatusBar.SystemStatusBar.CreateStatusItem(25);
            _sItem.Image          = NSImage.FromStream(File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/drop.png"));
            _sItem.Image.Template = true;
            _sItem.Action         = new ObjCRuntime.Selector("OnIconClick");
            _sItem.Target         = deleg;
            _sItem.HighlightMode  = true;
        }
Exemple #5
0
 public void CreatePopupAlphaWindow(int width, int height, IntPtr owner_hwnd)
 {
     PInvokeUtils.RECT frame = new PInvokeUtils.RECT();
     frame.right  = width;
     frame.bottom = height;
     CreateWindow(frame, SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ALPHA | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_TOOL, owner_hwnd);
     // Sciter BUG: window comes with WM_EX_APPWINDOW style
 }
Exemple #6
0
            /*
             #if WINDOWS || NETCORE
             * public bool ModifyStyle(PInvokeWindows.WindowStyles dwRemove, PInvokeWindows.WindowStyles dwAdd)
             * {
             *      int GWL_EXSTYLE = -20;
             *
             *      PInvokeWindows.WindowStyles dwStyle =
             *              (PInvokeWindows.WindowStyles) PInvokeWindows.GetWindowLongPtr(Handle, GWL_EXSTYLE);
             *      PInvokeWindows.WindowStyles dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
             *
             *      if (dwStyle == dwNewStyle)
             *              return false;
             *
             *      PInvokeWindows.SetWindowLongPtr(Handle, GWL_EXSTYLE, (IntPtr) dwNewStyle);
             *      return true;
             * }
             *
             * public bool ModifyStyleEx(PInvokeWindows.WindowStyles dwRemove, PInvokeWindows.WindowStyles dwAdd)
             * {
             *      int GWL_STYLE = -16;
             *
             *      PInvokeWindows.WindowStyles dwStyle =
             *              (PInvokeWindows.WindowStyles) PInvokeWindows.GetWindowLongPtr(Handle, GWL_STYLE);
             *      PInvokeWindows.WindowStyles dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
             *      if (dwStyle == dwNewStyle)
             *              return false;
             *
             *      PInvokeWindows.SetWindowLongPtr(Handle, GWL_STYLE, (IntPtr) dwNewStyle);
             *      return true;
             * }
             #endif*/

            /// <summary>
            /// Centers the window in the screen. You must call it after the window is created, but before it is shown to avoid flickering
            /// </summary>
            public void CenterWindow(IntPtr handle)
            {
                PInvokeWindows.GetWindowRect(handle, out var rectWindow);

                var rectWorkArea = new PInvokeUtils.RECT();

                PInvokeWindows.SystemParametersInfo(PInvokeWindows.SPI_GETWORKAREA, 0, ref rectWorkArea, 0);

                var newX = (rectWorkArea.Width - rectWindow.Width) / 2 + rectWorkArea.Left;
                var newY = (rectWorkArea.Height - rectWindow.Height) / 2 + rectWorkArea.Top;

                PInvokeWindows.MoveWindow(handle, newX, newY, rectWindow.Width, rectWindow.Height, false);
            }
Exemple #7
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();
        }
Exemple #8
0
        /// <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 | SW_ENABLE_DEBUG</param>
        public void CreateWindow(PInvokeUtils.RECT frame = new PInvokeUtils.RECT(), SciterXDef.SCITER_CREATE_WINDOW_FLAGS creationFlags = DefaultCreateFlags, IntPtr parent = new IntPtr())
        {
            _hwnd = _api.SciterCreateWindow(
                creationFlags,
                ref frame,
                _proc,
                IntPtr.Zero,
                parent
                );
            Debug.Assert(_hwnd != IntPtr.Zero);

            if (_hwnd == IntPtr.Zero)
            {
                throw new Exception("CreateWindow() failed");
            }

#if GTKMONO
            _gtkwindow = PInvokeGTK.gtk_widget_get_toplevel(_hwnd);
            Debug.Assert(_gtkwindow != IntPtr.Zero);
#elif OSX
            _nsview = new NSView(_hwnd);
#endif
        }
 public void Refresh(PInvokeUtils.RECT rc)
 {
     _api.SciterRefreshElementArea(_he, rc);
 }
 static extern bool GetWindowRect(IntPtr hwnd, out PInvokeUtils.RECT lpRect);
Exemple #11
0
 internal static SciterRectangle ToRectangle(this PInvokeUtils.RECT rect) =>
 new SciterRectangle(rect.Left, rect.Top, rect.Right, rect.Bottom);
Exemple #12
0
 internal static SciterSize ToSize(this PInvokeUtils.RECT rect) =>
 new SciterSize(rect.Width, rect.Height);