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


C# IProjection.ToPixel方法代码示例

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


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

示例1: SetLayout

		/// <summary>
		/// Sets the layout.
		/// </summary>
		/// <param name="pixelsWidth">Pixels width.</param>
		/// <param name="pixelsHeight">Pixels height.</param>
		/// <param name="view">View.</param>
		/// <param name="projection">Projection.</param>
		internal bool SetLayout(double pixelsWidth, double pixelsHeight, View2D view, IProjection projection)
		{
			double[] projected = projection.ToPixel (this.Location);
			double[] locationPixel = view.ToViewPort (pixelsWidth, pixelsHeight, projected [0], projected [1]);

//			if (locationPixel [0] > 0 && locationPixel [0] < pixelsWidth &&
//			    locationPixel [1] > 0 && locationPixel [1] < pixelsHeight) {

				// set the new location depending on the size of the image and the alignment parameter.
				double leftMargin = locationPixel [0];// - this.Bitmap.Size.Width / 2.0;
				double topMargin = locationPixel [1];
				switch (_alignment) {
				case MapMarkerAlignmentType.CenterTop:
					topMargin = locationPixel [1] + this.Image.Size.Height / 2.0;
					break;
				case MapMarkerAlignmentType.CenterBottom:
					topMargin = locationPixel [1] - this.Image.Size.Height / 2.0;
					break;
				}
				this.Center = new System.Drawing.PointF ((float)leftMargin, (float)topMargin);

				return true;
//			}
//			return false;
		}
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:22,代码来源:MapMarker.cs

示例2: SetLayout

        /// <summary>
        /// Sets the layout.
        /// </summary>
        /// <param name="pixelsWidth">Pixels width.</param>
        /// <param name="pixelsHeight">Pixels height.</param>
        /// <param name="view">View.</param>
        /// <param name="projection">Projection.</param>
        internal bool SetLayout(double pixelsWidth, double pixelsHeight, View2D view, IProjection projection)
        {
            double[] projected = projection.ToPixel (this.Location);
            double[] locationPixel = view.ToViewPort (pixelsWidth, pixelsHeight, projected [0], projected [1]);

            //			if (locationPixel [0] > 0 && locationPixel [0] < pixelsWidth &&
            //			    locationPixel [1] > 0 && locationPixel [1] < pixelsHeight) {

                // set the new location depending on the size of the image and the alignment parameter.
                double leftMargin = locationPixel [0];
                double topMargin = locationPixel [1];

                switch (_alignment) {
                case MapMarkerAlignmentType.CenterBottom:
                    topMargin = locationPixel [1] - (this.LayoutParameters as FrameLayout.LayoutParams).Height / 2.0;
                    break;
                case MapMarkerAlignmentType.CenterTop:
                    topMargin = locationPixel [1] + (this.LayoutParameters as FrameLayout.LayoutParams).Height / 2.0;
                    break;
                }

                (this.LayoutParameters as FrameLayout.LayoutParams).LeftMargin = (int)leftMargin;
                (this.LayoutParameters as FrameLayout.LayoutParams).TopMargin = (int)topMargin;
                return true;
            //			}
            //			return false;
        }
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:34,代码来源:MapMarker.cs


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