protected void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e) { e.Handled = true; Point curContentMousePoint = e.GetPosition(content); if (e.Delta > 0) { ZoomIn(curContentMousePoint); } else if (e.Delta < 0) { // don't allow zoomout les that original image if (ZoomAndPanControlMacro.ContentScale - 0.1 > ZoomAndPanControlMacro.FitScale()) { ZoomAndPanControlMacro.ZoomOut(curContentMousePoint); } else { ZoomAndPanControlMacro.ScaleToFit(); } ZoomOut(curContentMousePoint); } if (ZoomAndPanControlMacro.ContentScale > ZoomAndPanControlMacro.FitScale()) { LoadFullRes(); ImageListViewModel.FreeZoom = true; } }
private void ZoomAndPanControl_ContentScaleChanged(object sender, EventArgs e) { GeneratePreview(); var i = Math.Round(ZoomAndPanControlMacro.FitScale(), 4); ImageListViewModel.FreeZoom = Math.Round(ZoomAndPanControlMacro.ContentScale, 4) > Math.Round(ZoomAndPanControlMacro.FitScale(), 4); if (!ImageListViewModel.FreeZoom) { ImageListViewModel.ZoomFit = true; } }
public virtual void OnImageLoaded() { if (ImageListViewModel.ZoomFit && ZoomAndPanControlMacro != null) { ZoomAndPanControlMacro.ScaleToFit(); } else { if (ZoomAndPanControlMacro != null) { ZoomToFocus(); } } GeneratePreview(); }
private void ZoomToFocus() { if (!ImageListViewModel.ZoomToFocus) { return; } if ( ServiceProvider.Settings.SelectedBitmap.FileItem .FileInfo != null && ServiceProvider.Settings.SelectedBitmap.FileItem .FileInfo.FocusPoints.Count > 0) { ZoomAndPanControlMacro.SnapTo(new Point(ServiceProvider.Settings.SelectedBitmap.FileItem.FileInfo.FocusPoints[0].X + ServiceProvider.Settings.SelectedBitmap.FileItem.FileInfo.FocusPoints[0].Width / 2, ServiceProvider.Settings.SelectedBitmap.FileItem.FileInfo.FocusPoints[0].Y + ServiceProvider.Settings.SelectedBitmap.FileItem.FileInfo.FocusPoints[0].Height / 2)); } }
/// <summary> /// Zoom the viewport in, centering on the specified point (in content coordinates). /// </summary> private void ZoomIn(Point contentZoomCenter) { ZoomAndPanControlMacro.ZoomAboutPoint(ZoomAndPanControlMacro.ContentScale + 0.1, contentZoomCenter); }
private void TriggerEvent(string cmd, object o) { try { switch (cmd) { case WindowsCmdConsts.Next_Image: if (ImageLIst.SelectedIndex < ImageLIst.Items.Count - 1) { FileItem item = ImageLIst.SelectedItem as FileItem; if (item != null) { int ind = ImageLIst.Items.IndexOf(item); ImageLIst.SelectedIndex = ind + 1; } item = ImageLIst.SelectedItem as FileItem; if (item != null) { ImageLIst.ScrollIntoView(item); } } break; case WindowsCmdConsts.Prev_Image: if (ImageLIst.SelectedIndex > 0) { FileItem item = ImageLIst.SelectedItem as FileItem; if (item != null) { int ind = ImageLIst.Items.IndexOf(item); ImageLIst.SelectedIndex = ind - 1; } item = ImageLIst.SelectedItem as FileItem; if (item != null) { ImageLIst.ScrollIntoView(item); } } break; case WindowsCmdConsts.Like_Image: if (ImageLIst.SelectedItem != null) { FileItem item = null; if (o != null) { item = ServiceProvider.Settings.DefaultSession.GetByName(o as string); } else { item = ImageLIst.SelectedItem as FileItem; } if (item != null) { item.IsLiked = !item.IsLiked; } } break; case WindowsCmdConsts.Unlike_Image: if (ImageLIst.SelectedItem != null) { FileItem item = null; if (o != null) { item = ServiceProvider.Settings.DefaultSession .GetByName(o as string); } else { item = ImageLIst.SelectedItem as FileItem; } if (item != null) { item.IsUnLiked = !item.IsUnLiked; } } break; case WindowsCmdConsts.Del_Image: { DeleteItem(); } break; case WindowsCmdConsts.Select_Image: FileItem fileItem = o as FileItem; if (fileItem != null) { ImageLIst.SelectedValue = fileItem; ImageLIst.ScrollIntoView(fileItem); } break; case WindowsCmdConsts.Refresh_Image: RefreshImage(); break; case WindowsCmdConsts.Zoom_Image_Fit: ZoomAndPanControlMacro.ScaleToFit(); break; case WindowsCmdConsts.Zoom_Image_100: ZoomToFocus(); LoadFullRes(); ZoomAndPanControlMacro.ZoomTo(1.0); break; case WindowsCmdConsts.Zoom_Image_200: ZoomToFocus(); LoadFullRes(); ZoomAndPanControlMacro.ZoomTo(2.0); break; case WindowsCmdConsts.RotateLeft: { FileItem item = ImageLIst.SelectedItem as FileItem; if (item != null) { item.Rotation--; } } break; case WindowsCmdConsts.RotateRight: { FileItem item = ImageLIst.SelectedItem as FileItem; if (item != null) { item.Rotation++; } } break; case WindowsCmdConsts.ViewExternal: OpenInExternalViewer(); break; case WindowsCmdConsts.ViewExplorer: OpenInExplorer(); break; case WindowsCmdConsts.RefreshDisplay: if (ImageListViewModel.ZoomFit) { ZoomAndPanControlMacro.ScaleToFit(); } break; } if (cmd.StartsWith(WindowsCmdConsts.ZoomPoint)) { if (ZoomAndPanControlMacro != null && cmd.Contains("_")) { var vals = cmd.Split('_'); if (vals.Count() > 2) { double x; double y; double.TryParse(vals[1], out x); double.TryParse(vals[2], out y); if (cmd.EndsWith("!")) { ZoomAndPanControlMacro.SnapToRation(x, y); } else { ZoomAndPanControlMacro.AnimatedSnapToRation(x, y); } } } } } catch (Exception exception) { Log.Error("Unable to process event ", exception); } }