Fixed [#1469] by checking if there are grippers.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2516 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2013-03-06 19:31:07 +00:00
commit 1057d5f23a
3 changed files with 26 additions and 12 deletions

View file

@ -323,6 +323,9 @@ namespace Greenshot.Drawing {
} }
protected virtual void DoLayout() { protected virtual void DoLayout() {
if (grippers == null) {
return;
}
if (!layoutSuspended) { if (!layoutSuspended) {
int[] xChoords = new int[]{this.Left-2,this.Left+this.Width/2-2,this.Left+this.Width-2}; int[] xChoords = new int[]{this.Left-2,this.Left+this.Width/2-2,this.Left+this.Width-2};
int[] yChoords = new int[]{this.Top-2,this.Top+this.Height/2-2,this.Top+this.Height-2}; int[] yChoords = new int[]{this.Top-2,this.Top+this.Height/2-2,this.Top+this.Height-2};
@ -471,19 +474,26 @@ namespace Greenshot.Drawing {
} }
public virtual void ShowGrippers() { public virtual void ShowGrippers() {
if (grippers != null) {
for (int i = 0; i < grippers.Length; i++) { for (int i = 0; i < grippers.Length; i++) {
if(grippers[i].Enabled) grippers[i].Show(); if (grippers[i].Enabled) {
else grippers[i].Hide(); grippers[i].Show();
} else {
grippers[i].Hide();
}
}
} }
this.ResumeLayout(); this.ResumeLayout();
} }
public void HideGrippers() { public void HideGrippers() {
this.SuspendLayout(); this.SuspendLayout();
if (grippers != null) {
for (int i = 0; i < grippers.Length; i++) { for (int i = 0; i < grippers.Length; i++) {
grippers[i].Hide(); grippers[i].Hide();
} }
} }
}
public void ResizeTo(int width, int height, int anchorPosition) { public void ResizeTo(int width, int height, int anchorPosition) {
this.SuspendLayout(); this.SuspendLayout();
@ -554,7 +564,7 @@ namespace Greenshot.Drawing {
} }
private void SwitchParent(Surface newParent) { private void SwitchParent(Surface newParent) {
if (parent != null) { if (parent != null && grippers != null) {
for (int i=0; i<grippers.Length; i++) { for (int i=0; i<grippers.Length; i++) {
parent.Controls.Remove(grippers[i]); parent.Controls.Remove(grippers[i]);
} }

View file

@ -58,11 +58,13 @@ namespace Greenshot.Drawing {
} }
protected void Init() { protected void Init() {
if (grippers != null) {
for (int i = 0; i < grippers.Length; i++) { for (int i = 0; i < grippers.Length; i++) {
grippers[i].Enabled = false; grippers[i].Enabled = false;
grippers[i].Visible = false; grippers[i].Visible = false;
} }
} }
}
[OnDeserializedAttribute()] [OnDeserializedAttribute()]
private void OnDeserialized(StreamingContext context) { private void OnDeserialized(StreamingContext context) {

View file

@ -50,10 +50,12 @@ namespace Greenshot.Drawing {
} }
protected void Init() { protected void Init() {
if (grippers != null) {
foreach (int index in new int[] { 1, 2, 3, 5, 6, 7 }) { foreach (int index in new int[] { 1, 2, 3, 5, 6, 7 }) {
grippers[index].Enabled = false; grippers[index].Enabled = false;
} }
} }
}
public override void Draw(Graphics graphics, RenderMode rm) { public override void Draw(Graphics graphics, RenderMode rm) {
graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.SmoothingMode = SmoothingMode.HighQuality;