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


C# Canvas.DrawLines方法代码示例

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


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

示例1: Draw

 public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature)
 {
     var lineString = ((LineString) feature.Geometry).Vertices;
     var paints = style.ToAndroid();
     //using (var paint = new Paint {Color = Color.Black, StrokeWidth = 8, AntiAlias = true})
     foreach (var paint in paints)
     {
         var vertices = lineString;
         var points = vertices.ToAndroid();
         WorldToScreen(viewport, points);
         canvas.DrawLines(points, paint);
         paint.Dispose();
     }
 }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:14,代码来源:LineStringRenderer.cs

示例2: Draw

        public override void Draw(Canvas canvas)
        {
            //Console.WriteLine("EqualizerPresetGraphView - Draw - Width: {0} Height: {1}", Width, Height);

            float padding = 6 * Resources.DisplayMetrics.Density;
            float heightAvailable = Height - (padding*2);            

            var paintRect = new Paint {
                AntiAlias = true,
                Color = Color.ParseColor("#222222")
            };
            paintRect.SetStyle(Paint.Style.Fill);
            canvas.DrawRect(new Rect(0, 0, Width, Height), paintRect);

            if (_preset == null)
                return;

            // Draw center line
            var paintCenterLine = new Paint {
                AntiAlias = true,
                Color = Color.DarkGray
            };
            paintCenterLine.SetStyle(Paint.Style.Fill);
            paintCenterLine.StrokeWidth = 2f;
            canvas.DrawLine(padding, Height / 2, Width - padding, Height / 2, paintCenterLine);

            // Draw 20Hz and 20kHz lines
            paintCenterLine.StrokeWidth = 1f;
            canvas.DrawLine(padding, padding, padding, Height - padding, paintCenterLine);
            canvas.DrawLine(Width - padding, padding, Width - padding, Height - padding, paintCenterLine);

            var paintText = new Paint {
                AntiAlias = true,
                Color = Color.Gray,
                TextSize = 14 * Resources.DisplayMetrics.Density
            };
            float textWidth = paintText.MeasureText(_preset.Bands[_preset.Bands.Count - 1].CenterString);
            canvas.DrawText(_preset.Bands[0].CenterString, padding * 2, Height - (padding * 2), paintText);
            canvas.DrawText(_preset.Bands[_preset.Bands.Count - 1].CenterString, Width - textWidth - (padding * 2), Height - (padding * 2), paintText);

            if (_preset == null)
                return;

            // Draw equalizer line
            var points = new List<float>();
            var paintEQLine = new Paint
            {
                AntiAlias = true,
                Color = Color.Yellow
            };
            paintEQLine.SetStyle(Paint.Style.Stroke);
            paintEQLine.StrokeWidth = 2f * Resources.DisplayMetrics.Density;
            float x = padding;
            for (int a = 0; a < _preset.Bands.Count; a++)
            {
                // Value range is -6 to 6.
                var band = _preset.Bands[a];
                //float ratio = (band.Gain + 6) / (padding * 2);
                float ratio = (band.Gain + 6f) / 12f;
                float y = padding + heightAvailable - (ratio * (Height - (padding * 2)));

                //Console.WriteLine("EqualizerPresetGraphView - Draw - Width: {0} Height: {1} ratio: {2} x: {3} y: {4} padding: {5} heightAvailable: {6}", Width, Height, ratio, x, y, padding, heightAvailable);
                points.Add(x);
                points.Add(y);

                // Add the same point a second time because Android needs start/end for each segment
                if (a > 0 && a < _preset.Bands.Count - 1)
                {
                    points.Add(x);
                    points.Add(y);
                }

                x += (Width - (padding * 2)) / (_preset.Bands.Count - 1);
            }
            canvas.DrawLines(points.ToArray(), paintEQLine);
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:76,代码来源:EqualizerPresetGraphView.cs


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