private void PenSizeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { WpfAnnotationUI ann = this.AnnotationViewer.Annotations.ActiveAnnotation; if (ann == null) { return; } if (this.PenSizeSlider.Value == 0) { ann.SetValue(WpfAnnotationUI.OutlineProperty, null); } else { AnnotationPen pen = (AnnotationPen)ann.GetValue(WpfAnnotationUI.OutlineProperty); if (pen == null) { Color clr = Colors.Black; if (this.OutlineComboBox.SelectedIndex > -1) { clr = ((KeyValuePair <string, Color>) this.OutlineComboBox.SelectedItem).Value; } pen = new AnnotationPen(WpfObjectConverter.ConvertColor(clr), (float)this.PenSizeSlider.Value); ann.SetValue(WpfAnnotationUI.OutlineProperty, pen); } else { pen.Width = (float)this.PenSizeSlider.Value; } } }
private void OutlineComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { WpfAnnotationUI ann = this.AnnotationViewer.Annotations.ActiveAnnotation; if (ann == null) { return; } KeyValuePair <string, Color> val = (KeyValuePair <string, Color>) this.OutlineComboBox.SelectedItem; AnnotationPen pen = (AnnotationPen)ann.GetValue(WpfAnnotationUI.OutlineProperty); if (pen == null) { if (this.PenSizeSlider.Value > 0) { pen = new AnnotationPen(WpfObjectConverter.ConvertColor(val.Value), (float)this.PenSizeSlider.Value); ann.SetValue(WpfAnnotationUI.OutlineProperty, pen); } } else { pen.Color = WpfObjectConverter.ConvertColor(val.Value); } }
/// <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 BorderColorToolStripMenuItem_Click(object sender, EventArgs e) { AnnotationPen pen = GetAnnotationPen(annotationViewer.Annotations.ActiveAnnotation, "Outline"); if (pen == null) { return; } Color clr = GetColor(pen.Color); if (clr != Color.Empty) { if (pen.Brush != null && pen.Brush.FillType == FillType.Hatch) { pen.Brush.HatchForeColor = clr; } else { pen.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); }
/// <summary> /// Initializes a new instance of the <see cref="AnnotationDefaults"/> class. /// </summary> public AnnotationDefaults() { _table = new Hashtable { { AnnotationType.Ellipse, new EllipseAnnotation(new AnnotationBrush(Color.Red), new AnnotationPen(Color.Red)) }, { AnnotationType.EmbeddedImage, new EmbeddedImageAnnotation() }, { AnnotationType.Freehand, new FreehandAnnotation(new AnnotationPen(Color.Blue, 4)) }, { AnnotationType.Lines, new LinesAnnotation() }, { AnnotationType.Polygon, new PolygonAnnotation(new AnnotationPen(Color.Black), new AnnotationBrush(Color.Green)) }, { AnnotationType.Rectangle, new RectangleAnnotation(new AnnotationBrush(Color.Orange), new AnnotationPen(Color.Silver)) }, { AnnotationType.ReferencedImage, new ReferencedImageAnnotation() }, { AnnotationType.Text, new TextAnnotation(string.Empty, new AnnotationFont("Arial", 12), new AnnotationBrush(Color.Black), new AnnotationBrush(Color.Gainsboro), new AnnotationPen(Color.Black)) }, { AnnotationType.Redaction, new RectangleAnnotation(new AnnotationBrush(Color.Black), null) } }; // Callout var leader = new AnnotationPen(Color.Black, 2); leader.EndCap = new AnnotationLineCap(AnnotationLineCapStyle.Arrow, new SizeF(15, 15)); _table.Add(AnnotationType.Callout, new CalloutAnnotation(string.Empty, new AnnotationFont("Times New Roman", 12), new AnnotationBrush(Color.Black), 4, new AnnotationBrush(Color.White), new AnnotationPen(Color.Black, 2), leader, 10)); // Line var textOutline = new AnnotationPen(Color.Black); textOutline.EndCap = new AnnotationLineCap(AnnotationLineCapStyle.FilledArrow, new SizeF(15, 15)); _table.Add(AnnotationType.Line, new LineAnnotation(textOutline)); // Rubberstamp var stamp = new RubberStampAnnotation(); stamp.Data.Size = new SizeF(400, 110); stamp.Data.CanMirror = false; stamp.Text = "DRAFT"; _table.Add(AnnotationType.RubberStamp, stamp); // Sticky Note var sticky = new TextAnnotation(string.Empty, new AnnotationFont("Arial", 12), new AnnotationBrush(Color.Black), new AnnotationBrush(SystemColors.Info), new AnnotationPen(Color.Black, 1)); sticky.Data.Size = new SizeF(200, 120); sticky.Shadow = new AnnotationBrush(Color.FromArgb(120, Color.Silver)); sticky.ShadowOffset = new PointF(5, 5); _table.Add(AnnotationType.StickyNote, sticky); // Rectangle Highlighter var rc = new RectangleAnnotation(new AnnotationBrush(Color.Yellow), null); rc.Translucent = true; _table.Add(AnnotationType.RectangleHighlighter, rc); // Freehand Highlighter var fh = new FreehandAnnotation(new AnnotationPen(Color.Yellow, 20)); fh.Translucent = true; fh.LineType = FreehandLineType.Curves; _table.Add(AnnotationType.FreehandHighlighter, fh); }
/// <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; } } }
/// <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; }