Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Generates the drawing of the measurements.
        /// </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 GetMeasurementDrawing(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;

                MeasureAdorner measAdorner = (MeasureAdorner)adornerLayerManager.GetAdorner(AdornerLayerManager.MEASUREMENT_ADORNER);
                foreach (MeasurementLine lineObj in measAdorner.GetMeasurementLines())
                {
                    SolidColorBrush lscb = Brushes.Green;
                    Pen             lp1  = new Pen(lscb, 5d * Ratio);

                    dc.DrawLine(lp1, lineObj.StartPoint, lineObj.EndPoint);

                    float lineLength = (lineObj.Length * measAdorner.SamplingSpace) / 1000;

                    FormattedText formattedText =
                        new FormattedText(lineLength.ToString("F") + "m", CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight,
                                          new Typeface("Veranda"), 32, Brushes.Green);
                    //formattedText.MaxTextWidth = 300;
                    //formattedText.MaxTextHeight = 240;
                    //formattedText.SetFontSize(32 * (96.0 / 72.0));

                    PrintDialog tempPrnDialog = new PrintDialog();

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

                    Point textMidPoint = new Point(lineObj.MidPoint.X - (formattedText.Width / 2), lineObj.MidPoint.Y - (formattedText.Height / 2));

                    Rect LegendRect;
                    LegendRect = new Rect(textMidPoint, new Size(formattedText.Width, formattedText.Height));

                    SolidColorBrush   scb = Brushes.Green;
                    Pen               p1  = new Pen(scb, (5D * Ratio));
                    RectangleGeometry rg  = new RectangleGeometry(LegendRect, 0, 0);
                    dc.DrawGeometry(Brushes.White, null, rg);
                    dc.DrawText(formattedText, textMidPoint);
                }
            }

            return(dw);
        }
Ejemplo n.º 4
0
        public void Measurements_MenuItem_Click(object sender, RoutedEventArgs e)
        {
            UnregisterMouseEvents();

            Measurement_Show_MenuItem_Click(sender, e);
            MeasureAdorner adorner = (MainXRayView.AdornerLayerManager[AdornerLayerManager.MEASUREMENT_ADORNER] as MeasureAdorner);

            adorner.Enabled = true;

            Image image = new Image();

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

            Stream cursorStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("L3.Cargo.Workstation.Plugins.XRayImageBase.Resources.Cursors.ruler.cur");
            Cursor CustomCursor = new System.Windows.Input.Cursor(cursorStream);

            MainXRayView.MainImage.Cursor = CustomCursor;
        }