コード例 #1
0
        protected override void OnAttached()
        {
            parent = AssociatedObject.GetParent <Grid>();

            parent.Children.Remove(AssociatedObject);

            zoomable = new ZoomableCanvas();

            zoomable.Children.Add(AssociatedObject);

            zoomable.Loaded += Zoomable_Loaded;

            parent.Children.Add(zoomable);

            if (UseInParent)
            {
                parent.MouseWheel += OnMouseWheel;
                parent.MouseMove  += OnMouseMove;
            }
            else
            {
                zoomable.MouseWheel += OnMouseWheel;
                zoomable.MouseMove  += OnMouseMove;
            }
        }
コード例 #2
0
        public static void DeleteSingleSlideViewRect(Grid gSlideBox)
        {
            Border         border = gSlideBox.FindName("bGridBox") as Border;
            ZoomableCanvas obj    = gSlideBox.FindName("zcGrid") as ZoomableCanvas;

            border.Visibility = Visibility.Collapsed;
            obj.Children.Clear();
        }
コード例 #3
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);
            }
        }
コード例 #4
0
 private void ZoomableCanvasLoaded(object sender, RoutedEventArgs e)
 {
     _zoomableCanvas = sender as ZoomableCanvas;
     if (_zoomableCanvas != null)
     {
         _zoomableCanvas.RealizationPriority = DispatcherPriority.Background;
         _zoomableCanvas.RealizationRate     = 10;
         InitializeCanvas();
     }
 }
コード例 #5
0
        private static Point ZoomCenter(ItemsCanvas itemsCanvas)
        {
            ZoomableCanvas zoomableCanvas = itemsCanvas.ZoomableCanvas;
            Point          viewCenter     = new Point(zoomableCanvas.ActualWidth / 2.0, zoomableCanvas.ActualHeight / 2.0);
            Point          zoomCenter     = viewCenter + (Vector)zoomableCanvas.Offset;

            if (itemsCanvas.IsRoot)
            {
                // Compensate for root center offset to windows
                zoomCenter -= new Vector(10, 10);
            }

            return(zoomCenter);
        }
コード例 #6
0
 private void ZoomableCanvasLoaded(object sender, RoutedEventArgs e)
 {
     _zoomableCanvas = (sender as ZoomableCanvas);
     if (_zoomableCanvas != null && _zoomableCanvas.Children.Count == 0 && base.Tag != "1")
     {
         _zoomableCanvas.RealizationPriority = DispatcherPriority.Background;
         _zoomableCanvas.RealizationRate     = 10;
         InitializeCanvas();
         if (this.Ini != null)
         {
             this.Ini(sender, e);
         }
     }
 }
コード例 #7
0
 public void BaseMapLayer_Loaded(object sender, RoutedEventArgs e)
 {
     BaseCanvas = (ZoomableCanvas)sender;
 }
コード例 #8
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);
        }
コード例 #9
0
ファイル: MainWindow.cs プロジェクト: muqsit-0010/Algo
 //capturing the canvas on the back of lstFloor for later use
 void loaded(object sender, RoutedEventArgs e)
 {
     cvsFloor = sender as ZoomableCanvas;
 }
コード例 #10
0
        public static Border CreateSlideBox(ResourceDictionary rdDirectory)
        {
            Rectangle rectangle = new Rectangle();

            rectangle.SetValue(FrameworkElement.StyleProperty, rdDirectory["rectLeft"]);
            Rectangle rectangle2 = new Rectangle();

            rectangle2.SetValue(FrameworkElement.StyleProperty, rdDirectory["rectTop"]);
            Rectangle rectangle3 = new Rectangle();

            rectangle3.SetValue(FrameworkElement.StyleProperty, rdDirectory["rectRight"]);
            Rectangle rectangle4 = new Rectangle();

            rectangle4.SetValue(FrameworkElement.StyleProperty, rdDirectory["rectBottom"]);
            Grid grid = new Grid();

            grid.SetValue(FrameworkElement.StyleProperty, rdDirectory["MultiScaleImageBox"]);
            Border border = new Border();

            border.SetValue(FrameworkElement.StyleProperty, rdDirectory["SlideNameBorder"]);
            Label label = new Label();

            label.SetValue(FrameworkElement.StyleProperty, rdDirectory["SlideName"]);
            border.Child = label;
            StackPanel      stackPanel      = CreatRulerBox(rdDirectory);
            MultiScaleImage multiScaleImage = new MultiScaleImage();

            multiScaleImage.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            multiScaleImage.VerticalContentAlignment   = VerticalAlignment.Stretch;
            Border border2 = new Border();

            border2.SetValue(FrameworkElement.StyleProperty, rdDirectory["bGridBox"]);
            ZoomableCanvas scopedElement = (ZoomableCanvas)(border2.Child = new ZoomableCanvas());
            Grid           grid2         = new Grid();

            grid2.SetValue(FrameworkElement.StyleProperty, rdDirectory["gMarkBox"]);
            Grid grid3 = new Grid();

            grid3.Children.Add(multiScaleImage);
            grid3.Children.Add(border2);
            grid3.Children.Add(grid2);
            grid.Children.Add(border);
            grid.Children.Add(stackPanel);
            grid.Children.Add(grid3);
            grid.Children.Add(rectangle);
            grid.Children.Add(rectangle2);
            grid.Children.Add(rectangle4);
            grid.Children.Add(rectangle3);
            Border result = new Border
            {
                Child = grid
            };

            NameScope.SetNameScope(grid, new NameScope());
            grid.RegisterName("bSlideNameBorder", border);
            grid.RegisterName("lSlideName", label);
            grid.RegisterName("sRulerToolBox", stackPanel);
            grid.RegisterName("gFlipBox", grid3);
            grid.RegisterName("mMultiScaleImage", multiScaleImage);
            grid.RegisterName("bGridBox", border2);
            grid.RegisterName("gMarkBox", grid2);
            grid.RegisterName("zcGrid", scopedElement);
            grid.RegisterName("rectLeft", rectangle);
            grid.RegisterName("rectTop", rectangle2);
            grid.RegisterName("rectBottom", rectangle4);
            grid.RegisterName("rectRight", rectangle3);
            return(result);
        }
コード例 #11
0
 public DrawGraphics(ref ZoomableCanvas zCanvas, ref Canvas canvas)
 {
     MyCanvas  = zCanvas;
     Benchmark = canvas;
 }
コード例 #12
0
 public void SetZoomableCanvas(ZoomableCanvas zoomableCanvas) =>
 ItemsCanvas.SetZoomableCanvas(zoomableCanvas);