Esempio n. 1
0
        protected override bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
        {
            if (_model == null)
            {
                return(false);
            }

            if (prms.cmd == SciterXBehaviors.DRAW_EVENTS.DRAW_CONTENT)
            {
                var pngExporter = new PngExporter()
                {
                    Width      = prms.area.Width,
                    Height     = prms.area.Height,
                    Background = OxyColors.Transparent
                };

                /*using(var ms = new MemoryStream())
                 * {
                 *      var bmp = pngExporter.ExportToBitmap(_model);
                 *
                 *      using(var img = new SciterImage(bmp))
                 *      {
                 *              new SciterGraphics(prms.gfx).BlendImage(img, prms.area.left, prms.area.top);
                 *      }
                 * }*/

                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        protected override bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
        {
            if (prms.cmd == SciterXBehaviors.DRAW_EVENTS.DRAW_CONTENT)
            {
                using (SciterGraphics g = new SciterGraphics(prms.gfx))
                {
                    g.StateSave();
                    g.Translate(prms.area.left, prms.area.top);

                    List <Tuple <float, float> > points = new List <Tuple <float, float> >
                    {
                        Tuple.Create(100.0f, 0.0f),
                        Tuple.Create(150.0f, 150.0f),
                        Tuple.Create(50.0f, 150.0f)
                    };

                    g.LineColor = new RGBAColor(0, 0, 255);
                    g.FillColor = new RGBAColor(255, 0, 0);
                    g.LineWidth = 5;
                    g.Polygon(points);
                    g.Ellipse(200, 50, 50, 50);

                    g.StateRestore();
                }

                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        protected override bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
        {
            if (prms.cmd == SciterXBehaviors.DRAW_EVENTS.DRAW_CONTENT)
            {
                lock (_invalidateLock)
                {
                    if (_isModelInvalidated)
                    {
                        if (_model != null)
                        {
                            ((IPlotModel)_model).Update(this._updateDataFlag);
                            _updateDataFlag = false;
                        }

                        _isModelInvalidated = false;
                    }
                }

                lock (_renderingLock)
                {
                    using (var gfx = new SciterGraphics(prms.gfx))
                    {
                        _renderContext.SetGraphicsTarget(gfx);

                        gfx.StateSave();
                        gfx.Translate(prms.area.left + 0.5f, prms.area.top + 0.5f);

                        if (_model != null)
                        {
                            var size = _se.SizePadding;
                            ((IPlotModel)_model).Render(_renderContext, size.cx, size.cy);
                        }

                        // zoomRectangle, empty?
                        if (_zoomRectangle.Width != 0 && _zoomRectangle.Height != 0)
                        {
                            gfx.FillColor = new RGBAColor(0xFF, 0xFF, 0x00, 0x40);
                            gfx.Rectangle((float)_zoomRectangle.Left, (float)_zoomRectangle.Top, (float)_zoomRectangle.Right, (float)_zoomRectangle.Bottom);
                        }

                        if (_tracker != null)
                        {
                            Debug.Assert(_tracker.Item != null);
                            Debug.Assert(_tracker.Text != null);
                            gfx.FillColor = new RGBAColor(255, 0, 0);
                            gfx.Ellipse((float)_tracker.Position.X, (float)_tracker.Position.Y, 10, 10);
                        }

                        gfx.StateRestore();
                    }
                }
            }
            return(false);
        }
Esempio n. 4
0
        protected override bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
        {
            if (prms.cmd == SciterXBehaviors.DRAW_EVENTS.DRAW_CONTENT)
            {
                SciterText txt = SciterText.Create("hi", se._he);

                using (SciterGraphics g = new SciterGraphics(prms.gfx))
                {
                    g.DrawText(txt, 0, 0, 7);
                }

                return(true);
            }
            return(false);
        }
        protected override bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
        {
            var b = new Bitmap(406, 400);

            using (var g = Graphics.FromImage(b))
            {
                LinearGradientBrush linGrBrush = new LinearGradientBrush(
                    new Point(0, 10),
                    new Point(200, 10),
                    Color.FromArgb(255, 255, 0, 0),                       // Opaque red
                    Color.FromArgb(255, 0, 0, 255));                      // Opaque blue
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.FillEllipse(linGrBrush, 0, 30, 200, 100);
            }

            var img = new SciterImage(b);
            var gfx = new SciterGraphics(prms.gfx);

            gfx.BlendImage(img, 0, 0);
            return(true);
        }
        protected override bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
        {
            if (prms.cmd == SciterXBehaviors.DRAW_EVENTS.DRAW_CONTENT)
            {
                SciterText txt = SciterText.Create("hi", new SciterXGraphics.SCITER_TEXT_FORMAT
                {
                    fontFamily = "Arial",
                    fontSize   = 15,
                    fontWeight = 400,
                    lineHeight = 30
                });

                using (SciterGraphics g = new SciterGraphics(prms.gfx))
                {
                    g.DrawText(txt, 0, 0, 7);
                }

                return(true);
            }
            return(false);
        }
Esempio n. 7
0
        // EventProc
        private bool EventProc(IntPtr tag, IntPtr he, uint evtg, IntPtr prms)
        {
            SciterElement se = null;

            if (he != IntPtr.Zero)
            {
                se = new SciterElement(he);
            }

            switch ((SciterXBehaviors.EVENT_GROUPS)evtg)
            {
            case SciterXBehaviors.EVENT_GROUPS.SUBSCRIPTIONS_REQUEST:
            {
                SciterXBehaviors.EVENT_GROUPS groups;
                Subscription(se, out groups);
                Marshal.WriteInt32(prms, (int)groups);
                return(true);
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_INITIALIZATION:
            {
                SciterXBehaviors.INITIALIZATION_PARAMS p = (SciterXBehaviors.INITIALIZATION_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.INITIALIZATION_PARAMS));
                if (p.cmd == SciterXBehaviors.INITIALIZATION_EVENTS.BEHAVIOR_ATTACH)
                {
#if DEBUG
                    Debug.Assert(_is_attached == false);
                    _is_attached = true;
#endif
                    _attached_handlers.Add(this);
                    Attached(se);
                }
                else if (p.cmd == SciterXBehaviors.INITIALIZATION_EVENTS.BEHAVIOR_DETACH)
                {
#if DEBUG
                    Debug.Assert(_is_attached == true);
                    _is_attached = false;
#endif
                    _attached_handlers.Remove(this);
                    Detached(se);
                }
                return(true);
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_MOUSE:
            {
                SciterXBehaviors.MOUSE_PARAMS p = (SciterXBehaviors.MOUSE_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.MOUSE_PARAMS));
                return(OnMouse(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_KEY:
            {
                SciterXBehaviors.KEY_PARAMS p = (SciterXBehaviors.KEY_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.KEY_PARAMS));
                return(OnKey(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_FOCUS:
            {
                SciterXBehaviors.FOCUS_PARAMS p = (SciterXBehaviors.FOCUS_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.FOCUS_PARAMS));
                return(OnFocus(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_DRAW:
            {
                SciterXBehaviors.DRAW_PARAMS p = (SciterXBehaviors.DRAW_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.DRAW_PARAMS));
                return(OnDraw(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_TIMER:
            {
                SciterXBehaviors.TIMER_PARAMS p = (SciterXBehaviors.TIMER_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.TIMER_PARAMS));
                if (p.timerId != IntPtr.Zero)
                {
                    return(OnTimer(se, p.timerId));
                }
                return(OnTimer(se));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_BEHAVIOR_EVENT:
            {
                SciterXBehaviors.BEHAVIOR_EVENT_PARAMS p = (SciterXBehaviors.BEHAVIOR_EVENT_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.BEHAVIOR_EVENT_PARAMS));
                SciterElement se2 = p.he != IntPtr.Zero ? new SciterElement(p.he) : null;
                return(OnEvent(se, se2, p.cmd, p.reason, new SciterValue(p.data)));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_METHOD_CALL:
            {
                SciterXDom.METHOD_PARAMS p = (SciterXDom.METHOD_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXDom.METHOD_PARAMS));
                return(OnMethodCall(se, p.methodID));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_DATA_ARRIVED:
            {
                SciterXBehaviors.DATA_ARRIVED_PARAMS p = (SciterXBehaviors.DATA_ARRIVED_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.DATA_ARRIVED_PARAMS));
                return(OnDataArrived(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_SCROLL:
            {
                SciterXBehaviors.SCROLL_PARAMS p = (SciterXBehaviors.SCROLL_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.SCROLL_PARAMS));
                return(OnScroll(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_SIZE:
                return(OnSize(se));

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_SCRIPTING_METHOD_CALL:
            {
                IntPtr RESULT_OFFSET = Marshal.OffsetOf(typeof(SciterXBehaviors.SCRIPTING_METHOD_PARAMS), "result");
#if OSX
                if (IntPtr.Size == 4)
                {
                    Debug.Assert(RESULT_OFFSET.ToInt32() == 12);
                }
#else
                if (IntPtr.Size == 4)
                {
                    Debug.Assert(RESULT_OFFSET.ToInt32() == 16);                                    // yep 16, strange but is what VS C++ compiler says
                }
#endif
                else if (IntPtr.Size == 8)
                {
                    Debug.Assert(RESULT_OFFSET.ToInt32() == 24);
                }

                SciterXBehaviors.SCRIPTING_METHOD_PARAMS        p  = (SciterXBehaviors.SCRIPTING_METHOD_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.SCRIPTING_METHOD_PARAMS));
                SciterXBehaviors.SCRIPTING_METHOD_PARAMS_Wraper pw = new SciterXBehaviors.SCRIPTING_METHOD_PARAMS_Wraper(p);

                bool bOK = OnScriptCall(se, pw.name, pw.args, out pw.result);
                if (bOK && pw.result != null)
                {
                    SciterXValue.VALUE vres = pw.result.ToVALUE();
                    IntPtr             vptr = IntPtr.Add(prms, RESULT_OFFSET.ToInt32());
                    Marshal.StructureToPtr(vres, vptr, false);
                }

                return(bOK);
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_TISCRIPT_METHOD_CALL:
                /*
                 * COMMENTED BECAUSE THIS EVENT IS NEVER USED, AND JUST ADDS MORE CONFUSION
                 * INSTEAD, IT'S BETTER TO HANDLE EVENT_GROUPS.HANDLE_SCRIPTING_METHOD_CALL/OnScriptCall
                 *      {
                 *              SciterXBehaviors.TISCRIPT_METHOD_PARAMS p = Marshal.PtrToStructure<SciterXBehaviors.TISCRIPT_METHOD_PARAMS>(prms);
                 *              bool res = OnScriptCall(se, p);
                 *              return res;
                 *      }
                 */
                return(false);

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_GESTURE:
            {
                SciterXBehaviors.GESTURE_PARAMS p = (SciterXBehaviors.GESTURE_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.GESTURE_PARAMS));
                return(OnGesture(se, p));
            }

            default:
                Debug.Assert(false);
                return(false);
            }
        }
Esempio n. 8
0
 protected virtual bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
 {
     return(false);
 }