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); } }
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 TextSize_TextChanged(object sender, TextChangedEventArgs e) { WpfAnnotationUI ann = this.AnnotationViewer.Annotations.ActiveAnnotation; if (ann == null) { return; } string txt = this.textSize.Text; if (txt.Length == 0) { return; } string[] items = txt.Split(','); if (items.Length != 2) { return; } double width = 0; double height = 0; if (double.TryParse(items[0].Trim(), out width) && double.TryParse(items[1].Trim(), out height)) { ann.Size = new Size(width, height); } }
private void TextLocation_TextChanged(object sender, TextChangedEventArgs e) { WpfAnnotationUI ann = this.AnnotationViewer.Annotations.ActiveAnnotation; if (ann == null) { return; } string txt = this.textLocation.Text; if (txt.Length == 0) { return; } string[] items = txt.Split(','); if (items.Length != 2) { return; } double x = 0; double y = 0; if (double.TryParse(items[0].Trim(), out x) && double.TryParse(items[1].Trim(), out y)) { ann.Location = new Point(x, y); } }
/// <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 ShadowCheckBox_Unchecked(object sender, RoutedEventArgs e) { WpfAnnotationUI ann = this.AnnotationViewer.Annotations.ActiveAnnotation; if (ann != null) { ann.SetValue(WpfAnnotationUI.ShadowProperty, null); } }
private void ShadowCheckBox_Checked(object sender, RoutedEventArgs e) { WpfAnnotationUI ann = this.AnnotationViewer.Annotations.ActiveAnnotation; if (ann != null) { ann.SetValue(WpfAnnotationUI.ShadowProperty, new AnnotationBrush(System.Drawing.Color.FromArgb(120, System.Drawing.Color.Silver))); } }
private void OffsetSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { WpfAnnotationUI ann = this.AnnotationViewer.Annotations.ActiveAnnotation; if (ann != null) { ann.SetValue(WpfAnnotationUI.ShadowOffsetProperty, new Point(e.NewValue, e.NewValue)); } }
private void FlipAnnotation(bool horizontal, bool pivot) { WpfAnnotationUI ann = this.AnnotationViewer.Annotations.ActiveAnnotation; if (ann == null) { return; } ann.Mirror((horizontal ? MirrorDirection.Horizontal : MirrorDirection.Vertical), !pivot); }
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); } }