Browse Source

Fixed SD2-724: CustomDialog does not expand to fit buttons

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1347 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
f13e699e99
  1. 12
      src/Main/Core/Project/Src/Services/MessageService/CustomDialog.cs

12
src/Main/Core/Project/Src/Services/MessageService/CustomDialog.cs

@ -50,7 +50,6 @@ namespace ICSharpCode.Core
for (int i = 0; i < buttons.Length; i++) { for (int i = 0; i < buttons.Length; i++) {
Button newButton = new Button(); Button newButton = new Button();
newButton.FlatStyle = FlatStyle.System; newButton.FlatStyle = FlatStyle.System;
newButton.Anchor = AnchorStyles.Right;
newButton.Tag = i; newButton.Tag = i;
string buttonLabel = StringParser.Parse(buttonLabels[i]); string buttonLabel = StringParser.Parse(buttonLabels[i]);
newButton.Text = buttonLabel; newButton.Text = buttonLabel;
@ -68,15 +67,17 @@ namespace ICSharpCode.Core
CancelButton = buttons[cancelButton]; CancelButton = buttons[cancelButton];
} }
pos -= 4; // remove space after last button pos += 4; // add space before first button
// (we don't start with pos=4 because this space doesn't belong to the button panel)
if (pos > clientSize.Width) { if (pos > clientSize.Width) {
clientSize.Width = pos; clientSize.Width = pos;
} }
clientSize.Height += panel.Height + 6; clientSize.Height += panel.Height + 6;
this.ClientSize = clientSize; this.ClientSize = clientSize;
int start = (panel.ClientSize.Width - pos) / 2; int start = (clientSize.Width - pos) / 2;
for (int i = 0; i < buttons.Length; i++) { for (int i = 0; i < buttons.Length; i++) {
((Button)buttons[i]).Location = new Point(start + positions[i], 4); buttons[i].Location = new Point(start + positions[i], 4);
} }
panel.Controls.AddRange(buttons); panel.Controls.AddRange(buttons);
} }
@ -92,7 +93,6 @@ namespace ICSharpCode.Core
this.Close(); this.Close();
} }
#region Windows Forms Designer generated code
/// <summary> /// <summary>
/// This method is required for Windows Forms designer support. /// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might /// Do not change the method contents inside the source code editor. The Forms designer might
@ -123,7 +123,6 @@ namespace ICSharpCode.Core
// //
// CustomDialog // CustomDialog
// //
// this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(274, 112); this.ClientSize = new System.Drawing.Size(274, 112);
this.Controls.Add(this.label); this.Controls.Add(this.label);
this.Controls.Add(this.panel); this.Controls.Add(this.panel);
@ -137,6 +136,5 @@ namespace ICSharpCode.Core
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "CustomDialog"; this.Text = "CustomDialog";
} }
#endregion
} }
} }

Loading…
Cancel
Save