private RectangleF?DrawWaveSpecturum(Graphics graphics, WavePlotPara plotPara, IEnumerable <ChannelPlotData> plotDatas)
        {
            PlotElementInfoAbs wave = this._content;

            if (wave == null)
            {
                return(null);
            }

            //填充主波形背景
            if (wave.BackgroudColor != null)
            {
                graphics.FillRectangle(wave.BackgroudColor, wave.Area);
            }

            if (plotPara == null || plotDatas == null)
            {
                return(null);
            }

            double     sbto            = plotPara.SBTOMillisecond;      //显示区域起始时间
            double     seto            = plotPara.GetSETOMillisecond(); //显示区域结束时间
            RectangleF?wavSelectedArea = this.GetSelectedAreaBackground(wave.Area, plotPara, sbto, seto);

            if (wavSelectedArea.HasValue)
            {
                //填充主波形选中背景
                graphics.FillRectangle(this._seleactionAreaBrush, wavSelectedArea.Value);
            }

            //绘制波形图
            this.DrawWaveDb(graphics, wave, plotPara, plotDatas, false);

            return(wavSelectedArea);
        }
Exemple #2
0
        public void PerformDrawing(RectangleF?clipRect, Action draw)
        {
            bool recreated = false;

            do
            {
                try
                {
                    recreated = false;
                    BeginDrawing(clipRect);
                    draw();
                    EndDrawing(clipRect != null);
                }
                catch (s.SharpDXException ex)
                {
                    if (ex.ResultCode == 0x8899000C)                     // D2DERR_RECREATE_TARGET
                    {
                        Debug.WriteLine("Recreating targets");
                        // need to recreate render target
                        CreateRenderTarget();
                        CurrentRenderTarget = Control;
                        globalRenderTarget  = null;
                        recreated           = true;
                    }
                }
            }while (recreated);
        }
        public override void AddPotentialFocusableElements(RectangleF?startingRect, ICollection <FrameworkElement> elements)
        {
            ICollection <FrameworkElement> potentialElements = new List <FrameworkElement>();

            base.AddPotentialFocusableElements(startingRect, potentialElements);

            object restoreFocusItem = RestoreFocusItem;

            // Try and find the element that has the restoreFocusItem as Context
            if (restoreFocusItem != null && _itemsHostPanel != null)
            {
                foreach (FrameworkElement potentialElement in potentialElements)
                {
                    Visual element = potentialElement;
                    while (element != null && element.VisualParent != _itemsHostPanel)
                    {
                        element = element.VisualParent;
                    }
                    if (element?.Context == restoreFocusItem)
                    {
                        // Just add this element to ensure that
                        // it gets the focus
                        elements.Add(potentialElement);
                        return;
                    }
                }
            }

            // No matching element found, use the default focus selection
            CollectionUtils.AddAll(elements, potentialElements);
        }
Exemple #4
0
        public void DrawImage(IBitmapImage Image, RectangleF?Region, int Opacity = 100)
        {
            if (!(Image is DrawingImage drawingImage))
            {
                return;
            }

            var img = drawingImage.Image;

            var region = Region is RectangleF r
                ? new Rectangle((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height)
                : new Rectangle(Point.Empty, img.Size);

            if (Opacity < 100)
            {
                var colormatrix = new ColorMatrix
                {
                    Matrix33 = Opacity / 100.0f
                };

                var imgAttribute = new ImageAttributes();
                imgAttribute.SetColorMatrix(colormatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

                _graphics.DrawImage(img, region, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imgAttribute);
            }
            else
            {
                _graphics.DrawImage(img, region);
            }
        }
Exemple #5
0
        /// <summary>
        /// Predicts which FrameworkElement should get the focus when the specified <paramref name="key"/>
        /// was pressed.
        /// </summary>
        /// <param name="currentFocusRect">The borders of the currently focused control.</param>
        /// <param name="key">The key to evaluate.</param>
        /// <returns>Framework element which gets focus when the specified <paramref name="key"/> was
        /// pressed, or <c>null</c>, if no focus change should take place.</returns>
        public FrameworkElement PredictFocus(RectangleF?currentFocusRect, Key key)
        {
            FrameworkElement element = _root;

            if (element == null)
            {
                return(null);
            }
            if (key == Key.Up)
            {
                return(element.PredictFocus(currentFocusRect, MoveFocusDirection.Up));
            }
            if (key == Key.Down)
            {
                return(element.PredictFocus(currentFocusRect, MoveFocusDirection.Down));
            }
            if (key == Key.Left)
            {
                return(element.PredictFocus(currentFocusRect, MoveFocusDirection.Left));
            }
            if (key == Key.Right)
            {
                return(element.PredictFocus(currentFocusRect, MoveFocusDirection.Right));
            }
            return(null);
        }
 internal FieldActualInfo(Page page, Template.Field actualfield, RectangleF?actualRectangle, FieldActualInfo tableFieldActualInfo)
 {
     this.page            = page;
     ActualField          = actualfield;
     ActualRectangle      = actualRectangle;
     TableFieldActualInfo = tableFieldActualInfo;
 }
Exemple #7
0
        public void Draw(Texture2D texture, RectangleF targetRectangle, RectangleF?sourceRectangle, Color color, Vector2 origin, QuadEffects effects, float layerDepth)
        {
            PrepareGroup();

            if (targetRectangle.Width == 0 || targetRectangle.Height == 0)
            {
                // Empty draw, ignore it
                return;
            }

            var bounds = texture.Bounds;
            var s      = new Vector2I(bounds.Width, bounds.Height);

            var entry = new BatchEntry();

            entry.Texture       = texture;
            entry.Color         = color;
            entry.SourceRect    = sourceRectangle ?? new RectangleF(0, 0, s.X, s.Y);
            entry.Origin        = origin;
            entry.SpriteEffects = effects;
            entry.Transform     =
                Matrix.CreateScale(targetRectangle.Width / entry.SourceRect.Width, targetRectangle.Height / entry.SourceRect.Height, 1.0f) *
                Matrix.CreateTranslation(targetRectangle.X, targetRectangle.Y, 0);

            currentBatch.Entries.Add(entry);
        }
        /// <summary>
        /// Adds a sprite to a batch of sprites for rendering using the specified texture, position, source rectangle, color, rotation, origin, scale, effects, and layer.
        /// </summary>
        /// <param name="texture">A texture.</param>
        /// <param name="position">The location (in screen coordinates) to draw the sprite.</param>
        /// <param name="sourceRectangle">A rectangle that specifies (in texels) the source texels from a texture. Use null to draw the entire texture. </param>
        /// <param name="color">The color to tint a sprite. Use Color4.White for full color with no tinting.</param>
        /// <param name="rotation">Specifies the angle (in radians) to rotate the sprite about its center.</param>
        /// <param name="origin">The sprite origin in the texture in pixels (dependent of image orientation). Default value is (0,0) which represents the upper-left corner.</param>
        /// <param name="scale">Scale factor.</param>
        /// <param name="effects">Effects to apply.</param>
        /// <param name="orientation">The source image orientation</param>
        /// <param name="layerDepth">The depth of a layer. By default, 0 represents the front layer and 1 represents a back layer. Use SpriteSortMode if you want sprites to be sorted during drawing.</param>
        public void Draw(Texture texture, Vector2 position, RectangleF?sourceRectangle, Color4 color, float rotation,
                         Vector2 origin, float scale = 1f, SpriteEffects effects = SpriteEffects.None, ImageOrientation orientation = ImageOrientation.AsIs, float layerDepth = 0, Color4 colorAdd = default(Color4), SwizzleMode swizzle = SwizzleMode.None)
        {
            var destination = new RectangleF(position.X, position.Y, scale, scale);

            DrawSprite(texture, ref destination, true, ref sourceRectangle, color, colorAdd, rotation, ref origin, effects, orientation, layerDepth, swizzle);
        }
Exemple #9
0
        /// <summary>
        /// Adds a sprite to a batch of sprites for rendering using the specified texture, position, source rectangle, color, rotation, origin, scale, effects, and layer.
        /// </summary>
        /// <param name="texture">A texture.</param>
        /// <param name="position">The location (in screen coordinates) to draw the sprite.</param>
        /// <param name="sourceRectangle">A rectangle that specifies (in texels) the source texels from a texture. Use null to draw the entire texture. </param>
        /// <param name="color">The color to tint a sprite. Use Color.White for full color with no tinting.</param>
        /// <param name="rotation">Specifies the angle (in radians) to rotate the sprite about its center.</param>
        /// <param name="origin">The sprite origin in the texture in pixels (dependent of image orientation). Default value is (0,0) which represents the upper-left corner.</param>
        /// <param name="scale">Scale factor.</param>
        /// <param name="effects">Effects to apply.</param>
        /// <param name="orientation">The source image orientation</param>
        /// <param name="layerDepth">The depth of a layer. By default, 0 represents the front layer and 1 represents a back layer. Use SpriteSortMode if you want sprites to be sorted during drawing.</param>
        public void Draw(Texture texture, Vector2 position, RectangleF?sourceRectangle, Color4 color, float rotation,
                         Vector2 origin, Vector2 scale, SpriteEffects effects = SpriteEffects.None, ImageOrientation orientation = ImageOrientation.AsIs, float layerDepth = 0)
        {
            var destination = new RectangleF(position.X, position.Y, scale.X, scale.Y);

            DrawSprite(texture, ref destination, true, ref sourceRectangle, color, rotation, ref origin, effects, orientation, layerDepth);
        }
Exemple #10
0
        internal void InternalDrawGlyph(ref InternalDrawCommand parameters, ref Vector2 fontSize, ref Glyph glyph, float x, float y, float nextx, ref Vector2 auxiliaryScaling)
        {
            if (char.IsWhiteSpace((char)glyph.Character) || glyph.Subrect.Width == 0 || glyph.Subrect.Height == 0)
            {
                return;
            }

            var spriteEffects = parameters.SpriteEffects;

            var offset = new Vector2(x, y + GetBaseOffsetY(fontSize.Y) + glyph.Offset.Y);

            Vector2.Modulate(ref offset, ref AxisDirectionTable[(int)spriteEffects & 3], out offset);
            Vector2.Add(ref offset, ref parameters.Origin, out offset);
            offset.X = (float)Math.Round(offset.X);
            offset.Y = (float)Math.Round(offset.Y);

            if (spriteEffects != SpriteEffects.None)
            {
                // For mirrored characters, specify bottom and/or right instead of top left.
                var glyphRect = new Vector2(glyph.Subrect.Right - glyph.Subrect.Left, glyph.Subrect.Top - glyph.Subrect.Bottom);
                Vector2.Modulate(ref glyphRect, ref AxisIsMirroredTable[(int)spriteEffects & 3], out offset);
            }
            var        destination     = new RectangleF(parameters.Position.X, parameters.Position.Y, parameters.Scale.X, parameters.Scale.Y);
            RectangleF?sourceRectangle = glyph.Subrect;

            parameters.SpriteBatch.DrawSprite(Textures[glyph.BitmapIndex], ref destination, true, ref sourceRectangle, parameters.Color, new Color4(0, 0, 0, 0), parameters.Rotation, ref offset, spriteEffects, ImageOrientation.AsIs, parameters.Depth, swizzle, true);
        }
Exemple #11
0
 public void SetClip(IGraphicsPath path)
 {
     ResetClip();
     clipPath   = path;
     clipBounds = path.Bounds;
     ApplyClip();
 }
Exemple #12
0
 public UserListRow(PnlUserList parent, GPG.Multiplayer.Client.Clans.ClanMember clanMember, UserListStyles style, UserListCategories initialCategory)
 {
     this.PlayerAwards = null;
     this.PlayerStatus = null;
     this.mCategory = UserListCategories.Online;
     this.mPreviousRow = null;
     this.mNextRow = null;
     this.mIsSelected = false;
     this.LastCategory = null;
     this.ClanRankImage = null;
     this.Award1Image = null;
     this.Award2Image = null;
     this.Award3Image = null;
     this.AvatarImage = null;
     this.StatusImage = null;
     this.ClanLabelBounds = null;
     this.mParent = parent;
     this.mClanMember = clanMember;
     this.mStyle = style;
     this.mCategory = initialCategory;
     this.Parent.MouseMove += new MouseEventHandler(this.Parent_MouseMove);
     this.Parent.MouseDown += new MouseEventHandler(this.Parent_MouseDown);
     this.Parent.MouseUp += new MouseEventHandler(this.Parent_MouseUp);
     this.BindToClanMember(clanMember);
 }
Exemple #13
0
        //Constructors
        /// <summary>
        /// Create a Quad.
        /// </summary>
        /// <param name="pos">Position.</param>
        /// <param name="dim">Dimensions.</param>
        /// <param name="colors">Color of each vertex - use NULL if no special colors needed.</param>
        /// <param name="texpath">Path to the texture to use - leave empty ("") if no texture needed.</param>
        /// <param name="texcoords">OPTIONAL: Custom texture-coordinates. Leave as NULL if not needed (use whole image/texture). Default is NULL.</param>
        /// <param name="vbo">OPTIONAL: Which VBO to put the data in. Default is -1, which means get the default one from the VBOHandler-class.</param>
        /// <param name="progid">OPTIONAL: Which Shader program to use. Default is -1, which means get the default one from the ShaderHandler-class.</param>
        /// <param name="InterleavedVBO">OPTIONAL: True if the data should be interleaved in the VBO. Default is true.</param>
        /// <param name="PosInVBO">OPTIONAL: Put the postion into the VBO. Default is false, since position is calculated in the shader instead.</param>
        public Drawable(Vector3 pos, Vector2 dim, Vector4[] colors, string texpath, RectangleF? texcoords = null, int vbo = -1, int progid = -1, bool InterleavedVBO = true, bool PosInVBO = false)
        {
            //Quad/2D
            pos_V3 = pos;
            center_V3 = new Vector3(pos.X + (dim.X / 2), pos.Y + (dim.Y / 2), 0.0f);
            posInVBO_B = PosInVBO;
            texCoords_RFN = texcoords;
            shadowCaster_B = false;
            //ammountOfVerticesI = (() ? 6 : 3);
            //texUnit_I = 0;
            ammountOfVertices_I = 6; //If we ever need a "non-doubletri" Quad remember to update this!!!

            if(vbo > 0) { vBO_I = vbo; } else { vBO_I = VBOHandler.DefaultBuffer; }
            if(vBO_I <= 0) { Console.WriteLine("ERROR: Error getting VBO buffer! (" + vBO_I + ") (Quad)"); }
            if(progid > 0) { progID_I = progid; } else { progID_I = ShaderHandler.DefaultProgram; }
            if(progID_I <= 0) { Console.WriteLine("ERROR: Error getting Shader Program! (" + progID_I + ") (Quad)"); }
            //iProgID = progid; uiVBO = vbo;
            //Console.WriteLine("Drawable: Pos: " + posV3 + " Dimensions: " + dim + " - VBO: " + vBOI + " - Shader: " + progIDI);

            attrVert_I = ShaderHandler.GetAttribLoc(progID_I, "v3Vert");
            attrCol_I = ShaderHandler.GetAttribLoc(progID_I, "v4ColorIn");
            attrTexCoords_I = ShaderHandler.GetAttribLoc(progID_I, "v2TexCoordsIn");
            //iUniformPos = ShaderHandler.GetAttribLoc(iProgID, "v3Position");
            uniformUseCol_I = ShaderHandler.GetUniformLoc(progID_I, "iUseCol");
            uniformUseTex_I = ShaderHandler.GetUniformLoc(progID_I, "iUseTex");
            uniformStaticPos_I = ShaderHandler.GetUniformLoc(progID_I, "iStaticPos");
            uniformSampler_I = ShaderHandler.GetUniformLoc(progID_I, "s2dSample");
            uniformMod_I = ShaderHandler.GetUniformLoc(progID_I, "m4Model");
            uniformShadowCaster_I = ShaderHandler.GetUniformLoc(progID_I, "iShadowCaster");
            #if DEBUG
            /*if(attrVert_I < 0) { Console.WriteLine("ERROR: Error binding attribute \"Vert\" in a drawable!"); }
            if(attrCol_I < 0) { Console.WriteLine("ERROR: Error binding attribute \"Color\" in a drawable!"); }
            if(attrTexCoords_I < 0) { Console.WriteLine("ERROR: Error binding attribute \"TexCoords\" in a drawable!"); }
            //if(iUniformPos < 0) { Console.WriteLine("ERROR: Error binding uniform \"Position\" in a drawable!"); }
            if(uniformUseCol_I < 0) { Console.WriteLine("ERROR: Error binding uniform \"UseCol\" in a drawable!"); }
            if(uniformUseTex_I < 0) { Console.WriteLine("ERROR: Error binding uniform \"UseTex\" in a drawable!"); }
            if(uniformSampler_I < 0) { Console.WriteLine("ERROR: Error binding uniform \"Sampler\" in a drawable!"); } else { GL.Uniform1(uniformSampler_I, 0); } //Change if ever need more than Texture Unit 0! (Also see in Draw())
            if(uniformMod_I < 0) { Console.WriteLine("ERROR: Error binding uniform \"Model\" in a drawable!"); }*/
            #endif

            if(colors != null && colors.Length > 0) { //If color(s)
                for(int i = 0; i < colors.Length; i++) {
                    //Convert color if needed
                    if(colors[i].X > 1 || colors[i].Y > 1 || colors[i].Z > 1 || colors[i].W > 1) {
                        colors[i] = Misc.ColorVec4ToVector4(colors[i]);
                    }
                }
                hasColor_B = true;
            }
            else { hasColor_B = false; }

            if(texpath != "") { //If texture
                texID_I = TextureHandler.LoadTexture(texpath);
                hasTexture_B = true;
                GL.Uniform1(uniformSampler_I, 0); //Move?
            }
            else { texID_I = 0; hasTexture_B = false; }

            InitVBOData(pos_V3, dim, colors, texpath, texcoords, vbo, progid, InterleavedVBO, PosInVBO);
        }
Exemple #14
0
        // 進行と描画


        public void 描画する(DeviceContext dc, 種類 type, Vector2 中央位置dpx, float 拡大率 = 1f)
        {
            var 矩形 = new RectangleF?();

            switch (type)
            {
            case 種類._Tom1: 矩形 = this._矢印の矩形リスト["Up"]; break;

            case 種類._Tom2: 矩形 = this._矢印の矩形リスト["Down"]; break;

            case 種類.左_Snare: 矩形 = this._矢印の矩形リスト["Left"]; break;

            case 種類.右_Tom3: 矩形 = this._矢印の矩形リスト["Right"]; break;
            }

            if (矩形 is null)
            {
                return;
            }

            var 左上位置dpx = new Vector3(
                Global.GraphicResources.画面左上dpx.X + 中央位置dpx.X - 矩形.Value.Width * 拡大率 / 2f,
                Global.GraphicResources.画面左上dpx.Y + 中央位置dpx.Y - 矩形.Value.Height * 拡大率 / 2f,
                0f);

            var 換行列 =
                Matrix.Scaling(拡大率) *
                Matrix.Translation(左上位置dpx);

            this._矢印画像.描画する(dc, 換行列, 転送元矩形: 矩形);
        }
    public void AddImage(Image image) {
        // scale image
        float widthMultiplier = maxDimension / (float)image.Width;
        float heightMultiplier = maxDimension / (float)image.Height;
        float minMultiplier = Math.Min(Math.Min(widthMultiplier, heightMultiplier), 1f);
        float newWidth = minMultiplier * (float)image.Width;
        float newHeight = minMultiplier * (float)image.Height;

        // choose a random translation & rotation
        float angle = GetRandomAngle();
        PointF newDimensions = RotateAndFindNewDimensions(new PointF(newWidth, newHeight), angle);
        PointF offset = GetRandomOffset(newDimensions);
        surfaceGraphics.TranslateTransform(offset.X, offset.Y);
        surfaceGraphics.RotateTransform(angle);

        // draw borders + image
        DrawRectangle(Brushes.White, newWidth, newHeight, thickLineWidth);
        DrawRectangle(Brushes.Black, newWidth, newHeight, thinLineWidth);
        surfaceGraphics.DrawImage(image, -newWidth / 2f, -newHeight / 2f, newWidth, newHeight);

        // calculate new image boundaries
        RectangleF newBounds = new RectangleF(
            offset.X - newDimensions.X / 2f,
            offset.Y - newDimensions.Y / 2f,
            newDimensions.X,
            newDimensions.Y);

        if (surfaceBounds.HasValue) {
            surfaceBounds = Union(surfaceBounds.Value, newBounds);
        } else {
            surfaceBounds = newBounds;
        }

        surfaceGraphics.ResetTransform();
    }
Exemple #16
0
        public void SetVarValueText(
            int index, string titleTxt, float maxValue, string fontTxt, string backTxt, Font font,
            Color color, RectangleF?incRect, float lineHeight, DrawPositionType drawPosType, bool isLimitBox)
        {
            ScTxtInfo txtInfo;

            if (rowTextInfoList[index] != null)
            {
                txtInfo = rowTextInfoList[index];
            }
            else
            {
                txtInfo = new ScTxtInfo(this);
            }

            txtInfo.maxVarValue    = maxValue;
            txtInfo.fontTxt        = fontTxt;
            txtInfo.backTxt        = backTxt;
            txtInfo.txtColor       = color;
            txtInfo.txtFont        = font;
            txtInfo.lineHeight     = lineHeight;
            txtInfo.incRect        = incRect;
            txtInfo.drawPosType    = drawPosType;
            txtInfo.isLimitBox     = isLimitBox;
            txtInfo.titleTxt       = titleTxt;
            txtInfo.isMultipleRow  = false;
            rowTextInfoList[index] = txtInfo;
        }
        public FrameContext(UIView view, UIView relativeView)
        {
            View = view;

            Frame = View.Frame;
            ParentBounds = View.Superview != null ? View.Superview.Bounds : (RectangleF?)null;
            RelativeFrame = relativeView != null ? relativeView.Frame : (RectangleF?)null;
        }
 /// <summary>
 ///     Adds a string to a batch of sprites for rendering using the specified font, text, position, color,
 ///     layer, and width (in pixels) where to wrap the text at.
 /// </summary>
 /// <remarks>
 ///     <see cref="BitmapFont" /> objects are loaded from the Content Manager.
 ///     See the <see cref="BitmapFont"/> class for more information.
 ///     Before any calls to DrawString you must call <see cref="SpriteBatch.Begin" />. Once all calls
 ///     are complete, call <see cref="SpriteBatch.End" />.
 ///     Use a newline character (\n) to draw more than one line of text.
 /// </remarks>
 /// <param name="spriteBatch"></param>
 /// <param name="font">A font for displaying text.</param>
 /// <param name="text">The text message to display.</param>
 /// <param name="position">The location (in screen coordinates) to draw the text.</param>
 /// <param name="color">
 ///     The <see cref="Color" /> to tint a sprite. Use <see cref="Color.White" /> for full color with no
 ///     tinting.
 /// </param>
 /// <param name="layerDepth">
 ///     The depth of a layer. By default, 0 represents the front layer and 1 represents a back layer.
 ///     Use SpriteSortMode if you want sprites to be sorted during drawing.
 /// </param>
 /// <param name="clippingRectangle">
 /// Clips the boundaries of the text so that it's not drawn outside the clipping rectangle.
 /// </param>
 public static void DrawString(
     this SpriteBatch spriteBatch, BitmapFont font, string text, Vector2 position,
     Color color, float layerDepth, RectangleF?clippingRectangle = null)
 {
     DrawString(
         spriteBatch, font, text, position, color, 0, Vector2.Zero,
         Vector2.One, SpriteEffects.None, layerDepth, clippingRectangle);
 }
Exemple #19
0
 /**
  * <summary>Renders the specified contents into an image context.</summary>
  * <param name="contents">Source contents.</param>
  * <param name="size">Image size expressed in device-space units (that is typically pixels).</param>
  * <param name="area">Content area to render; <code>null</code> corresponds to the entire
  * <see cref="IContentContext.Box">content bounding box</see>.</param>
  * <returns>Image representing the rendered contents.</returns>
  */
 public Image Render(
     Contents contents,
     SizeF size,
     RectangleF?area
     )
 {
     return(Render(contents.ContentContext, size, area));
 }
Exemple #20
0
 public static Vector4 GetTexCoord(SizeF texelSize, RectangleF?sourceRectangle)
 {
     if (sourceRectangle.HasValue)
     {
         return(GetTexCoord(texelSize, sourceRectangle.GetValueOrDefault()));
     }
     return(new Vector4(0, 0, 1, 1));
 }
 public static void DrawString(
     this SpriteBatch spriteBatch, BitmapFont font, StringBuilder text, Vector2 position, Color color, float rotation,
     Vector2 origin, float scale, SpriteEffects effect, float layerDepth, RectangleF?clippingRectangle = null)
 {
     DrawString(
         spriteBatch, font, text, position, color, rotation, origin,
         new Vector2(scale, scale), effect, layerDepth, clippingRectangle);
 }
Exemple #22
0
 // Set the print area to display, or null to not display print area.
 public void SetPrintArea(RectangleF?printArea)
 {
     if (!this.printArea.Equals(printArea))
     {
         this.printArea = printArea;
         RaiseChanged(null);
     }
 }
 public static void DrawString(
     this SpriteBatch spriteBatch, BitmapFont font, StringBuilder text,
     Vector2 position, Color color, RectangleF?clippingRectangle = null)
 {
     DrawString(
         spriteBatch, font, text, position, color, 0, Vector2.Zero,
         Vector2.One, SpriteEffects.None, 0, clippingRectangle);
 }
        private static SizeF GetSprites(
            GlyphEnumerator glyphs, ICollection <GlyphSprite> output, Vector2 position,
            Color color, float rotation, Vector2 origin, Vector2 scale, float depth, RectangleF?clipRect)
        {
            GlyphSprite sprite;
            SizeF       size = SizeF.Empty;

            int index = 0;

            while (glyphs.MoveNext())
            {
                Glyph glyph = glyphs.CurrentGlyph;
                if (glyph.FontRegion == null)
                {
                    continue;
                }

                Vector2         glyphOrigin = position - glyph.Position + origin;
                Vector2         newPos      = position;
                TextureRegion2D region      = glyph.FontRegion.TextureRegion;

                sprite.Visible = region.Bounds.IsVisible(
                    ref newPos, glyphOrigin, scale, clipRect, out RectangleF srcRect);

                if (!sprite.Visible) // restore values
                {
                    newPos  = position;
                    srcRect = region.Bounds;
                }

                sprite.Char       = glyph.Character;
                sprite.Texture    = region.Texture;
                sprite.Index      = index;
                sprite.SourceRect = srcRect;
                sprite.Position   = newPos;
                sprite.Color      = color;
                sprite.Rotation   = rotation;
                sprite.Origin     = glyphOrigin;
                sprite.Scale      = scale;
                sprite.Depth      = depth;

                output.Add(sprite);
                index++;

                float rowX = glyph.Position.X + srcRect.Width * scale.X - newPos.X;
                if (rowX > size.Width)
                {
                    size.Width = rowX;
                }

                float rowY = glyph.Position.Y + srcRect.Height * scale.Y - newPos.Y;
                if (rowY > size.Height)
                {
                    size.Height = rowY;
                }
            }
            return(new SizeF(size.Width, size.Height));
        }
        /// <summary>
        /// 添加局部刷新区域[添加成功返回true,失败返回false]
        /// </summary>
        /// <param name="reg">需要局部刷新的矩形区域</param>
        /// <returns>添加成功返回true,失败返回false</returns>
        private bool AddPartRefreshArea(RectangleF?reg)
        {
            if (reg.HasValue)
            {
                return(this.AddPartRefreshArea(reg.Value));
            }

            return(false);
        }
        protected override RectangleF TextureBounds(RectangleF?textureRect = null)
        {
            // We need non-zero texture bounds for EdgeSmoothness to work correctly.
            // Let's be very conservative and use a tenth of the size of a pixel in the
            // largest possible texture.
            float smallestPixelTenth = 0.1f / GLWrapper.MaxTextureSize;

            return(new RectangleF(0, 0, smallestPixelTenth, smallestPixelTenth));
        }
Exemple #27
0
 public static void Draw(
     this SpriteBatch spriteBatch,
     TextureRegion2D textureRegion,
     Vector2 position,
     Color color,
     RectangleF?clippingRectangle = null)
 {
     Draw(spriteBatch, textureRegion, position, color, 0, Vector2.Zero, Vector2.One, SpriteFlip.None, 0, clippingRectangle);
 }
Exemple #28
0
 public void SetClip(IGraphicsPath path)
 {
     TransformStack.PopAll();
     ResetClip();
     clipPath   = path.Clone().ToWpf();           // require a clone so changes to path don't affect current clip
     clipBounds = clipPath.Bounds.ToEtoF();
     ApplyClip();
     TransformStack.PushAll();
 }
Exemple #29
0
 public void SetClip(RectangleF rectangle)
 {
     TransformStack.PopAll();
     ResetClip();
     clipBounds = rectangle;
     clipPath   = null;
     ApplyClip();
     TransformStack.PushAll();
 }
Exemple #30
0
        public void DrawTriangle(Triangle vertexTriangle, ColourInfo colour, RectangleF?textureRect = null, Action <TexturedVertex2D> vertexAction = null, Vector2?inflationPercentage = null)
        {
            if (TextureGL == null || !TextureGL.Bind())
            {
                return;
            }

            TextureGL.DrawTriangle(vertexTriangle, TextureBounds(textureRect), colour, vertexAction, inflationPercentage);
        }
Exemple #31
0
        public void DrawQuad(Quad vertexQuad, ColourInfo colour, RectangleF?textureRect = null, Action <TexturedVertex2D> vertexAction = null, Vector2?inflationPercentage = null, Vector2?blendRangeOverride = null)
        {
            if (TextureGL == null || !TextureGL.Bind())
            {
                return;
            }

            TextureGL.DrawQuad(vertexQuad, TextureBounds(textureRect), colour, vertexAction, inflationPercentage, blendRangeOverride);
        }
Exemple #32
0
 public void SetClip(RectangleF rectangle)
 {
     ReverseTransform();
     ResetClip();
     clipBounds = currentTransform.ToEto().TransformRectangle(rectangle);
     clipPath   = null;
     ApplyClip();
     ApplyTransform();
 }
Exemple #33
0
        public void Draw(Quad vertexQuad, Color4 colour, RectangleF?textureRect = null, VertexBatch <TexturedVertex2D> spriteBatch = null, Vector2?inflationPercentage = null)
        {
            if (TextureGL == null || !TextureGL.Bind())
            {
                return;
            }

            TextureGL.Draw(vertexQuad, textureBounds(textureRect), colour, spriteBatch, inflationPercentage);
        }
Exemple #34
0
 public void ResetClip()
 {
     if (clipBounds != null)
     {
         Control.Pop();
         clipBounds = null;
         clipPath   = null;
     }
 }
Exemple #35
0
 public void SetBounds(int top)
 {
     try
     {
         int x = 0;
         this.ClientBounds = new Rectangle(x, top, this.Parent.ClientSize.Width, 0x18);
         if (this.Style == UserListStyles.Clan)
         {
             if (this.ClanRankImage != null)
             {
                 this.ClanRankBounds = new Rectangle(x + 2, top + 2, this.ClanRankImage.Width, this.ClanRankImage.Height);
             }
             this.NameLabelLocation = new PointF((float) (x + 0x2d), (float) (top + 4));
         }
         else
         {
             if (Program.Settings.Awards.ShowAwards)
             {
                 if (this.Award1Image != null)
                 {
                     this.Award1Bounds = new Rectangle(x + 2, top + 2, this.Award1Image.Width, this.Award1Image.Height);
                 }
                 if (this.Award2Image != null)
                 {
                     this.Award2Bounds = new Rectangle(x + 0x16, top + 2, this.Award2Image.Width, this.Award2Image.Height);
                 }
                 if (this.Award3Image != null)
                 {
                     this.Award3Bounds = new Rectangle(x + 0x2a, top + 2, this.Award3Image.Width, this.Award3Image.Height);
                 }
             }
             if (Program.Settings.Awards.ShowAvatars)
             {
                 Image image;
                 if (Program.Settings.Awards.ShowAwards)
                 {
                     if (this.AvatarImage != null)
                     {
                         lock ((image = this.AvatarImage))
                         {
                             this.AvatarBounds = new Rectangle(x + 0x42, top + 2, this.AvatarImage.Width, this.AvatarImage.Height);
                         }
                     }
                 }
                 else if (this.AvatarImage != null)
                 {
                     lock ((image = this.AvatarImage))
                     {
                         this.AvatarBounds = new Rectangle(x + 2, top + 2, this.AvatarImage.Width, this.AvatarImage.Height);
                     }
                 }
             }
             if (Program.Settings.Awards.ShowAwards && Program.Settings.Awards.ShowAvatars)
             {
                 this.NameLabelLocation = new PointF((float) (x + 0x6d), (float) (top + 4));
             }
             else if (Program.Settings.Awards.ShowAwards)
             {
                 this.NameLabelLocation = new PointF((float) (x + 0x41), (float) (top + 4));
             }
             else if (Program.Settings.Awards.ShowAvatars)
             {
                 this.NameLabelLocation = new PointF((float) (x + 0x2d), (float) (top + 4));
             }
             else
             {
                 this.NameLabelLocation = new PointF((float) (x + 2), (float) (top + 4));
             }
             this.ClanLabelBounds = null;
         }
         this.StatusBounds = new Rectangle(this.ClientBounds.Width - 0x16, top + 2, 20, 20);
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
 }
Exemple #36
0
 public void Paint(Rectangle clip, Graphics g)
 {
     try
     {
         if (this.Visible && !this.ClientBounds.IsEmpty)
         {
             SolidBrush brush;
             if (this.Style == UserListStyles.Clan)
             {
                 if (this.IsSelected)
                 {
                     using (brush = new SolidBrush(Color.FromArgb(0x2e, 0x2e, 0x49)))
                     {
                         g.FillRectangle(brush, this.ClientBounds);
                     }
                 }
                 if (this.ClanRankImage != null)
                 {
                     g.DrawImage(this.ClanRankImage, this.ClanRankBounds);
                 }
                 using (brush = new SolidBrush(this.NameColor))
                 {
                     g.DrawString(this.ClanMember.Name, this.NameFont, brush, this.NameLabelLocation);
                 }
                 if (this.StatusImage != null)
                 {
                     g.DrawImage(this.StatusImage, this.StatusBounds, new Rectangle(10, 0, 20, 20), GraphicsUnit.Pixel);
                 }
             }
             else
             {
                 if (!this.ClanLabelBounds.HasValue)
                 {
                     SizeF ef = DrawUtil.MeasureString(g, this.User.Name, this.NameFont);
                     SizeF ef2 = DrawUtil.MeasureString(g, this.User.ClanAbbreviation, Program.Settings.Chat.Appearance.ClanTagFont);
                     this.ClanLabelBounds = new RectangleF((this.NameLabelLocation.X + ef.Width) + 5f, this.NameLabelLocation.Y + 2f, ef2.Width + 6f, ef2.Height);
                 }
                 if (this.IsSelected)
                 {
                     using (brush = new SolidBrush(Color.FromArgb(0x2e, 0x2e, 0x49)))
                     {
                         g.FillRectangle(brush, this.ClientBounds);
                     }
                 }
                 if (Program.Settings.Awards.ShowAwards)
                 {
                     if (this.Award1Image != null)
                     {
                         g.DrawImage(this.Award1Image, this.Award1Bounds);
                     }
                     if (this.Award2Image != null)
                     {
                         g.DrawImage(this.Award2Image, this.Award2Bounds);
                     }
                     if (this.Award3Image != null)
                     {
                         g.DrawImage(this.Award3Image, this.Award3Bounds);
                     }
                 }
                 if (Program.Settings.Awards.ShowAvatars && (this.AvatarImage != null))
                 {
                     lock (this.AvatarImage)
                     {
                         g.DrawImage(this.AvatarImage, this.AvatarBounds);
                     }
                 }
                 using (brush = new SolidBrush(this.NameColor))
                 {
                     g.DrawString(this.User.Name, this.NameFont, brush, this.NameLabelLocation);
                 }
                 using (brush = new SolidBrush(Program.Settings.Chat.Appearance.ClanColor))
                 {
                     g.DrawString(this.User.ClanAbbreviation, Program.Settings.Chat.Appearance.ClanTagFont, brush, this.ClanLabelBounds.Value);
                 }
                 if (this.StatusImage != null)
                 {
                     g.DrawImage(this.StatusImage, this.StatusBounds, new Rectangle(10, 0, 20, 20), GraphicsUnit.Pixel);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
 }
Exemple #37
0
 public void SetCullingArea(RectangleF cullingArea)
 {
     _cullingArea = cullingArea;
 }
    public override void DeepCopy(IDeepCopyable source, ICopyManager copyManager)
    {
      Detach();
      object oldLayoutTransform = LayoutTransform;
      base.DeepCopy(source, copyManager);
      FrameworkElement fe = (FrameworkElement) source;
      Width = fe.Width;
      Height = fe.Height;
      Style = copyManager.GetCopy(fe.Style);
      ActualWidth = fe.ActualWidth;
      ActualHeight = fe.ActualHeight;
      HorizontalAlignment = fe.HorizontalAlignment;
      VerticalAlignment = fe.VerticalAlignment;
      Focusable = fe.Focusable;
      FontSize = fe.FontSize;
      FontFamily = fe.FontFamily;
      MinWidth = fe.MinWidth;
      MinHeight = fe.MinHeight;
      MaxWidth = fe.MaxWidth;
      MaxHeight = fe.MaxHeight;
      _setFocusPrio = fe.SetFocusPrio;
      _renderedBoundingBox = null;

      ContextMenuCommand = copyManager.GetCopy(fe.ContextMenuCommand);

      // Need to manually call this because we are in a detached state
      OnLayoutTransformPropertyChanged(_layoutTransformProperty, oldLayoutTransform);

      Attach();
    }
    public override void Render(RenderContext parentRenderContext)
    {
      if (!IsVisible)
        return;

      RectangleF bounds = ActualBounds;
      if (bounds.Width <= 0 || bounds.Height <= 0)
        return;

      Matrix? layoutTransformMatrix = LayoutTransform == null ? new Matrix?() : LayoutTransform.GetTransform();
      Matrix? renderTransformMatrix = RenderTransform == null ? new Matrix?() : RenderTransform.GetTransform();

      RenderContext localRenderContext = parentRenderContext.Derive(bounds, layoutTransformMatrix, renderTransformMatrix, RenderTransformOrigin, Opacity);
      Matrix finalTransform = localRenderContext.Transform;
      if (finalTransform != _finalTransform)
      {
        _finalTransform = finalTransform;
        _inverseFinalTransform = Matrix.Invert(_finalTransform.Value);
        _renderedBoundingBox = CalculateBoundingBox(_innerRect, finalTransform);
      }

      Brushes.Brush opacityMask = OpacityMask;
      Effect effect = Effect;
      if (opacityMask == null && effect == null)
        // Simply render without opacity mask
        RenderOverride(localRenderContext);
      else
      {
        // Control has an opacity mask or Effect
        // Get global render surface and render texture or create them if they doesn't exist
        RenderTextureAsset renderTexture = ContentManager.Instance.GetRenderTexture(GLOBAL_RENDER_TEXTURE_ASSET_KEY);

        // Ensure they are allocated
        renderTexture.AllocateRenderTarget(GraphicsDevice.Width, GraphicsDevice.Height);
        if (!renderTexture.IsAllocated)
          return;

        // Morpheus_xx: these are typical performance results comparing direct rendering to texture and rendering 
        // to surfaces (for multisampling support).

        // Results inside GUI-Test OpacityMask screen for default skin (720p windowed / fullscreen 1080p)
        // Surface + full StretchRect -> Texture    : 350 fps / 174 fps 
        // Texture                                  : 485 fps / 265 fps

        // After OpacityMask fix:
        // Surface + full StretchRect -> Texture    : 250 fps / 155 fps 
        // Surface + Occupied Rect -> Texture       : 325 fps / 204 fps 
        // Texture                                  : 330 fps / 213 fps

        // Results inside GUI-Test OpacityMask screen for Reflexion skin (fullscreen 1080p)
        // Surface + full StretchRect -> Texture    : 142 fps
        // Texture                                  : 235 fps

        // Create a temporary render context and render the control to the render texture
        RenderContext tempRenderContext = new RenderContext(localRenderContext.Transform, localRenderContext.Opacity, bounds, localRenderContext.ZOrder);

        // If no effect is applied, clear only the area of the control, not whole render target (performance!)
        tempRenderContext.ClearOccupiedAreaOnly = effect == null;

        // An additional copy step is only required for multisampling surfaces
        bool isMultiSample = GraphicsDevice.Setup.IsMultiSample;
        if (isMultiSample)
        {
          RenderTargetAsset renderSurface = ContentManager.Instance.GetRenderTarget(GLOBAL_RENDER_SURFACE_ASSET_KEY);
          renderSurface.AllocateRenderTarget(GraphicsDevice.Width, GraphicsDevice.Height);
          if (!renderSurface.IsAllocated)
            return;

          // First render to the multisampled surface
          RenderToSurface(renderSurface, tempRenderContext);

          // Unfortunately, brushes/brush effects are based on textures and cannot work with surfaces, so we need this additional copy step
          // Morpheus_xx, 03/2013: changed to copy only the occupied area of Surface, instead of complete area. This improves performance a lot.
          GraphicsDevice.Device.StretchRectangle(
              renderSurface.Surface, ToRect(tempRenderContext.OccupiedTransformedBounds, renderSurface.Size), // new Rectangle(new Point(), renderSurface.Size),
              renderTexture.Surface0, ToRect(tempRenderContext.OccupiedTransformedBounds, renderTexture.Size), // new Rectangle(new Point(), renderTexture.Size),
              TextureFilter.None);
        }
        else
        {
          // Directly render to texture
          RenderToTexture(renderTexture, tempRenderContext);
        }

        // Render Effect
        if (effect == null)
        {
          // Use a default effect to draw the render target if none is set
          if (_defaultEffect == null)
          {
            _defaultEffect = new SimpleShaderEffect { ShaderEffectName = "normal" };
          }

          effect = _defaultEffect;
        }

        UpdateEffectMask(effect, tempRenderContext.OccupiedTransformedBounds, renderTexture.Width, renderTexture.Height, localRenderContext.ZOrder);
        if (effect.BeginRender(renderTexture.Texture, new RenderContext(Matrix.Identity, 1.0d, bounds, localRenderContext.ZOrder)))
        {
          _effectContext.Render(0);
          effect.EndRender();
        }
      }

      // Calculation of absolute render size (in world coordinate system)
      parentRenderContext.IncludeTransformedContentsBounds(localRenderContext.OccupiedTransformedBounds);
      _lastZIndex = localRenderContext.ZOrder;
    }
    /// <summary>
    /// Arranges the UI element and positions it in the given rectangle.
    /// </summary>
    /// <param name="outerRect">The final position and size the parent computed for this child element.</param>
    public void Arrange(RectangleF outerRect)
    {
      if (_isMeasureInvalid)
      {
#if DEBUG_LAYOUT
#if DEBUG_MORE_LAYOUT
        System.Diagnostics.Trace.WriteLine(string.Format("Arrange {0} Name='{1}', exiting because measurement is invalid", GetType().Name, Name));
#endif
#endif
        InvalidateLayout(true, true); // Re-schedule arrangement
        return;
      }
#if DEBUG_LAYOUT
#if DEBUG_MORE_LAYOUT
      System.Diagnostics.Trace.WriteLine(string.Format("Arrange {0} Name='{1}', outerRect={2}", GetType().Name, Name, outerRect));
#endif
#endif
      if (!_isArrangeInvalid && SameRect(_outerRect, outerRect))
      { // Optimization: If our input data is the same and the layout isn't invalid, we don't need to arrange again
#if DEBUG_LAYOUT
#if DEBUG_MORE_LAYOUT
        System.Diagnostics.Trace.WriteLine(string.Format("Arrange {0} Name='{1}', cutting short, outerRect={2} is like before and arrangement is not invalid", GetType().Name, Name, outerRect));
#endif
#endif
        return;
      }
#if DEBUG_LAYOUT
#if !DEBUG_MORE_LAYOUT
      System.Diagnostics.Trace.WriteLine(string.Format("Arrange {0} Name='{1}', outerRect={2}", GetType().Name, Name, outerRect));
#endif
#endif
      _isArrangeInvalid = false;

      // Those two properties have to be set by the render loop again the next time we render. We need to reset the values to null
      // because the BoundingBox property then uses a fallback value. It would be wrong to use the old _boundingBox value if we
      // re-arrange our contents.
      _renderedBoundingBox = null;
      _finalTransform = null;
      _inverseFinalTransform = null;

      _outerRect = SharpDXExtensions.CreateRectangleF(outerRect.Location, outerRect.Size);
      RectangleF rect = SharpDXExtensions.CreateRectangleF(outerRect.Location, outerRect.Size);
      RemoveMargin(ref rect, Margin);

      if (LayoutTransform != null)
      {
        Matrix layoutTransform = LayoutTransform.GetTransform().RemoveTranslation();
        if (!layoutTransform.IsIdentity)
        {
          SizeF resultInnerSize = _innerDesiredSize;
          SizeF resultOuterSize = resultInnerSize;
          layoutTransform.TransformIncludingRectangleSize(ref resultOuterSize);
          if (resultOuterSize.Width > rect.Width + DELTA_DOUBLE || resultOuterSize.Height > rect.Height + DELTA_DOUBLE)
            // Transformation of desired size doesn't fit into the available rect
            resultInnerSize = FindMaxTransformedSize(layoutTransform, rect.Size);
          rect = new RectangleF(
              rect.Location.X + (rect.Width - resultInnerSize.Width) / 2,
              rect.Location.Y + (rect.Height - resultInnerSize.Height) / 2,
              resultInnerSize.Width,
              resultInnerSize.Height);
        }
      }
      _innerRect = rect;

      InitializeTriggers();
      CheckFireLoaded(); // Has to be done after all triggers are initialized to make EventTriggers for UIElement.Loaded work properly

      ArrangeOverride();
      UpdateFocus(); // Has to be done after all children have arranged to make SetFocusPrio work properly
    }
Exemple #41
0
 // Set the print area to display, or null to not display print area.
 public void SetPrintArea(RectangleF? printArea)
 {
     if (!this.printArea.Equals(printArea)) {
         this.printArea = printArea;
         RaiseChanged(null);
     }
 }
    public override void Render(RenderContext parentRenderContext)
    {
      if (!IsVisible)
        return;

      RectangleF bounds = ActualBounds;
      if (bounds.Width <= 0 || bounds.Height <= 0)
        return;

      Matrix? layoutTransformMatrix = LayoutTransform == null ? new Matrix?() : LayoutTransform.GetTransform();
      Matrix? renderTransformMatrix = RenderTransform == null ? new Matrix?() : RenderTransform.GetTransform();

      RenderContext localRenderContext = parentRenderContext.Derive(bounds, layoutTransformMatrix,
          renderTransformMatrix, RenderTransformOrigin, Opacity);
       Matrix finalTransform = localRenderContext.Transform;
      if (finalTransform != _finalTransform)
      {
        _finalTransform = finalTransform;
        _inverseFinalTransform = Matrix.Invert(_finalTransform.Value);
        _renderedBoundingBox = CalculateBoundingBox(_innerRect, finalTransform);
      }

      Brushes.Brush opacityMask = OpacityMask;
      if (opacityMask == null && Effect == null)
        // Simply render without opacity mask
        RenderOverride(localRenderContext);
      else
      { 
        // Control has an opacity mask or Effect
        // Get global render surface and render texture or create them if they doesn't exist
        RenderTextureAsset renderTexture = ContentManager.Instance.GetRenderTexture(GLOBAL_RENDER_TEXTURE_ASSET_KEY);

        // Ensure they are allocated
        renderTexture.AllocateRenderTarget(GraphicsDevice.Width, GraphicsDevice.Height);
        if (!renderTexture.IsAllocated)
          return;

        // Morpheus_xx: these are typical performance results comparing direct rendering to texture and rendering 
        // to surfaces (for multisampling support).

        // Results inside GUI-Test OpacityMask screen for default skin (720p windowed / fullscreen 1080p)
        // Surface + full StretchRect -> Texture    : 350 fps / 174 fps 
        // Texture                                  : 485 fps / 265 fps

        // Results inside GUI-Test OpacityMask screen for Reflexion skin (fullscreen 1080p)
        // Surface + full StretchRect -> Texture    : 142 fps
        // Texture                                  : 235 fps

        // Create a temporary render context and render the control to the render texture
        RenderContext tempRenderContext = new RenderContext(localRenderContext.Transform, localRenderContext.Opacity, bounds, localRenderContext.ZOrder);

        // An additional copy step is only required for multisampling surfaces
        bool isMultiSample = GraphicsDevice.Setup.IsMultiSample;
        if (isMultiSample)
        {
          RenderTargetAsset renderSurface = ContentManager.Instance.GetRenderTarget(GLOBAL_RENDER_SURFACE_ASSET_KEY);
          renderSurface.AllocateRenderTarget(GraphicsDevice.Width, GraphicsDevice.Height);
          if (!renderSurface.IsAllocated)
            return;

          // First render to the multisampled surface
          RenderToSurface(renderSurface, tempRenderContext);

          // Unfortunately, brushes/brush effects are based on textures and cannot work with surfaces, so we need this additional copy step
          GraphicsDevice.Device.StretchRectangle(
              renderSurface.Surface,  new Rectangle(Point.Empty, renderSurface.Size),
              renderTexture.Surface0, new Rectangle(Point.Empty, renderTexture.Size),
              TextureFilter.None);
        }
        else
          // Directly render to texture
          RenderToTexture(renderTexture, tempRenderContext);

        // Add bounds to our calculated, occupied area.
        // If we don't do that, lines at the border of this element might be dimmed because of the filter (see OpacityMask test in GUITestPlugin).
        // The value was just found by testing. Any better solution is welcome.
        if (opacityMask != null)
        {
          const float OPACITY_MASK_BOUNDS = 0.9f;
          RectangleF occupiedTransformedBounds = tempRenderContext.OccupiedTransformedBounds;
          occupiedTransformedBounds.X -= OPACITY_MASK_BOUNDS;
          occupiedTransformedBounds.Y -= OPACITY_MASK_BOUNDS;
          occupiedTransformedBounds.Width += OPACITY_MASK_BOUNDS * 2;
          occupiedTransformedBounds.Height += OPACITY_MASK_BOUNDS * 2;

          // If the control bounds have changed we need to update our primitive context to make the 
          // texture coordinates match up
          if (_updateOpacityMask || _opacityMaskContext == null ||
              occupiedTransformedBounds != _lastOccupiedTransformedBounds ||
            renderTexture.Size != _lastOpacityRenderSize)
          {
            UpdateOpacityMask(occupiedTransformedBounds, renderTexture.Width, renderTexture.Height, localRenderContext.ZOrder);
            _lastOccupiedTransformedBounds = occupiedTransformedBounds;
            _updateOpacityMask = false;
            _lastOpacityRenderSize = renderTexture.Size;
          }

          // Now render the opacity texture with the OpacityMask brush)
          if (opacityMask.BeginRenderOpacityBrush(renderTexture.Texture, new RenderContext(Matrix.Identity, bounds)))
          {
            _opacityMaskContext.Render(0);
            opacityMask.EndRender();
          }
        }

        // Render Effect
        Effects.Effect effect = Effect;
        if (effect != null)
        {
          UpdateEffectMask(effect, tempRenderContext.OccupiedTransformedBounds, renderTexture.Width, renderTexture.Height, localRenderContext.ZOrder);
          if (effect.BeginRender(renderTexture.Texture, new RenderContext(Matrix.Identity, 1.0d, bounds, localRenderContext.ZOrder)))
          {
            _effectContext.Render(0);
            effect.EndRender();
          }
        }

      }
      // Calculation of absolute render size (in world coordinate system)
      parentRenderContext.IncludeTransformedContentsBounds(localRenderContext.OccupiedTransformedBounds);
      _lastZIndex = localRenderContext.ZOrder;
    }