Example #1
0
 void UninstallScale()
 {
     zoomable         = null;
     uiObjectProvider = null;
     if (zoomElement == null)
     {
         return;
     }
     if (metroWindow != null)
     {
         metroWindow.WindowDpiChanged -= MetroWindow_WindowDpiChanged;
     }
     zoomElement.Loaded            -= ZoomElement_Loaded;
     zoomElement.PreviewMouseWheel -= ZoomElement_PreviewMouseWheel;
     foreach (var b in commandBindings)
     {
         zoomElement.CommandBindings.Remove(b);
     }
     foreach (var b in keyBindings)
     {
         zoomElement.InputBindings.Remove(b);
     }
     zoomElement = null;
     ResetBindings();
 }
Example #2
0
 private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     viewModel = this.DataContext as IZoomable;
     Debug.Assert(viewModel != null, $"The view model '{DataContext.GetType()}' does not support IZoomable");
     if (viewModel == null)
     {
         return;
     }
     viewModel.OnScaleChanged += ViewModel_OnScaleChanged;
 }
Example #3
0
 void InstallScaleCore(IUIObjectProvider provider, IZoomable zoomable)
 {
     UninstallScale();
     if (zoomable == null)
     {
         return;
     }
     this.zoomable = zoomable;
     SetZoomValue(zoomable.ZoomValue, force: true);
 }
Example #4
0
 void InstallScale(IZoomable zoomable)
 {
     UninstallScale();
     if (zoomable == null)
     {
         return;
     }
     this.zoomable = zoomable;
     ScaleValue    = zoomable.ScaleValue;
 }
        protected Vector3 ClampScaling(IZoomable zoomable, Vector3 scaling)
        {
            Vector3 clampedScaling = Vector3.one;

            for (int i = 0; i < 2; i++)
            {
                clampedScaling[i] = zoomable.ScaleRange[i].Clamp(zoomable.Transform.localScale[i] * scaling[i])
                                    / zoomable.Transform.localScale[i];
            }
            return(clampedScaling);
        }
Example #6
0
 protected override void Update(CommandInfo info)
 {
     if (IdeApp.Workbench.ActiveDocument == null)
     {
         info.Enabled = false;
     }
     else
     {
         IZoomable zoom = IdeApp.Workbench.ActiveDocument.GetContent <IZoomable> (true);
         info.Enabled = zoom != null && zoom.EnableZoomReset;
     }
 }
Example #7
0
        protected virtual void InternalZoomOut()
        {
            IZoomable zoomable = GetZoomable();

            if ((zoomable != null) && (zoomable.CanZoomOut()))
            {
                zoomable.ZoomOut();
            }
            else
            if (_surfaceStack.Count > 1)
            {
                Pop();
            }
        }
Example #8
0
 void UninstallScale()
 {
     currentScaleValue = 1;
     zoomable          = null;
     if (scaleElement == null)
     {
         return;
     }
     if (metroWindow != null)
     {
         metroWindow.WindowDPIChanged -= MetroWindow_WindowDPIChanged;
     }
     scaleElement.Loaded -= ScaleElement_Loaded;
     scaleElement.RemoveHandler(UIElement.MouseWheelEvent, new MouseWheelEventHandler(ScaleElement_MouseWheel));
     foreach (var b in commandBindings)
     {
         scaleElement.CommandBindings.Remove(b);
     }
     foreach (var b in keyBindings)
     {
         scaleElement.InputBindings.Remove(b);
     }
     scaleElement = null;
 }
Example #9
0
        protected override void Run()
        {
            IZoomable zoom = IdeApp.Workbench.ActiveDocument.GetContent <IZoomable> (true);

            zoom.ZoomReset();
        }
Example #10
0
 protected override void TaskGrid_Zooming(IZoomable grid, Vector3 scaling, Vector3 translation)
 {
 }
Example #11
0
 void UpdateZoomHandler(DocumentHandler handler)
 {
     if (zoomHandler != null)
         zoomHandler.ZoomChanged -= new EventHandler(zoomHandler_ZoomChanged);
     zoomHandler = handler.ZoomHandler;
     if (handler.IsZoomable)
         zoomHandler.ZoomChanged += new EventHandler(zoomHandler_ZoomChanged);
     zoomingToolStrip.Enabled = handler.IsZoomable;
     zoomToolStripLabel.Enabled = handler.IsZoomable;
     autoZoomToolStripButton.Enabled = handler.IsZoomable;
     UpdateZoomValue();
 }
Example #12
0
 protected override void TaskGrid_ZoomingStopped(IZoomable grid)
 {
     zoom.Time.Stop();
 }
 protected virtual void TaskGrid_ZoomingStopped(IZoomable grid)
 {
 }
 protected virtual void TaskGrid_Zooming(IZoomable grid, Vector3 scaling, Vector3 translation)
 {
 }
 protected override void TaskGrid_ZoomingStopped(IZoomable grid)
 {
     zoomingActivated = false;
 }
 protected override void TaskGrid_Zooming(IZoomable grid, Vector3 scaling, Vector3 translation)
 {
     zooming             = true;
     zoomingScaling      = Vector3.Scale(zoomingScaling, scaling);
     zoomingTranslation += translation;
 }
 protected override void TaskGrid_ZoomingStarted(IZoomable grid)
 {
     zoomingActivated = true;
 }
Example #18
0
 protected override void TaskGrid_ZoomingStarted(IZoomable grid)
 {
     zoom.Count++;
     zoom.Time.Start();
 }
Example #19
0
        public virtual bool CanZoomOut()
        {
            IZoomable zoomable = GetZoomable();

            return((_surfaceStack.Count > 1) || ((zoomable != null) && (zoomable.CanZoomOut())));
        }
Example #20
0
        public virtual bool CanZoomIn()
        {
            IZoomable zoomable = GetZoomable();

            return((zoomable != null) && (zoomable.CanZoomIn()));
        }
Example #21
0
 private void OnMouseMove(object sender, MouseEventArgs e)
 {
     mousePos = e.Location;
     foreach (var obj in Objects)
         if (obj.ClickLocation.IsPointIn(mousePos))
         {
             if (obj is IZoomable)
             {
                 if (zoomable == obj)
                     return;
                 zoomable = obj as IZoomable;
                 if (lastBitmap != null)
                     lock (lastBitmap)
                         lastBitmap = null;
             }
             if (obj is IHooverable)
             {
                 if (hover == obj)
                     return;
                 hover?.OnHoverLeave();
                 hover = obj as IHooverable;
                 hover.OnHover();
             }
             return;
         }
     zoomable = null;
 }