Exemplo n.º 1
0
        public static void GetSlideScanInfo(MultiScaleImage mSlide, StackPanel sDefaultScanInfo, Grid gScanInfo)
        {
            if (mSlide.Source == null)
            {
                sDefaultScanInfo.Visibility = Visibility.Visible;
                gScanInfo.Visibility        = Visibility.Collapsed;
                return;
            }
            sDefaultScanInfo.Visibility = Visibility.Collapsed;
            gScanInfo.Visibility        = Visibility.Visible;
            string       slideScanInfo = mSlide.Source.sbcCurrentSlide.GetSlideScanInfo();
            List <Label> list          = new List <Label>();

            foreach (Label child in gScanInfo.Children)
            {
                if (Grid.GetColumn(child) == 1)
                {
                    list.Add(child);
                }
            }
            string[] array = slideScanInfo.Split(new string[1]
            {
                "|"
            }, StringSplitOptions.None);
            for (int i = 0; i < array.Length; i++)
            {
                list[i].Content = array[i];
            }
            list.Clear();
            array = null;
        }
Exemplo n.º 2
0
 public myPolyline(AnnoListControl alc, Canvas canvasboard, MultiScaleImage msi, List <AnnotationBase> objectlist, int SlideZoom, double Calibration)
 {
     SetPara(alc, canvasboard, msi, objectlist, SlideZoom, Calibration);
     msi.MouseLeftButtonDown += MouseDown;
     base.AnnotationType      = AnnotationType.Polygon;
     base.ControlName         = base.AnnotationType + DateTime.Now.ToString("yyyyMMddHHmmss");
 }
Exemplo n.º 3
0
 public myTmaRectangle(AnnoListControl alc, Canvas canvasboard, MultiScaleImage msi, List <AnnotationBase> objectlist, int SlideZoom, double Calibration, List <myTmaRectangle> tmpobj)
 {
     m_tmpobj = tmpobj;
     SetPara(alc, canvasboard, msi, objectlist, SlideZoom, Calibration);
     base.AnnotationType = AnnotationType.TmaRectangle;
     base.ControlName    = base.AnnotationType + DateTime.Now.ToString("yyyyMMddHHmmss");
 }
Exemplo n.º 4
0
        public static void RotateSlide(Grid gSlideBox, int iTargetActualAngle)
        {
            MultiScaleImage multiScaleImage = gSlideBox.FindName("mMultiScaleImage") as MultiScaleImage;
            RotateTransform renderTransform = new RotateTransform(iTargetActualAngle);
            int             acuteAngle      = PublicMethods.GetAcuteAngle(iTargetActualAngle);
            float           num             = (float)Math.Sin(Math.PI / 180.0 * (double)acuteAngle);
            float           num2            = (float)Math.Cos(Math.PI / 180.0 * (double)acuteAngle);
            float           num3            = (0f - (float)(multiScaleImage.ActualWidth - gSlideBox.ActualWidth)) / 2f;
            float           num4            = (0f - (float)(multiScaleImage.ActualHeight - gSlideBox.ActualHeight)) / 2f;

            multiScaleImage.RenderTransformOrigin = new Point(0.5, 0.5);
            multiScaleImage.RenderTransform       = renderTransform;
            float num5  = (float)gSlideBox.ActualWidth;
            float num6  = (float)gSlideBox.ActualHeight;
            float num7  = num5 * num2 + num6 * num;
            float num8  = num5 * num + num6 * num2;
            float num9  = (0f - (num7 - num5)) / 2f;
            float num10 = (0f - (num8 - num6)) / 2f;

            multiScaleImage.Margin = new Thickness(num9, num10, num9, num10);
            Point pDeltaOffset = default(Point);

            if (multiScaleImage.Source != null)
            {
                pDeltaOffset.X = 0f - num3 + num9;
                pDeltaOffset.Y = 0f - num4 + num10;
                multiScaleImage.DeltaToPan(pDeltaOffset, false, 2);
            }
        }
        /// <summary>
        ///Constructor
        /// </summary>
        public HotspotIconControl(Canvas parent, ScatterView parentScatterView,Hotspot hotspotData, MultiScaleImage msi )
        {
            InitializeComponent();
            m_hotspotData = hotspotData;
            m_parent = parent;
            _msi = msi;
            m_parentScatterView = parentScatterView;
            m_detailControl = new HotspotDetailsControl(m_parent, m_parentScatterView, m_hotspotData, msi);

            try
            {
                String imgUri = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) +  "\\Data\\Hotspots\\Icons\\normal.png";
                normal = new BitmapImage();
                normal.BeginInit();
                normal.UriSource = new Uri(imgUri, UriKind.Relative);
                normal.CacheOption = BitmapCacheOption.OnLoad;
                normal.EndInit();

                highlighted = new BitmapImage();
                imgUri = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Data\\Hotspots\\Icons\\highlighted.png";
                highlighted.BeginInit();
                highlighted.UriSource = new Uri(imgUri, UriKind.Relative);
                highlighted.CacheOption = BitmapCacheOption.OnLoad;
                highlighted.EndInit();

                WriteableBitmap wbmap = new WriteableBitmap(normal);

            }
            catch (Exception e)
            {

            }
        }
Exemplo n.º 6
0
 public myPin(AnnoListControl alc, Canvas canvasboard, MultiScaleImage msi, int SlideZoom, List <AnnotationBase> objectlist)
 {
     SetPara(alc, canvasboard, msi, objectlist, SlideZoom, base.Calibration);
     msi.MouseLeftButtonDown += Pinline_handle_MouseDown;
     base.AnnotationType      = AnnotationType.Remark;
     base.ControlName         = base.AnnotationType + DateTime.Now.ToString("yyyyMMddHHmmss");
 }
Exemplo n.º 7
0
        /// <summary>
        /// 初始化控件
        /// </summary>
        private void InitMultiScaleImage()
        {
            this.msi = new MultiScaleImage();
            //string imgDir = @"D:\MyTestCode\wpf_deepzoom_demo\MyDeepZoomTest\MyDeepZoomTest\Doc\Sample\9_files\";
            //this.msi.Source = new MyMultiScaleTileSource(65792, 63488, 256, 0, imgDir); // 9层图
            //this.msi.Source = new MyMultiScaleTileSource(33024, 31744, 256, 0, imgDir); // 8层图
            //this.msi.Source = new MyMultiScaleTileSource(16640, 15872, 256, 0, imgDir); // 7层图
            //this.msi.Source = new MyMultiScaleTileSource(8448, 7936, 256, 0, imgDir); // 6层图
            //this.msi.Source = new MyMultiScaleTileSource(4352, 4096, 256, 0, imgDir); // 5层图
            //this.msi.Source = new MyMultiScaleTileSource(2304, 2048, 256, 0, imgDir); // 4层图
            //this.msi.Source = new MyMultiScaleTileSource(1280, 1024, 256, 0, imgDir); // 3层图
            //this.msi.Source = new MyMultiScaleTileSource(768, 512, 256, 0, imgDir); // 2层图

            string datPath = @"D:\WSITestData\DatImages\411681C03200807006.dat";

            this.msi.Source = new DatMultiScaleTileSource(65792, 63488, 256, 0, datPath);

            this.Bg.Children.Add(this.msi);

            this.msi.MouseLeftButtonDown += Msi_MouseLeftButtonDown;
            this.msi.MouseMove           += Msi_MouseMove;
            this.msi.MouseLeftButtonUp   += Msi_MouseLeftButtonUp;
            this.msi.MouseWheel          += Msi_MouseWheel;
            ZoomableCanvas.Refresh       += ZoomableCanvas_Refresh;
        }
Exemplo n.º 8
0
 public myRectZoom(AnnoListControl alc, Canvas canvasboard, MultiScaleImage msi, List <AnnotationBase> objectlist, int SlideZoom, double Calibration)
 {
     SetPara(alc, canvasboard, msi, objectlist, SlideZoom, Calibration);
     msi.MouseRightButtonDown += MouseDown;
     base.ControlName          = "Myrectzoom" + DateTime.Now.ToString("yyyyMMddHHmmss");
     Rotate = Rotate;
 }
Exemplo n.º 9
0
 public static void CameraOptionsChanged(MultiScaleImage mSlide, Image imgPreview, Border bNavigation, Image imgDragTool, Image imgLabel, Polyline pShowMarksChecked, Polyline pShowRulerChecked, Polyline pShowNavigationChecked, Polyline pShowSlideLabelChecked, float fScreenRatio, ResourceDictionary rdDirectory)
 {
     if (mSlide.Source != null)
     {
         Grid gSlideBox = (mSlide.Parent as Grid).Parent as Grid;
         imgPreview.Source = GetPreviewPicture(gSlideBox, bNavigation, imgDragTool, imgLabel, pShowMarksChecked, pShowRulerChecked, pShowNavigationChecked, pShowSlideLabelChecked, fScreenRatio, rdDirectory);
     }
 }
Exemplo n.º 10
0
 public void XmlSetPara(AnnoListControl alc, Canvas canvasboard, MultiScaleImage msi, List <AnnotationBase> objectlist, int SlideZoom, double Calibration)
 {
     M_FiguresCanvas  = canvasboard;
     this.msi         = msi;
     this.objectlist  = objectlist;
     AnnoControl      = alc;
     this.SlideZoom   = SlideZoom;
     this.Calibration = Calibration;
 }
Exemplo n.º 11
0
        public static void CreateSingleSlideViewRect(Grid gSlideBox, Border bViewInfoBorder, Grid gViewInfo)
        {
            Dictionary <string, string> dictionary      = new Dictionary <string, string>();
            MultiScaleImage             multiScaleImage = gSlideBox.FindName("mMultiScaleImage") as MultiScaleImage;
            Border         obj            = gSlideBox.FindName("bGridBox") as Border;
            ZoomableCanvas zoomableCanvas = gSlideBox.FindName("zcGrid") as ZoomableCanvas;

            obj.Visibility = Visibility.Visible;
            System.Windows.Size imageSize = multiScaleImage.Source.ImageSize;
            zoomableCanvas.Width  = imageSize.Width;
            zoomableCanvas.Height = imageSize.Height;
            dictionary            = multiScaleImage.Source.sbcCurrentSlide.GetAllViewInfo();
            System.Drawing.Size viewSize = multiScaleImage.Source.sbcCurrentSlide.GetViewSize();
            string[]            array    = new string[7];
            foreach (string value in dictionary.Values)
            {
                array = value.Split(new string[1]
                {
                    "|"
                }, StringSplitOptions.RemoveEmptyEntries);
                System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
                ViewRectInfo viewRectInfo = new ViewRectInfo();
                viewRectInfo.fXMotorPos = float.Parse(array[3]);
                viewRectInfo.fYMotorPos = float.Parse(array[4]);
                viewRectInfo.fZMotorPos = float.Parse(array[5]);
                if (float.Parse(array[6]) == 1f)
                {
                    viewRectInfo.strAutoFocus = GlobalVariable.listCurrentLanguage[116];
                    rectangle.Stroke          = new SolidColorBrush(System.Windows.Media.Color.FromRgb(byte.MaxValue, 0, 0));
                    rectangle.SetValue(Panel.ZIndexProperty, 2);
                }
                else
                {
                    viewRectInfo.strAutoFocus = GlobalVariable.listCurrentLanguage[117];
                    rectangle.Stroke          = new SolidColorBrush(System.Windows.Media.Color.FromRgb(57, 176, 181));
                }
                rectangle.DataContext = viewRectInfo;
                System.Windows.Point pPixelPoint = new System.Windows.Point(float.Parse(array[1]), float.Parse(array[2]));
                System.Windows.Point point       = multiScaleImage.ScanPixelToSlideRatio(pPixelPoint);
                rectangle.HorizontalAlignment = HorizontalAlignment.Left;
                rectangle.VerticalAlignment   = VerticalAlignment.Top;
                rectangle.StrokeThickness     = 1.0;
                rectangle.Width      = (float)viewSize.Width;
                rectangle.Height     = (float)viewSize.Height;
                rectangle.Margin     = new Thickness(point.X * imageSize.Width, point.Y * imageSize.Height, 0.0, 0.0);
                rectangle.Fill       = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, byte.MaxValue, byte.MaxValue, byte.MaxValue));
                rectangle.MouseMove += delegate(object sender, MouseEventArgs e)
                {
                    if (bViewInfoBorder.Visibility != Visibility.Collapsed)
                    {
                        ViewRectInfo dataContext = (sender as System.Windows.Shapes.Rectangle).DataContext as ViewRectInfo;
                        gViewInfo.DataContext = dataContext;
                    }
                };
                zoomableCanvas.Children.Add(rectangle);
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Gets the parts from the template.
 /// </summary>
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     this.multiScaleImage = this.GetTemplateChild(DeepZoomViewer.ElementMultiScaleImage) as MultiScaleImage;
     if (this.multiScaleImage != null)
     {
         this.multiScaleImage.ImageOpenSucceeded += new RoutedEventHandler(this.MultiScaleImage_ImageOpenSucceeded);
         this.multiScaleImage.ImageOpenFailed    += new EventHandler <ExceptionRoutedEventArgs>(this.MultiScaleImage_ImageOpenFailed);
     }
 }
Exemplo n.º 13
0
 public MagicZoomTileSource1(int imageWidth, int imageHeight, int tileWidth, int overlap, IMAGE_INFO_STRUCT infoStruct, float zoom, MultiScaleImage msi)
     : base(imageWidth, imageHeight, tileWidth, overlap)
 {
     InfoStruct = infoStruct;
     width      = imageWidth;
     height     = imageHeight;
     Xzoom      = zoom;
     TileWidth  = tileWidth;
     Msi        = msi;
 }
Exemplo n.º 14
0
        public void UseSpringsNoAnimations()
        {
            MultiScaleImage msi = new MultiScaleImage();

            msi.UseSprings    = false;
            msi.ViewportWidth = 2.0;
            Assert.AreEqual(2.0, msi.ViewportWidth, "OriginalWidth");
            msi.ViewportWidth = .2;
            Assert.AreEqual(.2, msi.ViewportWidth, "FinalWidth");
        }
Exemplo n.º 15
0
        public static void ResetNavigatorSizeAndSource(MultiScaleImage mCurrentMultiScaleImage, MultiScaleImage mNavigationImage, ref float fNavigatorWidth, ref float fNavigatorHeight, float fScreenRatio)
        {
            Grid   grid   = mNavigationImage.Parent as Grid;
            Border border = (grid.Parent as Grid).Parent as Border;

            if (mCurrentMultiScaleImage.Source == null)
            {
                border.Visibility = Visibility.Hidden;
                return;
            }
            Size imageSize = mCurrentMultiScaleImage.Source.ImageSize;

            fNavigatorWidth  = (float)imageSize.Width / 256f;
            fNavigatorHeight = (float)imageSize.Height / 256f;
            float num = fNavigatorHeight / fNavigatorWidth;

            if (fNavigatorWidth < 220f || fNavigatorHeight < 220f)
            {
                if (num > 1f)
                {
                    fNavigatorWidth  = 220f;
                    fNavigatorHeight = 220f * num;
                }
                else
                {
                    fNavigatorHeight = 220f;
                    fNavigatorWidth  = 220f / num;
                }
            }
            if (fNavigatorWidth > 300f || fNavigatorHeight > 300f)
            {
                if (num > 1f)
                {
                    fNavigatorWidth  = 300f / num;
                    fNavigatorHeight = 300f;
                }
                else
                {
                    fNavigatorHeight = 300f * num;
                    fNavigatorWidth  = 300f;
                }
            }
            fNavigatorWidth  /= fScreenRatio;
            fNavigatorHeight /= fScreenRatio;
            border.Width      = fNavigatorWidth + 4f;
            border.Height     = fNavigatorHeight + 4f;
            grid.Width        = fNavigatorWidth;
            grid.Height       = fNavigatorHeight;
            grid.UpdateLayout();
            if (mNavigationImage.Source != mCurrentMultiScaleImage.Source)
            {
                mNavigationImage.Source = mCurrentMultiScaleImage.Source;
            }
            border.Visibility = Visibility.Visible;
        }
Exemplo n.º 16
0
        public void ChangeUseSprings()
        {
            MultiScaleImage msi = new MultiScaleImage();

            msi.UseSprings    = false;
            msi.ViewportWidth = 3.0;
            Assert.AreEqual(3.0, msi.ViewportWidth, "OriginalWidth");

            msi.UseSprings    = true;
            msi.ViewportWidth = .3;
            Assert.AreEqual(.3, msi.ViewportWidth, "FinalWidth");
        }
Exemplo n.º 17
0
        public static void UpdateMagnifierMark(MultiScaleImage mSlide, Grid gMagnifierFlipBox)
        {
            MultiScaleImage multiScaleImage = gMagnifierFlipBox.FindName("mMagnifier") as MultiScaleImage;
            Grid            grid            = gMagnifierFlipBox.FindName("gMagnifierMarkBox") as Grid;

            if (mSlide.Source == multiScaleImage.Source)
            {
                Grid grid2 = PublicMethods.FindSlideBox(mSlide).FindName("gMarkBox") as Grid;
                for (int i = 0; i < grid2.Children.Count; i++)
                {
                    grid.Children[i].Visibility = grid2.Children[i].Visibility;
                }
            }
        }
Exemplo n.º 18
0
        public MainPage(string encodedVideo)
        {
            InitializeComponent();

            byte[] videoDescriptor = Convert.FromBase64String(encodedVideo);
            string xml             = Encoding.UTF8.GetString(videoDescriptor, 0, videoDescriptor.Length);

            XmlSerializer serializer = new XmlSerializer(typeof(TimelapseVideo));

            using (StringReader reader = new StringReader(xml))
            {
                this.Video = (TimelapseVideo)serializer.Deserialize(reader);
            }

            this.ImageFrames = new List <MultiScaleImage>(10)
            {
                null, null, null, null, null, null, null, null, null, null
            };
            for (var i = 9; i >= 0; i--)
            {
                MultiScaleImage image = new MultiScaleImage();
                image.Width   = 800;
                image.Height  = 600;
                image.Source  = new DeepZoomImageTileSource(new Uri(this.Video.Frames.ElementAt <TimelapseFrame>(i).Url, UriKind.Absolute));
                image.Opacity = 0;

                if (i == 0)
                {
                    image.ImageOpenSucceeded += ImageOpened;
                }

                this.ImageFrames.Insert(i, image);
                ImageCanvas.Children.Add(image);
            }
            this.ImageFrames.ElementAt(0).Opacity = 1;


            /*
             * ThreadStart loader = delegate()
             * {
             *  foreach (TimelapseFrame frame in this.Video.Frames)
             *  {
             *      Dispatcher.BeginInvoke(new Action(() => this.Image.Source = new DeepZoomImageTileSource(new Uri(frame.Url, UriKind.Absolute))));
             *      Thread.Sleep(1000);
             *  }
             * };
             *
             * new Thread(loader).Start(); */
        }
Exemplo n.º 19
0
        public static void MagnifierZoomAboutPoint(Grid gMagnifierFlipBox, MultiScaleImage mSlide, Border bMagnifierBorder, Point pSlideBoxPixelPoint, float fScreenRatio)
        {
            MultiScaleImage multiScaleImage = gMagnifierFlipBox.FindName("mMagnifier") as MultiScaleImage;

            gMagnifierFlipBox.FindName("gMagnifierMarkBox");
            if (mSlide.Source == null)
            {
                multiScaleImage.Visibility = Visibility.Collapsed;
                return;
            }
            multiScaleImage.Visibility = Visibility.Visible;
            if (multiScaleImage.Source != mSlide.Source)
            {
                multiScaleImage.Source = mSlide.Source;
                GetMagnifierMark(mSlide, gMagnifierFlipBox, fScreenRatio);
            }
            float num = mSlide.fTargetScale * 2f;

            if (multiScaleImage.OriginalScale != (double)num)
            {
                float num2 = float.Parse(multiScaleImage.DataContext.ToString()) * num;
                multiScaleImage.minScaleRelativeToMinSize = 1.0;
                multiScaleImage.OriginalScale             = num;
                multiScaleImage.MaxScaleRelativeToMaxSize = 4f * num;
                float currentScale = multiScaleImage.GetCurrentScale();
                multiScaleImage.ScaleCanvas(num2 / currentScale, new Point(bMagnifierBorder.Width / 2.0, bMagnifierBorder.Height / 2.0));
            }
            Point slideBoxFlipValue = PublicMethods.GetSlideBoxFlipValue(PublicMethods.FindSlideBox(mSlide));

            if (PublicMethods.GetElementFlipValue(gMagnifierFlipBox) != slideBoxFlipValue)
            {
                FlipTool.FlipElement(gMagnifierFlipBox, slideBoxFlipValue.X, slideBoxFlipValue.Y);
            }
            int elementActualAngle = PublicMethods.GetElementActualAngle(mSlide);

            if (PublicMethods.GetElementActualAngle(multiScaleImage) != elementActualAngle)
            {
                RotateMagnifier(multiScaleImage, elementActualAngle);
            }
            pSlideBoxPixelPoint = PublicMethods.FlipPoint(PublicMethods.FindSlideBox(mSlide), pSlideBoxPixelPoint);
            Point pPixelPoint     = mSlide.BoxPixelToControlPixel(pSlideBoxPixelPoint);
            Point pNavigatorRatio = mSlide.ControlPixelToSlideRatio(pPixelPoint, false);
            Point pDeltaOffset    = multiScaleImage.RatioOffsetToDeltaOffset(pNavigatorRatio);

            multiScaleImage.DeltaToPan(pDeltaOffset);
            Mark.UpdateAllMarks(gMagnifierFlipBox, fScreenRatio);
        }
Exemplo n.º 20
0
        public static void InitializeTool(MultiScaleImage mSlide, Image imgPreview, Border bNavigation, Image imgDragTool, Image imgLabel, Polyline pShowMarksChecked, Polyline pShowRulerChecked, Polyline pShowNavigationChecked, Polyline pShowSlideLabelChecked, float fScreenRatio, ResourceDictionary rdDirectory)
        {
            Grid grid = (mSlide.Parent as Grid).Parent as Grid;

            if (grid.ActualHeight > 500.0)
            {
                imgPreview.Height = 500.0;
                imgPreview.Width  = imgPreview.Height * grid.ActualWidth / grid.ActualHeight;
            }
            else
            {
                imgPreview.Height = grid.ActualHeight;
                imgPreview.Width  = grid.ActualWidth;
            }
            imgPreview.Stretch = Stretch.Uniform;
            imgPreview.Source  = GetPreviewPicture(grid, bNavigation, imgDragTool, imgLabel, pShowMarksChecked, pShowRulerChecked, pShowNavigationChecked, pShowSlideLabelChecked, fScreenRatio, rdDirectory);
        }
Exemplo n.º 21
0
        public static void GetMagnifierMark(MultiScaleImage mSlide, Grid gMagnifierFlipBox, float fScreenRatio)
        {
            MultiScaleImage multiScaleImage = gMagnifierFlipBox.FindName("mMagnifier") as MultiScaleImage;
            Grid            grid            = gMagnifierFlipBox.FindName("gMagnifierMarkBox") as Grid;

            if (mSlide.Source == multiScaleImage.Source)
            {
                grid.Children.Clear();
                Mark.GetMark(multiScaleImage, grid, fScreenRatio, 2);
                Mark.UpdateAllMarks(gMagnifierFlipBox, fScreenRatio);
                Grid grid2 = PublicMethods.FindSlideBox(mSlide).FindName("gMarkBox") as Grid;
                for (int i = 0; i < grid2.Children.Count; i++)
                {
                    grid.Children[i].Visibility = grid2.Children[i].Visibility;
                }
            }
        }
Exemplo n.º 22
0
        public static void RotateMagnifier(MultiScaleImage mMagnifier, int iTargetActualAngle)
        {
            RotateTransform renderTransform = new RotateTransform(iTargetActualAngle);

            mMagnifier.RenderTransformOrigin = new Point(0.5, 0.5);
            mMagnifier.RenderTransform       = renderTransform;
            int   acuteAngle = PublicMethods.GetAcuteAngle(iTargetActualAngle);
            float num        = (float)Math.Sin(Math.PI / 180.0 * (double)acuteAngle);
            float num2       = (float)Math.Cos(Math.PI / 180.0 * (double)acuteAngle);
            float num3       = (float)mMagnifier.ActualWidth;
            float num4       = (float)mMagnifier.ActualHeight;
            float num5       = num3 * num2 + num4 * num;
            float num6       = num3 * num + num4 * num2;
            float num7       = (0f - (num5 - num3)) / 2f;
            float num8       = (0f - (num6 - num4)) / 2f;

            mMagnifier.Margin = new Thickness(num7, num8, num7, num8);
        }
Exemplo n.º 23
0
        public void UpdateMeasureTool(MultiScaleImage mSlide, bool animate = false, float fDurationTime = 0f, EasingFunctionBase easing = null)
        {
            Grid  gSlideBox     = PublicMethods.FindSlideBox(mSlide);
            Point pNormalPoint  = mSlide.SlideRatioToBoxPixel(pStartRatio);
            Point pNormalPoint2 = mSlide.SlideRatioToBoxPixel(pOverRatio);

            pNormalPoint  = PublicMethods.FlipPoint(gSlideBox, pNormalPoint);
            pNormalPoint2 = PublicMethods.FlipPoint(gSlideBox, pNormalPoint2);
            if (!animate)
            {
                CloseMeasureToolAnimation();
                lMeasureLine.X1      = pNormalPoint.X;
                lMeasureLine.Y1      = pNormalPoint.Y;
                lMeasureLine.X2      = pNormalPoint2.X;
                lMeasureLine.Y2      = pNormalPoint2.Y;
                lMeasureValue.Margin = new Thickness((lMeasureLine.X2 - lMeasureLine.X1) / 2.0 + lMeasureLine.X1 - 30.0, (lMeasureLine.Y2 - lMeasureLine.Y1) / 2.0 + lMeasureLine.Y1 - 20.0, 0.0, 0.0);
            }
            else
            {
                lMeasureLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(pNormalPoint.Y, TimeSpan.FromMilliseconds(fDurationTime))
                {
                    EasingFunction = easing
                }, HandoffBehavior.Compose);
                lMeasureLine.BeginAnimation(Line.X2Property, new DoubleAnimation(pNormalPoint2.X, TimeSpan.FromMilliseconds(fDurationTime))
                {
                    EasingFunction = easing
                }, HandoffBehavior.Compose);
                lMeasureLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(pNormalPoint2.Y, TimeSpan.FromMilliseconds(fDurationTime))
                {
                    EasingFunction = easing
                }, HandoffBehavior.Compose);
                DoubleAnimation doubleAnimation = new DoubleAnimation(pNormalPoint.X, TimeSpan.FromMilliseconds(fDurationTime))
                {
                    EasingFunction = easing
                };
                doubleAnimation.CurrentTimeInvalidated += delegate
                {
                    CloseMeasureToolAnimation(4);
                    lMeasureValue.Margin = new Thickness((lMeasureLine.X2 - lMeasureLine.X1) / 2.0 + lMeasureLine.X1 - 30.0, (lMeasureLine.Y2 - lMeasureLine.Y1) / 2.0 + lMeasureLine.Y1 - 20.0, 0.0, 0.0);
                };
                lMeasureLine.BeginAnimation(Line.X1Property, doubleAnimation, HandoffBehavior.Compose);
            }
        }
Exemplo n.º 24
0
 public static void UpdateZoomValue(MultiScaleImage mSlide, Label lZoomValue, Rectangle rController, Line lValueLine, float fScreenRatio, Label lOne, Label lDefault)
 {
     if (mSlide.Source != null)
     {
         float num = ScaleToZoom(mSlide, mSlide.fTargetScale, fScreenRatio);
         num = (float)Math.Round(num, 2);
         float num2 = 0f;
         num2 = ((!(num >= 1f)) ? (fTotalHeight - GetTopValue(1f) - 10f + 30f * (1f - num)) : (fTotalHeight - GetTopValue(num) - 10f));
         lZoomValue.Margin  = new Thickness(20.0, num2 - 5f, 0.0, 0.0);
         rController.Margin = new Thickness(0.0, num2, 0.0, 0.0);
         lZoomValue.Content = num.ToString("0.00") + "X";
         lValueLine.Y2      = num2;
         float num3 = (float)Math.Round(mSlide.Source.sbcCurrentSlide.dMaxActualZoom, 2);
         if (num > num3)
         {
             lZoomValue.Foreground = new SolidColorBrush(Color.FromRgb(byte.MaxValue, 0, 0));
             lOne.Background       = new SolidColorBrush(Color.FromRgb(byte.MaxValue, byte.MaxValue, byte.MaxValue));
             lOne.Foreground       = new SolidColorBrush(Color.FromRgb(0, 0, 0));
         }
         else if (num < num3)
         {
             lZoomValue.Foreground = new SolidColorBrush(Color.FromRgb(byte.MaxValue, byte.MaxValue, byte.MaxValue));
             lOne.Background       = new SolidColorBrush(Color.FromRgb(byte.MaxValue, byte.MaxValue, byte.MaxValue));
             lOne.Foreground       = new SolidColorBrush(Color.FromRgb(0, 0, 0));
         }
         else
         {
             lZoomValue.Foreground = new SolidColorBrush(Color.FromRgb(byte.MaxValue, byte.MaxValue, byte.MaxValue));
             lOne.Background       = new SolidColorBrush(Color.FromRgb(57, 176, 181));
             lOne.Foreground       = new SolidColorBrush(Color.FromRgb(byte.MaxValue, byte.MaxValue, byte.MaxValue));
         }
         float num4 = ScaleToZoom(mSlide, (float)mSlide.OriginalScale, fScreenRatio);
         num4 = (float)Math.Round(num4, 2);
         if (num == num4)
         {
             lDefault.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Image/home_active.png", UriKind.RelativeOrAbsolute)));
         }
         else
         {
             lDefault.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Image/home.png", UriKind.RelativeOrAbsolute)));
         }
     }
 }
Exemplo n.º 25
0
 public static void RotateNavigator(Border bNavigation, MultiScaleImage mNavigationImage, int iActualAngle, float fNavigatorWidth, float fNavigatorHeight)
 {
     try
     {
         RotateTransform renderTransform       = new RotateTransform(iActualAngle);
         Point           renderTransformOrigin = new Point(0.5, 0.5);
         int             acuteAngle            = PublicMethods.GetAcuteAngle(iActualAngle);
         float           num  = (float)Math.Sin(Math.PI / 180.0 * (double)acuteAngle);
         float           num2 = (float)Math.Cos(Math.PI / 180.0 * (double)acuteAngle);
         float           num3 = fNavigatorHeight * num + fNavigatorWidth * num2;
         float           num4 = fNavigatorHeight * num2 + fNavigatorWidth * num;
         bNavigation.Width  = 4f + num3;
         bNavigation.Height = 4f + num4;
         mNavigationImage.RenderTransformOrigin = renderTransformOrigin;
         mNavigationImage.RenderTransform       = renderTransform;
     }
     catch
     {
     }
 }
Exemplo n.º 26
0
        public static void UpdateRuler(Grid gSlideBox, ref float fWidthPerPixel)
        {
            MultiScaleImage multiScaleImage = gSlideBox.FindName("mMultiScaleImage") as MultiScaleImage;
            StackPanel      obj             = gSlideBox.FindName("sRulerToolBox") as StackPanel;
            Label           label           = obj.FindName("lRulerValue") as Label;
            StackPanel      stackPanel      = obj.FindName("sRulerItem") as StackPanel;

            obj.Visibility = Visibility.Visible;
            float fTargetScale = multiScaleImage.fTargetScale;
            float num          = (float)(10.0 / multiScaleImage.Source.sbcCurrentSlide.dMaxActualZoom);

            fWidthPerPixel = num / fTargetScale;
            float num2 = fWidthPerPixel * 80f;

            num2          = ((num2 < 20f) ? 20f : ((num2 < 50f) ? 50f : ((num2 < 100f) ? 100f : ((num2 < 200f) ? 200f : ((num2 < 500f) ? 500f : ((num2 < 1000f) ? 1000f : ((num2 < 2000f) ? 2000f : ((!(num2 < 5000f)) ? 10000f : 5000f))))))));
            label.Content = num2 + "μm";
            foreach (Label child in stackPanel.Children)
            {
                child.Width = num2 / fWidthPerPixel / 5f;
            }
        }
Exemplo n.º 27
0
        private Rect GetThumbnailRect(double thumbnailWidth)
        {
            MultiScaleImage multiScaleImage = m_MultiScaleImage;
            double          num             = multiScaleImage.ActualWidth;
            double          num2            = multiScaleImage.ActualHeight;
            double          num3            = 0.0;
            double          num4            = 0.0;

            if (m_Angle >= 0.0 && num > Setting.AngelMsiOffset * 2.0 && num2 > Setting.AngelMsiOffset * 2.0)
            {
                num  -= Setting.AngelMsiOffset * 2.0;
                num2 -= Setting.AngelMsiOffset * 2.0;
            }
            if (m_Angle != 0.0)
            {
                num3 = Setting.AngelMsiOffset;
                num4 = Setting.AngelMsiOffset;
            }
            Point  point = default(Point);
            double scale = multiScaleImage.ZoomableCanvas.Scale;
            double num5  = ScaleToViewportWidth(scale, num, multiScaleImage.Source.ImageSize.Width);
            double num6  = thumbnailWidth * num5;
            double num7  = num6 * num2 / num;

            point.X = (multiScaleImage.ZoomableCanvas.Offset.X + num3) * num5 / num;
            point.Y = (multiScaleImage.ZoomableCanvas.Offset.Y + num4) * num5 / num;
            double num8   = point.X * thumbnailWidth;
            double num9   = point.Y * thumbnailWidth;
            Point  point2 = new Point(num8, num9);

            if (m_Angle != 0.0)
            {
                Point center = new Point(0.0, 0.0);
                Point point3 = new Point(num8 + num6 / 2.0, num9 + num7 / 2.0);
                Point p      = new Point(point3.X - m_OrgWidth / 2.0, point3.Y - m_OrgHeight / 2.0);
                Point point4 = PointRotate(center, p, 360.0 - m_Angle);
                point2 = new Point(point4.X - num6 / 2.0 + m_Width / 2.0, point4.Y - num7 / 2.0 + m_Height / 2.0);
            }
            return(new Rect(point2.X, point2.Y, num6, num7));
        }
Exemplo n.º 28
0
 public static void UpdateNavigationViewport(MultiScaleImage mCurrentMultiScaleImage, MultiScaleImage mNavigatorImage, Rectangle rViewport, Line lHorLine, Line lVerLine)
 {
     if (mCurrentMultiScaleImage.Source != null)
     {
         float fTargetScale       = mCurrentMultiScaleImage.fTargetScale;
         Point pTargetOffset      = mCurrentMultiScaleImage.pTargetOffset;
         Grid  grid               = PublicMethods.FindSlideBox(mCurrentMultiScaleImage);
         Size  imageSize          = mCurrentMultiScaleImage.Source.ImageSize;
         float num                = (float)(mNavigatorImage.ActualWidth * grid.ActualWidth / (imageSize.Width * (double)fTargetScale));
         float num2               = (float)((double)num * grid.ActualHeight / grid.ActualWidth);
         float num3               = (float)mCurrentMultiScaleImage.Margin.Left;
         float num4               = (float)mCurrentMultiScaleImage.Margin.Top;
         float num5               = (float)((pTargetOffset.X - (double)num3) * (double)num / grid.ActualWidth);
         float num6               = (float)((pTargetOffset.Y - (double)num4) * (double)num2 / grid.ActualHeight);
         Point point              = new Point(num5 + num / 2f, 0f - (num6 + num2 / 2f));
         int   elementActualAngle = PublicMethods.GetElementActualAngle(mCurrentMultiScaleImage);
         Point point2             = (elementActualAngle != 0) ? PublicMethods.GetRotatePoint(point, -elementActualAngle, new Point(mNavigatorImage.ActualWidth / 2.0, (0.0 - mNavigatorImage.ActualHeight) / 2.0)) : point;
         rViewport.SetValue(Canvas.LeftProperty, point2.X - (double)(num / 2f));
         rViewport.SetValue(Canvas.TopProperty, 0.0 - point2.Y - (double)(num2 / 2f));
         rViewport.Width  = num;
         rViewport.Height = num2;
         if (num < 15f && num2 < 15f)
         {
             rViewport.Visibility = Visibility.Collapsed;
         }
         else
         {
             rViewport.Visibility = Visibility.Visible;
         }
         lHorLine.X1 = -1000.0;
         lHorLine.X2 = 3000.0;
         lHorLine.Y1 = 0.0 - point2.Y;
         lHorLine.Y2 = 0.0 - point2.Y;
         lVerLine.X1 = point2.X;
         lVerLine.X2 = point2.X;
         lVerLine.Y1 = -1000.0;
         lVerLine.Y2 = 3000.0;
     }
 }
Exemplo n.º 29
0
        public static void MagnifierZoomAboutCenter(Border bMagnifierBorder, MainWindow mainWindow, Grid gAllSlideBox, float fScreenRatio)
        {
            Grid gMagnifierFlipBox = bMagnifierBorder.FindName("gMagnifierFlipBox") as Grid;

            if (bMagnifierBorder.Margin == default(Thickness))
            {
                float num  = (float)(mainWindow.Width - 60.0 - bMagnifierBorder.Width) / 2f;
                float num2 = (float)(mainWindow.Height - 20.0 - bMagnifierBorder.Height) / 2f;
                bMagnifierBorder.Margin = new Thickness(num, num2, 0.0, 0.0);
                bMagnifierBorder.UpdateLayout();
            }
            Point           point = new Point(bMagnifierBorder.Margin.Left + bMagnifierBorder.Width / 2.0, bMagnifierBorder.Margin.Top + bMagnifierBorder.Height / 2.0);
            Point           pSlideBoxPixelPoint = new Point(0.0, 0.0);
            MultiScaleImage multiScaleImage     = null;

            foreach (FrameworkElement child in gAllSlideBox.Children)
            {
                if (child is Border)
                {
                    Border border = child as Border;
                    multiScaleImage = ((border.Child as Grid).FindName("mMultiScaleImage") as MultiScaleImage);
                    if (multiScaleImage.Source != null)
                    {
                        Point point2 = border.TranslatePoint(new Point(0.0, 0.0), mainWindow);
                        if (new Rect(point2.X, point2.Y, border.ActualWidth, border.ActualHeight).Contains(point))
                        {
                            pSlideBoxPixelPoint = mainWindow.TransformToVisual(border).Transform(point);
                            break;
                        }
                    }
                }
            }
            if (multiScaleImage != null)
            {
                MagnifierZoomAboutPoint(gMagnifierFlipBox, multiScaleImage, bMagnifierBorder, pSlideBoxPixelPoint, fScreenRatio);
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Display a hotspot icon on screen.
        /// </summary>
        public void loadHotspotIcon(int index, Canvas canvasParent, ScatterView scatterViewParent, MultiScaleImage msi)
        {
            if (index >= 0 && index < m_hotspotIcons.Length)
            {
                m_hotspotIcons[index] = new HotspotIconControl(canvasParent, scatterViewParent, m_hotspots[index], msi);
                m_hotspotIcons[index].displayOnScreen(msi);
                m_isOnScreen[index] = true;

                m_hotspotDetails[index] = m_hotspotIcons[index].DetailControl;
            }
        }
        /// <summary>
        /// Display the hotspot icon on screen.
        /// </summary>
        public void displayOnScreen(MultiScaleImage msi)
        {
            m_parent.Children.Add(this);
            try
            {
                hotspotCircle.Source = normal;

            }
            catch (Exception e)
            {

            }

            Double[] size = m_detailControl.findImageSize();

            screenPosX = (msi.GetZoomableCanvas.Scale * m_hotspotData.PositionX * size[0]) - msi.GetZoomableCanvas.Offset.X;
            screenPosY = (msi.GetZoomableCanvas.Scale * m_hotspotData.PositionY *size[1]) - msi.GetZoomableCanvas.Offset.Y;
            Canvas.SetLeft(this, screenPosX);
            Canvas.SetTop(this, screenPosY);
        }
        /// <summary>
        /// Update the icon screen location with respect to the artwork.
        /// </summary>
        public void updateScreenLocation(MultiScaleImage msi)
        {
            Double[] size = m_detailControl.findImageSize();
            screenPosX = (msi.GetZoomableCanvas.Scale * m_hotspotData.PositionX *size[0]) - msi.GetZoomableCanvas.Offset.X;
            screenPosY = (msi.GetZoomableCanvas.Scale * m_hotspotData.PositionY *size[1]) - msi.GetZoomableCanvas.Offset.Y;

            Canvas.SetLeft(this, screenPosX);
            Canvas.SetTop(this, screenPosY);
        }
Exemplo n.º 33
0
        public static void UpdateViewRect(Grid gSlideBox, bool bScaleChanged, bool animate = false, float fDurationTime = 0f, EasingFunctionBase easing = null)
        {
            MultiScaleImage mSlide       = gSlideBox.FindName("mMultiScaleImage") as MultiScaleImage;
            ZoomableCanvas  zcCycleGrid  = gSlideBox.FindName("zcGrid") as ZoomableCanvas;
            Border          border       = gSlideBox.FindName("bGridBox") as Border;
            float           fTargetScale = mSlide.fTargetScale;

            if (zcCycleGrid.Children.Count == 0)
            {
                return;
            }
            System.Windows.Point point = mSlide.SlideRatioToBoxPixel(new System.Windows.Point(0.0, 0.0));
            int elementActualAngle     = PublicMethods.GetElementActualAngle(mSlide);

            if (!animate)
            {
                zcCycleGrid.ApplyAnimationClock(ZoomableCanvas.ScaleProperty, null);
                border.ApplyAnimationClock(FrameworkElement.MarginProperty, null);
                border.Margin     = new Thickness(point.X, point.Y, 0.0, 0.0);
                zcCycleGrid.Scale = fTargetScale;
                if (bScaleChanged)
                {
                    foreach (System.Windows.Shapes.Rectangle child in zcCycleGrid.Children)
                    {
                        child.StrokeThickness = 1f / fTargetScale;
                    }
                }
            }
            else
            {
                border.BeginAnimation(FrameworkElement.MarginProperty, new ThicknessAnimation(new Thickness(point.X, point.Y, 0.0, 0.0), TimeSpan.FromMilliseconds(fDurationTime))
                {
                    EasingFunction = easing
                }, HandoffBehavior.Compose);
                if (bScaleChanged)
                {
                    DoubleAnimation doubleAnimation = new DoubleAnimation(fTargetScale, TimeSpan.FromMilliseconds(fDurationTime))
                    {
                        EasingFunction = easing
                    };
                    int i = 0;
                    doubleAnimation.CurrentTimeInvalidated += delegate
                    {
                        Task.Factory.StartNew(delegate
                        {
                            i++;
                            if (i % 3 == 0)
                            {
                                float fCurrentScale = 0f;
                                zcCycleGrid.Dispatcher.BeginInvoke((Action) delegate
                                {
                                    fCurrentScale = mSlide.GetCurrentScale();
                                    foreach (System.Windows.Shapes.Rectangle child2 in zcCycleGrid.Children)
                                    {
                                        child2.StrokeThickness = 1f / fCurrentScale;
                                    }
                                }, DispatcherPriority.Loaded);
                            }
                        }, TaskCreationOptions.AttachedToParent);
                    };
                    zcCycleGrid.BeginAnimation(ZoomableCanvas.ScaleProperty, doubleAnimation, HandoffBehavior.Compose);
                }
            }
            System.Windows.Point point3 = border.RenderTransformOrigin = new System.Windows.Point(0.0, 0.0);
            border.RenderTransform = new RotateTransform(elementActualAngle);
        }
Exemplo n.º 34
0
        /// <summary>
        /// Display all hotspot icons on screen.
        /// </summary>
        public void loadAllHotspotsIcon(Canvas canvasParent, ScatterView scatterViewParent, MultiScaleImage msi)
        {
            if (m_hotspots != null)
            {
                for (int i = 0; i < m_hotspots.Length; i++)
                {
                    if (m_isSelected[i] == true)
                        loadHotspotIcon(i, canvasParent, scatterViewParent, msi);

                }
            }
        }
Exemplo n.º 35
0
 public void registerMSI(MultiScaleImage m, Timeline t)
 {
     if (!msiToTLDict.ContainsKey(m))
         msiToTLDict.Add(m, t);
 }
Exemplo n.º 36
0
 /// <summary>
 /// Specify all hotspots locations with respect to its artwork.
 /// </summary>
 public void updateHotspotLocations(Canvas canvasParent, ScatterView scatterViewParent, MultiScaleImage msi)
 {
     if (m_hotspots != null)
     {
         for (int i = 0; i < m_hotspots.Length; i++)
         {
             updateHotspotLocation(i, canvasParent, scatterViewParent, msi);
         }
     }
 }
Exemplo n.º 37
0
        /// <summary>
        /// Specify a hotspot location with respect to its artwork.
        /// </summary>
        public void updateHotspotLocation(int index, Canvas canvasParent, ScatterView scatterViewParent, MultiScaleImage msi)
        {
            if (index >= 0 && index < m_hotspotIcons.Length)
            {
                if (m_isOnScreen[index] == true)
                {
                    m_hotspotIcons[index].updateScreenLocation(msi);

                    if (m_hotspotDetails[index].IsOnScreen == true)
                    {
                        m_hotspotDetails[index].updateScreenLocation(msi);
                    }
                }
            }
        }
        /// <summary>
        /// Update the screen location of the control with respect to the artwork.
        /// </summary>
        /// 
        public void updateScreenLocation(MultiScaleImage msi)
        {
            Double[] size = this.findImageSize();

            screenPosX = (msi.GetZoomableCanvas.Scale * m_hotspotData.PositionX * size[0]) - msi.GetZoomableCanvas.Offset.X;
            screenPosY = (msi.GetZoomableCanvas.Scale * m_hotspotData.PositionY * size[1]) - msi.GetZoomableCanvas.Offset.Y;
            this.Center = new Point(screenPosX + this.Width / 2.0, screenPosY + this.Height / 2.0); // uncomment this to make the detail control move as the user pans
        }
Exemplo n.º 39
0
 public MultiScaleImageAutomationPeer(MultiScaleImage owner)
     : base(owner)
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public HotspotDetailsControl(Canvas parentCanvas, ScatterView parentScatterView, Hotspot hotspotData, MultiScaleImage msi)
 {
     InitializeComponent();
     m_hotspotData = hotspotData;
     m_parentCanvas = parentCanvas;
     m_parentScatterView = parentScatterView;
     m_msi = msi;
     //ScatterViewItem
     this.PreviewMouseWheel += new MouseWheelEventHandler(HotspotDetailsControl_PreviewMouseWheel);
     isOnScreen = false;
     hasVideo = false;
     _hasBeenOpened = false;
     _volume = .5;
        // windowSize = new Size();
     sizeChanged = true;
     firstTime = true;
 }