コード例 #1
0
ファイル: XRayView.xaml.cs プロジェクト: marzlia/CXPortal
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            this.Loaded -= new RoutedEventHandler(OnLoaded);

            MeasureAdorner measureAdorner = new MeasureAdorner(MainImage, PanAndZoomControl);

            measureAdorner.SamplingSpace = m_ViewObject.SamplingSpace;
            measureAdorner.SamplingSpeed = m_ViewObject.SamplingSpeed;
            _AdornerLayerManager.Add(AdornerLayerManager.MEASUREMENT_ADORNER, measureAdorner);

            AnnotationAdorner annotationAdorner = new AnnotationAdorner(MainImage, PanAndZoomControl);

            _AdornerLayerManager.Add(AdornerLayerManager.ANNOTATION_ADORNER, annotationAdorner);

            if (m_ViewObject.Annotations != null && m_ViewObject.Annotations.Count > 0)
            {
                var annotAdorner = (_AdornerLayerManager.GetAdorner(AdornerLayerManager.ANNOTATION_ADORNER) as AnnotationAdorner);
                annotAdorner.SetCanCreateAnnotation(CanCreateNewAnnot);
                if (annotAdorner != null)
                {
                    foreach (AnnotationInfo info in m_ViewObject.Annotations)
                    {
                        annotAdorner.AddAnnotationInfo(info, true);
                    }
                }
            }
            _AdornerLayerManager.Hide(AdornerLayerManager.ANNOTATION_ADORNER);
            _AdornerLayerManager.Show(AdornerLayerManager.ANNOTATION_ADORNER);

            AOIAdorner aoiAdorner = new AOIAdorner(MainImage, PanAndZoomControl);

            aoiAdorner.AlgServerRequestEvent += new AlgServerRequestEventHandler(AoiAdorner_AlgServerRequestEvent);
            _AdornerLayerManager.Add(AdornerLayerManager.AOI_ADORNER, aoiAdorner);
        }
コード例 #2
0
        private void UnregisterMouseEvents()
        {
            PanZoom_MenuItem.Icon      = null;
            Annotation_MenuItem.Icon   = null;
            Measurements_MenuItem.Icon = null;
            Magnifier_MenuItem.Icon    = null;
            AOI_MenuItem.Icon          = null;

            MainXRayView.PanAndZoomControl.MouseEventsEnabled = false;

            AnnotationAdorner annotationAdorner = (MainXRayView.AdornerLayerManager[AdornerLayerManager.ANNOTATION_ADORNER] as AnnotationAdorner);

            annotationAdorner.Enabled = false;

            MeasureAdorner measureAdorner = (MainXRayView.AdornerLayerManager[AdornerLayerManager.MEASUREMENT_ADORNER] as MeasureAdorner);

            measureAdorner.Enabled = false;

            AOIAdorner aoiAdorner = (MainXRayView.AdornerLayerManager[AdornerLayerManager.AOI_ADORNER] as AOIAdorner);

            aoiAdorner.Enabled = false;

            //MainXRayView.adonerImageObject.AOIButton_Clicked(m_ViewObject, false);

            MainXRayView.Magnifier_Panel.Effect   = null;
            m_MagnifierSettings.IsMagniferEnabled = false;
            MainXRayView.MainImage.Cursor         = Cursors.Arrow;

            Annotation_Rectangle.Visibility   = Visibility.Collapsed;
            Annotation_Ellipse.Visibility     = Visibility.Collapsed;
            PanAndZoom_Normal.Visibility      = System.Windows.Visibility.Collapsed;
            PanAndZoom_FitToScreen.Visibility = System.Windows.Visibility.Collapsed;
            Options_Menu_Seperator.Visibility = Visibility.Collapsed;
        }
コード例 #3
0
        public void Annotation_MenuItem_Click(object sender, RoutedEventArgs e)
        {
            UnregisterMouseEvents();

            Annotation_Show_MenuItem_Click(sender, e);
            AnnotationAdorner annotationAdorner = (MainXRayView.AdornerLayerManager[AdornerLayerManager.ANNOTATION_ADORNER] as AnnotationAdorner);

            annotationAdorner.Enabled = true;

            Annotation_Rectangle.Visibility   = Visibility.Visible;
            Annotation_Ellipse.Visibility     = Visibility.Visible;
            Options_Menu_Seperator.Visibility = Visibility.Visible;
            Image image = new Image();

            image.Source             = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/checkmark.gif", UriKind.Relative));
            Annotation_MenuItem.Icon = image;

            MainXRayView.MainImage.Cursor = Cursors.Pen;
        }
コード例 #4
0
 public abstract void Hide(AnnotationAdorner adorner);
コード例 #5
0
 public abstract void Show(AnnotationAdorner adorner);
コード例 #6
0
ファイル: XRayImageRenderer.cs プロジェクト: marzlia/CXPortal
        /// <summary>
        /// Generates the drawing of the annotations.
        /// </summary>
        /// <param name="sourceWidth">The width of the source image.</param>
        /// <param name="sourceHeight">The height of the source image.</param>
        /// <param name="displayWidth">The width of the container to put the bitmap. Scales the size of the drawings.</param>
        /// <param name="displayHeight">The height of the container to put the bitmap. Scales the size of the drawings.</param>
        /// <param name="adornerLayerManager">The adorner information object.</param>
        /// <param name="background">The background to create the drawing on.</param>
        public static DrawingVisual GetAnnotationDrawing(double sourceWidth, double sourceHeight, double displayWidth, double displayHeight, AdornerLayerManager adornerLayerManager, Brush background)
        {
            DrawingVisual dw = new DrawingVisual();

            using (DrawingContext dc = dw.RenderOpen())
            {
                Size  sz = new Size((int)sourceWidth, (int)sourceHeight);
                Pen   p  = new Pen();
                Point pt = new Point(1, 1);
                dc.DrawRectangle(background, p, new System.Windows.Rect(pt, sz));

                double widthRatio  = sourceWidth / displayWidth;
                double heightRatio = sourceHeight / displayHeight;
                double Ratio       = (widthRatio < heightRatio) ? widthRatio : heightRatio;

                char[] letters = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };

                int count = 0;

                AnnotationAdorner annotAdorner = (AnnotationAdorner)adornerLayerManager.GetAdorner(AdornerLayerManager.ANNOTATION_ADORNER);
                foreach (Annotation annotation in annotAdorner.GetAnnotations())
                {
                    Rect rect = annotation.Marking.Rect;

                    RectangleGeometry rg = new RectangleGeometry(rect, annotation.Marking.RadiusX, annotation.Marking.RadiusY);
                    //rg.
                    SolidColorBrush scb = Brushes.Green;
                    Pen             p1  = new Pen(scb, (5D * Ratio));
                    dc.DrawGeometry(null, p1, rg);

                    string index = string.Empty;

                    int div = (count / 26) - 1;
                    int rem = count % 26;

                    if (div >= 0)
                    {
                        index += letters[div];
                    }

                    index += letters[rem];

                    FormattedText formattedText =
                        new FormattedText(index, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight,
                                          new Typeface("Aharoni"), 32, Brushes.Green);
                    //formattedText.MaxTextWidth = 300;
                    //formattedText.SetFontSize(32 * (96.0 / 72.0));

                    PrintDialog tempPrnDialog = new PrintDialog();

                    if (sourceWidth > sourceHeight)
                    {
                        formattedText.SetFontSize((sourceWidth / tempPrnDialog.PrintableAreaWidth) * 11);
                    }
                    else
                    {
                        formattedText.SetFontSize((sourceHeight / tempPrnDialog.PrintableAreaHeight) * 13);
                    }

                    Rect LegendRect;

                    if (annotation.Marking.RadiusX > 0)
                    {
                        LegendRect = new Rect(annotation.Marking.Rect.TopLeft.X + (annotation.Marking.Rect.Width / 2) - ((formattedText.WidthIncludingTrailingWhitespace + 10) / 2),
                                              annotation.Marking.Rect.TopLeft.Y - formattedText.Height - 5, formattedText.WidthIncludingTrailingWhitespace + 12, formattedText.Height + 5);
                    }
                    else
                    {
                        LegendRect = new Rect(annotation.Marking.Rect.TopLeft.X, annotation.Marking.Rect.TopLeft.Y - formattedText.Height - 5, formattedText.WidthIncludingTrailingWhitespace + 12, formattedText.Height + 5);
                    }

                    rg = new RectangleGeometry(LegendRect, 0, 0);
                    dc.DrawGeometry(Brushes.LightYellow, p1, rg);

                    dc.DrawText(formattedText, new Point(LegendRect.TopLeft.X + 5, LegendRect.TopLeft.Y + 5));

                    count++;
                }
            }

            return(dw);
        }
コード例 #7
0
 public abstract void Hide(AnnotationAdorner adorner);
コード例 #8
0
 public abstract void Show(AnnotationAdorner adorner);