示例#1
0
        public override void Render(Graphics g, TexturedObject obj, Vector2D cameraPos)
        {
            GridTexture tex = (GridTexture)obj.GetActualTexture();

            g.InterpolationMode = tex.InterpolationMode;
            g.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

            if (tex.Image == null)
            {
                Exception ex = new RenderException("Image was not initialized in texture \"" + tex.Name);
                Log.Exception(ex);
                throw ex;
            }


            for (int x = 0; x < tex.xCount; x++)
            {
                for (int y = 0; y < tex.yCount; y++)
                {
                    g.DrawImage(
                        tex.Image,
                        new Rectangle(
                            new Point(
                                (int)(obj.GetStartPosition().X - cameraPos.X + x * obj.Scale.Width * obj.Size.Width),
                                (int)(obj.GetStartPosition().Y - cameraPos.Y + y * obj.Scale.Height * obj.Size.Height)
                                ), new System.Drawing.Size(
                                (int)(obj.Scale.Width * obj.Size.Width),
                                (int)(obj.Scale.Height * obj.Size.Height)
                                )
                            )
                        );
                }
            }
        }
示例#2
0
        /// <summary>
        /// Will expand the input into the appropriate content based on scope.
        /// </summary>
        /// <param name="scopeName">The scope name.</param>
        /// <param name="input">The input to be expanded.</param>
        /// <param name="htmlEncode">Function that will html encode the output.</param>
        /// <param name="attributeEncode">Function that will html attribute encode the output.</param>
        /// <returns>The expanded content.</returns>
        protected override string PerformExpand(string scopeName, string input, Func <string, string> htmlEncode, Func <string, string> attributeEncode)
        {
            FloatAlignment alignment    = GetAlignment(scopeName);
            var            renderMethod = GetRenderMethod(scopeName);

            return(RenderException.ConvertAny(() => renderMethod(input, alignment, attributeEncode)));
        }
        public override void Render(Graphics g, TexturedObject obj, Vector2D cameraPos)
        {
            RegularTexture tex = (RegularTexture)obj.GetActualTexture();

            g.InterpolationMode = tex.InterpolationMode;
            g.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

            if (tex.Image == null)
            {
                Exception ex = new RenderException("Image was not initialized in texture \"" + tex.Name);
                Log.Exception(ex);
                throw ex;
            }

            g.DrawImage(
                tex.Image,
                new Rectangle(
                    new Point(
                        (int)(obj.GetStartPosition().X - cameraPos.X),
                        (int)(obj.GetStartPosition().Y - cameraPos.Y)
                        ), new System.Drawing.Size(
                        (int)Math.Round(obj.Scale.Width * obj.Size.Width, MidpointRounding.AwayFromZero),
                        (int)Math.Round(obj.Scale.Height * obj.Size.Height, MidpointRounding.AwayFromZero)
                        )
                    )
                );
        }
示例#4
0
        private static string ExpandLinkWithText(string input, Func <string, string> attributeEncode, Func <string, string> htmlEncode)
        {
            TextPart part = RenderException.ConvertAny(() => Utility.ExtractTextParts(input));
            string   url  = part.Text;

            if (!url.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !url.StartsWith("mailto", StringComparison.OrdinalIgnoreCase))
            {
                url = "http://" + url;
            }

            return(string.Format(LinkFormat, attributeEncode(url), htmlEncode(part.FriendlyText)));
        }
示例#5
0
        /// <summary>
        /// Unbind this BufferObject.
        /// </summary>
        internal override void Unbind(GraphicsContext ctx)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException("ctx");
            }

            if (ctx.Caps.GlExtensions.TransformFeedback2_ARB)
            {
                // Bind this  feedback buffer
                Gl.BindTransformFeedback(Gl.TRANSFORM_FEEDBACK, 0);
            }
#if false
            else
            {
                // Manually map buffer objects
                foreach (KeyValuePair <uint, ArrayAttachment> pair in mAttachedArrays)
                {
                    Gl.BindBufferBase(Gl.TRANSFORM_FEEDBACK_BUFFER, pair.Key, 0);
                    RenderException.DebugCheckErrors();
                }
            }
#endif
        }