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(); }
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; }
void InstallScaleCore(IUIObjectProvider provider, IZoomable zoomable) { UninstallScale(); if (zoomable == null) { return; } this.zoomable = zoomable; SetZoomValue(zoomable.ZoomValue, force: true); }
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); }
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; } }
protected virtual void InternalZoomOut() { IZoomable zoomable = GetZoomable(); if ((zoomable != null) && (zoomable.CanZoomOut())) { zoomable.ZoomOut(); } else if (_surfaceStack.Count > 1) { Pop(); } }
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; }
protected override void Run() { IZoomable zoom = IdeApp.Workbench.ActiveDocument.GetContent <IZoomable> (true); zoom.ZoomReset(); }
protected override void TaskGrid_Zooming(IZoomable grid, Vector3 scaling, Vector3 translation) { }
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(); }
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; }
protected override void TaskGrid_ZoomingStarted(IZoomable grid) { zoom.Count++; zoom.Time.Start(); }
public virtual bool CanZoomOut() { IZoomable zoomable = GetZoomable(); return((_surfaceStack.Count > 1) || ((zoomable != null) && (zoomable.CanZoomOut()))); }
public virtual bool CanZoomIn() { IZoomable zoomable = GetZoomable(); return((zoomable != null) && (zoomable.CanZoomIn())); }
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; }