Exemplo n.º 1
0
        private InfosTextDecoration ParseTextDecorationEntry(XmlReader _reader, string _element)
        {
            InfosTextDecoration itd = new InfosTextDecoration();

            while (_reader.Read())
            {
                if (_reader.IsStartElement())
                {
                    if (_reader.Name == "TextDecoration")
                    {
                        itd = InfosTextDecoration.FromXml(_reader);
                    }
                }
                else if (_reader.Name == _element)
                {
                    break;
                }
                else
                {
                    // Fermeture d'un tag interne.
                }
            }

            return(itd);
        }
Exemplo n.º 2
0
        public DrawingText(int x, int y, int width, int height, long _iTimestamp, long _iAverageTimeStampsPerFrame)
        {
            m_Text                = "";          //KTS 04MAY2019 Changed from " " to "" to eliminate extra space at start of each line.
            m_TextboxColor        = Color.White; // Color.LightSteelBlue;
            m_BackgroundRectangle = new Rectangle(x, y, width, height);
            m_TextStyle           = new InfosTextDecoration("Arial", m_iDefaultFontSize, FontStyle.Bold, Color.White, Color.CornflowerBlue);

            m_InfosFading = new InfosFading(_iTimestamp, _iAverageTimeStampsPerFrame);
            m_bEditMode   = false;

            // Textbox initialization.
            m_TextBox              = new TextBox();
            m_TextBox.Visible      = false;
            m_TextBox.BackColor    = m_TextboxColor;
            m_TextBox.BorderStyle  = BorderStyle.None;
            m_TextBox.Text         = m_Text;
            m_TextBox.Font         = m_TextStyle.GetInternalFont();
            m_TextBox.Multiline    = true;
            m_TextBox.TextChanged += new EventHandler(TextBox_TextChanged);


            m_fStretchFactor    = 1.0;
            m_DirectZoomTopLeft = new Point(0, 0);
            RescaleCoordinates(m_fStretchFactor, m_DirectZoomTopLeft);
        }
Exemplo n.º 3
0
 public KeyframeLabel(bool _bIsBackgroundRelative, Color _color)
 {
     m_bBackgroundIsRelative = _bIsBackgroundRelative;
     Background = new Rectangle(-20, -50, 1, 1);
     m_TextInfos.Add("Label");
     m_TextDecoration    = new InfosTextDecoration("Arial", 8, FontStyle.Bold, Color.White, Color.FromArgb(160, _color));
     m_fRescaledFontSize = (double)m_TextDecoration.FontSize;
 }
Exemplo n.º 4
0
        public static AbstractDrawing FromXml(XmlTextReader _xmlReader, PointF _scale)
        {
            DrawingAngle2D da = new DrawingAngle2D(0, 0, 0, 0, 0, 0, 0, 0);

            while (_xmlReader.Read())
            {
                if (_xmlReader.IsStartElement())
                {
                    if (_xmlReader.Name == "PointO")
                    {
                        da.PointO = XmlHelper.PointParse(_xmlReader.ReadString(), ';');
                    }
                    else if (_xmlReader.Name == "PointA")
                    {
                        da.PointA = XmlHelper.PointParse(_xmlReader.ReadString(), ';');
                    }
                    else if (_xmlReader.Name == "PointB")
                    {
                        da.PointB = XmlHelper.PointParse(_xmlReader.ReadString(), ';');
                    }
                    else if (_xmlReader.Name == "TextDecoration")
                    {
                        da.m_InfosStyle = InfosTextDecoration.FromXml(_xmlReader);
                        da.UpdateBackgroundFillColor();
                    }
                    else if (_xmlReader.Name == "InfosFading")
                    {
                        da.m_InfosFading.FromXml(_xmlReader);
                    }
                    else
                    {
                        // forward compatibility : ignore new fields.
                    }
                }
                else if (_xmlReader.Name == "Drawing")
                {
                    break;
                }
                else
                {
                    // Fermeture d'un tag interne.
                }
            }

            // We only scale the position (PointO), not the size of the edges,
            // because changing the size of the edges will change angle value.
            Point ShiftOA = new Point(da.PointA.X - da.PointO.X, da.PointA.Y - da.PointO.Y);
            Point ShiftOB = new Point(da.PointB.X - da.PointO.X, da.PointB.Y - da.PointO.Y);

            da.PointO = new Point((int)((float)da.PointO.X * _scale.X), (int)((float)da.PointO.Y * _scale.Y));
            da.PointA = new Point(da.PointO.X + ShiftOA.X, da.PointO.Y + ShiftOA.Y);
            da.PointB = new Point(da.PointO.X + ShiftOB.X, da.PointO.Y + ShiftOB.Y);

            da.RescaleCoordinates(da.m_fStretchFactor, da.m_DirectZoomTopLeft);
            return(da);
        }
Exemplo n.º 5
0
 public ColorProfile()
 {
     // Default values
     m_DecorationAngle2D = new InfosTextDecoration(8, Color.DarkOliveGreen);
     m_DecorationChrono  = new InfosTextDecoration(10, Color.Black);
     m_DecorationCross2D = new LineStyle(1, LineShape.Simple, Color.CornflowerBlue);
     m_DecorationLine2D  = new LineStyle(3, LineShape.Simple, Color.LightGreen);
     m_DecorationPencil  = new LineStyle(6, LineShape.Simple, Color.LightGreen);
     m_DecorationText    = new InfosTextDecoration(10, Color.CornflowerBlue);
 }
Exemplo n.º 6
0
        public void Load(ColorProfile _origin)
        {
            log.Debug("Loading color profile from object.");

            this.m_DecorationAngle2D = _origin.m_DecorationAngle2D.Clone();
            this.m_DecorationChrono  = _origin.m_DecorationChrono.Clone();
            this.m_DecorationCross2D = _origin.m_DecorationCross2D.Clone();
            this.m_DecorationLine2D  = _origin.m_DecorationLine2D.Clone();
            this.m_DecorationPencil  = _origin.m_DecorationPencil.Clone();
            this.m_DecorationText    = _origin.m_DecorationText.Clone();
        }
Exemplo n.º 7
0
        public static KeyframeLabel FromXml(XmlTextReader _xmlReader, bool _relative, PointF _scale)
        {
            // Read all tags between <KeyframeLabel> and </KeyframeLabel> and fills up an object.

            KeyframeLabel kfl = new KeyframeLabel(_relative, Color.Black);

            while (_xmlReader.Read())
            {
                if (_xmlReader.IsStartElement())
                {
                    if (_xmlReader.Name == "SpacePosition")
                    {
                        Point p       = XmlHelper.PointParse(_xmlReader.ReadString(), ';');
                        Point adapted = new Point((int)((float)p.X * _scale.X), (int)((float)p.Y * _scale.Y));

                        kfl.Background         = new Rectangle(adapted, new Size(10, 10));
                        kfl.RescaledBackground = new Rectangle(adapted, new Size(10, 10));
                    }
                    else if (_xmlReader.Name == "TimePosition")
                    {
                        // Time was stored absolute.
                        kfl.m_iTimestamp = long.Parse(_xmlReader.ReadString());
                    }
                    else if (_xmlReader.Name == "TextDecoration")
                    {
                        kfl.m_TextDecoration = InfosTextDecoration.FromXml(_xmlReader);
                    }

                    /*else if (_xmlReader.Name == "BackgroundBrush")
                     * {
                     *  ParseBackgroundBrush(_xmlReader, kfl);
                     * }
                     * else if (_xmlReader.Name == "Font")
                     * {
                     *  ParseFont(_xmlReader, kfl);
                     * }*/
                    else
                    {
                        // forward compatibility : ignore new fields.
                    }
                }
                else if (_xmlReader.Name == "KeyframeLabel")
                {
                    break;
                }
                else
                {
                    // Fermeture d'un tag interne.
                }
            }

            return(kfl);
        }
Exemplo n.º 8
0
        public static AbstractDrawing FromXml(XmlTextReader _xmlReader, PointF _scale)
        {
            DrawingText dt = new DrawingText(0, 0, 0, 0, 0, 0);

            while (_xmlReader.Read())
            {
                if (_xmlReader.IsStartElement())
                {
                    if (_xmlReader.Name == "Text")
                    {
                        dt.m_Text = _xmlReader.ReadString();
                    }
                    else if (_xmlReader.Name == "Position")
                    {
                        Point p = XmlHelper.PointParse(_xmlReader.ReadString(), ';');
                        //dt.Background.Location = new Point(plotGrid.X, plotGrid.Y);

                        // Adapt to new Image size.
                        dt.m_BackgroundRectangle.Location = new Point((int)((float)p.X * _scale.X), (int)((float)p.Y * _scale.Y));
                    }
                    else if (_xmlReader.Name == "TextDecoration")
                    {
                        dt.m_TextStyle = InfosTextDecoration.FromXml(_xmlReader);
                    }
                    else if (_xmlReader.Name == "InfosFading")
                    {
                        dt.m_InfosFading.FromXml(_xmlReader);
                    }
                    else
                    {
                        // forward compatibility : ignore new fields.
                    }
                }
                else if (_xmlReader.Name == "Drawing")
                {
                    break;
                }
                else
                {
                    // Fermeture d'un tag interne.
                }
            }

            dt.RescaleCoordinates(dt.m_fStretchFactor, dt.m_DirectZoomTopLeft);
            dt.AutoSizeTextbox();

            return(dt);
        }
Exemplo n.º 9
0
        private float m_fSweepAngle;    // This is the actual value of the angle.
        #endregion

        #region Constructor
        public DrawingAngle2D(int Ox, int Oy, int Ax, int Ay, int Bx, int By, long _iTimestamp, long _iAverageTimeStampsPerFrame)
        {
            // Core
            PointO              = new Point(Ox, Oy);
            PointA              = new Point(Ax, Ay);
            PointB              = new Point(Bx, By);
            m_fStretchFactor    = 1.0;
            m_DirectZoomTopLeft = new Point(0, 0);

            // Decoration
            m_InfosStyle = new InfosTextDecoration("Arial", 12, FontStyle.Bold, Color.White, Color.DarkOliveGreen);
            UpdateBackgroundFillColor();

            // Fading
            m_InfosFading = new InfosFading(_iTimestamp, _iAverageTimeStampsPerFrame);

            // Computed
            RescaleCoordinates(m_fStretchFactor, m_DirectZoomTopLeft);
            m_BoundingPoint = new Point(0, 0);
        }
Exemplo n.º 10
0
 public override void RecallDecoration()
 {
     m_TextStyle = m_MemoTextStyle.Clone();
     AutoSizeTextbox();
 }
Exemplo n.º 11
0
 public override void MemorizeDecoration()
 {
     m_MemoTextStyle = m_TextStyle.Clone();
 }
Exemplo n.º 12
0
 public override void RecallDecoration()
 {
     m_InfosStyle = m_MemoInfosStyle.Clone();
 }
Exemplo n.º 13
0
 public override void MemorizeDecoration()
 {
     m_MemoInfosStyle = m_InfosStyle.Clone();
 }
Exemplo n.º 14
0
        public void Load(string _filePath)
        {
            log.Debug("Loading color profile from xml file.");

            XmlReader reader = new XmlTextReader(_filePath);

            if (reader != null)
            {
                try
                {
                    while (reader.Read())
                    {
                        if ((reader.IsStartElement()) && (reader.Name == "KinoveaColorProfile"))
                        {
                            while (reader.Read())
                            {
                                if (reader.IsStartElement())
                                {
                                    // TODO: Do not try to read from older format (1.1)

                                    switch (reader.Name)
                                    {
                                    case "Angle2D":
                                        m_DecorationAngle2D = ParseTextDecorationEntry(reader, reader.Name);
                                        break;

                                    case "Chrono":
                                        m_DecorationChrono = ParseTextDecorationEntry(reader, reader.Name);
                                        break;

                                    case "Cross2D":
                                        m_DecorationCross2D = ParseLineStyleEntry(reader, reader.Name);
                                        break;

                                    case "Line2D":
                                        m_DecorationLine2D = ParseLineStyleEntry(reader, reader.Name);
                                        break;

                                    case "Pencil":
                                        m_DecorationPencil = ParseLineStyleEntry(reader, reader.Name);
                                        break;

                                    case "Text":
                                        m_DecorationText = ParseTextDecorationEntry(reader, reader.Name);
                                        break;

                                    default:
                                        // DrawingTool from a newer file format...
                                        // We don't have a holder variable for it: ignore.
                                        break;
                                    }

                                    #region old format 1.1

                                    /*
                                     * switch (reader.Name)
                                     * {
                                     * case "TextColorRGB":
                                     *  m_ColorText = XmlHelper.ColorParse(reader.ReadString(), ';');
                                     *  break;
                                     * case "PencilColorRGB":
                                     *  m_ColorPencil = XmlHelper.ColorParse(reader.ReadString(), ';');
                                     *  break;
                                     * case "PencilSize":
                                     *  m_StylePencil.Size = int.Parse(reader.ReadString());
                                     *  break;
                                     * case "Cross2DColorRGB":
                                     *  m_ColorCross2D = XmlHelper.ColorParse(reader.ReadString(), ';');
                                     *  break;
                                     * case "Line2DColorRGB":
                                     *  m_ColorLine2D = XmlHelper.ColorParse(reader.ReadString(), ';');
                                     *  break;
                                     * case "Line2DSize":
                                     *  m_StyleLine2D.Size = int.Parse(reader.ReadString());
                                     *  break;
                                     * case "Line2DStartArrow":
                                     *  m_StyleLine2D.StartArrow = bool.Parse(reader.ReadString());
                                     *  break;
                                     * case "Line2DEndArrow":
                                     *  m_StyleLine2D.EndArrow = bool.Parse(reader.ReadString());
                                     *  break;
                                     * case "Angle2DColorRGB":
                                     *  m_ColorAngle2D = XmlHelper.ColorParse(reader.ReadString(), ';');
                                     *  break;
                                     * case "ChronoColorRGB":
                                     *  m_ColorChrono = XmlHelper.ColorParse(reader.ReadString(), ';');
                                     *  break;
                                     * default:
                                     *  // Parameter from a newer file format...
                                     *  // We don't have a holder variable for it: ignore.
                                     *  break;
                                     * }*/
                                    #endregion
                                }
                                else if (reader.Name == "KinoveaColorProfile")
                                {
                                    break;
                                }
                                else
                                {
                                    // Fermeture d'un tag interne.
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    log.Error("Error happenned while parsing color profile. We'll keep the default values.");
                    log.Error("File we tried to read was :" + _filePath);
                }
                finally
                {
                    reader.Close();
                }
            }
        }