public void ZoomIn(ViewZoomAnchor anchor, int zoomFactor) { this._baseSize = this.Size; this._baseLocation = this.Location; int oldWidth = this._baseSize.Width; int oldHeight = this._baseSize.Height; int locationX = this.Location.X; int locationY = this.Location.Y; int newWidth = (zoomFactor * this.ClientSize.Width) + (this.Size.Width - this.ClientSize.Width); int newHeight = (zoomFactor * this.ClientSize.Height) + (this.Size.Height - this.ClientSize.Height); // First change size, THEN move the window // Otherwise there is a chance to fail in a loop // Zoom requied -> Moved the windows 1st -> Focus is lost -> Window is moved back -> Focus is back on -> Zoom required -> ... this.Size = new Size(newWidth, newHeight); switch (anchor) { case ViewZoomAnchor.NW: break; case ViewZoomAnchor.N: this.Location = new Point(locationX - newWidth / 2 + oldWidth / 2, locationY); break; case ViewZoomAnchor.NE: this.Location = new Point(locationX - newWidth + oldWidth, locationY); break; case ViewZoomAnchor.W: this.Location = new Point(locationX, locationY - newHeight / 2 + oldHeight / 2); break; case ViewZoomAnchor.C: this.Location = new Point(locationX - newWidth / 2 + oldWidth / 2, locationY - newHeight / 2 + oldHeight / 2); break; case ViewZoomAnchor.E: this.Location = new Point(locationX - newWidth + oldWidth, locationY - newHeight / 2 + oldHeight / 2); break; case ViewZoomAnchor.SW: this.Location = new Point(locationX, locationY - newHeight + this._baseSize.Height); break; case ViewZoomAnchor.S: this.Location = new Point(locationX - newWidth / 2 + oldWidth / 2, locationY - newHeight + oldHeight); break; case ViewZoomAnchor.SE: this.Location = new Point(locationX - newWidth + oldWidth, locationY - newHeight + oldHeight); break; } }
public MainForm(ApplicationContext context) { this._context = context; this._zoomAnchorMap = new Dictionary <ViewZoomAnchor, RadioButton>(); this._cachedThumbnailZoomAnchor = ViewZoomAnchor.NW; this._suppressEvents = false; this._minimumSize = new Size(80, 60); this._maximumSize = new Size(80, 60); InitializeComponent(); this.ThumbnailsList.DisplayMember = "Title"; this.InitZoomAnchorMap(); }
public static ZoomAnchor Convert(ViewZoomAnchor value) { // Cheat based on fact that the order and byte values of both enums are the same return((ZoomAnchor)((int)value)); }
public static ZoomAnchor Convert(ViewZoomAnchor value) { // Cheat based on fact that the order and byte values of both enums are the same return (ZoomAnchor)((int)value); }