Esempio n. 1
0
        public static string Render(RenderFunc func)
        {
            string content = string.Empty;

            using (MemoryStream ms = new MemoryStream())
            {
                using (HtmlTextWriter htmlWriter = new HtmlTextWriter(new StreamWriter(ms)))
                {
                    func(htmlWriter);
                    htmlWriter.Flush();
                }

                using (StreamReader rdr = new StreamReader(ms))
                {
                    rdr.BaseStream.Position = 0;
                    content = rdr.ReadToEnd();
                }
            }


            ITemplateEngine te = ServiceLocator.Instance.Resolve<ITemplateEngine>();

            using (StringWriter sw = new StringWriter())
            {
                te.Process(JContext.Current.ViewData, string.Empty, sw, content);

                return sw.GetStringBuilder().ToString();
            }
        }
Esempio n. 2
0
        public static string Render(RenderFunc func)
        {
            string content = string.Empty;

            using (MemoryStream ms = new MemoryStream())
            {
                using (HtmlTextWriter htmlWriter = new HtmlTextWriter(new StreamWriter(ms)))
                {
                    func(htmlWriter);
                    htmlWriter.Flush();
                }

                using (StreamReader rdr = new StreamReader(ms))
                {
                    rdr.BaseStream.Position = 0;
                    content = rdr.ReadToEnd();
                }
            }


            ITemplateEngine te = ServiceLocator.Instance.Resolve <ITemplateEngine>();

            using (StringWriter sw = new StringWriter())
            {
                te.Process(JContext.Current.ViewData, string.Empty, sw, content);

                return(sw.GetStringBuilder().ToString());
            }
        }
Esempio n. 3
0
        public static void GizmoInit()
        {
            RenderFunc F = Render;

            GCHandle.Alloc(F);
            GizmoInit(F);
        }
 public virtual void DeregisterFromRendering(RenderFunc func, RenderType rendertype)
 {
     RenderFuncWrapper funcwrapper = delegate(global::System.IntPtr wndptr, global::System.IntPtr userptr) {
         func(new IOutputWindow(wndptr, false));
     };
     {
         IronSightEnginePINVOKE.IOutputWindow_DeregisterFromRendering__SWIG_0(swigCPtr, global::System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(funcwrapper), (int)rendertype);
     }
 }
Esempio n. 5
0
        public override void Release(RenderGraphObjectPool pool)
        {
            Clear();
            pool.Release(data);
            data       = null;
            renderFunc = null;

            // We need to do the release from here because we need the final type.
            pool.Release(this);
        }
Esempio n. 6
0
        //Constructor takes a reference to a data source of any type of object and a render function
        //It will also allow for the sending of historical data if sendOldData is true.
        //To send all data, set sendOldData to true and sendOldDataNumPoints to null.
        //If sendOldDataNumPoints is greater than the number of total points in the data set, it will send all data.
        //The data will be sent ever resendTime milliseconds (default 100). Nothing will be sent if no new data is present.
        public Connection(ref List<object> dataSource, RenderFunc renderFunction, bool sendOldData, int? sendOldDataNumPoints, int resendTime = 100)
        {
            //Create the timer
            m_timer = new System.Threading.Timer(this.TimerCallback, null, 0, resendTime);
            //Set data source for stream
            m_data = dataSource;
            //Set sendOldData value to determine if we send any old data
            m_sendOldData = sendOldData;
            //If we aren't sending old data, set the number of points to 0
            //If we are sending old data and the num points is not specified (or is larger than the data set), set the number of points to send to the entire data set
            //If we are sending old data and the num points is less than 0, send 0 points
            //If we are sending old data and the num points is between 0 and the number of available data points, send the number specified
            m_sendOldDataNumPoints = m_sendOldData ? !sendOldDataNumPoints.HasValue || sendOldDataNumPoints.Value > dataSource.Count ? dataSource.Count : sendOldDataNumPoints.Value < 0 ? 0 : sendOldDataNumPoints.Value : 0;
            //Set the render function
            m_renderFunc = renderFunction;

            //Set our data sending counter to the appropriate index in the data array
            m_lastDataSent = m_data.Count - m_sendOldDataNumPoints;
        }
Esempio n. 7
0
        public override void Prerender(UIRenderContext context)
        {
            var screenPosition = context.RenderPort;

            if (View == null)
            {
                View = Matrix.CreateLookAt(new Vector3(1f, 1f, 1f), Vector3.Zero, Vector3.Up);
            }
            if (Projection == null)
            {
                Projection = Matrix.CreateOrthographicOffCenter(-1, 1, -1, 1, 0.001f, 10000f);
                //Matrix.CreatePerspective(context.GraphicsDevice.Viewport.Width, context.GraphicsDevice.Viewport.Height, 0.001f, 10000f);
            }
            if (_renderTarget == null ||
                _renderTarget.Height != screenPosition.Height ||
                _renderTarget.Width != screenPosition.Width)
            {
                _rendered     = false;
                _renderTarget = new RenderTarget2D(context.GraphicsDevice, screenPosition.Width, screenPosition.Height, false, SurfaceFormat.Vector4, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents);
            }
            if (!SingleRender || !_rendered)
            {
                context.GraphicsDevice.SetRenderTarget(_renderTarget);
                context.GraphicsDevice.Clear(Colour);

                var renderContext = new RenderContext(context.GameTime, context.SpriteBatch, context.GraphicsDevice)
                {
                    Projection = Projection,
                    View       = View,
                };
                Renderable?.Render(renderContext);
                RenderFunc?.Invoke(renderContext);
                context.GraphicsDevice.SetRenderTarget(null);
                _rendered = true;
            }
        }
Esempio n. 8
0
 public SubRect(RenderFunc render, float length)
 {
     this.length = length;
     this.render = render;
 }
Esempio n. 9
0
 public void Add(RenderFunc render, float length)
 {
     stack.Peek().Add(new SubRect(render, length));
 }
Esempio n. 10
0
 public void Add(RenderFunc render)
 {
     Add(render, 0);
 }
Esempio n. 11
0
 static extern void GizmoInit(RenderFunc F);
Esempio n. 12
0
 /// <summary>
 /// Specify the render function to use for this pass.
 /// A call to this is mandatory for the pass to be valid.
 /// </summary>
 /// <typeparam name="PassData">The Type of the class that provides data to the Render Pass.</typeparam>
 /// <param name="renderFunc">Render function for the pass.</param>
 public void SetRenderFunc <PassData>(RenderFunc <PassData> renderFunc) where PassData : class, new()
 {
     ((RenderGraph.RenderPass <PassData>)m_RenderPass).renderFunc = renderFunc;
 }
Esempio n. 13
0
        public void Render(Cairo.Context context, double width, double height, RenderFunc renderer)
        {
            if (!Enabled)
            {
                context.Save();
                renderer(context, width, height);
                context.Restore();

                return;
            }

            double w = width;
            double h = height;
            bool   first;

            AccountForScaling(context, ref w, ref h);

            long id = UniqueId((int)w, (int)h);

            Cairo.Surface ret         = null;
            bool          disposesurf = true;

            first = d_renderStack.Count == 0;

            if (first)
            {
                d_cache.TryGetValue(id, out ret);
                disposesurf = false;
            }

            if (ret == null)
            {
                while (d_cacheQueue.Count >= d_maxSize && d_maxSize != 0)
                {
                    Remove(d_cacheQueue.Dequeue());
                }

                ret         = Create(context, w, h, first);
                disposesurf = !first;

                using (Cairo.Context ctx = new Cairo.Context(ret))
                {
                    // Apply scaling and rotation here
                    ctx.Scale(context.Matrix.Xx, context.Matrix.Yy);
                    ctx.LineWidth = context.LineWidth;

                    d_renderStack.Push(ctx);

                    renderer(ctx, width, height);

                    d_renderStack.Pop();
                }
            }

            context.Save();

            // Undo scaling here
            context.Scale(1.0 / context.Matrix.Xx, 1.0 / context.Matrix.Yy);
            context.SetSourceSurface(ret, 0, 0);
            context.Paint();
            context.Restore();

            if (disposesurf)
            {
                DisposeSurface(ret);
            }
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JGL.Heirarchy.SimpleObject"/> class.
 /// </summary>
 /// <param name='name'>Object name</param>
 //        public SimpleObject(string name = null)
 //            : base(name)
 //        {
 //
 //        }
 /// <summary>
 /// Initializes a new instance of the <see cref="JGL.Heirarchy.SimpleObject"/> class.
 /// </summary>
 /// <param name='name'>Object name</param>
 //        public SimpleObject(string name, RenderFunc renderFunc)
 //            : base(name)
 //        {
 //            _renderFunc = renderFunc;
 //        }
 /// <summary>
 /// Initializes a new instance of the <see cref="JGL.Heirarchy.SimpleObject"/> class.
 /// </summary>
 /// <param name='name'>Object name</param>
 public SimpleObject(RenderFunc renderFunc)
 {
     _renderFunc = renderFunc;
 }