using System;
using System.Drawing;
using Deltares.Dam.Data.Sensors;
using Deltares.Geometry.Forms;
using Deltares.Mathematics;
using Deltares.Standard;
using Deltares.Standard.Forms;
using Deltares.Standard.Forms.DExpress;
namespace Deltares.Dam.Forms
{
public class SensorDrawingObject : DrawingObject
{
private Sensor sensor = null;
private Color color = Color.Coral;
private Point2D point = null;
///
/// Initializes a new instance of the class.
///
public SensorDrawingObject()
{
this.Layer = -50;
}
///
/// Gets or sets the color.
///
///
/// The color.
///
public Color Color
{
get { return color; }
set { color = value; }
}
///
/// Sets the data object.
///
/// The data object.
public override void SetDataObject(object dataObject)
{
this.sensor = (Sensor)dataObject;
}
///
/// Gets the data object.
///
///
public override object GetDataObject()
{
return sensor;
}
///
/// Render this object in 3D space.
///
/// Rendering target information.
public override void Draw3D(GraphicsInfo info)
{
DrawingSupport.SetIEPDraw3D(info.Graphics);
DrawingSupport.Pen3D(System.Drawing.Drawing2D.DashStyle.Solid, 3, color);
if (sensor != null)
{
var calculatedPoint = new Point3D();
var sensorPoint = new Point3D(sensor.RelativeLocation, 0.0, sensor.Depth);
this.GetScaled3DPoint(info.Projection, new Point3D(sensorPoint.X, sensorPoint.Y, sensorPoint.Z), ref calculatedPoint);
DrawingSupport.Cross_Symbol3D(calculatedPoint.X, calculatedPoint.Z, 10);
point = new Point2D(calculatedPoint.X, calculatedPoint.Z);
}
}
///
/// Determines whether the screenpoint is on the location of the sensor (to support showing tooltip)
///
/// The projection.
/// The screen point.
///
public override bool ContainsPoint(IProjection projection, Point screenPoint)
{
var screenPoint2D = new Point2D(screenPoint.X, screenPoint.Y);
if (point != null)
{
if (Routines2D.DetermineIfPointsCoincide(point, screenPoint2D, 3))
{
return true;
}
}
return false;
}
///
/// Renders a label or tooltip to provide some information in text for this object.
///
/// Rendering target information.
public override void DrawLabel(GraphicsInfo info)
{
var realPoint = new Point(Convert.ToInt32(point.X), Convert.ToInt32(point.Y));
var screenPoint = new Point(realPoint.X + 20, realPoint.Y - 20);
DrawingSupport.DrawLabelAtPoint(info, realPoint, screenPoint, sensor.Name, Brushes.Black, Brushes.LemonChiffon, Brushes.DarkSlateGray);
}
}
}