using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using Microsoft.VisualBasic.CompilerServices;

namespace Super2d3dGraphLibrary;

[Description("Esta clase proporciona funcionalidad para las etiquetas que muestran un valor en el gráfico")]
public class ValueCaption
{
	private float m_sngPosX;

	private float m_sngPosY;

	private float m_sngHotSpotX;

	private float m_sngHotSpotY;

	private float m_sngPosXBestSoFar;

	private float m_sngPosYBestSoFar;

	private float m_sngPosXOld;

	private float m_sngPosYOld;

	private string m_strValue;

	private double m_dblNumericValue;

	private float m_sngXDisplacementDirection;

	private float m_sngYDisplacementDirection;

	private string m_strCaption;

	private int m_intSeriesIndex;

	private int m_intItemIndex;

	private GraphicsPath m_path;

	private bool m_blnShowDisplacementLine;

	private SizeF m_size;

	public int seriesIndex => m_intSeriesIndex;

	public int itemIndex => m_intItemIndex;

	public float X_Old
	{
		get
		{
			return m_sngPosXOld;
		}
		set
		{
			m_sngPosXOld = value;
		}
	}

	public float Y_Old
	{
		get
		{
			return m_sngPosYOld;
		}
		set
		{
			m_sngPosYOld = value;
		}
	}

	public float X_BestSoFar
	{
		get
		{
			return m_sngPosXBestSoFar;
		}
		set
		{
			m_sngPosXBestSoFar = value;
		}
	}

	public float Y_BestSoFar
	{
		get
		{
			return m_sngPosYBestSoFar;
		}
		set
		{
			m_sngPosYBestSoFar = value;
		}
	}

	public bool ShowDisplacementLine
	{
		get
		{
			return m_blnShowDisplacementLine;
		}
		set
		{
			m_blnShowDisplacementLine = value;
		}
	}

	public float sngXDisplacementDirection
	{
		get
		{
			if (m_sngXDisplacementDirection > 0f)
			{
				return 1f;
			}
			if (m_sngXDisplacementDirection < 0f)
			{
				return -1f;
			}
			return 0f;
		}
	}

	public float sngYDisplacementDirection
	{
		get
		{
			if (m_sngYDisplacementDirection > 0f)
			{
				return 1f;
			}
			if (m_sngYDisplacementDirection < 0f)
			{
				return -1f;
			}
			return 0f;
		}
		set
		{
			m_sngYDisplacementDirection = value;
		}
	}

	public Rectangle RECT
	{
		get
		{
			RectangleF bounds = m_path.GetBounds();
			return checked(new Rectangle((int)Math.Round(bounds.X), (int)Math.Round(bounds.Y), (int)Math.Round(bounds.Width), (int)Math.Round(bounds.Height)));
		}
	}

	public GraphicsPath PATH => m_path;

	public string Caption
	{
		get
		{
			return m_strCaption;
		}
		set
		{
			m_strCaption = value;
		}
	}

	public float X
	{
		get
		{
			return m_sngPosX;
		}
		set
		{
			m_sngPosX = value;
		}
	}

	public float Y
	{
		get
		{
			return m_sngPosY;
		}
		set
		{
			m_sngPosY = value;
		}
	}

	public string Value
	{
		get
		{
			if (Operators.CompareString(m_strCaption, "", TextCompare: false) != 0)
			{
				return m_strCaption;
			}
			if (Versioned.IsNumeric(m_strValue))
			{
				return double.Parse(m_strValue).ToString(strValueFormat);
			}
			return m_strValue;
		}
	}

	public double ValueNumeric => m_dblNumericValue;

	public float X_HotSpot
	{
		get
		{
			return m_sngHotSpotX;
		}
		set
		{
			m_sngHotSpotX = value;
		}
	}

	public float Y_HotSpot
	{
		get
		{
			return m_sngHotSpotY;
		}
		set
		{
			m_sngHotSpotY = value;
		}
	}

	public int Displacement => checked((int)Math.Round(Math.Sqrt(Math.Pow(m_sngHotSpotX - m_sngPosX, 2.0) + Math.Pow(m_sngHotSpotY - m_sngPosY, 2.0))));

	public SizeF Size
	{
		get
		{
			return m_size;
		}
		set
		{
			m_size = value;
		}
	}

	public ValueCaption(ref int seriesIndex, ref int itemIndex, ref float sngPosX, ref float sngPosY, double value)
	{
		int num = seriesIndex;
		int num2 = itemIndex;
		float sngPosX2 = sngPosX;
		float sngPosY2 = sngPosY;
		string value2 = Conversions.ToString(value);
		float sngHotSpotX = sngPosX;
		float sngHotSpotY = sngPosY;
		float num3 = 0f;
		float num4 = 0f;
		this._002Ector(num, num2, sngPosX2, sngPosY2, value2, value, sngHotSpotX, sngHotSpotY, ref num3, ref num4);
	}

	public ValueCaption(ref int seriesIndex, ref int itemIndex, ref float sngPosX, ref float sngPosY, string value)
	{
		int num = seriesIndex;
		int num2 = itemIndex;
		float sngPosX2 = sngPosX;
		float sngPosY2 = sngPosY;
		float sngHotSpotX = sngPosX;
		float sngHotSpotY = sngPosY;
		float num3 = 0f;
		float num4 = 0f;
		this._002Ector(num, num2, sngPosX2, sngPosY2, value, 0.0, sngHotSpotX, sngHotSpotY, ref num3, ref num4);
	}

	public ValueCaption(ref int seriesIndex, ref int itemIndex, ref float sngPosX, ref float sngPosY, string value, ref float numericValue)
	{
		int num = seriesIndex;
		int num2 = itemIndex;
		float sngPosX2 = sngPosX;
		float sngPosY2 = sngPosY;
		double numericValue2 = numericValue;
		float sngHotSpotX = sngPosX;
		float sngHotSpotY = sngPosY;
		float num3 = 0f;
		float num4 = 0f;
		this._002Ector(num, num2, sngPosX2, sngPosY2, value, numericValue2, sngHotSpotX, sngHotSpotY, ref num3, ref num4);
	}

	public ValueCaption(ref int seriesIndex, ref int itemIndex, ref float sngPosX, ref float sngPosY, string value, ref float sngHotSpotX, ref float sngHotSpotY)
	{
		int num = seriesIndex;
		int num2 = itemIndex;
		float sngPosX2 = sngPosX;
		float sngPosY2 = sngPosY;
		double numericValue = Conversions.ToDouble(value);
		float sngHotSpotX2 = sngHotSpotX;
		float sngHotSpotY2 = sngHotSpotY;
		float num3 = 0f;
		float num4 = 0f;
		this._002Ector(num, num2, sngPosX2, sngPosY2, value, numericValue, sngHotSpotX2, sngHotSpotY2, ref num3, ref num4);
	}

	public ValueCaption(int seriesIndex, int itemIndex, float sngPosX, float sngPosY, string value, double numericValue, float sngHotSpotX, float sngHotSpotY, ref float sngXDisplacementDirection, ref float sngYDisplacementDirection)
	{
		m_path = new GraphicsPath();
		m_size = default(SizeF);
		m_intSeriesIndex = seriesIndex;
		m_intItemIndex = itemIndex;
		if (sngPosX < 0f)
		{
			sngPosX = 0f;
		}
		if (sngPosY < 0f)
		{
			sngPosY = 0f;
		}
		m_sngPosX = sngPosX;
		m_sngPosY = sngPosY;
		m_sngHotSpotX = sngHotSpotX;
		m_sngHotSpotY = sngHotSpotY;
		m_strValue = value;
		m_dblNumericValue = numericValue;
		m_sngYDisplacementDirection = sngYDisplacementDirection;
		if (sngYDisplacementDirection == 0f)
		{
			if (m_sngPosY > m_sngHotSpotY)
			{
				m_sngYDisplacementDirection = 1f;
			}
			else if (m_sngPosY < m_sngHotSpotY)
			{
				m_sngYDisplacementDirection = -1f;
			}
		}
		m_sngXDisplacementDirection = sngXDisplacementDirection;
		if (sngXDisplacementDirection == 0f)
		{
			if (m_sngPosX > m_sngHotSpotX)
			{
				m_sngXDisplacementDirection = 1f;
			}
			else if (m_sngPosX < m_sngHotSpotX)
			{
				m_sngXDisplacementDirection = -1f;
			}
		}
	}

	public void AddZonePie(ref Rectangle r, float angle, float sweepangle)
	{
		m_path.AddPie(r, angle, sweepangle);
	}

	public void AddZoneRectangle(ref Rectangle r)
	{
		m_path.AddRectangle(r);
	}

	public void AddZoneCircle(ref Rectangle r)
	{
		m_path.AddEllipse(r);
	}

	public void AddZonePath(ref GraphicsPath path)
	{
		m_path.AddPath(path, connect: false);
	}

	public void AddZonePolygon(ref PointF[] points)
	{
		m_path.AddPolygon(points);
	}

	public bool Contains(float x, float y)
	{
		if (m_path != null)
		{
			return m_path.IsVisible(x, y);
		}
		return false;
	}

	public void MoveTo(float X, float Y)
	{
		m_sngPosX = X;
		m_sngPosY = Y;
	}
}
