Applied patch #3584491, this centers the image in the editor.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2243 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-11-06 06:08:26 +00:00
commit 599bb594ad
2 changed files with 17 additions and 0 deletions

View file

@ -1585,6 +1585,7 @@ namespace Greenshot {
this.Activated += new System.EventHandler(this.ImageEditorFormActivated); this.Activated += new System.EventHandler(this.ImageEditorFormActivated);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ImageEditorFormFormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ImageEditorFormFormClosing);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ImageEditorFormKeyDown); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ImageEditorFormKeyDown);
this.Resize += new System.EventHandler(this.ImageEditorFormResize);
this.toolStripContainer1.BottomToolStripPanel.ResumeLayout(false); this.toolStripContainer1.BottomToolStripPanel.ResumeLayout(false);
this.toolStripContainer1.BottomToolStripPanel.PerformLayout(); this.toolStripContainer1.BottomToolStripPanel.PerformLayout();
this.toolStripContainer1.ContentPanel.ResumeLayout(false); this.toolStripContainer1.ContentPanel.ResumeLayout(false);

View file

@ -342,6 +342,7 @@ namespace Greenshot {
this.Size = new Size(newWidth, newHeight); this.Size = new Size(newWidth, newHeight);
} }
dimensionsLabel.Text = this.Surface.Image.Width + "x" + this.Surface.Image.Height; dimensionsLabel.Text = this.Surface.Image.Width + "x" + this.Surface.Image.Height;
ImageEditorFormResize(source,new EventArgs());
} }
private void ReloadConfiguration(object source, FileSystemEventArgs e) { private void ReloadConfiguration(object source, FileSystemEventArgs e) {
@ -1199,5 +1200,20 @@ namespace Greenshot {
surface.ApplyBitmapEffect(Effects.Invert); surface.ApplyBitmapEffect(Effects.Invert);
updateUndoRedoSurfaceDependencies(); updateUndoRedoSurfaceDependencies();
} }
private void ImageEditorFormResize(object sender, EventArgs e) {
if (this.Surface == null) {
return;
}
Size imageSize = this.Surface.Image.Size;
Size currentImageClientSize = this.panel1.ClientSize;
if (currentImageClientSize.Height > imageSize.Height && currentImageClientSize.Width > imageSize.Width) {
var canvas = this.Surface as Control;
if (canvas != null) {
canvas.Top = (currentImageClientSize.Height - imageSize.Height) / 2;
canvas.Left = (currentImageClientSize.Width - imageSize.Width) / 2;
}
}
}
} }
} }