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


C# Point.ScreenToData方法代码示例

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


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

示例1: 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

示例2: MouseWheelZoom

		private void MouseWheelZoom(Point mousePos, int wheelRotationDelta) {
			Point zoomTo = mousePos.ScreenToData(Viewport.Transform);

			double zoomSpeed = Math.Abs(wheelRotationDelta / Mouse.MouseWheelDeltaForOneLine);
			zoomSpeed *= wheelZoomSpeed;
			if (wheelRotationDelta < 0) {
				zoomSpeed = 1 / zoomSpeed;
			}
			Viewport.Visible = Viewport.Visible.Zoom(zoomTo, zoomSpeed);
		}
开发者ID:BdGL3,项目名称:CXPortal,代码行数:10,代码来源:TouchPadScroll.cs

示例3: UpdateUIRepresentation

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

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

            if (!output.Contains(mousePos)) return;

            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;
                m_longitude = xValue; //kda
                if (xTextMapping != null)
                    text = xTextMapping(xValue);

                // doesnot have xTextMapping or it returned null
                if (text == null)
                    text = GetRoundedValue(visible.Left, visible.Right, 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;
                m_latitude = yValue; // kda
                text = null;
                if (yTextMapping != null)
                    text = yTextMapping(yValue);

                if (text == null)
                    text = GetRoundedValue(visible.Bottom, visible.Top, 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);

            Position = mousePos;
        }
开发者ID:K0lyuchiy,项目名称:Tass,代码行数:81,代码来源:CursorCoordinateGraph.xaml.cs


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