/// <summary> /// Initializes a new instance of the <see cref="TriangleAnnotation"/> class. /// </summary> /// <param name="points">The triangle points.</param> /// <param name="fill">The annotation fill.</param> /// <param name="outline">The annotation outline.</param> public TriangleAnnotation(Point[] points, AnnotationBrush fill, AnnotationPen outline) : base(3, points) { // WpfAnnotationUI already has dependency properties for fill and outline. this.SetValue(FillProperty, fill); this.SetValue(OutlineProperty, outline); }
private void TextColorToolStripMenuItem_Click(object sender, EventArgs e) { AnnotationBrush brush = GetAnnotationBrush(annotationViewer.Annotations.ActiveAnnotation, "FontBrush"); if (brush == null) { return; } Color clr = GetColor(brush.Color); if (clr != Color.Empty) { if (brush.FillType == FillType.Hatch) { brush.HatchForeColor = clr; } else { brush.Color = clr; } } UpdateAnnotationDefault(annotationViewer.Annotations.ActiveAnnotation); }
/// <summary> /// Derived classes must override this method and return a copy of itself. /// </summary> /// <param name="clone">The new clone to add additional properties values.</param> /// <returns> /// A copy of the annotation. /// </returns> /// <remarks> /// This method is called from Clone to allow additional properties to be set. The WpfAnnotationUI properties of the clone will be filled before this method is called. /// </remarks> protected override WpfAnnotationUI CloneOverride(WpfAnnotationUI clone) { TriangleAnnotation ann = clone as TriangleAnnotation; if (ann == null) { return(null); } AnnotationBrush fill = this.Fill; ann.Fill = fill == null ? null : fill.Clone(); AnnotationPen outline = this.Outline; ann.Outline = outline == null ? null : outline.Clone(); if (this.Points.Count > 0) { ann.Points.AddRange(this.Points.ToArray()); } ann.GripMode = this.GripMode; return(ann); }
private void FillColorToolStripMenuItem_Click(object sender, EventArgs e) { AnnotationBrush brush = GetAnnotationBrush(annotationViewer.Annotations.ActiveAnnotation, "Fill"); if (brush == null) { return; } Color clr = GetColor(brush.Color); if (clr != Color.Empty) { brush.Color = clr; } UpdateAnnotationDefault(annotationViewer.Annotations.ActiveAnnotation); }
/// <summary> /// This method is used to serialize the annotation. /// </summary> /// <returns> /// An AnnotationData object with the current annotation settings. /// </returns> /// <remarks>This is used when serializing the annotation to XMP.</remarks> protected override AnnotationData CreateDataSnapshotOverride() { Point[] points = this.Points.ToArray(); AnnotationBrush fill = this.Fill; AnnotationPen outline = this.Outline; if (fill != null) { fill = fill.Clone(); } if (outline != null) { outline = outline.Clone(); } return(new TriangleData(points, fill, outline)); }
private void Annotations_SelectedAnnotationsChanged(object sender, EventArgs e) { this.statusInfo.Content = "Selection Changed: {Count=" + this.AnnotationViewer.Annotations.SelectedAnnotations.Count.ToString() + "}"; // Update the property fields. WpfAnnotationUI ann = this.AnnotationViewer.Annotations.ActiveAnnotation; bool enabled = ann != null; this.textLocation.IsEnabled = enabled; this.textSize.IsEnabled = enabled; this.FillComboBox.IsEnabled = enabled; this.OutlineComboBox.IsEnabled = enabled; this.PenSizeSlider.IsEnabled = enabled; this.ShadowCheckBox.IsEnabled = enabled; this.OffsetSlider.IsEnabled = enabled; if (enabled) { this.textLocation.Text = ann.Location.X.ToString() + ", " + ann.Location.Y.ToString(); this.textSize.Text = ann.Size.Width.ToString() + ", " + ann.Size.Height.ToString(); AnnotationBrush b = (AnnotationBrush)ann.GetValue(WpfAnnotationUI.FillProperty); if (b != null) { SelectAddComboBoxItem(this.FillComboBox, WpfObjectConverter.ConvertColor(b.Color)); } AnnotationPen p = (AnnotationPen)ann.GetValue(WpfAnnotationUI.OutlineProperty); if (p != null) { SelectAddComboBoxItem(this.OutlineComboBox, WpfObjectConverter.ConvertColor(p.Color)); this.PenSizeSlider.Value = p.Width; } b = (AnnotationBrush)ann.GetValue(WpfAnnotationUI.ShadowProperty); this.ShadowCheckBox.IsChecked = b != null; if (b != null) { Point pt = (Point)ann.GetValue(WpfAnnotationUI.ShadowOffsetProperty); this.OffsetSlider.Value = pt.X; } } }
private void FillComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { WpfAnnotationUI ann = this.AnnotationViewer.Annotations.ActiveAnnotation; if (ann == null) { return; } KeyValuePair <string, Color> val = (KeyValuePair <string, Color>) this.FillComboBox.SelectedItem; AnnotationBrush brush = (AnnotationBrush)ann.GetValue(WpfAnnotationUI.FillProperty); if (brush == null) { brush = new AnnotationBrush(WpfObjectConverter.ConvertColor(val.Value)); ann.SetValue(WpfAnnotationUI.FillProperty, brush); } else { brush.Color = WpfObjectConverter.ConvertColor(val.Value); } }
/// <summary> /// Initializes a new instance of the <see cref="TriangleData"/> class. /// </summary> /// <param name="info">The information.</param> /// <param name="context">The context.</param> public TriangleData(SerializationInfo info, StreamingContext context) : base(info, context) { _fill = (AnnotationBrush)info.GetValue("Fill", typeof(AnnotationBrush)); _outline = (AnnotationPen)info.GetValue("Outline", typeof(AnnotationPen)); }
/// <summary> /// Initializes a new instance of the <see cref="TriangleData"/> class. /// </summary> /// <param name="points">The triangle points.</param> /// <param name="fill">The annotation fill.</param> /// <param name="outline">The annotation outline.</param> public TriangleData(Point[] points, AnnotationBrush fill, AnnotationPen outline) : base(new PointFCollection(WpfObjectConverter.ConvertPointF(points))) { _fill = fill; _outline = outline; }