Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic LaneGrid setup, 2 rows 1 column and re-sizable (Read 1974 times)
breiny
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Mar 10th, 2010
LaneGrid setup, 2 rows 1 column and re-sizable
Mar 10th, 2010 at 10:33pm
Print Post  
I am new to the WpfDiagram, I would like to setup the LaneGrid to have 1 column with 2 rows, that auto-sizes to the window size. I have looked at the provided Lanes sample solution, but I can't figure out how to set the row height, or column width. Any help would be appreciated
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: LaneGrid setup, 2 rows 1 column and re-sizable
Reply #1 - Mar 11th, 2010 at 8:59am
Print Post  
Hi,

Assuming that diagramView is a variable referencing the DiagramView object of interest, here is the C# code to setup the grid:

Code
Select All
Diagram diagram = diagramView.Diagram;
MindFusion.Diagramming.Wpf.Lanes.Grid laneGrid = diagram.LaneGrid;

laneGrid.ColumnCount = 1;
laneGrid.RowCount = 2;
diagram.EnableLanes = true; 


The code above simply initializes the lane grid with two rows and a column. In order to resize the rows and the column, we attach a handler to the DiagramView's SizeChanged event. Then assign the appropriate width and height to the grid columns and rows respectively. Here is the implementation of the SizeChanged event hander:

Code
Select All
void diagramView_SizeChanged(object sender, SizeChangedEventArgs e)
{
      Diagram diagram = diagramView.Diagram;
      MindFusion.Diagramming.Wpf.Lanes.Grid laneGrid = diagram.LaneGrid;

      double columnWidth = diagramView.ActualWidth - laneGrid.GetRowHeaderBounds().Width - SystemParameters.VerticalScrollBarWidth;
      double rowHeight = (diagramView.ActualHeight - laneGrid.GetColumnHeaderBounds().Height - SystemParameters.HorizontalScrollBarHeight) / laneGrid.RowHeaders.Count;

      laneGrid.ColumnHeaders[0].Width = columnWidth;
      laneGrid.RowHeaders[0].Height = rowHeight;
      laneGrid.RowHeaders[1].Height = rowHeight;
} 


The code above calculates the width of the column by subtracting the width of the row headers and the width of the vertical scroll bar from the actual width of the diagram view. A similar calculation is performed for row heights.

I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
breiny
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Mar 10th, 2010
Re: LaneGrid setup, 2 rows 1 column and re-sizable
Reply #2 - Mar 11th, 2010 at 2:46pm
Print Post  
Thanks a bunch, that worked great. This is the code that I needed.

[code]
laneGrid.ColumnHeaders[0].Width = columnWidth;
laneGrid.RowHeaders[0].Height = rowHeight;
laneGrid.RowHeaders[1].Height = rowHeight;

[/code]
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint