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


C# Point.DataToScreen方法代码示例

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


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

示例1: OnRenderCore

        protected override void  OnRenderCore(DrawingContext dc, RenderState state)
        {
            if (DataSource == null) return;
            var transform = Plotter2D.Viewport.Transform;

            Rect bounds = Rect.Empty;
            using (IPointEnumerator enumerator = DataSource.GetEnumerator(GetContext()))
            {
                Point point = new Point();
                while (enumerator.MoveNext())
                {
                    enumerator.GetCurrent(ref point);
                    enumerator.ApplyMappings(this);

                    Point zero = new Point(point.X, 0);
                    Point screenPoint = point.DataToScreen(transform);
                    Point screenZero = zero.DataToScreen(transform);

                    double height = screenPoint.Y = screenZero.Y;
                    height = (height >= 0) ? height : -height;

                    dc.DrawRectangle(Fill, new Pen(Stroke, StrokeThickness),
                                     new Rect(screenPoint.X - BarWidth / 2, screenZero.Y, BarWidth, height));

                    bounds = Rect.Union(bounds, point);
                }
            }

            ContentBounds = bounds;
        }
开发者ID:BdGL3,项目名称:CXPortal,代码行数:30,代码来源:BarGraph.cs

示例2: Render

        public override void Render(DrawingContext dc, Point screenPoint)
        {
            Point dataPoint = screenPoint.ScreenToData(this.ct.Transform);
            Point dataPointZero = new Point(dataPoint.X,0.0);
            Point screenPointZero = dataPointZero.DataToScreen(this.ct.Transform);
            //const double verticalShift = 5; // px

            //dc.DrawLine(new Pen(Brushes.Black, 1), Point.Add(screenPoint, new Vector(0, 40)), screenPoint);

            double pointx = screenPointZero.X + 2;
            double pointy = screenPointZero.Y + 2;

            FormattedText textToDraw = new FormattedText(dataPoint.Y.ToString("0.000"), Thread.CurrentThread.CurrentCulture,
                   FlowDirection.LeftToRight, new Typeface("Arial"), 12, Brushes.Black);
            dc.DrawText(textToDraw, new Point(pointx, pointy));

            /*
            string svalue = dataPoint.Y.ToString("0.000");
            foreach (var s in svalue)
            {
                if (s.Equals('.'))
                    continue;
                FormattedText textToDraw = new FormattedText(s.ToString(), Thread.CurrentThread.CurrentCulture,
                    FlowDirection.LeftToRight, new Typeface("Arial"), 12, Brushes.Black);
                dc.DrawText(textToDraw, new Point(pointx,pointy));
                pointy = pointy + 10;

            }
             * */
        }
开发者ID:supercrawler,项目名称:Chinchilla,代码行数:30,代码来源:XValueTextMarker.cs

示例3: UpdateUIRepresentation

		private void UpdateUIRepresentation(Point mousePos)
		{
			if (Plotter2D == null) return;

			var transform = Plotter2D.Viewport.Transform;
			DataRect visible = Plotter2D.Viewport.Visible;
			Rect output = Plotter2D.Viewport.Output;

			if (!output.Contains(mousePos))
			{
				if (autoHide)
				{
					horizGrid.Visibility = horizLine.Visibility = vertGrid.Visibility = vertLine.Visibility = Visibility.Hidden;
				}
				return;
			}

			if (!followMouse)
			{
				mousePos = mousePos.DataToScreen(transform);
			}

			horizLine.X1 = output.Left;
			horizLine.X2 = output.Right;
			horizLine.Y1 = mousePos.Y;
			horizLine.Y2 = mousePos.Y;

			vertLine.X1 = mousePos.X;
			vertLine.X2 = mousePos.X;
			vertLine.Y1 = output.Top;
			vertLine.Y2 = output.Bottom;

			if (UseDashOffset)
			{
				horizLine.StrokeDashOffset = (output.Right - mousePos.X) / 2;
				vertLine.StrokeDashOffset = (output.Bottom - mousePos.Y) / 2;
			}

			Point mousePosInData = mousePos.ScreenToData(transform);

			string text = null;

			if (showVerticalLine)
			{
				double xValue = mousePosInData.X;
				if (xTextMapping != null)
					text = xTextMapping(xValue);

				// doesnot have xTextMapping or it returned null
				if (text == null)
					text = GetRoundedValue(visible.XMin, visible.XMax, xValue);

				if (!String.IsNullOrEmpty(customXFormat))
					text = String.Format(customXFormat, text);
				horizTextBlock.Text = text;
			}

			double width = horizGrid.ActualWidth;
			double x = mousePos.X + blockShift.X;
			if (x + width > output.Right)
			{
				x = mousePos.X - blockShift.X - width;
			}
			Canvas.SetLeft(horizGrid, x);

			if (showHorizontalLine)
			{
				double yValue = mousePosInData.Y;
				text = null;
				if (yTextMapping != null)
					text = yTextMapping(yValue);

				if (text == null)
					text = GetRoundedValue(visible.YMin, visible.YMax, yValue);

				if (!String.IsNullOrEmpty(customYFormat))
					text = String.Format(customYFormat, text);
				vertTextBlock.Text = text;
			}

			// by default vertGrid is positioned on the top of line.
			double height = vertGrid.ActualHeight;
			double y = mousePos.Y - blockShift.Y - height;
			if (y < output.Top)
			{
				y = mousePos.Y + blockShift.Y;
			}
			Canvas.SetTop(vertGrid, y);

			if (followMouse)
				Position = mousePos;
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:92,代码来源:CursorCoordinateGraph.xaml.cs


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