private void ReadXml(XmlReader _xmlReader, PointF _scale) { _xmlReader.ReadStartElement(); while (_xmlReader.NodeType == XmlNodeType.Element) { switch (_xmlReader.Name) { case "PointList": ParsePointList(_xmlReader, _scale); break; case "DrawingStyle": m_Style = new DrawingStyle(_xmlReader); BindStyle(); break; case "InfosFading": m_InfosFading.ReadXml(_xmlReader); break; default: string unparsed = _xmlReader.ReadOuterXml(); log.DebugFormat("Unparsed content in KVA XML: {0}", unparsed); break; } } _xmlReader.ReadEndElement(); }
public DrawingText(PointF p, long timestamp, long averageTimeStampsPerFrame, DrawingStyle stylePreset) { text = " "; background.Rectangle = new RectangleF(p, SizeF.Empty); styleHelper.Bicolor = new Bicolor(Color.Black); styleHelper.Font = new Font("Arial", defaultFontSize, FontStyle.Bold); if (stylePreset != null) { style = stylePreset.Clone(); BindStyle(); } infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame); editing = false; textBox = new TextBox() { Visible = false, BackColor = Color.White, BorderStyle = BorderStyle.None, Multiline = true, Text = text, Font = styleHelper.GetFontDefaultSize(defaultFontSize) }; textBox.TextChanged += TextBox_TextChanged; UpdateLabelRectangle(); }
private void BindStyle() { DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("Plane")); style.Bind(styleHelper, "Color", "color"); style.Bind(styleHelper, "GridDivisions", "divisions"); style.Bind(styleHelper, "Perspective", "perspective"); }
public DrawingLine(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null) { points["a"] = origin; points["b"] = origin.Translate(10, 0); labelMeasure = new KeyframeLabel(GetMiddlePoint(), Color.Black, transformer); styleHelper.Color = Color.DarkSlateGray; styleHelper.LineSize = 1; if (preset == null) { preset = ToolManager.GetStylePreset("Line"); } style = preset.Clone(); BindStyle(); // Fading infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame); // Context menu mnuShowMeasure.Click += mnuShowMeasure_Click; mnuShowMeasure.Image = Properties.Drawings.measure; mnuSealMeasure.Click += mnuSealMeasure_Click; mnuSealMeasure.Image = Properties.Drawings.linecalibrate; }
public DrawingToolText() { m_DefaultStylePreset.Elements.Add("back color", new StyleElementColor(Color.CornflowerBlue)); m_DefaultStylePreset.Elements.Add("font size", new StyleElementFontSize(12)); m_StylePreset = m_DefaultStylePreset.Clone(); }
private void BindStyle() { DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("Chrono")); style.Bind(styleHelper, "Bicolor", "color"); style.Bind(styleHelper, "Font", "font size"); style.Bind(styleHelper, "Clock", "clock"); }
private static Cursor GetCursorCrossMark(DrawingStyle style) { // Cross inside a semi transparent circle (same as drawing). string keyColor = "back color"; if (!style.Elements.ContainsKey(keyColor)) { return(null); } Color c = (Color)style.Elements[keyColor].Value; Pen p = new Pen(c, 1); Bitmap b = new Bitmap(9, 9); Graphics g = Graphics.FromImage(b); // Center point is {4,4} g.DrawLine(p, 1, 4, 7, 4); g.DrawLine(p, 4, 1, 4, 7); SolidBrush tempBrush = new SolidBrush(Color.FromArgb(32, c)); g.FillEllipse(tempBrush, 0, 0, 8, 8); tempBrush.Dispose(); g.Dispose(); p.Dispose(); return(new Cursor(b.GetHicon())); }
public DrawingAngle(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null) { int length = 50; if (transformer != null) { length = transformer.Untransform(50); } points.Add("o", origin); points.Add("a", origin.Translate(0, -length)); points.Add("b", origin.Translate(length, 0)); styleHelper.Bicolor = new Bicolor(Color.Empty); styleHelper.Font = new Font("Arial", 12, FontStyle.Bold); if (preset == null) { preset = ToolManager.GetStylePreset("Angle"); } style = preset.Clone(); BindStyle(); // Fading infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame); mnuInvertAngle.Click += mnuInvertAngle_Click; mnuInvertAngle.Image = Properties.Drawings.angleinvert; }
public DrawingChrono(Point p, long start, long _AverageTimeStampsPerFrame, DrawingStyle _preset) { // Core m_iVisibleTimestamp = start; m_iStartCountingTimestamp = long.MaxValue; m_iStopCountingTimestamp = long.MaxValue; m_iInvisibleTimestamp = long.MaxValue; m_bCountdown = false; m_MainBackground.Rectangle = new Rectangle(p, Size.Empty); m_Timecode = "error"; m_StyleHelper.Bicolor = new Bicolor(Color.Black); m_StyleHelper.Font = new Font("Arial", 16, FontStyle.Bold); if (_preset != null) { m_Style = _preset.Clone(); BindStyle(); } m_Label = ""; m_bShowLabel = true; // We use the InfosFading utility to fade the chrono away. // The refererence frame will be the frame at which fading start. // Must be updated on "Hide" menu. m_InfosFading = new InfosFading(m_iInvisibleTimestamp, _AverageTimeStampsPerFrame); m_InfosFading.FadingFrames = m_iAllowedFramesOver; m_InfosFading.UseDefault = false; }
public static void SavePresets(string file) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.CloseOutput = true; using (XmlWriter w = XmlWriter.Create(file, settings)) { w.WriteStartElement("KinoveaColorProfile"); w.WriteElementString("FormatVersion", "3.0"); foreach (KeyValuePair <string, AbstractDrawingTool> tool in Tools) { DrawingStyle preset = tool.Value.StylePreset; if (preset != null && preset.Elements.Count > 0) { w.WriteStartElement("ToolPreset"); w.WriteAttributeString("Key", tool.Key); preset.WriteXml(w); w.WriteEndElement(); } } w.WriteEndElement(); } }
public DrawingGenericPosture(Guid toolId, PointF origin, GenericPosture posture, long timestamp, long averageTimeStampsPerFrame, DrawingStyle stylePreset) { this.toolId = toolId; this.origin = origin; this.genericPosture = posture; if (genericPosture != null) { Init(); } // Decoration and binding to mini editors. styleHelper.Bicolor = new Bicolor(Color.Empty); styleHelper.Font = new Font("Arial", 12, FontStyle.Bold); if (stylePreset == null) { stylePreset = new DrawingStyle(); stylePreset.Elements.Add("line color", new StyleElementColor(Color.DarkOliveGreen)); } style = stylePreset.Clone(); BindStyle(); // Fading infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame); menuFlipHorizontal.Click += menuFlipHorizontal_Click; menuFlipHorizontal.Image = Properties.Drawings.fliphorizontal; menuFlipVertical.Click += menuFlipVertical_Click; menuFlipVertical.Image = Properties.Drawings.flipvertical; }
public DrawingAngle(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null) { int length = 50; if (transformer != null) { length = transformer.Untransform(50); } points.Add("o", origin); points.Add("a", origin.Translate(length, 0)); points.Add("b", origin.Translate(0, -length)); styleHelper.Bicolor = new Bicolor(Color.Empty); styleHelper.Font = new Font("Arial", 12, FontStyle.Bold); if (preset == null) { preset = ToolManager.GetStylePreset("Angle"); } style = preset.Clone(); BindStyle(); // Fading infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame); mnuSignedAngle.Click += mnuSignedAngle_Click; mnuSignedAngle.Checked = signedAngle; mnuCounterClockwise.Click += mnuCounterClockwise_Click; mnuCounterClockwise.Checked = counterClockwise; mnuSupplementaryAngle.Click += mnuSupplementaryAngle_Click; mnuSupplementaryAngle.Checked = supplementaryAngle; }
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; }
private static DrawingStyle ImportPreset(DrawingStyle defaultStyle, DrawingStyle preset) { // This is used when importing the presets from XML. // Styling options may be added or removed between releases. // Compare the drawing's style elements with the elements in the default preset. // TODO: this should be done for KVA too. // Add options unknown to the preset. foreach (KeyValuePair <string, AbstractStyleElement> pair in defaultStyle.Elements) { if (!preset.Elements.ContainsKey(pair.Key)) { preset.Elements.Add(pair.Key, pair.Value); } } // Remove options unknown to the default. foreach (KeyValuePair <string, AbstractStyleElement> pair in preset.Elements) { if (!defaultStyle.Elements.ContainsKey(pair.Key)) { preset.Elements.Remove(pair.Key); } } return(preset); }
public DrawingChrono(PointF p, long start, long averageTimeStampsPerFrame, DrawingStyle preset = null) { // Core visibleTimestamp = start; startCountingTimestamp = long.MaxValue; stopCountingTimestamp = long.MaxValue; invisibleTimestamp = long.MaxValue; countdown = false; mainBackground.Rectangle = new RectangleF(p, SizeF.Empty); timecode = "error"; styleHelper.Bicolor = new Bicolor(Color.Black); styleHelper.Font = new Font("Arial", 16, FontStyle.Bold); if (preset == null) { preset = ToolManager.GetStylePreset("Chrono"); } style = preset.Clone(); BindStyle(); label = ""; showLabel = true; // We use the InfosFading utility to fade the chrono away. // The refererence frame will be the frame at which fading start. // Must be updated on "Hide" menu. infosFading = new InfosFading(invisibleTimestamp, averageTimeStampsPerFrame); infosFading.FadingFrames = allowedFramesOver; infosFading.UseDefault = false; }
public void ReadXml(XmlReader r) { if (r.MoveToAttribute("id")) { identifier = new Guid(r.ReadContentAsString()); } r.ReadStartElement(); while (r.NodeType == XmlNodeType.Element) { switch (r.Name) { case "Visible": Visible = XmlHelper.ParseBoolean(r.ReadElementContentAsString()); break; case "DrawingStyle": style = new DrawingStyle(r); BindStyle(); break; default: string unparsed = r.ReadOuterXml(); break; } } r.ReadEndElement(); }
public void ReadXml(XmlReader r, PointF scale, TimestampMapper timestampMapper, Metadata metadata) { Clear(); r.ReadStartElement(); while (r.NodeType == XmlNodeType.Element) { switch (r.Name) { case "DrawingStyle": style = new DrawingStyle(r); BindStyle(); break; case "AutoNumber": AbstractMultiDrawingItem item = MultiDrawingItemSerializer.Deserialize(r, scale, timestampMapper, metadata); AutoNumber number = item as AutoNumber; if (number != null) { metadata.AddMultidrawingItem(this, number); } break; default: string unparsed = r.ReadOuterXml(); log.DebugFormat("Unparsed content in KVA XML: {0}", unparsed); break; } } r.ReadEndElement(); }
public DrawingPolyline(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null) { points["0"] = origin; points["1"] = origin; styleHelper.Color = Color.DarkSlateGray; styleHelper.LineSize = 1; if (preset == null) { preset = ToolManager.GetStylePreset("Polyline"); } style = preset.Clone(); BindStyle(); infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame); mnuFinish.Click += mnuFinish_Click; mnuAddThenFinish.Click += mnuAddThenFinish_Click; mnuCloseMenu.Click += mnuCloseMenu_Click; mnuFinish.Image = Properties.Drawings.tick_small; mnuAddThenFinish.Image = Properties.Drawings.plus_small; mnuCloseMenu.Image = Properties.Drawings.cross_small; }
//------------------------------------------------------ // 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(); }
private void BindStyle() { DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("Rectangle")); style.Bind(styleHelper, "Color", "color"); style.Bind(styleHelper, "LineSize", "line size"); style.Bind(styleHelper, "PenShape", "pen shape"); }
public DrawingText(Point p, long _iTimestamp, long _iAverageTimeStampsPerFrame, DrawingStyle _preset) { m_Text = " "; m_Background.Rectangle = new Rectangle(p, Size.Empty); // Decoration & binding with editors m_StyleHelper.Bicolor = new Bicolor(Color.Black); m_StyleHelper.Font = new Font("Arial", m_iDefaultFontSize, FontStyle.Bold); if (_preset != null) { m_Style = _preset.Clone(); BindStyle(); } m_InfosFading = new InfosFading(_iTimestamp, _iAverageTimeStampsPerFrame); m_bEditMode = false; m_TextBox = new TextBox() { Visible = false, BackColor = Color.White, BorderStyle = BorderStyle.None, Multiline = true, Text = m_Text, Font = m_StyleHelper.GetFontDefaultSize(m_iDefaultFontSize) }; m_TextBox.TextChanged += new EventHandler(TextBox_TextChanged); UpdateLabelRectangle(); }
public DrawingPlane(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null) { // Decoration styleHelper.Color = Color.Empty; styleHelper.GridDivisions = 8; styleHelper.Perspective = true; styleHelper.ValueChanged += StyleHelper_ValueChanged; if (preset == null) { preset = ToolManager.GetStylePreset("Plane"); } style = preset.Clone(); BindStyle(); infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame); infosFading.UseDefault = false; infosFading.AlwaysVisible = true; planeWidth = 100; planeHeight = 100; quadPlane = new QuadrilateralF(planeWidth, planeHeight); mnuCalibrate.Click += new EventHandler(mnuCalibrate_Click); mnuCalibrate.Image = Properties.Drawings.linecalibrate; }
public DrawingToolLine2D() { m_DefaultStylePreset.Elements.Add("color", new StyleElementColor(Color.LightGreen)); m_DefaultStylePreset.Elements.Add("line size", new StyleElementLineSize(2)); m_DefaultStylePreset.Elements.Add("arrows", new StyleElementLineEnding(LineEnding.None)); m_StylePreset = m_DefaultStylePreset.Clone(); }
private void BindStyle() { DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("Line")); style.Bind(styleHelper, "Color", "color"); style.Bind(styleHelper, "LineSize", "line size"); style.Bind(styleHelper, "LineShape", "line shape"); style.Bind(styleHelper, "LineEnding", "arrows"); }
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 "PointO": points["o"] = XmlHelper.ParsePointF(xmlReader.ReadElementContentAsString()); break; case "PointA": points["a"] = XmlHelper.ParsePointF(xmlReader.ReadElementContentAsString()); break; case "PointB": points["b"] = XmlHelper.ParsePointF(xmlReader.ReadElementContentAsString()); 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; points["o"] = points["o"].Scale(scale.X, scale.Y); points["a"] = points["a"].Scale(scale.X, scale.Y); points["b"] = points["b"].Scale(scale.X, scale.Y); SignalAllTrackablePointsMoved(); }
public static void SetStylePreset(string tool, DrawingStyle style) { if (string.IsNullOrEmpty(tool) || !Tools.ContainsKey(tool)) { return; } Tools[tool].StylePreset = style; }
public AutoNumberManager(DrawingStyle preset) { styleHelper.Bicolor = new Bicolor(Color.Black); styleHelper.Font = new Font("Arial", defaultFontSize, FontStyle.Bold); if (preset != null) { style = preset.Clone(); BindStyle(); } }
public FormConfigureDrawing2(DrawingStyle _style, Action _invalidate) { m_Style = _style; m_Style.ReadValue(); m_Style.Memorize(); m_Invalidate = _invalidate; InitializeComponent(); LocalizeForm(); SetupForm(); }
/// <summary> /// Make sure that all options from the preset are in the passed style with matching names. /// This is used to import old KVA with missing keys or keys that have since changed name. /// In this case we push the default value of the tool. /// We generally don't try to match the tool variant in these case, the important thing is that the /// style elements are correct so we can at least change them later. /// </summary> public static void SanityCheck(DrawingStyle input, DrawingStyle preset) { foreach (string key in preset.Elements.Keys) { if (!input.Elements.ContainsKey(key)) { input.Elements.Add(key, preset.Elements[key].Clone()); } } }
public DrawingStyle Clone() { DrawingStyle clone = new DrawingStyle(); foreach (KeyValuePair <string, AbstractStyleElement> element in m_StyleElements) { clone.Elements.Add(element.Key, element.Value.Clone()); } return(clone); }