Exemple #1
0
        private BitmapSource ExtractAnnotationIcon(AnnotateIcon icon, AnnotateIconSize size)
        {
            BitmapSource returnSource = WpfObjectConverter.ConvertBitmap((Bitmap)IconResource.ExtractAnnotationIcon(icon, size));

            if (returnSource == null)
            {
                Assembly assm = Assembly.LoadFrom(@"Atalasoft.dotImage.dll");
                if (assm != null)
                {
                    Stream stream = assm.GetManifestResourceStream("Atalasoft.Imaging.Annotate.Icons._" + size.ToString().Substring(4) + "." + icon.ToString() + ".png");
                    returnSource = WpfObjectConverter.ConvertBitmap((Bitmap)System.Drawing.Image.FromStream(stream));
                }

                // if it's STILL null, then give up and make placeholders
                if (returnSource == null)
                {
                    switch (size.ToString())
                    {
                    case "size16":
                        returnSource = WpfObjectConverter.ConvertBitmap(new AtalaImage(16, 16, PixelFormat.Pixel24bppBgr, System.Drawing.Color.White).ToBitmap());
                        break;

                    case "size24":
                        returnSource = WpfObjectConverter.ConvertBitmap(new AtalaImage(24, 24, PixelFormat.Pixel24bppBgr, System.Drawing.Color.White).ToBitmap());
                        break;

                    case "size32":
                        returnSource = WpfObjectConverter.ConvertBitmap(new AtalaImage(32, 32, PixelFormat.Pixel24bppBgr, System.Drawing.Color.White).ToBitmap());
                        break;
                    }
                }
            }

            return(returnSource);
        }
Exemple #2
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);
            }
        }
Exemple #3
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;
                }
            }
        }
Exemple #4
0
            /// <summary>
            /// Called when rendering annotation.
            /// </summary>
            /// <param name="annotation">The annotation.</param>
            /// <param name="environment">The environment.</param>
            protected override void OnRenderAnnotation(TriangleAnnotation annotation, WpfRenderEnvironment environment)
            {
                Pen   pen   = WpfObjectConverter.ConvertAnnotationPen(annotation.Outline);
                Brush brush = WpfObjectConverter.ConvertAnnotationBrush(annotation.Fill);

                environment.DrawingContext.DrawGeometry(brush, pen, annotation.Geometry);
            }
Exemple #5
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;
                }
            }
        }
Exemple #6
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);
            }
        }
 /// <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;
 }