예제 #1
0
        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);
            }
        }
예제 #2
0
        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;
                }
            }
        }
예제 #3
0
        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;
                }
            }
        }
예제 #4
0
        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);
            }
        }