 |
|
 |
Most of the .Net inbuilt windows forms layout manager or layout capabilities are limited. You would need to resort to code to do professional layout tasks. For this reason, we created a professional layout manager called SmartLayouts to ease layout management. It is easy and powerful both simultaneously. To download demo version go to SmartLayouts Layout Manger
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Nice layout manager! It would have been quite useful before .Net 2.0, but now that we have access to TableLayoutPanel, what's the use of such a component? TableLayoutPanel is quite easy to use and handles absolute / percentage / autosize. You can add/remove columns and rows, span a control over several rows and or columns...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi,
Has anyone experienced and solved flicker when resizing a tab control with some pages and controls in each page?
Even with a very simple project (tab control, 2 pages, 1 textbox per page) the tab control redraw has a lot of flicker.
Thanks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi. I have tried with and without double buffer and the effect is the same. However, looking at the flicker now, I think I was probably being too critical. It is not so bad, and is probably as good as it is going to get with fully resizable and repositioned controls.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Ravi, Is it possible that the layoutmanger can position controls with respect to another control(Sibling controls). Is there a logic which could help me in doing that.
Thanks
Vicky (())
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Good job, thanks for it but when i run your demo project; first it does not let me to make the form more smaller than the original size it has. But after a few try to resize it from the right side (the side of buttons) of the form it lets me to make the form more smaller and i lose principle author label and text box. And when i recover the form to be able to see principle author label and text box i see principle authot textbox and ISBN textbox are sticked to each other and it becomes impossible to recover it.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
hnkaraca79 wrote: it does not let me to make the form more smaller than the original size it has.
That's intentional. See line 25 in LayoutManagerDemoFrm.cs: this.MinimumSize = Size; hnkaraca79 wrote: But after a few try to resize it from the right side (the side of buttons) of the form it lets me to make the form more smaller
That seems strange. I haven't been able to reproduce this behavior. Perhaps you commented out the above line in the code?
Thanks,
/ravi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Nope, i did not even see the code I just run your example. It is not happening in the first time, i am resizing from the right side several times. At the first times it does not let me to make the form smaller than it's original size. But later it lets me to make it more smaller and after a few tries i can make it more and more smaller. This can go on until i lose all the text box that i mentioned.
I will check/debug your code later and make a more valuable comment
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Interesting. I just retried using the release build, but am still unable to reproduce the problem. Also tried to make the form smaller after minimzing and maximizing the window.
Thanks,
/ravi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I need to install vs.2005 to debug it and i could not have time to look for it, but if it helps i am sending two screenshots to your email(which is stated in your signature)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Thanks for finding this issue. I can reproduce the bug by slowly (very slow) increase the size of the form and repeat it many times. And this is a math rounding problem.
The code calculates the changes in size (pxl) of the parent form and then redistributes the changes to the controls in the percentages as user specified. So the division between integers will inevitably cause small error in each adjustment due the rounding. It is possible during many resizing back and forth, the error can accumulated to distort the layout.
This is especially apparent when you slowly increase the size of the form. For example, when you increase the size by 1 pxl, then 1/3 of 1 pxl will be rounded away during calculation. Or more likely, when you increased the size by 4 pxl, the code will loss 1 pxl after the calculation for 1/3 adjustment. That is why normal resizing and maximize/minimize the screen have no apparent distortion (hence we failed to find this bug before release the code.). But slowly changing the form size will induce gradually increased distortion.
The solution for this math rounding problem is not trivial. The Layout manager has to have the knowledge of how to handle the rounding error. While the easy layout manager is good enough for normal use, this bug is a bit annoying. I will update the code once I find a simple solution (since this is an easy layout manager).
Thanks again for your feedback.
Eddie Zhou
qing zhou
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
As you say, the problem results from the accumulated rounding errors due to calculating the new position by applying the percentage change to the current position - each rounding error is carried forward to the next move.
The simple solution is to apply the percentage change to the initial position and to calculate the delta from the original position. This way there is only ever one rounding error applied to a control's position.
Here are the code changes that implement my solution:
LayoutManager.alignItems() - don't set m_nWidth and m_nHeight with the container's new size i.e.
public class LayoutManager { #region Properties
/// /// Gets the LayoutManager /// public ArrayList Items { get { return m_items; } }
#endregion
#region Operations
/// /// Initializes the layout manager. /// /// "container">Container control. public void init(Control container) { // Cache the operating context and initial dimensions m_container = container; m_nWidth = container.Width; m_nHeight = container.Height; }
/// /// Aligns the items under the layout manager /// public void alignItems() { // Ignore action if container has been minimized if (m_container is Form) { Form f = m_container as Form;
if (f.WindowState == FormWindowState.Minimized) return; }
// Compute change in dimensions int nDeltaWidth = m_container.Width - m_nWidth; int nDeltaHeight = m_container.Height - m_nHeight;
// Align controls foreach (LayoutManagerItem lim in m_items) { lim.align(nDeltaWidth, nDeltaHeight); } }
#endregion
#region Fields
/// Layout manager items to be aligned. ArrayList m_items = new ArrayList();
/// The container control. Control m_container = null;
/// Container int m_nWidth = 0;
/// Container int m_nHeight = 0;
#endregion }
Note - I also moved the align method to the LayoutManagerItem class as it seemed to make more sense to me to have it there.
Added 4 new fields to LayoutManagerItem to store the initial position values, set these in the constructor and use them to calculate the control's new size/position in the align() method i.e.
public class LayoutManagerItem {
#region Constructor
public LayoutManagerItem(Control ctrl, uint leftAdjustPct, uint topAdjustPct, uint rightAdjustPct, uint bottomAdjustPct) { m_ctrl = ctrl;
m_left = m_ctrl.Left; m_top = m_ctrl.Top; m_right = m_left + m_ctrl.Width; m_bottom = m_top + m_ctrl.Height;
m_leftAdjustPct = leftAdjustPct; m_topAdjustPct = topAdjustPct; m_rightAdjustPct = rightAdjustPct; m_bottomAdjustPct = bottomAdjustPct; }
#endregion
#region Operations
public void align(int nDeltaW, int nDeltaH) { int nLeft = m_left + (int)((nDeltaW * m_leftAdjustPct) / 100); int nTop = m_top + (int)((nDeltaH * m_topAdjustPct) / 100); int nRight = m_right + (int)((nDeltaW * m_rightAdjustPct) / 100); int nBottom = m_bottom + (int)((nDeltaH * m_bottomAdjustPct) / 100);
m_ctrl.Left = nLeft; m_ctrl.Top = nTop; m_ctrl.Width = nRight - nLeft; m_ctrl.Height = nBottom - nTop; }
#endregion
#region Fields
Control m_ctrl = null;
uint m_leftAdjustPct = 0;
uint m_rightAdjustPct = 0;
uint m_topAdjustPct = 0;
uint m_bottomAdjustPct = 0;
public int m_left = 0;
public int m_top = 0;
public int m_right = 0;
public int m_bottom = 0;
#endregion }
These fixes seem to correct the size/position problem.
Gavin
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Hi Gavin
Thanks for the elegant solution. I was thinking of setting a property for size (default to 5 pxl for triggering the align event vertically or horizontally) to smooth out the error. But I don’t like this method. Yours is much better.
Eddie Zhou
Eddie Zhou
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
Having spent quite a bit of time with the native layout support (in both .NET and Delphi), I found that there is some things that are lacking.
For example, keeping a control centered within its container but maintaining a fixed size.
Another is expressing the width or height of an an anchored control in terms of a percentage of the corresponding dimension of its container.
While the idea of doing your own layout management is great, does it offer more than just intamacy?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Yes, you're quite right. The layout manager I describe provides an easy way to do standard layout management. It would need to be enhanced to provide relative sizing and centering.
Thanks for your comments!
/ravi
My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
tonyt wrote: keeping a control centered within its container but maintaining a fixed size.
tonyt wrote: expressing the width or height of an an anchored control in terms of a percentage of the corresponding dimension of its container.
Both these capabilities are now available.
/ravi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
You can do this with the standard winforms layout manager. Just disable left AND right anchoring int the anchor property of the control.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |