Prechádzať zdrojové kódy

Dynamically change size of panel

Kenneth van Ewijk 10 rokov pred
rodič
commit
3b28c2c5d1

+ 13 - 0
ErgometerIPR/ErgometerApplication/PanelClientSteps.cs

@@ -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)

+ 15 - 2
ErgometerIPR/ErgometerDoctorApplication/Client/PanelClientSteps.cs

@@ -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)

+ 2 - 2
ErgometerIPR/ErgometerDoctorApplication/Client/SessionWindow.Designer.cs

@@ -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()
         {