Esempio n. 1
0
        //public static void DisplayGlobalCentered(this MultiScaleImage msi)
        //{
        //    msi.DisplayGlobalCentered(1, true);
        //}
        //priavte static void DisplayGlobalCentered(this MultiScaleImage msi, int nbVirtualWith, bool goBegin)
        //{
        //    Rect subImageRect = msi.GetGloblaRect(nbVirtualWith);
        //    double num = msi.ActualWidth / msi.ActualHeight;
        //    Point point;
        //    if (goBegin)
        //        point = new Point((subImageRect.X - (msi.ViewportWidth / 2.0)) + (subImageRect.Width / 2.0), (subImageRect.Y - ((msi.ViewportWidth / num) / 2.0)) + (subImageRect.Height / 2.0));
        //    else
        //        point = new Point(msi.ViewportOrigin.X, (subImageRect.Y - ((msi.ViewportWidth / num) / 2.0)) + (subImageRect.Height / 2.0));
        //    double zoomFactor = (msi.ActualWidth / subImageRect.Width) < (msi.ActualHeight / subImageRect.Height) ?
        //                                            msi.ActualWidth / subImageRect.Width : msi.ActualHeight / subImageRect.Height;
        //    msi.ViewportWidth = zoomFactor * msi.ViewportWidth;
        //    msi.ViewportOrigin = point;
        //}
        public static void DisplaySubImageCentered(this MultiScaleImage msi, int indexSubImage)
        {
            if (indexSubImage < 0 || indexSubImage >= msi.SubImages.Count)
                return;

            Rect subImageRect = msi.GetSubImageRect(indexSubImage);
            msi.CenterLogicalRect(subImageRect);
        }
Esempio n. 2
0
        public static void ZoomCenter(this MultiScaleImage msi, int nbVirtualPage)
        {
            Rect subImageRect = msi.GetGlobalRect(1);
            Rect imageRectElement = msi.LogicalToElementRect(subImageRect);

            // Calculate the zoom factor such that the image will fill up the entire screen
            double zoomFactor = (msi.ActualWidth / imageRectElement.Width) < (msi.ActualHeight / imageRectElement.Height) ?
                                                msi.ActualWidth / imageRectElement.Width : msi.ActualHeight / imageRectElement.Height;

            // Not a real zoom factor, don't zoom
            if (!zoomFactor.IsRational())
                return;

            // Center the image
            msi.CenterLogicalRect(subImageRect);

            // Use the mid point of the image to zoom from
            msi.ZoomAboutLogicalPoint(zoomFactor, (subImageRect.Left + subImageRect.Right) / 2, (subImageRect.Top + subImageRect.Bottom) / 2);
        }
Esempio n. 3
0
 public static void CenterLogicalRect(this MultiScaleImage msi, Rect rectLogical)
 {
     msi.CenterLogicalRect(rectLogical, msi.ViewportWidth);
 }