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


C# IPoint.ToWinPoint方法代码示例

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


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

示例1: DrawPoint

        private void DrawPoint(IPoint point, Image image)
        {
            var g = Renderer.Graphics;

            var winPoint = point.ToWinPoint();
            var width = (float)Evaluate(_scaleXEvaluator, _scaleX);
            var height = (float)Evaluate(_scaleYEvaluator, _scaleY);
            var alignment = Evaluate(_alignEvaluator, _alignment);
            winPoint.Y += GetVerticalAlignentOffset(alignment, height);
            winPoint.X += GetHorizontalAligmentOffset(alignment, width);


            if (image == null)
            {
                var pScreenF = Renderer.Transform(winPoint).ToPointF();
                var color = GetRenderColor(_opacityEvaluator, _opacity, _colorEvaluator, _color);
                using (var brush = new SolidBrush(color))
                    g.FillEllipse(brush, pScreenF.X - width / 2, pScreenF.Y - height / 2, width, height);
            }
            else
            {
                float scaleX = _marker.ScaleX != null ? float.Parse(_marker.ScaleX, System.Globalization.NumberFormatInfo.InvariantInfo) : 1;
                float scaleY = _marker.ScaleY != null ? float.Parse(_marker.ScaleY, System.Globalization.NumberFormatInfo.InvariantInfo) : 1;
                float angle = _marker.Angle != null ? float.Parse(_marker.Angle, System.Globalization.NumberFormatInfo.InvariantInfo) : 0;

                float opacity = _marker.Opacity != null ? float.Parse(_marker.Opacity, System.Globalization.NumberFormatInfo.InvariantInfo) : 1;

                float[][] matrixAlpha =
					  {
					   new float[] {1, 0, 0, 0, 0},
					   new float[] {0, 1, 0, 0, 0},
					   new float[] {0, 0, 1, 0, 0},
					   new float[] {0, 0, 0, opacity, 0}, 
					   new float[] {0, 0, 0, 0, 1}
					  };
                ColorMatrix colorMatrix = new ColorMatrix(matrixAlpha);

                ImageAttributes imageAttributes = new ImageAttributes();
                imageAttributes.SetColorMatrix(
                 colorMatrix,
                 ColorMatrixFlag.Default,
                 ColorAdjustType.Bitmap);

                var dest = new Rectangle((int)(point.X), (int)(point.Y), 10, 10);
                var src = new Rectangle(0, 0, image.Width, image.Height);

                //_g.DrawImage(image, dest, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes, null, IntPtr.Zero);
                var oldMatrix = (Matrix)g.Transform.Clone();

                using (var m = new Matrix())
                {
                    m.Scale(scaleX, scaleY);
                    //m.Rotate(angle);
                    //m.Translate(offsetX, offsetY);
                    //_g.MultiplyTransform(m, MatrixOrder.Append);

                    using (var f = new Font("Sppc", 10))
                        g.DrawString("B", f, Brushes.Red, point.ToPointF());

                    using (var pen = new Pen(Color.Black, 0.1f))
                        g.DrawLine(pen, (float)point.X, (float)point.Y, (float)point.X + 10, (float)point.Y);

                    g.Transform = oldMatrix;
                }
            }
        }
开发者ID:netgrim,项目名称:MapKit,代码行数:66,代码来源:MarkerRenderer.cs

示例2: RenderText

        private void RenderText(Feature feature, IPoint geometry, float size, float angle, string content, Font f, Brush brush, SizeF stringSize, ContentAlignment alignment)
        {
            geometry.ToWinPoint(ref _tempPoint);
            var pointF = Renderer.Transform(_tempPoint).ToPointF();
            var basePoint = new PointF(pointF.X, pointF.Y);

            
            pointF.Y -= (float)GetVerticalAlignentOffset(alignment, stringSize.Height);
            pointF.X += (float)GetHorizontalAligmentOffset(alignment, stringSize.Width);



            //using (var pen = new Pen(text.Color, 1 / (float)_scale))
            //{
            //    _g.DrawLine(pen, basePoint.X, basePoint.Y, basePoint.X + stringSize.Width, basePoint.Y);
            //    _g.DrawEllipse(pen, basePoint.X - 2, basePoint.Y - 2, 4, 4);
            //}

            var m = new Matrix();
            m.RotateAt(-angle, basePoint);
            var scaleX = (float)Evaluate(_scaleXEvaluator, _scaleX);
            var scaleY = (float)Evaluate(_scaleXEvaluator, _scaleY);

            m.Multiply(new Matrix(scaleX, 0.0f, 0.0f, scaleY, basePoint.X - (scaleX * basePoint.X), basePoint.Y - (scaleY * basePoint.Y)));
            Renderer.Graphics.MultiplyTransform(m);

            if (_labelBoxRenderer != null && _labelBoxRenderer.Visible) 
            {
                var oldModelView = Renderer.Translate;
                Renderer.Translate = System.Windows.Media.Matrix.Identity;

                var polygon = new RectangleF(pointF, stringSize).ToRectanglePolygon();
                var newFeature = feature;
                newFeature.Geometry = polygon;
                _labelBoxRenderer.Render(feature);

                Renderer.Translate = oldModelView;
            }

            Renderer.Graphics.DrawString(content, f, brush, pointF, StringFormat.GenericTypographic);
        }
开发者ID:netgrim,项目名称:MapKit,代码行数:41,代码来源:TextRenderer.cs


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