Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Ways to skin/change the DiagramView scrollbars? (Read 8848 times)
bogdip
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 70
Joined: Sep 8th, 2008
Ways to skin/change the DiagramView scrollbars?
Aug 21st, 2009 at 6:34am
Print Post  
Hello,

   We use in our application besides the DiagramView controls, some third party controls which uses different scroll bars then the classical VScrollBar which is used by the DiagramView. These controls can be set to use the just the silver xp theme look for their scrollbars so we want the DiagramView also to use just the silver xp look for its scrollbars, no matter what color scheme is set on the target machine.

Is there a possibility to skin the DiagramView scrollbars? The only way I found is to replace them entirely. Is there another simpler way to have a custom look for the DiagramView scrollbars?

Thanks,
Bogdan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Ways to skin/change the DiagramView scrollbars
Reply #1 - Aug 21st, 2009 at 9:20am
Print Post  
Hi,

We don't know of any way to change the style of the classic scrollbars. We have implemented styleable scrollbars for our scheduling component and could reuse them in the DiagramView implementation, though the built-in styles they support might not look exactly like the other controls you are using.

If the third party controls package you are using includes standalone scrollbar controls, you might try using them instead of the DiagramView ones. Set DiagramView.ShowScrollbars = false, and place the custom horizontal and vertical scrollbars at the right and bottom sides of the view. Handle the scroll events by setting the view's ScrollX and ScrollY. If using the DiagramView auto-scrolling feature, you might have to handle SrollChanged to update the scrollbar positions. In that case you might need to use a boolean flag to guard against infinite recursion in the scroll event handlers.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
bogdip
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 70
Joined: Sep 8th, 2008
Re: Ways to skin/change the DiagramView scrollbars
Reply #2 - Aug 24th, 2009 at 12:27pm
Print Post  
Thanks,

So the only solution is to place my third party scroll bars on to the diagram view and hide the original ones.
I encounter 2 issues here:

1. If I hide the original scroll bars (ShowScrollBars = false) than the border gap disappears.

I have a refresh layout method which is called each time a table node is added into the diagram:

public void RefreshDiagramLayout()
{
_ermDiagram.RouteAllLinks();

_layout.Arrange(_ermDiagram);//, _ermDiagram.Items);

//the Diagram.ResizeToFitItems method must be called after the Layout.Arrange was called,
//otherwise, chances exist that the items (tables) to not be correctly fit in the view
_ermDiagram.ResizeToFitItems(25, false);
}

But if ShowScrollBars = false then the 25 mm border gap disappears.

2. I need a way to update the scrollbars settings every time the diagram is updated. I don't know if this covers all the cases but I 've overwritten the DiagramView's OnLayout method, and after calling the base class's OnLayout, I copy the original scrollbars properties into the new ones (Visible, Value, Minimum, Maximum, SmallChange, LargeChange). Is this a correct approach ?

Thanks,
Bogdan[pre][/pre]
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Ways to skin/change the DiagramView scrollbars
Reply #3 - Aug 25th, 2009 at 3:39pm
Print Post  
1. Don't place them over the view, but outside aligned to the right and bottom.

2. You could handle the ScrollChanged, BoundsChanged and ZoomChanged events.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
bogdip
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 70
Joined: Sep 8th, 2008
Re: Ways to skin/change the DiagramView scrollbars
Reply #4 - Aug 28th, 2009 at 9:18am
Print Post  
Hi Stoyo,

1. I placed the new scollbars on the right and bottom of the diagram view, so the diagram view and the scrollbars are placed on a container panel, the scrollbars docked to the right and bottom and the diagram view filled in that container panel.
But it seams that if I set ShowScrollBars = false (no matter if new scrollbars are placed on the container panel or not), the border gap disappears.

The only way to overcome this unwanted behavior is to place the diagram view in its own container panel and set the Padding property to this panel. Is there another way to show that border gap and also to have "ShowScrollBars = false" ?

2. Thanks, that seems to handle all situations when the scrollbars are redimensioned. But I have a problem. I used this code which is called from the ScrollChanged, BoundsChanged and ZoomChanged event handlers:

Code
Select All
internal void SetCustomScrollBars()
        {
            //diagramView.VScrollBar.Visible = true;
            //diagramView.HScrollBar.Visible = true;

            if (diagramView.HScrollBar == null || !diagramView.HScrollBar.Visible)
            {
                horizontalScrollbar.Visible = false;
            }
            else
            {
                horizontalScrollbar.Visible = true;
                horizontalScrollbar.Minimum = diagramView.HScrollBar.Minimum;
                horizontalScrollbar.Maximum = diagramView.HScrollBar.Maximum;
                horizontalScrollbar.SmallChange = diagramView.HScrollBar.SmallChange;
                horizontalScrollbar.LargeChange = diagramView.HScrollBar.LargeChange;
                horizontalScrollbar.Value = diagramView.HScrollBar.Value;
            }

            if (diagramView.VScrollBar == null || !diagramView.VScrollBar.Visible)
            {
                verticalScrollbar.Visible = false;
            }
            else
            {
                verticalScrollbar.Visible = true;
                verticalScrollbar.Minimum = diagramView.VScrollBar.Minimum;
                verticalScrollbar.Maximum = diagramView.VScrollBar.Maximum;
                verticalScrollbar.SmallChange = diagramView.VScrollBar.SmallChange;
                verticalScrollbar.LargeChange = diagramView.VScrollBar.LargeChange;
                verticalScrollbar.Value = diagramView.VScrollBar.Value;
            }

            //diagramView.VScrollBar.Visible = false;
            //diagramView.HScrollBar.Visible = false;
        }
 



...and it's working very well but only when the ShowScrollBars=true. And in this case both scrollbars pairs are displayed, so I need to hide the original one. My problem is that if I set the ShowScrollBars=false the diagramView.HScrollBar and diagramView.VScrollBar are null so I can't use them anymore to copy their settings into the new ones.
I tried (the first and last 2 lines commented) to hide the original scrollbars on runtime (ShowScrollBars=true) but it does not work. They still appear.

Can you give me a hint on how to simulate the original scrollbars min/max/small/large properties updates into the new scrollbars?

Thanks,
Bogdan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Ways to skin/change the DiagramView scrollbars
Reply #5 - Aug 28th, 2009 at 11:23am
Print Post  
Hi,

The built-in scrollbars are set up like this

Code
Select All
private void ResetScrollbars()
{
	RectangleF visibleRegion = ClientToDoc(ClientRectangle);

	// happens with the docking control of a certain third party vendor
	if (visibleRegion.Width < 0)
		visibleRegion.Width = 0;
	if (visibleRegion.Height < 0)
		visibleRegion.Height = 0;

	hScrollBar.Minimum = (int)diagram.Bounds.Left;
	hScrollBar.Maximum = (int)diagram.Bounds.Right;
	hScrollBar.Value = (int)ValueInScrollRange(ScrollX, hScrollBar);
	hScrollBar.LargeChange = (int)visibleRegion.Width;
	hScrollBar.Visible = hScrollBar.LargeChange <
		hScrollBar.Maximum - hScrollBar.Minimum;
	if (!hScrollBar.Visible)
		SetScrollX(diagram.Bounds.Left);

	vScrollBar.Minimum = (int)diagram.Bounds.Top;
	vScrollBar.Maximum = (int)diagram.Bounds.Bottom;
	vScrollBar.Value = (int)ValueInScrollRange(ScrollY, vScrollBar);
	vScrollBar.LargeChange = (int)visibleRegion.Height;
	vScrollBar.Visible = vScrollBar.LargeChange <
		vScrollBar.Maximum - vScrollBar.Minimum;
	if (!vScrollBar.Visible)
		SetScrollY(diagram.Bounds.Top);
}

/// <summary>
/// Ensures that the specified value is within the range
/// of valid values for the specified scroller.
/// </summary>
static private float ValueInScrollRange(float value, ScrollBar scrollBar)
{
	return Math.Min(Math.Max(value, scrollBar.Minimum), scrollBar.Maximum);
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
bogdip
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 70
Joined: Sep 8th, 2008
Re: Ways to skin/change the DiagramView scrollbars
Reply #6 - Aug 28th, 2009 at 10:30pm
Print Post  
Great, it seems it did the trick. Only one small issue here: I replaced the

Code
Select All
 SetScrollX(diagram.Bounds.Left);  



with
Code
Select All
 ScrollX = diagram.Bounds.Left;  



because the SetScrollX is a private method. Are there any drawbacks in using ScollX assignment instead of calling the SetScrollX private method?

Ah, and I've added also a Layout event handler for the diagram view where I call the ResetScrollbars method. Because when resizing the diagram view, the scollbars did not get updated. (so, the ResetScollbars is now called from DiagramView_ScrollChanged, DiagramView_ZoomFactorChanged, DiagramView_Layout and Diagram_BoundsChanged event handlers ).

Thanks,
Bogdan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Ways to skin/change the DiagramView scrollbars
Reply #7 - Aug 30th, 2009 at 7:07am
Print Post  
Hi Bogdan,

The ScrollX setter just calls SetScrollX, and if ShowScrollbars is enabled, updates the built-in scrollbar's Value. So in your case setting ScrollX is the same as calling SetScrollX.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
bogdip
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 70
Joined: Sep 8th, 2008
Re: Ways to skin/change the DiagramView scrollbars
Reply #8 - Aug 31st, 2009 at 8:57am
Print Post  
Thanks a lot!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint