Dynamically change size of panel

This commit is contained in:
2015-11-02 14:34:31 +01:00
parent 2b2be4523e
commit 3b28c2c5d1
3 changed files with 30 additions and 4 deletions
@@ -30,6 +30,7 @@ namespace ErgometerApplication
this.Location = new System.Drawing.Point(0, 0);
this.Name = "PanelClientSteps";
this.Size = new System.Drawing.Size(284, 150);
this.Resize += PanelClientSteps_Resize;
//
// HeaderLabel
//
@@ -52,6 +53,18 @@ namespace ErgometerApplication
this.UitlegText.MaximumSize = new System.Drawing.Size(400, 0);
this.UitlegText.TabIndex = 2;
this.UitlegText.Text = text;
this.UitlegText.TextChanged += UitlegText_TextChanged;
}
private void UitlegText_TextChanged(object sender, EventArgs e)
{
if (UitlegText.Size.Height + UitlegText.Location.Y + 10 > this.Size.Height)
this.Size = new System.Drawing.Size(this.Size.Width, UitlegText.Size.Height + UitlegText.Location.Y + 10);
}
private void PanelClientSteps_Resize(object sender, EventArgs e)
{
UitlegText.MaximumSize = new System.Drawing.Size(this.Size.Width - 20, 0);
}
public void setText(string text)
@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ErgometerApplication
namespace ErgometerDoctorApplication
{
public class PanelClientSteps : Panel
{
@@ -30,6 +30,7 @@ namespace ErgometerApplication
this.Location = new System.Drawing.Point(0, 0);
this.Name = "PanelClientSteps";
this.Size = new System.Drawing.Size(284, 150);
this.Resize += PanelClientSteps_Resize;
//
// HeaderLabel
//
@@ -48,10 +49,22 @@ namespace ErgometerApplication
this.UitlegText.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.UitlegText.Location = new System.Drawing.Point(12, 35);
this.UitlegText.Name = "UitlegText";
this.UitlegText.MaximumSize = new System.Drawing.Size(400, 0);
this.UitlegText.Size = new System.Drawing.Size(800, 32);
this.UitlegText.MaximumSize = new System.Drawing.Size(400, 0);
this.UitlegText.TabIndex = 2;
this.UitlegText.Text = text;
this.UitlegText.TextChanged += UitlegText_TextChanged;
}
private void UitlegText_TextChanged(object sender, EventArgs e)
{
if(UitlegText.Size.Height + UitlegText.Location.Y + 10 > this.Size.Height)
this.Size = new System.Drawing.Size(this.Size.Width, UitlegText.Size.Height + UitlegText.Location.Y + 10);
}
private void PanelClientSteps_Resize(object sender, EventArgs e)
{
UitlegText.MaximumSize = new System.Drawing.Size(this.Size.Width - 20, 0);
}
public void setText(string text)
@@ -50,7 +50,7 @@ namespace ErgometerDoctorApplication
this.energy = new PanelClientData("Energie", 0, 200);
this.actualpower = new PanelClientData("Absolute Weerstand", 0, 400);
this.time = new PanelClientData("Tijd", 0, 400);
this.steps = new ErgometerApplication.PanelClientSteps();
this.steps = new PanelClientSteps();
this.panelClientContainer.SuspendLayout();
this.panelTopBar.SuspendLayout();
@@ -158,7 +158,7 @@ namespace ErgometerDoctorApplication
private System.Windows.Forms.Label labelUsername;
private System.Windows.Forms.Label labelHallo;
public PanelClientData heartBeat, RPM, speed, distance, power, energy, seconds, actualpower, time;
public ErgometerApplication.PanelClientSteps steps;
public PanelClientSteps steps;
private void createTitle()
{