当前位置: 首页>>代码示例>>C#>>正文


C# Media.EndUse方法代码示例

本文整理汇总了C#中Media.EndUse方法的典型用法代码示例。如果您正苦于以下问题:C# Media.EndUse方法的具体用法?C# Media.EndUse怎么用?C# Media.EndUse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Media的用法示例。


在下文中一共展示了Media.EndUse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawRectangle

        ///// <summary>
        ///// Draws the specified <see cref="Media.Drawing"/>
        ///// </summary>
        ///// <param name="drawing">The <see cref="Media.Drawing"/> to draw</param>
        //public void Draw(Media.Drawing drawing)
        //{
        //    if (typeof(Media.GeometryDrawing).IsAssignableFrom(drawing.GetType()))
        //    {
        //        Media.GeometryDrawing geometryDrawing;
        //        geometryDrawing = (Media.GeometryDrawing)drawing;
        //        if (geometryDrawing.FillBrush != null)
        //        {
        //            geometryDrawing.FillBrush.BeginUse(drawing);
        //            geometryDrawing.Render();
        //            geometryDrawing.FillBrush.EndUse();
        //        }
        //        return;
        //    }
        //}

        ///// <summary>
        ///// Draw the specified <see cref="Media.Geometry"/> with the specified stroke thickness, fill brush and stroke brush
        ///// </summary>
        ///// <param name="geometry">The <see cref="Media.Geometry"/> to draw</param>
        ///// <param name="primitiveType">The <see cref="PrimitiveType"/> used to render the specified <see cref="Media.Geometry"/></param>
        ///// <param name="strokeThickness">The thickness of the specified <see cref="Media.Geometry"/>'s contour</param>
        ///// <param name="fillBrush">The <see cref="Media.Brush"/> used to paint the inside of the specified <see cref="Media.Geometry"/></param>
        ///// <param name="strokeBrush">The <see cref="Media.Brush"/> used to draw the specified <see cref="Media.Geometry"/>'s contour</param>
        //public void DrawGeometry(Media.Geometry geometry, PrimitiveType primitiveType, double strokeThickness, Media.Brush fillBrush, Media.Brush strokeBrush)
        //{
        //    Media.GeometryDrawing geometryDrawing;
        //    geometryDrawing = new Media.GeometryDrawing(primitiveType, geometry) { StrokeThickness = strokeThickness, FillBrush = fillBrush, StrokeBrush = strokeBrush };
        //    this.Draw(geometryDrawing);
        //    geometryDrawing.Dispose();
        //}

        /// <summary>
        /// Draws a rectangle with the specified width, height, border thickness and brushes
        /// </summary>
        /// <param name="rectangle">The <see cref="Media.Rectangle"/> representing the rectangle's width and height</param>
        /// <param name="borderThickness">The <see cref="Media.Thickness"/> representing the rectangle's border thickness</param>
        /// <param name="fillBrush">The <see cref="Media.Brush"/> with which to paint the rectangle's fill</param>
        /// <param name="borderBrush">The <see cref="Media.Brush"/> with which to paaint the rectangle's border brush</param>
        public void DrawRectangle(Media.Rectangle rectangle, Media.Thickness borderThickness, Media.Brush fillBrush, Media.Brush borderBrush)
        {
            Media.Geometry geometry;
            Media.GeometryDrawing geometryDrawing;
            float leftThickness, topThickness, rightThickness, bottomThickness;
            geometry = rectangle.ToGeometry();
            geometryDrawing = new Media.GeometryDrawing(PrimitiveType.Quads, geometry);
            leftThickness = Convert.ToSingle(borderThickness.Left);
            topThickness = Convert.ToSingle(borderThickness.Top);
            rightThickness = Convert.ToSingle(borderThickness.Right);
            bottomThickness = Convert.ToSingle(borderThickness.Bottom);
            //Check whether or not to fill the rectangle
            if (fillBrush != null)
            {
                //Begin using the brush
                fillBrush.BeginUse(geometryDrawing);
                //Draw the rectangle
                geometryDrawing.Render();
                //End using the brush
                fillBrush.EndUse();
            }
            //Check whether or not we are expected to draw a border
            if (borderBrush != null)
            {
                //Begin using the border brush
                borderBrush.BeginUse(geometryDrawing);
                //Create the left border
                if (rectangle.Left > 0)
                {
                    GL.LineWidth(leftThickness);
                    GL.Begin(PrimitiveType.LineStrip);
                    GL.Vertex2(rectangle.Left, rectangle.Bottom);
                    GL.Vertex2(rectangle.Left, rectangle.Top);
                    GL.End();
                }
                //Create the top border
                if (rectangle.Top > 0)
                {
                    GL.LineWidth(topThickness);
                    GL.Begin(PrimitiveType.LineStrip);
                    GL.Vertex2(rectangle.Left - (borderThickness.Left / 2), rectangle.Top);
                    GL.Vertex2(rectangle.Right + (borderThickness.Right / 2), rectangle.Top);
                    GL.End();
                }
                //Create the right border
                if (rectangle.Right > 0)
                {
                    GL.LineWidth(rightThickness);
                    GL.Begin(PrimitiveType.LineStrip);
                    GL.Vertex2(rectangle.Right, rectangle.Top);
                    GL.Vertex2(rectangle.Right, rectangle.Bottom);
                    GL.End();
                }
                //Create the bottom line
                if (rectangle.Bottom > 0)
                {
                    GL.LineWidth(bottomThickness);
//.........这里部分代码省略.........
开发者ID:yonglehou,项目名称:Photon,代码行数:101,代码来源:DrawingContext.cs


注:本文中的Media.EndUse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。