public static void Limit(IViewport viewport, ZoomMode zoomMode, MinMax zoomLimits, IReadOnlyList <double> mapResolutions, PanMode panMode, BoundingBox panLimits, BoundingBox mapEnvelope) { viewport.Resolution = LimitResolution(viewport.Resolution, viewport.Width, viewport.Height, zoomMode, zoomLimits, mapResolutions, mapEnvelope); LimitExtent(viewport, panMode, panLimits, mapEnvelope); }
/// <summary> /// Makes the image large enough so its maximum dimension fits snugly in the control. /// </summary> public void Reposition(ZoomMode zoomMode) { switch (zoomMode) { case ZoomMode.ActualSize: _xZoom = 1.0f; _yZoom = 1.0f; TopLeftOffset = new Point(0, 0); break; case ZoomMode.ZoomToFit: _xZoom = (float)ClientSize.Width / _image.Width; _yZoom = _xZoom; Offset = new Point(_image.Width / 2, _image.Height / 2); break; case ZoomMode.ZoomAndStretch: _xZoom = (float)ClientSize.Width / _image.Width; _yZoom = (float)ClientSize.Height / _image.Height; Offset = new Point(_image.Width / 2, _image.Height / 2); break; default: break; } }
/// <summary> /// this method draws the image with the image mode specified /// </summary> /// <param name="zoomMode">describes how the original image will appear in the control</param> public void ZoomImage(ZoomMode zoomMode) { var amount = 1d; Point center = new Point(this.Width / 2, this.Height / 2); int width = currentDisplayImage.Width; int height = currentDisplayImage.Height; switch (zoomMode) { case ZoomMode.ActualSize: amount = 1; break; case ZoomMode.FitHeight: amount = (double)this.Height / height; break; case ZoomMode.FitPage: amount = (double)this.Height / height; if ((double)this.Width / width < amount) { amount = (double)this.Width / width; } break; case ZoomMode.FitWidth: amount = (double)this.Width / width; break; default: throw new Exception("Invalid zoom request!!"); } ZoomImage(amount, center); }
/// <summary> /// _dos the update Z position target value. /// </summary> /// <param name="aViewportResizeDelta_float">A viewport resize delta_float.</param> /// <param name="aLastViewportResizeDelta_float">A last viewport resize delta_float.</param> /// <param name="aChangeAmount_float">A change amount_float.</param> private void _doUpdateZPositionTargetValue(bool aIsCurrentTargetRectWithinBoundary_boolean, bool aAreAllHighAndLowTrackableObjectsInView_boolean, float aChangeAmount_float) { Debug.Log(aChangeAmount_float); if (Mathf.Sign(aChangeAmount_float) < 0) { _currentZoomMode = ZoomMode.ZoomingOut; } else { _currentZoomMode = ZoomMode.ZoomingIn; } //******************************** //IF TARGET IS PROPERLY WITHIN BOUNDS THEN PROCEED TO DOLLY //******************************** if (_hasBordingPaddingChanged_boolean || _trackingMode == TrackingMode.CurrentlyTracking || _lastZoomMode == _currentZoomMode) { _zPosition_lerptarget.targetValue += aChangeAmount_float; _lastZoomMode = _currentZoomMode; } //RESET _hasBordingPaddingChanged_boolean = false; }
/// <summary> /// Loads image at default zoom and position. /// (If you DON'T wish to reposition use the <see cref="Image"/> property instead.) /// </summary> public void LoadImage(Image image, ZoomMode zoomMode) { _image = image; _xZoom = _maxZoom; _yZoom = _maxZoom; _offset = new Point(image.Width / 2, image.Height / 2); Reposition(zoomMode); }
public FRPreview() { Inicializando = true; pageImages = new List <Image>(); BackColor = SystemColors.AppWorkspace; zoomMode = ZoomMode.FullPage; startPage = 0; SetStyle(ControlStyles.OptimizedDoubleBuffer, true); InitializeComponent(); Inicializando = false; }
private void setProperties(float left, float top, float width, float height, int zoom, ZoomMode zoomMode) { _left = left; _top = top; _width = width; _height = height; _zoom = zoom; _zoomMode = zoomMode; createArray(); }
/// <summary> /// Initializes a new instance of the Bytescout.PDF.Destination. /// </summary> /// <param name="page">The destination page.</param> public Destination(Page page) { if (page == null) { throw new ArgumentNullException("page"); } _page = page; _zoomMode = ZoomMode.FitXYZ; createArray(); }
//Zoom on the centre of the graph window. private void Zoom(ZoomMode zoomMode) { //Zoom with using the mousePosition. //Initialise local variables. int MaxZoomValue = 8, MinZoomValue = -15; if (zoomMode == ZoomMode.ZoomIn && ZoomValue >= MinZoomValue) { //Decrement zoom value. ZoomValue--; graphProperties.IncrementX *= Math.Pow(2, -1); graphProperties.IncrementY *= Math.Pow(2, -1); graphProperties.XStart += graphProperties.XRange / 4; graphProperties.XEnd -= graphProperties.XRange / 4; graphProperties.YStart += graphProperties.YRange / 4; graphProperties.YEnd -= graphProperties.YRange / 4; //Transform drawing and data line batches. _penLineBatch.ScaleLines(graphProperties.CanvasWidth, graphProperties.CanvasHeight, ZoomMode.ZoomIn); foreach (var plot in _plots) { plot.ScaleLines(graphProperties.CanvasWidth, graphProperties.CanvasHeight, ZoomMode.ZoomIn); } } else if (zoomMode == ZoomMode.ZoomOut && ZoomValue <= MaxZoomValue) { //Increment zoom. ZoomValue++; graphProperties.XStart -= graphProperties.XRange / 2; graphProperties.XEnd += graphProperties.XRange / 2; graphProperties.YStart -= graphProperties.YRange / 2; graphProperties.YEnd += graphProperties.YRange / 2; graphProperties.IncrementX *= Math.Pow(2, 1); graphProperties.IncrementY *= Math.Pow(2, 1); //Transform drawing and data line batches. _penLineBatch.ScaleLines(graphProperties.CanvasWidth, graphProperties.CanvasHeight, ZoomMode.ZoomOut); foreach (var plot in _plots) { plot.ScaleLines(graphProperties.CanvasWidth, graphProperties.CanvasHeight, ZoomMode.ZoomOut); } } //Update graph to apply changes. Update(); }
partial void OnZoomModeChangedPartial(ZoomMode zoomMode) { if (_presenter != null) { _presenter.IsZoomEnabled = zoomMode == ZoomMode.Enabled; // Apply these in case _presenter was not initialized when they were set _presenter.MinimumZoomScale = MinZoomFactor; _presenter.MaximumZoomScale = MaxZoomFactor; } }
private static ToolStripMenuItem CreateMenuItem(ZoomMode mode, int zoomPercent, EventHandler handler, bool selected) { ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem(); toolStripMenuItem.Click += handler; toolStripMenuItem.Checked = selected; ZoomItem zoomItem = new ZoomItem(mode, zoomPercent); toolStripMenuItem.Text = zoomItem.ToString(); toolStripMenuItem.Tag = zoomItem; return(toolStripMenuItem); }
//public static Layer Current //{ // get // { // // Controleer eerst of currentLayer null is // // Zoja geef dan de eerste/laatste?? laag terug // return new Layer(); // } // set { ; } //} //public static Layer GetCurrentLayer(List<Group> groups) //{ // return new Layer(); //} private static void Zoom(Aggregate aggregator, ZoomMode zoomMode, int layerHandle) { if (zoomMode == ZoomMode.ZoomToExtents) { // Zoom to maxExtents aggregator.MapWin.ZoomToMaxExtents(); } else { // Zoom to the extents of the given layer aggregator.MapWin.ZoomToLayer(layerHandle); } }
private static bool NeedCustomEntry(ZoomMode zoomMode, int zoomPercent) { if (zoomMode != ZoomMode.Percent) { return(false); } int[] defaultPercents = DefaultPercents; foreach (int num in defaultPercents) { if (zoomPercent == num) { return(false); } } return(true); }
partial void OnZoomModeChangedPartial(ZoomMode zoomMode) { // On iOS, zooming is disabled by setting Minimum/MaximumZoomScale both to 1 switch (zoomMode) { default: _presenter?.OnMinZoomFactorChanged(1f); _presenter?.OnMaxZoomFactorChanged(1f); break; case ZoomMode.Enabled: _presenter?.OnMinZoomFactorChanged(MinZoomFactor); _presenter?.OnMaxZoomFactorChanged(MaxZoomFactor); break; } }
public void Zoom(ZoomMode mode) { if (mode == ZoomMode.Normal) { this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; this.pictureBox1.Dock = DockStyle.None; this.pictureBox1.Location = Point.Empty; this.pictureBox1.Invalidate(); } if (mode == ZoomMode.Fit) { this.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; this.pictureBox1.Dock = DockStyle.Fill; this.pictureBox1.Invalidate(); } }
public static void LimitResolution(IViewport viewport, ZoomMode zoomMode, MinMax zoomLimits, IReadOnlyList <double> mapResolutions, BoundingBox mapEnvelope) { if (zoomMode == ZoomMode.None) { return; } var resolutionExtremes = zoomLimits ?? GetExtremes(mapResolutions); if (resolutionExtremes == null) { return; } if (zoomMode == ZoomMode.KeepWithinResolutions) { if (resolutionExtremes.Min > viewport.Resolution) { viewport.Resolution = resolutionExtremes.Min; } if (resolutionExtremes.Max < viewport.Resolution) { viewport.Resolution = resolutionExtremes.Max; } } else if (zoomMode == ZoomMode.KeepWithinResolutionsAndAlwaysFillViewport) { if (resolutionExtremes.Min > viewport.Resolution) { viewport.Resolution = resolutionExtremes.Min; } // This is the ...AndAlwaysFillViewport part var viewportFillingResolution = CalculateResolutionAtWhichMapFillsViewport(viewport, mapEnvelope); if (viewportFillingResolution < resolutionExtremes.Min) { viewport.Resolution = viewport.Resolution; // Mission impossible. Can't adhere to both restrictions } var limit = Math.Min(resolutionExtremes.Max, viewportFillingResolution); if (limit < viewport.Resolution) { viewport.Resolution = limit; } } }
public IEnumerator AutoZoom(float amout, bool giveControl = false, float speed = 1) { float bigger = _initZoomAmount + amout + speed; float smaller = _initZoomAmount + amout - speed; _wheelSpeed = -speed *Mathf.Sign(amout); while (!((_zoomAmount < bigger) && (_zoomAmount > smaller))) { yield return(null); } _wheelSpeed = 0; if (giveControl) { _autoZoom = ZoomMode.Initial; } }
public void ToggleZoom(ZoomMode mode) { switch (mode) { case ZoomMode.Full: _tilesetAccessor.TileWidthAndSizeInPixels = 25; break; case ZoomMode.Half: _tilesetAccessor.TileWidthAndSizeInPixels = 12; break; default: throw new ArgumentException(string.Format("The given '{0}' is currently not supported.", mode), nameof(mode)); } _canvasPanel.Size = _tilesetAccessor.GetAreaSize(SimulationSession.Area); _zoomStateChanged = true; }
private void Update() { if (Input.GetKeyDown(KeyCode.P) && ReferenceBuffer.Instance.focusManager.SafeToTrigger()) { this.connTracker.Persist(); } // if (Input.GetKeyDown(KeyCode.R) && ReferenceBuffer.Instance.focusManager.SafeToTrigger()) // { // this.ResetData(); // } if (Input.GetKeyDown(KeyCode.T) && ReferenceBuffer.Instance.focusManager.SafeToTrigger()) { this.inputCanvas.InputsHide(); } if (Input.GetKeyDown(KeyCode.G) && ReferenceBuffer.Instance.focusManager.SafeToTrigger()) { this.connRegisterer.ResetToNull(); } if (Input.GetKeyDown(KeyCode.G) && ReferenceBuffer.Instance.focusManager.SafeToTrigger()) { this.resultCanvas.Show(); this.camHandling.SetRotateToView(this.resultCanvasVantigePoint); } if (Input.GetKeyDown(KeyCode.Escape)) { if (this.inputCanvas.AreInputsShowing()) { this.inputCanvas.InputsHide(); } else { this.camHandling.UntriggerZoom(); this.zoomMode = ZoomMode.OuterZoom; } } this.DragControllsOnUpdate(); }
// Update is called once per frame void Update() { if (CurrentMode == ZoomMode.Paused) { if (++Timer >= PauseDelay) { CurrentMode = ZoomMode.ZoomingIn; Timer = 0; } } else if (CurrentMode == ZoomMode.ZoomingIn) { Camera.main.fieldOfView -= ZoomSpeed; if (Camera.main.fieldOfView <= ScareZoom) { Camera.main.fieldOfView = ScareZoom; CurrentMode = ZoomMode.ZoomingOut; } } else if (CurrentMode == ZoomMode.ZoomingOut) { Camera.main.fieldOfView += ScareSpeed; if (Camera.main.fieldOfView >= SettleZoom) { Camera.main.fieldOfView = SettleZoom; CurrentMode = ZoomMode.Settle; Speed = ScareSpeed; } } else if (CurrentMode == ZoomMode.Settle) { Camera.main.fieldOfView += Speed; if (Speed >= -SettleSpeed) { Speed -= SettleAccel; } if (Camera.main.fieldOfView <= NormalZoom) { Camera.main.fieldOfView = NormalZoom; CurrentMode = ZoomMode.Paused; } } }
private float getNextZoomValue(ZoomMode zoomMode) { float newZoom = zoom; if (zoomSteps.Count > 0) { float maxZoom = zoomSteps[zoomSteps.Count - 1]; if (zoomMode == ZoomMode.In) { //find next bigger zoom step if (newZoom < maxZoom) { for (int i = 0; i < zoomSteps.Count; i++) { if (zoomSteps[i] > newZoom) { newZoom = zoomSteps[i]; break; } } } } else { //find the next smaller zoom step for (int i = zoomSteps.Count - 1; i >= 0; i--) { if (zoomSteps[i] < newZoom) { newZoom = zoomSteps[i]; break; } } } } return(newZoom); }
//Scale lines by factors of 2 depending on ZoomMode. public void ScaleLines(double canvasWidth, double canvasHeight, ZoomMode zoomMode) { if (zoomMode == ZoomMode.ZoomIn) { foreach (LightLine line in BatchList) { line.X1 = 2 * line.X1 - canvasWidth / 2; line.X2 = 2 * line.X2 - canvasWidth / 2; line.Y1 = 2 * line.Y1 - canvasHeight / 2; line.Y2 = 2 * line.Y2 - canvasHeight / 2; } } else if (zoomMode == ZoomMode.ZoomOut) { foreach (LightLine line in BatchList) { line.X1 = (2 * line.X1 + canvasWidth) / 4; line.X2 = (2 * line.X2 + canvasWidth) / 4; line.Y1 = (2 * line.Y1 + canvasHeight) / 4; line.Y2 = (2 * line.Y2 + canvasHeight) / 4; } } }
public static void Populate(ToolStripComboBox comboBox, ZoomMode selectedMode, int selectedPercent) { comboBox.Items.Clear(); comboBox.Items.Add(new ZoomItem(ZoomMode.PageWidth, 100)); comboBox.Items.Add(new ZoomItem(ZoomMode.FullPage, 100)); if (selectedMode != ZoomMode.Percent) { comboBox.SelectedIndex = ((selectedMode != ZoomMode.PageWidth) ? 1 : 0); } int[] defaultPercents = DefaultPercents; foreach (int num in defaultPercents) { comboBox.Items.Add(new ZoomItem(ZoomMode.Percent, num)); if (selectedMode == ZoomMode.Percent && selectedPercent == num) { comboBox.SelectedIndex = comboBox.Items.Count - 1; } } if (NeedCustomEntry(selectedMode, selectedPercent)) { comboBox.Items.Add(new ZoomItem(selectedMode, selectedPercent)); comboBox.SelectedIndex = comboBox.Items.Count - 1; } }
/// <summary> /// this method draws the image with the image mode specified /// </summary> /// <param name="zoomMode">describes how the original image will appear in the control</param> public void ZoomImage(ZoomMode zoomMode) { var amount = 1d; Point center; switch (zoomMode) { case ZoomMode.ActualSize: amount = 1; center = new Point(OriginalImage.Width / 2, OriginalImage.Height / 2); break; case ZoomMode.FitHeight: amount = (double)this.Height / OriginalImage.Height; center = new Point(OriginalImage.Width / 2, OriginalImage.Height / 2); break; case ZoomMode.FitPage: amount = (double)this.Height / OriginalImage.Height; if ((double)this.Width / OriginalImage.Width < amount) { amount = this.Width / OriginalImage.Width; } center = new Point(OriginalImage.Width / 2, OriginalImage.Height / 2); break; case ZoomMode.FitWidth: amount = (double)this.Width / OriginalImage.Width; center = new Point(OriginalImage.Width / 2, OriginalImage.Height / 2); break; default: throw new Exception("Invalid zoom request!!"); } ZoomImage(amount, center); }
private void parseZoomMode(PDFArray arr) { PDFName mode = arr[1] as PDFName; _zoomMode = TypeConverter.PDFNameToPDFZoomMode(mode); }
public void ZoomFitAll(bool relocate) { // TODO: Focus if (Image != null) { var ratio = Image.Width / (double)Image.Height; int newWidth; int newHeight; if (Image.Width > Image.Height) { if (Width > Height) { newHeight = Height; newWidth = (int)(newHeight * ratio); } else { newWidth = Width; newHeight = (int)(newWidth / ratio); } } else { if (Width > Height) { newHeight = Height; newWidth = (int)(newHeight * ratio); } else { newWidth = Width; newHeight = (int)(newWidth / ratio); } } var newX = Width / 2 - newWidth / 2; var newY = relocate ? Height / 2 - newHeight / 2 : _pictureBox.Top; MoveImage(newX, newY, newWidth, newHeight); } _zoomMode = ZoomMode.FitAll; }
private void Zoom(double factor) { // TODO: Focus var newWidth = (int)(_pictureBox.Width * factor); var newHeight = (int)(_pictureBox.Height * factor); var newX = _pictureBox.Left - (newWidth / 2 - _pictureBox.Width / 2); var newY = _pictureBox.Top - (newHeight / 2 - _pictureBox.Height / 2); if (newY > 0) newY = 0; MoveImage(newX, newY, newWidth, newHeight); _zoomMode = ZoomMode.Zoom; }
/// <summary> /// this method draws the image with the image mode specified /// </summary> /// <param name="zoomMode">describes how the original image will appear in the control</param> public void ZoomImage(ZoomMode zoomMode) { var amount = 1d; Point center; switch (zoomMode) { case ZoomMode.ActualSize: amount = 1; center = new Point(OriginalImage.Width / 2, OriginalImage.Height / 2); break; case ZoomMode.FitHeight: amount = (double)this.Height / OriginalImage.Height; center = new Point(OriginalImage.Width / 2, OriginalImage.Height / 2); break; case ZoomMode.FitPage: amount = (double)this.Height / OriginalImage.Height; if ((double)this.Width / OriginalImage.Width < amount) amount = this.Width / OriginalImage.Width; center = new Point(OriginalImage.Width / 2, OriginalImage.Height / 2); break; case ZoomMode.FitWidth: amount = (double)this.Width / OriginalImage.Width; center = new Point(OriginalImage.Width / 2, OriginalImage.Height / 2); break; default: throw new Exception("Invalid zoom request!!"); } ZoomImage(amount, center); }
/// <summary> /// Reset data. /// </summary> public void Reset() { FramelineShowed = true; StartingTime = 0.0; ZoomScale = 1.0; ZoomMode = ZoomMode.FrameLevel; Duration = 0.0; }
/// <summary> /// _dos the update Z position target value. /// </summary> /// <param name="aViewportResizeDelta_float">A viewport resize delta_float.</param> /// <param name="aLastViewportResizeDelta_float">A last viewport resize delta_float.</param> /// <param name="aChangeAmount_float">A change amount_float.</param> private void _doUpdateZPositionTargetValue (bool aIsCurrentTargetRectWithinBoundary_boolean, bool aAreAllHighAndLowTrackableObjectsInView_boolean, float aChangeAmount_float) { Debug.Log (aChangeAmount_float); if (Mathf.Sign (aChangeAmount_float) < 0) { _currentZoomMode = ZoomMode.ZoomingOut; } else { _currentZoomMode = ZoomMode.ZoomingIn; } //******************************** //IF TARGET IS PROPERLY WITHIN BOUNDS THEN PROCEED TO DOLLY //******************************** if (_hasBordingPaddingChanged_boolean || _trackingMode == TrackingMode.CurrentlyTracking || _lastZoomMode == _currentZoomMode) { _zPosition_lerptarget.targetValue += aChangeAmount_float; _lastZoomMode = _currentZoomMode; } //RESET _hasBordingPaddingChanged_boolean = false; }
private void OnZoomModeChanged(ZoomMode zoomMode) { OnZoomModeChangedPartial(zoomMode); }
private JSValue JS_Zoom_SetModeWidth(object sender, JavascriptMethodEventArgs args) { zoomMode = ZoomMode.Width; return null; }
/// <summary> /// this method draws the image with the image mode specified /// </summary> /// <param name="zoomMode">describes how the original image will appear in the control</param> public void ZoomImage(ZoomMode zoomMode) { var amount = 1d; Point center = new Point(this.Width / 2, this.Height / 2); int width = currentDisplayImage.Width; int height = currentDisplayImage.Height; switch (zoomMode) { case ZoomMode.ActualSize: amount = 1; break; case ZoomMode.FitHeight: amount = (double)this.Height / height; break; case ZoomMode.FitPage: amount = (double)this.Height / height; if ((double)this.Width / width < amount) amount = (double)this.Width / width; break; case ZoomMode.FitWidth: amount = (double)this.Width / width; break; default: throw new Exception("Invalid zoom request!!"); } ZoomImage(amount, center); }
//Zoom in on the position of the mouse cursor. public void Zoom(ZoomMode zoomMode, Point mousePosition) { //Zoom with using mouse position. //Initialise local variables. int MaxZoomValue = 8, MinZoomValue = -15; double xOffSet = 0; double yOffSet = 0; //If the graph is to be zoomed in. if (zoomMode == ZoomMode.ZoomIn && ZoomValue >= MinZoomValue) { //Apply mousePositon translation. xOffSet = graphProperties.CanvasWidth / 2 + -mousePosition.X; yOffSet = graphProperties.CanvasHeight / 2 + -mousePosition.Y; //Decrement ZoomValue. ZoomValue--; graphProperties.IncrementX *= Math.Pow(2, -1); graphProperties.IncrementY *= Math.Pow(2, -1); graphProperties.XStart -= xOffSet * graphProperties.IncrementX / graphProperties.XInterval; graphProperties.XEnd -= xOffSet * graphProperties.IncrementX / graphProperties.XInterval; graphProperties.YStart += yOffSet * graphProperties.IncrementY / graphProperties.YIncrement; graphProperties.YEnd += yOffSet * graphProperties.IncrementY / graphProperties.YIncrement; graphProperties.XStart += graphProperties.XRange / 4; graphProperties.XEnd -= graphProperties.XRange / 4; graphProperties.YStart += graphProperties.YRange / 4; graphProperties.YEnd -= graphProperties.YRange / 4; _penLineBatch.ScaleLines(graphProperties.CanvasWidth, graphProperties.CanvasHeight, ZoomMode.ZoomIn); _penLineBatch.TranslateLines(xOffSet, yOffSet); foreach (var plot in _plots) { plot.ScaleLines(graphProperties.CanvasWidth, graphProperties.CanvasHeight, ZoomMode.ZoomIn); plot.TranslateLines(xOffSet, yOffSet); } } //If the graph is to be zoomed out. else if (zoomMode == ZoomMode.ZoomOut && ZoomValue <= MaxZoomValue) { //Apply mousePositon translation. xOffSet = -graphProperties.CanvasWidth / 2 + mousePosition.X; yOffSet = -graphProperties.CanvasHeight / 2 + mousePosition.Y; //Increment ZoomValue. ZoomValue++; graphProperties.XStart -= graphProperties.XRange / 2; graphProperties.XEnd += graphProperties.XRange / 2; graphProperties.YStart -= graphProperties.YRange / 2; graphProperties.YEnd += graphProperties.YRange / 2; graphProperties.XStart -= xOffSet * graphProperties.IncrementX / graphProperties.XInterval; graphProperties.XEnd -= xOffSet * graphProperties.IncrementX / graphProperties.XInterval; graphProperties.YStart += yOffSet * graphProperties.IncrementY / graphProperties.YIncrement; graphProperties.YEnd += yOffSet * graphProperties.IncrementY / graphProperties.YIncrement; graphProperties.IncrementX *= Math.Pow(2, 1); graphProperties.IncrementY *= Math.Pow(2, 1); _penLineBatch.TranslateLines(xOffSet, yOffSet); _penLineBatch.ScaleLines(graphProperties.CanvasWidth, graphProperties.CanvasHeight, ZoomMode.ZoomOut); foreach (var plot in _plots) { plot.TranslateLines(xOffSet, yOffSet); plot.ScaleLines(graphProperties.CanvasWidth, graphProperties.CanvasHeight, ZoomMode.ZoomOut); } } //Update to graph to finalise changes. Update(); }
public void ZoomFitWidth(bool relocate) { if (Image != null) { var imageRatio = Image.Width / (double)Image.Height; var newWidth = Image.Width > Width ? Width : Image.Width; var newHeight = (int)(newWidth / imageRatio); var newX = Width / 2 - newWidth / 2; var newY = Image.Height > Height ? 0 : Height / 2 - newHeight / 2; MoveImage(newX, newY, newWidth, newHeight); } _zoomMode = ZoomMode.FitWidth; }
partial void OnZoomModeChangedPartial(ZoomMode zoomMode);
public void ZoomOriginal(bool relocate) { if (Image != null) { var newWidth = Image.Size.Width; var newHeight = Image.Size.Height; var newX = Width / 2 - newWidth / 2; var newY = 0; MoveImage(newX, newY, newWidth, newHeight); } _zoomMode = ZoomMode.OriginalSize; }
internal virtual void HandleMouse() { if (Input.GetMouseButton(1)) { // 右ボタンドラッグで回転 if ((axes & RotationAxes.Yaw) > RotationAxes.None) { rotation.y += Input.GetAxis("Mouse X") * sensitivityX; rotation.y = ClampAngle(rotation.y, minimumAngles.y, maximumAngles.y); } if ((axes & RotationAxes.Pitch) > RotationAxes.None) { rotation.x -= Input.GetAxis("Mouse Y") * sensitivityY; rotation.x = ClampAngle(rotation.x, minimumAngles.x, maximumAngles.x); } UpdateTransform(); } else if (Input.GetMouseButton(2)) { // 中ボタンドラッグで並進移動 Vector3 screenVector = new Vector3( Input.GetAxis("Mouse X") * dragSensitivity, Input.GetAxis("Mouse Y") * dragSensitivity, 0f ); //translation -= transform.rotation * screenVector; translation -= screenVector; UpdateTransform(); } else { // ホイールで接近・離脱 float wheelDelta = Input.GetAxis("Mouse ScrollWheel") * wheelSensitivity; ZoomMode mode = zoomMode; // Shiftキーが押されていて、かつZoomModeがZoomかDollyならば、モードを入れ替える if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { if (mode == ZoomMode.Dolly) { mode = ZoomMode.Zoom; } else if (mode == ZoomMode.Zoom) { mode = ZoomMode.Dolly; } } if (wheelDelta != 0f) { if ((mode & ZoomMode.Dolly) != ZoomMode.None) { // ドリーの場合。カメラを近づけたり遠ざけたり。 dolly += wheelDelta; dolly = Mathf.Clamp(dolly, -2f, 5f); // Logarithm of distance [m] range distance = originalDistance * Mathf.Pow(10f, -dolly); UpdateTransform(); } else if ((mode & ZoomMode.Zoom) != ZoomMode.None) { // ズームの場合。カメラのFOVを変更 zoom -= wheelDelta; zoom = Mathf.Clamp(zoom, -1f, 2f); // Logarithm of field-of-view [deg] range UpdateTransform(); } } } }
public void Save(string fileName, int width, int height, ZoomMode zoomMode=ZoomMode.GeometricProportion) { using (Image originalImg = Image.FromStream(_stream)) { Size size = originalImg.Size; switch (zoomMode) { case ZoomMode.GeometricProportion: if (size.Width > width || size.Height > height) { float scale = Math.Min((float)width / size.Width, (float)height / size.Height); size = new Size((int)(scale * size.Width), (int)(scale * size.Height)); } break; case ZoomMode.Fixed: size = new Size(width, height); break; } using (Bitmap bmp = new Bitmap(size.Width, size.Height)) using (Graphics g = Graphics.FromImage(bmp)) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.Clear(Color.Transparent); g.DrawImage(originalImg, 0, 0, size.Width, size.Height); bmp.Save(GetFilePath(fileName),ImageFormat.Jpeg); } } }
public static double LimitResolution(double resolution, double screenWidth, double screenHeight, ZoomMode zoomMode, MinMax zoomLimits, IReadOnlyList <double> mapResolutions, BoundingBox mapEnvelope) { if (zoomMode == ZoomMode.Unlimited) { return(resolution); } var resolutionExtremes = zoomLimits ?? GetExtremes(mapResolutions); if (resolutionExtremes == null) { return(resolution); } if (zoomMode == ZoomMode.KeepWithinResolutions) { if (resolutionExtremes.Min > resolution) { return(resolutionExtremes.Min); } if (resolutionExtremes.Max < resolution) { return(resolutionExtremes.Max); } } else if (zoomMode == ZoomMode.KeepWithinResolutionsAndAlwaysFillViewport) { if (resolutionExtremes.Min > resolution) { return(resolutionExtremes.Min); } // This is the ...AndAlwaysFillViewport part var viewportFillingResolution = CalculateResolutionAtWhichMapFillsViewport(screenWidth, screenHeight, mapEnvelope); if (viewportFillingResolution < resolutionExtremes.Min) { return(resolution); // Mission impossible. Can't adhere to both restrictions } var limit = Math.Min(resolutionExtremes.Max, viewportFillingResolution); if (limit < resolution) { return(limit); } } return(resolution); }
private JSValue JS_Zoom_SetModeHeight(object sender, JavascriptMethodEventArgs args) { zoomMode = ZoomMode.Height; return null; }