Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) GridLane Merge cells like excel functionallity? (Read 4174 times)
Gabriel
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 30
Joined: Oct 9th, 2012
GridLane Merge cells like excel functionallity?
Oct 22nd, 2012 at 9:31am
Print Post  
Hello,

I have a gridlane diagram on which I need to allow the user to select continuous cells and "merge" them like excel.

I'm taking a look and it seems that this control doesn't allow that kind of operation, not even multiselect of cells (needed to allow the user to select what cells he wants to merge).

Anyone has any suggestion about how this kind of feature could be accomplished?
Thank you in advance
Regards
Gabriel
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: GridLane Merge cells like excel functionallity?
Reply #1 - Oct 22nd, 2012 at 1:56pm
Print Post  
Hi,

The attached sample illustrates a possible way to achieve cell merging using the built-in lane grid.

Let me know if it helps.

Regards,
Meppy
  

MergedCells.zip (Attachment deleted)
Back to top
 
IP Logged
 
Gabriel
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 30
Joined: Oct 9th, 2012
Re: GridLane Merge cells like excel functionallity?
Reply #2 - Oct 22nd, 2012 at 3:11pm
Print Post  
Hello,

That is great!!
Thank you very much.

However I have two issues with the solution.
1) The cells inside a "merged block" can also be selected individually. Nevertheless, I think I can solve this with some similar "trick".

2) If the cells has a "text", how can I write the text to a "merged block" as it is considered as just one cell? (i.e. the text flows for all cells.

Again, thank you very much for you support.
Regards
gabriel
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: GridLane Merge cells like excel functionallity?
Reply #3 - Oct 23rd, 2012 at 6:30am
Print Post  
Hi,

Unfortunately, there is no straightforward way to achieve this. I was able to do it by superimposing a transparent custom-drawn node on top of the entire diagram and drawing the text of the merged blocks in the DrawNode event handler. As a result, the text of the cells may appear on top of the grid headers if the view is scrolled.

Let me know if this works.

Regards,
Meppy
  

MergedCells_001.zip (Attachment deleted)
Back to top
 
IP Logged
 
Gabriel
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 30
Joined: Oct 9th, 2012
Re: GridLane Merge cells like excel functionallity?
Reply #4 - Oct 23rd, 2012 at 1:41pm
Print Post  
Hello,
Again, thank you very much for the support.
It works perfectly. I had to modify it to adjust some behaviors (like selecting the merge cells like excell) and added code to "unmerge" cells, but it works Smiley

About the text on top the grid headers, that is a problem, but maybe there is a way to know if the "cells" that are under the merged cell are currently visible, and if not (because they are under the "header", just avoid draw the text of the mergeblock.
What do you think?

Again, thank you.

Regards
Gabriel
  
Back to top
 
IP Logged
 
Gabriel
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 30
Joined: Oct 9th, 2012
Re: GridLane Merge cells like excel functionallity?
Reply #5 - Oct 23rd, 2012 at 2:12pm
Print Post  
Hello again,
I've just found that in your example you set the property:
laneGrid.HeadersOnTop = false;

If I change it from false to Top, the text on the mergeblock is hidden under the headers when the user scrolls the diagram.
Is there any reason to have that property as false?

Gabriel
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: GridLane Merge cells like excel functionallity?
Reply #6 - Oct 23rd, 2012 at 3:09pm
Print Post  
Hi,

In this sample there is no specific reason for HeadersOnTop to be false other than for testing purposes. If HeadersOnTop is set to true, then the grid headers are displayed on top of all diagram items. This includes the special transparent node that is used to custom-draw the texts of the merged cell blocks. I must have forgotten HeadersOnTop=false which resulted in texts displayed on top of the headers.

I hope this helps.

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


I Love MindFusion!

Posts: 30
Joined: Oct 9th, 2012
Re: GridLane Merge cells like excel functionallity?
Reply #7 - Oct 29th, 2012 at 11:30am
Print Post  
Hello again,

With some modifications I was able to merge the cells.
However I'm having a problem now, because as the diagram is seting the
Behavior= Behavior.DoNothing;
I can not select shapeNodes that are drawed over the gridLane.
Any suggestion about how can I mantain the "select and move" of shapes functionallity but with the "rangeselect" feature?

Thank you in advance,
Regards
Gabriel
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: GridLane Merge cells like excel functionallity?
Reply #8 - Oct 29th, 2012 at 2:50pm
Print Post  
Hi,

Try the following custom behavior:

Code
Select All
class SelectBehavior : ModifyBehavior
{
	public SelectBehavior(DiagramView diagramView)
		: base(diagramView)
	{
	}

	public override InteractionState StartDraw(PointF point)
	{
		InteractionState state = base.StartDraw(point);

		if (state.CurrentItem == Diagram.Selection &&
			Diagram.GetItemAt(point, true) == null)
		{
			RectangleF bounds = RectangleF.Empty;
			if (Diagram.LaneGrid.GetCellFromPoint(point, ref bounds) != null)
				return null;
		}

		return state;
	}
} 


This behavior removes the multiple selection aspect of the default Modify behavior when the user clicks and drags over the lane grid. The multiple selection still occurs when the click happens outside of the grid.

Assign an instance of this behavior to the DiagramView object:

Code
Select All
diagramView1.CustomBehavior = new SelectBehavior(diagramView1); 


Finally, in the DiagramView.MouseDown handler do not initiate cell selection if the click was above an item:

Code
Select All
...
if ((cell = laneGrid.GetCellFromPoint(point, ref bounds)) != null[b]&&
	diagram1.GetItemAt(point, true) == null)
... 


Let me know if this helps.

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


I Love MindFusion!

Posts: 30
Joined: Oct 9th, 2012
Re: GridLane Merge cells like excel functionallity?
Reply #9 - Oct 30th, 2012 at 10:43am
Print Post  
Hello,
Thank you for the answer, I had almost do something similar Smiley
Anothe question, I'm trying to catch the rightclick event over a cell so I have added the following:

diagramView.Click += new EventHandler(diagramView_Click);

But the event is only thrown the first time I right click on the diagram. The second time it is just ignored.
What am I missing?
Thank you
Gabriel
  
Back to top
 
IP Logged
 
Gabriel
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 30
Joined: Oct 9th, 2012
Re: GridLane Merge cells like excel functionallity?
Reply #10 - Oct 30th, 2012 at 11:46am
Print Post  
Hello,

I've just noticed that the right click event is only ignored if the diagramView.ContextMenuStrip variable is not null.

Is there any way to avoid this behavior, so I can capture the right click event AND add the contextmenustrip?

thank you
Gabriel
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: GridLane Merge cells like excel functionallity?
Reply #11 - Oct 30th, 2012 at 11:57am
Print Post  
Hi,

The Click event seems to be raised quite regularly in my test application. Maybe what you are experiencing is somehow related to the fact that the mouse is being captured in the DiagramView.MouseDown event handler. You can try to limit the cell selection interaction in MouseDown only to left mouse button clicks. This way the mouse will not be captured on right clicks.

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint