Ejemplo n.º 1
0
        public DrawingLine(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            points["a"] = origin;
            points["b"] = origin.Translate(10, 0);
            miniLabel.SetAttach(GetMiddlePoint(), true);

            styleHelper.Color         = Color.DarkSlateGray;
            styleHelper.LineSize      = 1;
            styleHelper.LineShape     = LineShape.Solid;
            styleHelper.LineEnding    = LineEnding.None;
            styleHelper.ValueChanged += StyleHelper_ValueChanged;
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Line");
            }

            style = preset.Clone();
            BindStyle();

            // Fading
            infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            // Context menu
            ReinitializeMenu();
            mnuCalibrate.Click += mnuCalibrate_Click;
            mnuCalibrate.Image  = Properties.Drawings.linecalibrate;
        }
Ejemplo n.º 2
0
        //------------------------------------------------------
        // Note:
        // When using the planar calibration, the projection of the circle in world space and back in image space
        // creates an ellipse whose center is not exactly on the center of the original circle.
        // This is why there are extra checks to move the minilabel attachment point everytime the drawing moves,
        // changes size, or when the calibration changes.
        //------------------------------------------------------

        #region Constructor
        public DrawingCircle(PointF center, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            this.center = center;
            miniLabel.SetAttach(center, true);

            if (transformer != null)
            {
                this.radius = transformer.Untransform(25);
            }

            this.radius      = Math.Min(radius, 10);
            this.infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            styleHelper.Color         = Color.Empty;
            styleHelper.LineSize      = 1;
            styleHelper.PenShape      = PenShape.Solid;
            styleHelper.ValueChanged += StyleHelper_ValueChanged;
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Circle");
            }

            style = preset.Clone();
            BindStyle();

            ReinitializeMenu();
        }
Ejemplo n.º 3
0
        public void ReadXml(XmlReader xmlReader, PointF scale, TimestampMapper timestampMapper)
        {
            if (xmlReader.MoveToAttribute("id"))
            {
                identifier = new Guid(xmlReader.ReadContentAsString());
            }

            if (xmlReader.MoveToAttribute("name"))
            {
                name = xmlReader.ReadContentAsString();
            }

            xmlReader.ReadStartElement();

            while (xmlReader.NodeType == XmlNodeType.Element)
            {
                switch (xmlReader.Name)
                {
                case "Start":
                {
                    PointF p = XmlHelper.ParsePointF(xmlReader.ReadElementContentAsString());
                    points["a"] = p.Scale(scale.X, scale.Y);
                    break;
                }

                case "End":
                {
                    PointF p = XmlHelper.ParsePointF(xmlReader.ReadElementContentAsString());
                    points["b"] = p.Scale(scale.X, scale.Y);
                    break;
                }

                case "ExtraData":
                {
                    TypeConverter enumConverter = TypeDescriptor.GetConverter(typeof(TrackExtraData));
                    trackExtraData = (TrackExtraData)enumConverter.ConvertFromString(xmlReader.ReadElementContentAsString());
                    break;
                }

                case "MeasureLabel":
                {
                    miniLabel = new MiniLabel(xmlReader, scale);
                    break;
                }

                case "DrawingStyle":
                    style = new DrawingStyle(xmlReader);
                    BindStyle();
                    break;

                case "InfosFading":
                    infosFading.ReadXml(xmlReader);
                    break;

                case "Measure":
                    xmlReader.ReadOuterXml();
                    break;

                default:
                    string unparsed = xmlReader.ReadOuterXml();
                    log.DebugFormat("Unparsed content in KVA XML: {0}", unparsed);
                    break;
                }
            }

            xmlReader.ReadEndElement();
            initializing       = false;
            measureInitialized = true;
            miniLabel.SetAttach(GetMiddlePoint(), false);
            miniLabel.BackColor = styleHelper.Color;
            SignalAllTrackablePointsMoved();
        }
Ejemplo n.º 4
0
 public override void MoveDrawing(float dx, float dy, Keys modifiers, bool zooming)
 {
     points["0"] = points["0"].Translate(dx, dy);
     SignalTrackablePointMoved();
     miniLabel.SetAttach(points["0"], true);
 }
Ejemplo n.º 5
0
        public void ReadXml(XmlReader xmlReader, PointF scale, TimestampMapper timestampMapper)
        {
            if (xmlReader.MoveToAttribute("id"))
            {
                identifier = new Guid(xmlReader.ReadContentAsString());
            }

            if (xmlReader.MoveToAttribute("name"))
            {
                name = xmlReader.ReadContentAsString();
            }

            xmlReader.ReadStartElement();

            while (xmlReader.NodeType == XmlNodeType.Element)
            {
                switch (xmlReader.Name)
                {
                case "Origin":
                    center = XmlHelper.ParsePointF(xmlReader.ReadElementContentAsString());
                    break;

                case "Radius":
                    radius = (int)(xmlReader.ReadElementContentAsInt() * scale.X);
                    break;

                case "ExtraData":
                {
                    TypeConverter enumConverter = TypeDescriptor.GetConverter(typeof(TrackExtraData));
                    trackExtraData = (TrackExtraData)enumConverter.ConvertFromString(xmlReader.ReadElementContentAsString());
                    break;
                }

                case "MeasureLabel":
                {
                    miniLabel = new MiniLabel(xmlReader, scale);
                    break;
                }

                case "ShowCenter":
                    showCenter = XmlHelper.ParseBoolean(xmlReader.ReadElementContentAsString());
                    break;

                case "DrawingStyle":
                    style = new DrawingStyle(xmlReader);
                    BindStyle();
                    break;

                case "InfosFading":
                    infosFading.ReadXml(xmlReader);
                    break;

                default:
                    string unparsed = xmlReader.ReadOuterXml();
                    log.DebugFormat("Unparsed content in KVA XML: {0}", unparsed);
                    break;
                }
            }

            xmlReader.ReadEndElement();
            initializing       = false;
            measureInitialized = true;
            miniLabel.SetAttach(center, false);
            miniLabel.BackColor = styleHelper.Color;
        }