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; } }
public virtual void OnImageLoaded() { if (ImageListViewModel.ZoomFit && ZoomAndPanControlMacro != null) { ZoomAndPanControlMacro.ScaleToFit(); } else { if (ZoomAndPanControlMacro != null) { ZoomToFocus(); } } GeneratePreview(); }
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); } }