# HG changeset patch # User StephaneLenclud # Date 1443098150 -7200 # Node ID e22bf44c4300e23696df645615e0687c354d27d9 # Parent 0f3e7b21c663c9b61d8825b3dde8d62beff87f0d Fixing issues where layout change would not be detected beccause of partial field similarity between new and older layout. Therefore we now clear our fields whenever our layout is changed. Now resetting our create bitmap flag, hoping it will fix our rather large memory usage when minimized. diff -r 0f3e7b21c663 -r e22bf44c4300 Client/MainForm.cs --- a/Client/MainForm.cs Thu Sep 03 20:05:09 2015 +0200 +++ b/Client/MainForm.cs Thu Sep 24 14:35:50 2015 +0200 @@ -220,6 +220,16 @@ layout.Columns[1].Width = 25F; //Send layout to server iClient.SetLayout(layout); + + //Set texts + iClient.CreateFields(new DataField[] + { + new DataField(0, textBoxTop.Text, Alignment), + new DataField(1, textBoxBottom.Text, Alignment), + new DataField(2, "Third text field", Alignment), + new DataField(3, "Forth text field", Alignment) + }); + } private void buttonSetBitmap_Click(object sender, EventArgs e) diff -r 0f3e7b21c663 -r e22bf44c4300 Server/MainForm.cs --- a/Server/MainForm.cs Thu Sep 03 20:05:09 2015 +0200 +++ b/Server/MainForm.cs Thu Sep 24 14:35:50 2015 +0200 @@ -133,6 +133,7 @@ UpdateStatus(); //We have a bug when drawing minimized and reusing our bitmap + //Though I could not reproduce it on Windows 10 iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb); iCreateBitmap = false; @@ -879,8 +880,9 @@ //Draw to bitmap if (iCreateBitmap) { - iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb); - } + iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb); + iCreateBitmap = false; + } tableLayoutPanel.DrawToBitmap(iBmp, tableLayoutPanel.ClientRectangle); //iBmp.Save("D:\\capture.png"); @@ -1269,8 +1271,8 @@ { if (WindowState == FormWindowState.Minimized) { - // Do some stuff - //iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb); + // To workaround our empty bitmap bug on Windows 7 we need to recreate our bitmap when the application is minimized + // That's apparently not needed on Windows 10 but we better leave it in place. iCreateBitmap = true; } } @@ -1502,11 +1504,18 @@ //Don't change a thing if the layout is the same if (!client.Layout.IsSameAs(aLayout)) { + Debug.Print("SetClientLayoutThreadSafe: Layout updated."); //Set our client layout then client.Layout = aLayout; + //Layout has changed clear our fields then + client.Fields.Clear(); // UpdateClientTreeViewNode(client); } + else + { + Debug.Print("SetClientLayoutThreadSafe: Layout has not changed."); + } } } } @@ -1553,7 +1562,7 @@ layoutChanged = true; } - //Now that we know hour fields are in place just update that one + //Now that we know our fields are in place just update that one client.Fields[aField.Index] = aField; if (client.Fields[aField.Index].IsSameLayout(aField)) @@ -1602,6 +1611,14 @@ UpdateTableLayoutPanel(iCurrentClientData); } } + else + { + Debug.Print("Layout has not changed."); + } + } + else + { + Debug.Print("WARNING: content and layout have not changed!"); } //When a client field is set we try switching to this client to present the new information to our user