 |
|
 |
When we put the splitter on a form, it works as expected. However, when we put it on a custom control (or standard panel), it has problems. It correctly draws itself, and correctly hides/shows the "controlToHide". However, the location of the splitter does not move. When we place everything on a Panel, it moves, but the "dark gray" outline of the "old" position remains. Our guess is that there is a bunch of extra processing that occurs behind the scenes on the Form vs. a control. Any ideas on how we might get this to work correctly? Thanks.
|
|
|
|
 |
|
 |
Yeah! I met the same problem:
Please allow me to use the term "Shadow" to describe the stuff which I really didn't know how to name it. The term "Shadow" is: When you press the splitter( don't release you mouse ) or drag the splitter, you can see a "Shadow" which helps to identify the position of the splitter.
----------------------------------------------
OK, here is the issue:
1, I set the UseAnimation to "False", Mozila style and run the application.
2, When I click the splitter, everything is OK except the "Shadow" still left.
3, And I replace your splitter with .Net 2.0's. The sistuation still happens. So I think it's Windows's fault.
Release PunCha's Power!
|
|
|
|
 |
|
 |
I think it's splitter's bug. i also met this shadow when using splitter with user control in panel. anyone please help
|
|
|
|
 |
|
 |
It appears you can't drag/resize the splitter by attempting to "grab" the splitter button. The button only allows clicking to hide a control. It would be nice to allow re-sizing as well but didn't find a way.
|
|
|
|
 |
|
 |
You can made the following changes to the member function OnMouseDown:
protected override void OnMouseDown(MouseEventArgs e)
{
if (this.controlToHide != null)
{
if ( this.controlToHide.Visible)
{
base.OnMouseDown(e);
}
}
}
Release PunCha's Power!
|
|
|
|
 |
|
 |
I added offscreen drawing to OnPaint. At times I could see the individual dots being drawn
Other than that great control and thanks!
t
relavent code
// OnPaint is now an override rather than an event in version 1.1
protected override void OnPaint(PaintEventArgs e)
{
// create a Graphics object
Graphics g = e.Graphics;
//create our offscreen bitmap
Bitmap b = new Bitmap(ClientRectangle.Width,
ClientRectangle.Height);
Graphics bg = Graphics.FromImage(b);
bg.Clear(this.BackColor);
// find the rectangle for the splitter and paint it
Rectangle r = this.ClientRectangle; // fixed in version 1.1
// g.FillRectangle(new SolidBrush(this.BackColor), r);
#region Vertical Splitter
// Check the docking style and create the control rectangle accordingly
if(this.Dock == DockStyle.Left || this.Dock == DockStyle.Right)
{
// create a new rectangle in the vertical center of the splitter for our collapse control button
rr = new Rectangle(r.X, (int)r.Y + ((r.Height - 115)/2), 8, 115);
// force the width to 8px so that everything always draws correctly
this.Width = 8;
// draw the background color for our control image
if(hot)
{
bg.FillRectangle(new SolidBrush(hotColor), new Rectangle(rr.X + 1, rr.Y, 6, 115));
}
else
{
bg.FillRectangle(new SolidBrush(this.BackColor), new Rectangle(rr.X + 1, rr.Y, 6, 115));
}
// draw the top & bottom lines for our control image
bg.DrawLine(new Pen(SystemColors.ControlDark, 1), rr.X + 1, rr.Y, rr.X + rr.Width - 2, rr.Y);
bg.DrawLine(new Pen(SystemColors.ControlDark, 1), rr.X + 1, rr.Y + rr.Height, rr.X + rr.Width - 2, rr.Y + rr.Height);
if(this.Enabled)
{
// draw the arrows for our control image
// the ArrowPointArray is a point array that defines an arrow shaped polygon
bg.FillPolygon(new SolidBrush(SystemColors.ControlDarkDark), ArrowPointArray(rr.X + 2, rr.Y + 3));
bg.FillPolygon(new SolidBrush(SystemColors.ControlDarkDark), ArrowPointArray(rr.X + 2, rr.Y + rr.Height - 9));
}
// draw the dots for our control image using a loop
int x = rr.X + 3;
int y = rr.Y + 14;
// Visual Styles added in version 1.1
switch(visualStyle)
{
case VisualStyles.Mozilla:
for(int i=0; i < 30; i++)
{
// light dot
bg.DrawLine(new Pen(SystemColors.ControlLightLight), x, y + (i*3), x+1, y + 1 + (i*3));
// dark dot
bg.DrawLine(new Pen(SystemColors.ControlDarkDark), x+1, y + 1 + (i*3), x+2, y + 2 + (i*3));
// overdraw the background color as we actually drew 2px diagonal lines, not just dots
if(hot)
{
bg.DrawLine(new Pen(hotColor), x+2, y + 1 + (i*3), x+2, y + 2 + (i*3));
}
else
{
bg.DrawLine(new Pen(this.BackColor), x+2, y + 1 + (i*3), x+2, y + 2 + (i*3));
}
}
break;
case VisualStyles.DoubleDots:
for(int i=0; i < 30; i++)
{
// light dot
bg.DrawRectangle(new Pen(SystemColors.ControlLightLight), x, y + 1 + (i*3), 1, 1 );
// dark dot
bg.DrawRectangle(new Pen(SystemColors.ControlDark), x - 1, y +(i*3), 1, 1 );
i++;
// light dot
bg.DrawRectangle(new Pen(SystemColors.ControlLightLight), x + 2, y + 1 + (i*3), 1, 1 );
// dark dot
bg.DrawRectangle(new Pen(SystemColors.ControlDark), x + 1, y + (i*3), 1, 1 );
}
break;
case VisualStyles.Win9x:
bg.DrawLine(new Pen(SystemColors.ControlLightLight), x, y, x + 2, y);
bg.DrawLine(new Pen(SystemColors.ControlLightLight), x, y, x,y + 90);
bg.DrawLine(new Pen(SystemColors.ControlDark), x + 2, y, x + 2, y + 90);
bg.DrawLine(new Pen(SystemColors.ControlDark), x, y + 90, x + 2, y + 90);
break;
case VisualStyles.XP:
for(int i=0; i < 18; i++)
{
// light dot
bg.DrawRectangle(new Pen(SystemColors.ControlLight), x, y + (i*5), 2, 2 );
// light light dot
bg.DrawRectangle(new Pen(SystemColors.ControlLightLight), x + 1, y + 1 + (i*5), 1, 1 );
// dark dark dot
bg.DrawRectangle(new Pen(SystemColors.ControlDarkDark), x, y +(i*5), 1, 1 );
// dark fill
bg.DrawLine(new Pen(SystemColors.ControlDark), x, y + (i*5), x, y + (i*5) + 1);
bg.DrawLine(new Pen(SystemColors.ControlDark), x, y + (i*5), x + 1, y + (i*5));
}
break;
case VisualStyles.Lines:
for(int i=0; i < 44; i++)
{
bg.DrawLine(new Pen(SystemColors.ControlDark), x, y + (i*2), x + 2, y + (i*2));
}
break;
}
// Added in version 1.3
if(this.borderStyle != System.Windows.Forms.Border3DStyle.Flat)
{
// Paint the control border
ControlPaint.DrawBorder3D(bg, this.ClientRectangle, this.borderStyle, Border3DSide.Left);
ControlPaint.DrawBorder3D(bg, this.ClientRectangle, this.borderStyle, Border3DSide.Right);
}
}
#endregion
// Horizontal Splitter support added in v1.2
#region Horizontal Splitter
else if (this.Dock == DockStyle.Top || this.Dock == DockStyle.Bottom)
{
// create a new rectangle in the horizontal center of the splitter for our collapse control button
rr = new Rectangle((int)r.X + ((r.Width - 115)/2), r.Y, 115, 8);
// force the height to 8px
this.Height = 8;
// draw the background color for our control image
if(hot)
{
bg.FillRectangle(new SolidBrush(hotColor), new Rectangle(rr.X, rr.Y + 1, 115, 6));
}
else
{
bg.FillRectangle(new SolidBrush(this.BackColor), new Rectangle(rr.X, rr.Y + 1, 115, 6));
}
// draw the left & right lines for our control image
bg.DrawLine(new Pen(SystemColors.ControlDark, 1), rr.X, rr.Y + 1, rr.X, rr.Y + rr.Height - 2);
bg.DrawLine(new Pen(SystemColors.ControlDark, 1), rr.X + rr.Width, rr.Y + 1, rr.X + rr.Width, rr.Y + rr.Height - 2);
if(this.Enabled)
{
// draw the arrows for our control image
// the ArrowPointArray is a point array that defines an arrow shaped polygon
bg.FillPolygon(new SolidBrush(SystemColors.ControlDarkDark), ArrowPointArray(rr.X + 3, rr.Y + 2));
bg.FillPolygon(new SolidBrush(SystemColors.ControlDarkDark), ArrowPointArray(rr.X + rr.Width - 9, rr.Y + 2));
}
// draw the dots for our control image using a loop
int x = rr.X + 14;
int y = rr.Y + 3;
// Visual Styles added in version 1.1
switch(visualStyle)
{
case VisualStyles.Mozilla:
for(int i=0; i < 30; i++)
{
// light dot
bg.DrawLine(new Pen(SystemColors.ControlLightLight), x + (i*3), y, x + 1 + (i*3), y + 1);
// dark dot
bg.DrawLine(new Pen(SystemColors.ControlDarkDark), x + 1 + (i*3), y + 1, x + 2 + (i*3), y + 2);
// overdraw the background color as we actually drew 2px diagonal lines, not just dots
if(hot)
{
bg.DrawLine(new Pen(hotColor), x + 1 + (i*3), y + 2, x + 2 + (i*3), y + 2);
}
else
{
bg.DrawLine(new Pen(this.BackColor), x + 1 + (i*3), y + 2, x + 2 + (i*3), y + 2);
}
}
break;
case VisualStyles.DoubleDots:
for(int i=0; i < 30; i++)
{
// light dot
bg.DrawRectangle(new Pen(SystemColors.ControlLightLight), x + 1 + (i*3), y, 1, 1 );
// dark dot
bg.DrawRectangle(new Pen(SystemColors.ControlDark), x + (i*3), y - 1, 1, 1 );
i++;
// light dot
bg.DrawRectangle(new Pen(SystemColors.ControlLightLight), x + 1 + (i*3), y + 2, 1, 1 );
// dark dot
bg.DrawRectangle(new Pen(SystemColors.ControlDark), x + (i*3), y + 1, 1, 1 );
}
break;
case VisualStyles.Win9x:
bg.DrawLine(new Pen(SystemColors.ControlLightLight), x, y, x, y + 2);
bg.DrawLine(new Pen(SystemColors.ControlLightLight), x, y, x + 88, y);
bg.DrawLine(new Pen(SystemColors.ControlDark), x, y + 2, x + 88, y + 2);
bg.DrawLine(new Pen(SystemColors.ControlDark), x + 88, y, x + 88, y + 2);
break;
case VisualStyles.XP:
for(int i=0; i < 18; i++)
{
// light dot
bg.DrawRectangle(new Pen(SystemColors.ControlLight), x + (i*5), y, 2, 2 );
// light light dot
bg.DrawRectangle(new Pen(SystemColors.ControlLightLight), x + 1 + (i*5), y + 1, 1, 1 );
// dark dark dot
bg.DrawRectangle(new Pen(SystemColors.ControlDarkDark), x +(i*5), y, 1, 1 );
// dark fill
bg.DrawLine(new Pen(SystemColors.ControlDark), x + (i*5), y, x + (i*5) + 1, y);
bg.DrawLine(new Pen(SystemColors.ControlDark), x + (i*5), y, x + (i*5), y + 1);
}
break;
case VisualStyles.Lines:
for(int i=0; i < 44; i++)
{
bg.DrawLine(new Pen(SystemColors.ControlDark), x + (i*2), y, x + (i*2), y + 2);
}
break;
}
// Added in version 1.3
if(this.borderStyle != System.Windows.Forms.Border3DStyle.Flat)
{
// Paint the control border
ControlPaint.DrawBorder3D(bg, this.ClientRectangle, this.borderStyle, Border3DSide.Top);
ControlPaint.DrawBorder3D(bg, this.ClientRectangle, this.borderStyle, Border3DSide.Bottom);
}
}
#endregion
else
{
throw new Exception("The Collapsible Splitter control cannot have the Filled or None Dockstyle property");
}
//push our bitmap forward to the screen
g.DrawImage(b, 0, 0);
bg.Dispose();
b.Dispose();
// dispose the Graphics object
g.Dispose();
}
|
|
|
|
 |
|
 |
I have placed it on my form but I don't know how to expand it
|
|
|
|
 |
|
 |
"It" itself doesn't collapse, rather it collapses the control you've specified in the ControlToHide property. In all other respects it works the same as the standard Splitter control. For more info read the article or the comments in the code.
|
|
|
|
 |
|
 |
hanks for your reply,I'm really enjoying it but how come yuo didn't post the sample with it.I have got 2 questions:
1)how can I put the spliter on the other side of control like what you have done in your demo?Mine is always stuck to the edge of the form.
2)How can I adjust the height of control.
That's awesome man.
|
|
|
|
 |
|
 |
Hi there!
I am using the collapsible splitter in combination with Weifen Lou´s DockPanelSuite.
When I use the collapsibleSplitter with normal windows forms panels everything works perfect. As soon as I use a DockPanel instead of the normal Panel it appears that the splitter control is sometimes drawn, sometimes not drawn or sometimes partly drawn.
Cause that phenomenon is only happening in combination with dockpanelsuite I guess it´s a problem of the dockpanelsuite.
Does anybody have a clue what the problem is about and do you know how to solve it or at least give me a hint?
thanks in advance,
rascreek
|
|
|
|
 |
|
 |
I have the same problem. I am not using the DockPanelSuite, however, my form is very heavily paneled. Have you found a solution since your post?
|
|
|
|
 |
|
 |
I think the Panel controls just ignore the CollapsibleSplitter. I've cooked up a sample project that shows this behaviour. I've posted it at
http://www.vbrad.com/downloads/furty.zip
for the author to take a look at.
|
|
|
|
 |
|
 |
Please check the control heirarchy in your project.
The CollapsibleSplitter is the same as the base Splitter control in the fact that it will only have an effect on sibling controls - it cannot have any effect on controls that are higher up the heirarchy than itself, and will not have a direct effect on controls lower in the heirarchy.
Unfortunately I get emails every week from people who make the CollapsibleSplitter a child of a panel/control and then wonder why it doesn't hide it.
If in doubt, replace the CollapsibleSplitter with a standard Splitter and test..
|
|
|
|
 |
|
 |
Furty, the controls are definetely in the proper hierarchy. If you don't believe me, check out the sample project, I posted 2 messages above.
I believe, when the entire set of panels is in a parent panel, the inner panels do ignore the CollapsibleSplitter, but don't ignore the regular Splitter control.
I fixed the issue in my app by removing as many panels as I possibly could, but if you'll check the sample project, you'll see that I am right.
Btw, thanks again for a fantastic component.
|
|
|
|
 |
|
 |
Hi robdogg,
I've had a look at your sample app, and the problem is definately related to heirarchy, or more specifically, the z-order within the heirarchy.
In order to make the sample application behave the way you want, you need to manipulate the z-order so it looks like this:
Form1
-panelPage
--panelNameAndBrowser
---browser
---panel1
----checkBox1
----radioButton1
--collapsibleSplitter1
--panelCalendar
Use the Send to Back/Send to Front from the context menu to get it in the right order, and it will work as expected.
Hope this helps.
|
|
|
|
 |
|
 |
Furty,
Thank you very much. Your comments were right on the money. I had no idea that the order of the controls being added via the .Controls.Add made a difference. Kind of odd. I would thing that zorder would be manipulated via perhaps a ZOrder property, but it doesn't exist.
|
|
|
|
 |
|
 |
hey guys!
i just came back from my well-earned holidays and see the solution to my problem has been found!
thanks a lot furty and also rob for the example file!
I like it when my first working day starts with good news!
greets,
ras
|
|
|
|
 |
|
 |
I can't seem to get this to work with a tabConrol. It works great with the other controls I have tried. I get an error in designed view saying that only tabPages can be added to a tabControl.
I can make it work but it doesn't look right, it docks on the left side of the tabControl with the arrows facing the wrong way.
Any ideas?
Thanks
|
|
|
|
 |
|
 |
The error message you're seeing is correct - a blank TabControl will only accept a TabPage instance as a child. What is it you want to collapse? If it's the TabControl itself, you should be adding the CollapsibleSplitter to the control that's parent to the TabControl, not the TabControl itself.
For example, if your TabControl's parent is a form, and the CollpasibleSplitter to the Form, if it's a panel add the splitter to the panel, etc.
Hope this helps.
|
|
|
|
 |
|
 |
Hey...cool deal here. But why do you say "based on Mozilla web browser".
This idea has been around a lot longer than the Mozilla people and even before the Netscape type's decided to snipe some school code and start a company.
hmmm...might have actually been one of those boys in Redmond that first came out with the idea (as I remember it anyway)
|
|
|
|
 |
|
 |
DeeWorld wrote:
Hey...cool deal here. But why do you say "based on Mozilla web browser".
Quite simply because that's exactly what I modelled it from -The size, the behaviour and the visual style all come from Mozilla's implementation.
You're right in the fact that this style of control has been in many other products, most notably probably being Adobe Acrobat, but I'd still think that Mozilla is the application that truly popularised it.
DeeWorld wrote:
hmmm...might have actually been one of those boys in Redmond that first came out with the idea (as I remember it anyway)
Old enemies die hard eh?
The blogless coder
|
|
|
|
 |
|
 |
How can I make the grippie shorter? Any ideas?
|
|
|
|
 |
|
 |
Unfortunately in this (old) release the height of the button was hard coded in many places - it can be done, but it's going to take a few compiles to get it working right.
Much better would be for me to actually get around to posting V2 of this control which has been done for a few months now
The blogless coder
|
|
|
|
 |
|
 |
>>Much better would be for me to actually get around to posting V2 of this control which has been done for a few months now
<<
Then by all means, post it.
Also, if you aren't planning to post it in the near future, is it possible to receive it from you privately?
Thanks
|
|
|
|
 |
|
 |
robdogg1 wrote:
Then by all means, post it.
As sson as I figure out how to make more hours in the day, I will
robdogg1 wrote:
Also, if you aren't planning to post it in the near future, is it possible to receive it from you privately?
The updated control is now part of a much bigger library - my intention was to prepare the entire library as an article, rather than just the updated splitter code.
The blogless coder
|
|
|
|
 |
|