System.Windows.Forms.DataVisualization.Charting.TextAnnotation.EndPlacement()

Here are the examples of the csharp api class System.Windows.Forms.DataVisualization.Charting.TextAnnotation.EndPlacement() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

View license
private void MainChart_MouseMove(object sender, MouseEventArgs e)
		{
			if (m_isPlacingAnnotation) return;

			while (m_isChartUpdating)
			{
			}

			try
			{
				m_isPlacingAnnotation = true;
				var xValueUnderCursor = MainChart.ChartAreas[0].AxisX.PixelPositionToValue(e.X);
				var results = MainChart.HitTest(e.X, e.Y, false, ChartElementType.DataPoint);
				var point = results.Where(x => x.ChartElementType == ChartElementType.DataPoint)
				                   .Select(x => x.Object as DataPoint)
				                   .Where(x => x != null && x.Tag != null)
				                   .OrderBy(x => Math.Abs(xValueUnderCursor - x.XValue))
				                   .FirstOrDefault();

				if (point == null) return;
				if (m_pointUnderCursor != null && !m_pointerUnderCursorSelected)
				{
					m_pointUnderCursor.MarkerSize = ChartMarkerSize;
				}

				m_pointUnderCursor = point;
				m_pointerUnderCursorSelected = m_pointUnderCursor.MarkerSize == ChartSelectedMarkerSize;
				m_pointUnderCursor.MarkerSize = ChartSelectedMarkerSize;

				m_valueAnnotation.BeginPlacement();
				{
					m_valueAnnotation.AnchorX = m_pointUnderCursor.XValue;
					m_valueAnnotation.AnchorY = m_pointUnderCursor.YValues[0];
					m_valueAnnotation.Text = m_pointUnderCursor.Tag.ToString();
				}
				m_valueAnnotation.EndPlacement();
			}
			catch (Exception)
			{
				// Ignore
			}
			finally
			{
				m_isPlacingAnnotation = false;
			}
		}