1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-26 02:34:05 +02:00

Fix button positioning in FormMessage

This commit is contained in:
chylex 2017-03-23 20:34:56 +01:00
parent f1db1ba708
commit 29a02db07d
3 changed files with 14 additions and 6 deletions

View File

@ -33,7 +33,7 @@ private void InitializeComponent() {
this.panelActions.Dock = System.Windows.Forms.DockStyle.Bottom; this.panelActions.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panelActions.Location = new System.Drawing.Point(0, 84); this.panelActions.Location = new System.Drawing.Point(0, 84);
this.panelActions.Name = "panelActions"; this.panelActions.Name = "panelActions";
this.panelActions.Size = new System.Drawing.Size(233, 49); this.panelActions.Size = new System.Drawing.Size(98, 49);
this.panelActions.TabIndex = 0; this.panelActions.TabIndex = 0;
// //
// labelMessage // labelMessage
@ -66,6 +66,7 @@ private void InitializeComponent() {
this.Name = "FormMessage"; this.Name = "FormMessage";
this.ShowIcon = false; this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.SizeChanged += new System.EventHandler(this.FormMessage_SizeChanged);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -19,7 +19,7 @@ public FormMessage(string caption, string text, MessageBoxIcon messageIcon){
this.prevLabelWidth = labelMessage.Width; this.prevLabelWidth = labelMessage.Width;
this.prevLabelHeight = labelMessage.Height; this.prevLabelHeight = labelMessage.Height;
this.minFormWidth = 18; this.minFormWidth = 20;
switch(messageIcon){ switch(messageIcon){
case MessageBoxIcon.Information: case MessageBoxIcon.Information:
@ -50,11 +50,18 @@ public FormMessage(string caption, string text, MessageBoxIcon messageIcon){
this.labelMessage.Text = text; this.labelMessage.Text = text;
} }
private void FormMessage_SizeChanged(object sender, EventArgs e){
for(int index = 0; index < buttonCount; index++){
Control control = panelActions.Controls[index];
control.Location = new Point(Width-110-index*96, control.Location.Y);
}
}
public Button AddButton(string title, DialogResult result = DialogResult.OK){ public Button AddButton(string title, DialogResult result = DialogResult.OK){
Button button = new Button{ Button button = new Button{
Anchor = AnchorStyles.Bottom | AnchorStyles.Right, Anchor = AnchorStyles.Bottom,
Font = SystemFonts.MessageBoxFont, Font = SystemFonts.MessageBoxFont,
Location = new Point(Width-112-buttonCount*96, 12), Location = new Point(Width-110-buttonCount*96, 12),
Size = new Size(88, 26), Size = new Size(88, 26),
TabIndex = buttonCount, TabIndex = buttonCount,
Text = title, Text = title,
@ -99,7 +106,7 @@ private void labelMessage_SizeChanged(object sender, EventArgs e){
prevLabelHeight -= 8; prevLabelHeight -= 8;
} }
realFormWidth = Width-(icon == null ? 32+35+(labelMessage.Margin.Left-labelMessage.Margin.Right) : 0)+labelMessage.Margin.Right+labelMessage.Width-prevLabelWidth; realFormWidth = Width-(icon == null ? 67+(labelMessage.Margin.Left-labelMessage.Margin.Right) : 46)+labelMessage.Margin.Right+labelMessage.Width-prevLabelWidth;
Width = Math.Max(realFormWidth, minFormWidth); Width = Math.Max(realFormWidth, minFormWidth);
Height += labelMessage.Height-prevLabelHeight; Height += labelMessage.Height-prevLabelHeight;

View File

@ -54,7 +54,7 @@ public void HandleException(string caption, string message, bool canIgnore, Exce
Anchor = AnchorStyles.Bottom | AnchorStyles.Left, Anchor = AnchorStyles.Bottom | AnchorStyles.Left,
Enabled = loggedSuccessfully, Enabled = loggedSuccessfully,
Font = SystemFonts.MessageBoxFont, Font = SystemFonts.MessageBoxFont,
Location = new Point(12, 12), Location = new Point(6, 12),
Margin = new Padding(0, 0, 48, 0), Margin = new Padding(0, 0, 48, 0),
Size = new Size(88, 26), Size = new Size(88, 26),
Text = "Show Error Log", Text = "Show Error Log",