public float SetZoom(ZoomType type) { switch (type) { case ZoomType.Minus: { _index--; if (_index < 0) { _index = 0; } return(Configuration.MySettings.ZoomValue = _zooms[_index]); } case ZoomType.Plus: { _index++; if (_index > _zooms.Length - 1) { _index = _zooms.Length - 1; } return(Configuration.MySettings.ZoomValue = _zooms[_index]); } default: return(_zooms[_index]); } }
public void PageZoom(ZoomType zoomType) { this.zoom_type = zoomType; // Store the favourite zoom if (remember_last_read_page) { switch (zoomType) { case ZoomType.Zoom1Up: ConfigurationManager.Instance.ConfigurationRecord.GUI_LastPagesUp = "1"; break; case ZoomType.Zoom2Up: ConfigurationManager.Instance.ConfigurationRecord.GUI_LastPagesUp = "2"; break; case ZoomType.ZoomNUp: ConfigurationManager.Instance.ConfigurationRecord.GUI_LastPagesUp = "N"; break; case ZoomType.ZoomWholeUp: ConfigurationManager.Instance.ConfigurationRecord.GUI_LastPagesUp = "W"; break; default: break; } } ReconsiderZoom(); }
private void ZoomCtrl() { if (OnFingerZoom == null) { return; } ZoomType zoomType = ZoomType.None; #if UNITY_EDITOR || UNITY_STANDALONE_WIN if (Input.GetAxis("Mouse ScrollWheel") > 0) { zoomType = ZoomType.In; } if (Input.GetAxis("Mouse ScrollWheel") < 0) { zoomType = ZoomType.Out; } #elif UNITY_IPHONE || UNITY_ANDROID if (Input.touchCount == 2) { if (Vector2.Distance(oldFingerPos1, oldFingerPos2) > Vector2.Distance(oldFingerPos1, oldFingerPos2)) { zoomType = ZoomType.Out; } else { zoomType = ZoomType.In; } oldFingerPos1 = Input.touches[0].position; oldFingerPos2 = Input.touches[1].position; } #endif OnFingerZoom(zoomType); }
// Open filedialog to ask user to select new file private void openNewFile() { if (isGIF) { timer1.Stop(); } using (OpenFileDialog openFileDialog1 = new OpenFileDialog()) { openFileDialog1.InitialDirectory = currentDir.FullName; openFileDialog1.Filter = "image files|*.jpg;*.JPG;*.jpeg;*.png;*.gif|All files|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { imagefilepath = new FileInfo(openFileDialog1.FileName); currentDir = new DirectoryInfo(imagefilepath.DirectoryName); newFileList(); Image = (Bitmap)Bitmap.FromFile(imagefilepath.FullName); zoomType = ZoomType.Center; firstDraw = true; pictureBox1.Invalidate(); updateFormText(); setGIF(); } } }
public static Size CalculateImageSize(ZoomType ZoomType, Size FromSize, Size ToSize) { if (ZoomType == ZoomType.CenterIfNoZoom) { if (FromSize.Width < ToSize.Width && FromSize.Height < ToSize.Height) { ZoomType = Drawing.ZoomType.Center; } else { ZoomType = Drawing.ZoomType.Zoom; } } switch (ZoomType) { case Drawing.ZoomType.Tile: return(ToSize); case Drawing.ZoomType.Center: var left = (FromSize.Width - ToSize.Width) / 2; var top = (FromSize.Height - ToSize.Height) / 2; return(new Size(left < 0 ? ToSize.Width : ToSize.Width - left, top < 0 ? ToSize.Height : ToSize.Height - top)); case Drawing.ZoomType.Stretch: return(ToSize); case Drawing.ZoomType.Zoom: int nw, nh; SetZoomSize(FromSize.Width, FromSize.Height, ToSize.Width, ToSize.Height, out nw, out nh); return(new Size(nw, nh)); } return(ToSize); }
public void Execute(object parameter) { ZoomType type = (ZoomType)Enum.Parse(typeof(ZoomType), (string)parameter, true); switch (type) { case ZoomType.ZoomIn: _data.Zoom *= 1.2; break; case ZoomType.ZoomOut: _data.Zoom /= 1.2; break; case ZoomType.Normal: _data.Zoom = 1; break; case ZoomType.Change: _data.ImagePath = "C:\\Users\\jicwang\\Documents\\Study\\Code\\CSharp\\WPF\\WPFMVVMDemo\\WPFMVVMDemo\\WPFMVVMDemo\\Images\\000.ico"; break; default: break; } }
public void ZoomAs(ZoomType zoomType) { if (OriginalContentSize.IsEmpty) { return; } Rectangle rect = ViewPort; if (rect.Width <= 0 || rect.Height <= 0) { return; } switch (zoomType) { case ZoomType.FitPage: Zoom = Math.Min((float)rect.Width / OriginalContentSize.Width, (float)rect.Height / OriginalContentSize.Height); break; case ZoomType.FitWidth: Zoom = (float)rect.Width / OriginalContentSize.Width; break; case ZoomType.FitHeight: Zoom = (float)rect.Height / OriginalContentSize.Height; break; } }
public void SetZoomType(ZoomType zoomType) { //ExStart //ExFor:Document.ViewOptions //ExFor:ViewOptions //ExFor:ViewOptions.ZoomType //ExSummary:Shows how to set a custom zoom type, which older versions of Microsoft Word will apply to a document upon loading. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Hello world!"); // Set the "ZoomType" property to "ZoomType.PageWidth" to get Microsoft Word // to automatically zoom the document to fit the width of the page. // Set the "ZoomType" property to "ZoomType.FullPage" to get Microsoft Word // to automatically zoom the document to make the entire first page visible. // Set the "ZoomType" property to "ZoomType.TextFit" to get Microsoft Word // to automatically zoom the document to fit the inner text margins of the first page. doc.ViewOptions.ZoomType = zoomType; doc.Save(ArtifactsDir + "ViewOptions.SetZoomType.doc"); //ExEnd doc = new Document(ArtifactsDir + "ViewOptions.SetZoomType.doc"); Assert.AreEqual(zoomType, doc.ViewOptions.ZoomType); }
public static void ChangeZoom(ZoomType newZoom) { if (newZoom != ActiveZoomType) { ActiveZoomType = newZoom; Form.RepaintMap(); } }
public async void ImageZoom(Point point, ScrollViewer sv, Image img, ZoomType zoomtype = ZoomType.DotByDot) { var bmp = img.Source as BitmapSource; if (bmp == null) { return; } if (bmp.PixelHeight == 0 || bmp.PixelWidth == 0) { return; } float?zoom = 1; //枠内 if (sv.ActualHeight > bmp.PixelHeight && sv.ActualWidth > bmp.PixelWidth) { sv.ChangeView(null, null, zoom); sv.MinZoomFactor = (float)zoom; return; } sv.IsEnabled = false; //枠外 zoom = (float?)(1 / (bmp.PixelHeight / sv.ActualHeight) * 0.99); var temp_zoom = (float?)(1 / (bmp.PixelWidth / sv.ActualWidth) * 0.99); if (temp_zoom < zoom) { zoom = temp_zoom; } if (zoom > 0.1) { sv.MinZoomFactor = (float)zoom; } float?horizontaloffset = (float?)(point.X - sv.ActualWidth / 2.0); float?verticaloffset = (float?)(point.Y - sv.ActualHeight / 2.0); switch (zoomtype)//1:デフォルト 2:ドットバイドット<=>デフォルト { case ZoomType.UniformToFill: sv.ChangeView(null, null, zoom); break; case ZoomType.DotByDot: var z = (int)(sv.ZoomFactor * 1000) - (int)(zoom * 1000); if (z > -3 && 3 > z) { zoom = 1; } sv.ChangeView(horizontaloffset, verticaloffset, zoom); break; } await Task.Delay(300); sv.IsEnabled = true; }
public void Zoom(ZoomType zoomType) { // Modify the spacing between labels until we hit a limit. // if we hit the spacing limit, we merge labels together and reset the spacing. // update the displayRange variable to keep it in sync with what is currently displayed. // check that labels are not null to determine maximum zooming levels. }
public static Bitmap ResizeImage(this Bitmap b, Size size, ZoomType ZoomType) { var bit = new Bitmap(size.Width, size.Height); using (var g = Graphics.FromImage(bit)) { g.DrawImageEx(b, new Rectangle(0, 0, size.Width, size.Height), ZoomType); } return(bit); }
private void MouseDown(MouseEventArgs e, EventHandleStatus status) { if (e.Button == MouseButtons.Left) { _beginPoint = e.Location; _prePoint = _beginPoint; _zoomType = ZoomType.Pan; status.Handled = true; } }
public void SetZoom(Transform target, ZoomType type) { m_zoomTarget = target; m_curZoomParam = m_zoomParam[(int)type]; if (m_timerDelay != null) { m_timerDelay.stop = true; m_timerDelay.Reset(); } m_timerDelay = new GameUtils.Timer4View(m_curZoomParam.m_fTimeDelay, Init, 1); }
/// <summary> /// Scale viewer to size specified by zoom /// </summary> /// <param name="viewer">Document to zoom</param> /// <param name="zoom">Zoom Enumeration to specify how pages are stretched in print and preview</param> public static void Zoom(DocumentViewer viewer, ZoomType zoom) { switch (zoom) { case ZoomType.Height: viewer.FitToHeight(); break; case ZoomType.Width: viewer.FitToWidth(); break; case ZoomType.TwoWide: viewer.FitToMaxPagesAcross(2); break; case ZoomType.Full: break; } }
/// <summary> /// 摄像机缩放 /// </summary> /// <param name="obj"></param> private void OnZoom(ZoomType obj) { switch (obj) { case ZoomType.In: CameraCtrl.Instance.SetCameraZoom(0); break; case ZoomType.Out: CameraCtrl.Instance.SetCameraZoom(1); break; } }
float GetGoalOrthoSize(ZoomType zoomType) { if (zoomType == ZoomType.In) { zoomLevel--; return(cam.orthographicSize / zoomFactor); } else { zoomLevel++; return(cam.orthographicSize * zoomFactor); } }
public ZoomImageCommand(ZoomType zoomType, VideoCaptureDevice videoCaptureDevice) { Safeguard.EnsureNotNull("videoCaptureDevice", videoCaptureDevice); this.zoomType = zoomType; this.videoCaptureDevice = videoCaptureDevice; if (!Initialized) { this.videoCaptureDevice.GetCameraPropertyRange(CameraControlProperty.Zoom, out MinZoom, out MaxZoom, out StepSize, out DefaultValue, out ControlFlags); Initialized = true; } }
internal void ToggleZoom() { if (zoom_type == ZoomType.ZoomNUp) { zoom_type = ZoomType.ZoomWholeUp; } else { zoom_type = ZoomType.ZoomNUp; } ReconsiderZoom(); }
/// <summary> /// Converte o tipo para o formato do c3 /// </summary> /// <param name="zoomType">A maneira de realizar o zoom no gráfico</param> /// <returns></returns> string ObterZoomType(ZoomType zoomType) { switch (zoomType) { case ZoomType.Drag: return("drag"); case ZoomType.Scrool: return("scroll"); default: return("scroll"); } }
/// <summary> /// 缩放类型生成缩放比例 /// </summary> /// <param name="zoomType"></param> private void zoomImage(ZoomType zoomType) { if (this._srcImage == null) { return; } switch (zoomType) { case ZoomType.ZoomIn: if (this._scale < MAX_SCALE) { this._scale += SCALE_GAP; break; } else { return; } case ZoomType.ZoomOut: if (this._scale > MIN_SCALE) { this._scale -= SCALE_GAP; break; } else { return; } case ZoomType.Origin: this._scale = 1.0; break; case ZoomType.Auto: this._scale = 1.0; // 计算放置PictureBox的Panel的长宽与原始图像的比例 // 取最小值即可得到最适应的缩放比 this._scale = Math.Min(this._scale, Convert.ToDouble(this.panelPicPnl.Width - 10) / this._srcImage.Width); this._scale = Math.Min(this._scale, Convert.ToDouble(this.panelPicPnl.Height - 10) / this._srcImage.Height); break; default: this._scale = 1.0; break; } showImage(); }
public static Bitmap ResizeImage(this Bitmap b, Size size, CompositingQuality CompositingQuality, InterpolationMode InterpolationMode, PixelOffsetMode PixelOffsetMode, SmoothingMode SmoothingMode, ZoomType ZoomType ) { var bit = new Bitmap(size.Width, size.Height); using (var g = Graphics.FromImage(bit)) { g.DrawImageEx(b, new Rectangle(0, 0, size.Width, size.Height), CompositingQuality, InterpolationMode, PixelOffsetMode, SmoothingMode, ZoomType, null); } return(bit); }
public void Execute(object parameter) { ZoomType type = (ZoomType)Enum.Parse(typeof(ZoomType), (string)parameter); switch (type) { case ZoomType.Normal: _data.Zoom = 1; break; case ZoomType.ZoomIn: _data.Zoom *= 1.2; break; case ZoomType.ZoomOut: _data.Zoom /= 1.2; break; } }
IEnumerator Zoom(ZoomType zoomType) { inZoomSequence = true; float goalOrthoSize = GetGoalOrthoSize(zoomType); bool reachedGoalZoom = Mathf.Abs(cam.orthographicSize - goalOrthoSize) < 0.5f; while (!reachedGoalZoom) { cam.orthographicSize += (goalOrthoSize - cam.orthographicSize) / (8 / (zoomSpeed * Time.deltaTime)); yield return(new WaitForEndOfFrame()); if (!reachedGoalZoom) { reachedGoalZoom = Mathf.Abs(cam.orthographicSize - goalOrthoSize) < 0.3f; } } inZoomSequence = false; }
/// <summary> /// Function:Zoom /// Author:Jerry Xu /// Date:2008-6-17 /// </summary> /// <param name="pZoomType">ZoomType:Enum</param> public void Zoom(ZoomType pZoomType) { //int unitWidth; //Zoom the dragdraplayoutcontrol out //if (pZoomType == ZoomType.ZoomOut) //{ // dragDropControl.Width = dragDropControl.Width * 2; // dragDropControl.UnitWidth = dragDropControl.UnitWidth * 2; // //unitWidth = dragDropControl. _unitWidth * 2; // for (int i = 0; i < dragDropControl.Controls.Count; i++) // { // dragDropControl.Controls[i].Width = dragDropControl.Controls[i].Width * 2; // if (i != 0) // dragDropControl.Controls[i].Left = dragDropControl.Controls[i - 1].Left + dragDropControl.Controls[i - 1].Width; // } // //trackBar1.Width = trackBar1.Width * 2; //} ////Zoom the dragdraplayoutcontrol in //if (pZoomType == ZoomType.ZoomIn) //{ // dragDropControl.Width = dragDropControl.Width / 2; // dragDropControl.UnitWidth = dragDropControl.UnitWidth / 2; // for (int i = 0; i < dragDropControl.Controls.Count; i++) // { // dragDropControl.Controls[i].Width = dragDropControl.Controls[i].Width / 2; // if (i != 0) // dragDropControl.Controls[i].Left = dragDropControl.Controls[i - 1].Left + dragDropControl.Controls[i - 1].Width; // } // //trackBar1.Width = trackBar1.Width / 2; //} dragDropControl.Zoom(pZoomType); trackBar1.Zoom(pZoomType); //unitWidth = dragDropControl.UnitWidth; //trackBar1.UnitWidth = unitWidth; //trackBar1.SmallChange = unitWidth; //trackBar1.LargeChange = unitWidth; hScrollBar.Maximum = dragDropControl.Width - hScrollBar.Width; hScrollBar.Minimum = 0; }
/// <summary> /// 图像缩放 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void zoom_Click(object sender, EventArgs e) { if (curBitmap != null) { zoom zoomForm = new zoom(); if (zoomForm.ShowDialog() == DialogResult.OK) { //得到横向和纵向缩放量 double x = Convert.ToDouble(zoomForm.GetXZoom); double y = Convert.ToDouble(zoomForm.GetYZoom); ZoomType zt = ZoomType.NearestNeighborInterpolation; if (!zoomForm.GetNearOrBil) { zt = ZoomType.BilinearInterpolation; } bool zoomResult = Zoom(curBitmap, x, y, out curBitmap, zt); Invalidate(); } } }
public void Zoom(ZoomType type, int zoomAmount = 0) { StopAllCoroutines(); switch (type) { case ZoomType.Progressive: StartCoroutine(ZoomProgressive(zoomAmount)); break; case ZoomType.Instant: InstantZoom(zoomAmount); break; case ZoomType.Intro: StartCoroutine(ZoomIntro(ZOOM_SPEED)); break; case ZoomType.Init: StartCoroutine(ReinitZoom()); break; } }
private void zoomView(ZoomType zoomType) { if (zoomType == ZoomType.In) { if ((lifeGrid.Width < (_zoomMax * _zoomStartX)) && (lifeGrid.Height < (_zoomMax * _zoomStartY))) { lifeGrid.Width = Convert.ToInt32(lifeGrid.Width * _zoomRate); lifeGrid.Height = Convert.ToInt32(lifeGrid.Height * _zoomRate); _zoomCount += 1; } } else { if ((lifeGrid.Width > _zoomStartX) || (lifeGrid.Height > _zoomStartY)) { lifeGrid.Width = Convert.ToInt32(lifeGrid.Width / _zoomRate); lifeGrid.Height = Convert.ToInt32(lifeGrid.Height / _zoomRate); _zoomCount -= 1; } } updateFormVisuals(); }
public void Zoom(ZoomType zoom) { ClearTimeLabel(); _scaleBarStartPos = 0; _orgiStep = 5; count++; if (count == 10) { count = 0; } if (zoom == ZoomType.ZoomOut) { _unitWidth = _unitWidth * 2; _smallChange = _unitWidth; _largeChange = _unitWidth; _trackBarCtrlLastWidth = 0; this.Width = this.Width * 2; } //Zoom the dragdraplayoutcontrol in if (zoom == ZoomType.ZoomIn) { _unitWidth = _unitWidth / 2; _smallChange = _unitWidth; _largeChange = _unitWidth; _trackBarCtrlLastWidth = 0; this.Width = this.Width / 2; } lblInnerSlide.Left = playTrackBarCtrl.Left + slideSpan + playTrackBarCtrl.Value * _unitWidth; if (LblSlide != null) { LblSlide.Visible = true; LblSlide.Left = lblInnerSlide.Left - slideOffset; OnValueChanged(); } }
/// <summary> /// Updates the zoom. /// </summary> /// <param name="times">The times.</param> internal void UpdateZoom(double times) { if (_zoomEnabled) { if (times > 0.0) { ZoomState = ZoomType.Enlarge; } else if (times < 0.0) { ZoomState = ZoomType.Reduce; } else { ZoomState = ZoomType.None; } if (times != 0.0) { double range = Range; MinValue += range * times; MaxValue -= range * times; } } }
static extern void gimp_zoom_model_zoom(IntPtr model, ZoomType zoom_type, double scale);
// Fix me: implement ZoomButton. Probably in separate class public static double ZoomStep(ZoomType zoomType, double scale) { return gimp_zoom_model_zoom_step(zoomType, scale); }
/// <summary> /// 无损压缩JPEG图片 /// </summary> /// <param name="sFile">原图片</param> /// <param name="dFile">压缩后保存位置</param> /// <param name="height">高度</param> /// <param name="width"></param> /// <param name="flag">压缩质量 1-100</param> /// <param name="type">压缩缩放类型</param> /// <returns></returns> public static bool Thumbnail(string sFile, string dFile, int height, int width, int flag, ZoomType type) { System.Drawing.Image iSource = System.Drawing.Image.FromFile(sFile); ImageFormat tFormat = iSource.RawFormat; //缩放后的宽度和高度 int towidth = width; int toheight = height; // int x = 0; int y = 0; int ow = iSource.Width; int oh = iSource.Height; switch (type) { case ZoomType.WH://指定高宽缩放(可能变形) { break; } case ZoomType.W://指定宽,高按比例 { toheight = iSource.Height * width / iSource.Width; break; } case ZoomType.H://指定高,宽按比例 { towidth = iSource.Width * height / iSource.Height; break; } case ZoomType.Cut://指定高宽裁减(不变形) { if ((double)iSource.Width / (double)iSource.Height > (double)towidth / (double)toheight) { oh = iSource.Height; ow = iSource.Height * towidth / toheight; y = 0; x = (iSource.Width - ow) / 2; } else { ow = iSource.Width; oh = iSource.Width * height / towidth; x = 0; y = (iSource.Height - oh) / 2; } break; } default: break; } Bitmap ob = new Bitmap(towidth, toheight); Graphics g = Graphics.FromImage(ob); g.Clear(System.Drawing.Color.WhiteSmoke); g.CompositingQuality = CompositingQuality.HighQuality; g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(iSource , new Rectangle(x, y, towidth, toheight) , new Rectangle(0, 0, iSource.Width, iSource.Height) , GraphicsUnit.Pixel); g.Dispose(); //以下代码为保存图片时,设置压缩质量 EncoderParameters ep = new EncoderParameters(); long[] qy = new long[1]; qy[0] = flag;//设置压缩的比例1-100 EncoderParameter eParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qy); ep.Param[0] = eParam; try { ImageCodecInfo[] arrayICI = ImageCodecInfo.GetImageEncoders(); ImageCodecInfo jpegICIinfo = null; for (int i = 0; i < arrayICI.Length; i++) { if (arrayICI[i].FormatDescription.Equals("JPEG")) { jpegICIinfo = arrayICI[i]; break; } } if (jpegICIinfo != null) { ob.Save(dFile, jpegICIinfo, ep);//dFile是压缩后的新路径 } else { ob.Save(dFile, tFormat); } return true; } catch { return false; } finally { iSource.Dispose(); ob.Dispose(); } }
static extern double gimp_zoom_model_zoom_step(ZoomType zoom_type, double scale);
internal void ZoomIn() { this.ZoomType = ImageOrganizer.Common.ZoomType.Zoom; var ZoomPercent = this.ZoomPercent; ZoomPercent *= 1.5d; if (ZoomPercent > MaxZoomIn) ZoomPercent = MaxZoomIn; this.ZoomPercent = ZoomPercent; this.RefreshActiveImage(); }
internal void ZoomOut() { this.ZoomType = ImageOrganizer.Common.ZoomType.Zoom; var ZoomPercent = this.ZoomPercent; ZoomPercent /= 1.5d; if (ZoomPercent < MaxZoomOut) ZoomPercent = MaxZoomOut; this.ZoomPercent = ZoomPercent; this.RefreshActiveImage(); }
internal void FitWidth() { this.ZoomType = ImageOrganizer.Common.ZoomType.FitWidth; this.RefreshActiveImage(); }
internal void ZoomFit() { this.ZoomType = ImageOrganizer.Common.ZoomType.BestFit; this.RefreshActiveImage(); }
internal void ActualSize() { this.ZoomType = ImageOrganizer.Common.ZoomType.Zoom; this.ZoomPercent = 1d; this.RefreshActiveImage(); }
internal void FitHeight() { this.ZoomType = ImageOrganizer.Common.ZoomType.FitHeight; this.RefreshActiveImage(); }
/** * Zooms the camera to a point on the screen. The zoom amount is given on camera initialization. */ public void zoomToPoint(Vec2 screenPosition, ZoomType zoomType) { Mat22 zoom; switch (zoomType) { case ZoomType.ZOOM_IN: zoom = upScale; break; case ZoomType.ZOOM_OUT: zoom = downScale; break; default: throw new Exception("Invalid zoom type"); } transform.getScreenToWorld(screenPosition, oldCenter); transform.mulByTransform(zoom); transform.getScreenToWorld(screenPosition, newCenter); oldCenter.subLocal(newCenter); Vec2 transformedMove = oldCenter; // set, just in case bad impl by someone if (!transform.isYFlip()) { transformedMove.y = -transformedMove.y; } transform.setCenter(transform.getCenter().add(transformedMove)); }
static extern IntPtr gimp_zoom_button_new(IntPtr model, ZoomType zoom_type, IconSize icon_size);
IEnumerator ShapeWipe ( Camera cam1 , Camera cam2 , float time , ZoomType zoom , Mesh mesh , float rotateAmount ) { yield return ShapeWipe( cam1, cam2, time, zoom, mesh, rotateAmount, null ); }
private void FireZoomEvent(ZoomType type) { if (!_draggedRectangle.HasValue) { throw new InvalidOperationException("A drag rectangle must be created before firing this event."); } double xScale = AttachedGraph.XScale; double yScale = AttachedGraph.YScale; // The X and Y offsets to move the origin int distanceToZeroX = -(int)Math.Round(AttachedGraph.Window.MinimumX * xScale) + AttachedGraph.DisplayRectangle.X; int distanceToZeroY = -(int)Math.Round(AttachedGraph.Window.MaximumY * yScale) + AttachedGraph.DisplayRectangle.Y; Window window = Window.GetWindowFromRectangle(_draggedRectangle.Value, distanceToZeroX, distanceToZeroY, xScale, yScale); if (type == ZoomType.ZoomOut) { window = window.Add(AttachedGraph.Window); } var handler = Zoom; if (handler != null) { handler(this, new GenericEventArgs<Window>(window)); } ClearZoomRectangle(); }
public IEnumerator ShapeWipe ( Camera cam1 , Camera cam2 , float time , ZoomType zoom , Mesh mesh , float rotateAmount , AnimationCurve _curve ) { curve = _curve; useCurve = curve != null; if (!shapeMaterial) { shapeMaterial = new Material ( "Shader \"DepthMask\" {" + " SubShader {" + " Tags { \"Queue\" = \"Background\" }" + " Lighting Off ZTest LEqual ZWrite On Cull Off ColorMask 0" + " Pass {}" + " }" + "}" ); } if (!shape) { GameObject gobjShape = new GameObject("Shape"); gobjShape.AddComponent("MeshFilter"); gobjShape.AddComponent("MeshRenderer"); shape = gobjShape.transform; shape.renderer.material = shapeMaterial; } CameraSetup (cam1, cam2, true, false); Camera useCam = (zoom == ZoomType.Shrink)? cam1 : cam2; Camera otherCam = (zoom == ZoomType.Shrink)? cam2 : cam1; float originalDepth = otherCam.depth; CameraClearFlags originalClearFlags = otherCam.clearFlags; otherCam.depth = useCam.depth+1; otherCam.clearFlags = CameraClearFlags.Depth; shape.gameObject.active = true; (shape.GetComponent<MeshFilter>() as MeshFilter).mesh = mesh; shape.position = otherCam.transform.position + otherCam.transform.forward * (otherCam.nearClipPlane+.01f); shape.parent = otherCam.transform; shape.localRotation = Quaternion.identity; if( useCurve ) { float rate = 1.0f/time; if (zoom == ZoomType.Shrink) { for (float i = 1.0f; i > 0.0f; i -= Time.deltaTime * rate) { float t = curve.Evaluate( i ); shape.localScale = new Vector3(t, t, t); shape.localEulerAngles = new Vector3(0.0f, 0.0f, i * rotateAmount); yield return 0; } } else { for (float i = 0.0f; i < 1.0f; i += Time.deltaTime * rate) { float t = curve.Evaluate( i ); shape.localScale = new Vector3(t, t, t); shape.localEulerAngles = new Vector3(0.0f, 0.0f, -i * rotateAmount); yield return 0; } } } else{ float rate = 1.0f/time; if (zoom == ZoomType.Shrink) { for (float i = 1.0f; i > 0.0f; i -= Time.deltaTime * rate) { float t = Mathf.Lerp(1.0f, 0.0f, Mathf.Sin((1.0f-i) * Mathf.PI * 0.5f)); // Slow down near the end shape.localScale = new Vector3(t, t, t); shape.localEulerAngles = new Vector3(0.0f, 0.0f, i * rotateAmount); yield return 0; } } else { for (float i = 0.0f; i < 1.0f; i += Time.deltaTime * rate) { float t = Mathf.Lerp(1.0f, 0.0f, Mathf.Sin((1.0f-i) * Mathf.PI * 0.5f)); // Start out slower shape.localScale = new Vector3(t, t, t); shape.localEulerAngles = new Vector3(0.0f, 0.0f, -i * rotateAmount); yield return 0; } } } otherCam.clearFlags = originalClearFlags; otherCam.depth = originalDepth; CameraCleanup (cam1, cam2); shape.parent = null; shape.gameObject.active = false; }
IEnumerator RectWipe ( Camera cam1 , Camera cam2 , float time , ZoomType zoom ) { yield return RectWipe( cam1, cam2, time, zoom, null ); }
public IEnumerator RectWipe ( Camera cam1 , Camera cam2 , float time , ZoomType zoom , AnimationCurve _curve ) { curve = _curve; useCurve = curve != null; CameraSetup (cam1, cam2, true, false); Camera useCam = (zoom == ZoomType.Shrink)? cam1 : cam2; Camera otherCam = (zoom == ZoomType.Shrink)? cam2 : cam1; Rect originalRect = useCam.rect; float originalDepth = useCam.depth; useCam.depth = otherCam.depth+1; if( useCurve ) { float rate= 1.0f/(time); if (zoom == ZoomType.Shrink) { for (float i = 0.0f; i < 1.0f; i += Time.deltaTime * rate) { float t = curve.Evaluate( i )*0.5f; cam1.rect = new Rect(t, t, 1.0f-t*2, 1.0f-t*2); yield return 0; } } else { for (float i = 0.0f; i < 1.0f; i += Time.deltaTime * rate) { float t = curve.Evaluate( i )*0.5f; cam2.rect = new Rect(.5f - t, .5f - t, t * 2.0f, t * 2.0f); yield return 0; } } } else { float rate = 1.0f/(time*2); if (zoom == ZoomType.Shrink) { for (float i = 0.0f; i < .5; i += Time.deltaTime * rate) { float t = Mathf.Lerp(0.0f, .5f, Mathf.Sin(i * Mathf.PI)); // Slow down near the end cam1.rect = new Rect(t, t, 1.0f-t*2, 1.0f-t*2); yield return 0; } } else { for (float i = 0.0f; i < .5f; i += Time.deltaTime * rate) { float t = Mathf.Lerp(.5f, 0.0f, Mathf.Sin((.5f-i) * Mathf.PI)); // Start out slower cam2.rect = new Rect(.5f-t, .5f-t, t*2.0f, t*2.0f); yield return 0; } } } useCam.rect = originalRect; useCam.depth = originalDepth; CameraCleanup (cam1, cam2); }
private void ZoomAndRecenterView(ZoomType zoomType, Cairo.PointD point) { if (zoomType == ZoomType.ZoomOut && (CanvasSize.Width == 1 || CanvasSize.Height ==1)) return; //Can't zoom in past a 1x1 px canvas double zoom; if (!ViewActions.TryParsePercent (PintaCore.Actions.View.ZoomComboBox.ComboBox.ActiveText, out zoom)) zoom = Scale * 100; zoom = Math.Min (zoom, 3600); PintaCore.Chrome.Canvas.GdkWindow.FreezeUpdates (); PintaCore.Actions.View.SuspendZoomUpdate (); Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.Canvas.Parent; bool adjustOnMousePosition = point.X >= 0.0 && point.Y >= 0.0; double center_x = adjustOnMousePosition ? point.X : view.Hadjustment.Value + (view.Hadjustment.PageSize / 2.0); double center_y = adjustOnMousePosition ? point.Y : view.Vadjustment.Value + (view.Vadjustment.PageSize / 2.0); center_x = (center_x - Offset.X) / Scale; center_y = (center_y - Offset.Y) / Scale; if (zoomType == ZoomType.ZoomIn || zoomType == ZoomType.ZoomOut) { int i = 0; Predicate<string> UpdateZoomLevel = zoomInList => { switch (zoomType) { case ZoomType.ZoomIn: if (zoomInList == Catalog.GetString ("Window") || int.Parse (zoomInList.Trim ('%')) <= zoom) { PintaCore.Actions.View.ZoomComboBox.ComboBox.Active = i - 1; return true; } break; case ZoomType.ZoomOut: if (zoomInList == Catalog.GetString ("Window")) return true; if (int.Parse (zoomInList.Trim ('%')) < zoom) { PintaCore.Actions.View.ZoomComboBox.ComboBox.Active = i; return true; } break; } return false; }; foreach (string item in PintaCore.Actions.View.ZoomCollection) { if (UpdateZoomLevel (item)) break; i++; } } PintaCore.Actions.View.UpdateCanvasScale (); // Quick fix : need to manually update Upper limit because the value is not changing after updating the canvas scale. // TODO : I think there is an event need to be fired so that those values updated automatically. view.Hadjustment.Upper = CanvasSize.Width < view.Hadjustment.PageSize ? view.Hadjustment.PageSize : CanvasSize.Width; view.Vadjustment.Upper = CanvasSize.Height < view.Vadjustment.PageSize ? view.Vadjustment.PageSize : CanvasSize.Height; RecenterView (center_x, center_y); PintaCore.Actions.View.ResumeZoomUpdate (); PintaCore.Chrome.Canvas.GdkWindow.ThawUpdates (); }
public void Zoom(ZoomType zoomType, double scale) { gimp_zoom_model_zoom(_model, zoomType, scale); }