Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) There a way to have a tablenode handle its events? (Read 9796 times)
consolejoker
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Dec 17th, 2007
There a way to have a tablenode handle its events?
Mar 18th, 2008 at 3:11pm
Print Post  
Seems you have to handle them on the diagramView level. I would like to implement a custom TableNode instance by deriving from it from TableNode and having it populate its rows/cols on it's own based on some parameters, and handle events on its own.

As it is now it seems you have to do a lot of plumbing outside of the TableNode to get it to work and fake hosting input controls etc. Is there an easier way?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: There a way to have a tablenode handle its eve
Reply #1 - Mar 18th, 2008 at 3:25pm
Print Post  
What kind of events do you need to handle for tables? There are some overridable methods defined in the base classes, and we could add more specific methods for TableNode as well.

Stoyan
  
Back to top
 
IP Logged
 
consolejoker
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Dec 17th, 2007
Re: There a way to have a tablenode handle its eve
Reply #2 - Mar 18th, 2008 at 3:32pm
Print Post  
Stoyo wrote on Mar 18th, 2008 at 3:25pm:
What kind of events do you need to handle for tables? There are some overridable methods defined in the base classes, and we could add more specific methods for TableNode as well.

Stoyan


CellClick, CellEnter, CellLeave, CellHover are the ones that come to mind. Right now I have to handle them off of the diagram/diagramView and that sort of binds knowledge of those special cases to the diagram/View.

I'm essentially trying to create a special class that will take any custom class that has certain .NET attributes and which will then act as a factory to create an instance of a tablenode that displays the properties of that custom class and handle basic events for displaying it, sort of a dynamic property sheet.
  
Back to top
 
IP Logged
 
consolejoker
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Dec 17th, 2007
Re: There a way to have a tablenode handle its eve
Reply #3 - Mar 18th, 2008 at 3:36pm
Print Post  
Btw, what is the CellTextEdited event for? If I have a cell in a table, the only way to edit it is to dynamically show my own input control right? There is nothing built in?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: There a way to have a tablenode handle its eve
Reply #4 - Mar 18th, 2008 at 3:57pm
Print Post  
There is the DiagramView.AllowInplaceEdit property - enable it and you should be able to edit the cell text by double-clicking the cell.
  
Back to top
 
IP Logged
 
consolejoker
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Dec 17th, 2007
Re: There a way to have a tablenode handle its eve
Reply #5 - Mar 18th, 2008 at 5:03pm
Print Post  
Stoyo wrote on Mar 18th, 2008 at 3:57pm:
There is the DiagramView.AllowInplaceEdit property - enable it and you should be able to edit the cell text by double-clicking the cell.


OK I didn't know about this feature. I think this could be really useful but its missing a few things that I cannot for the life of me find anywhere.

Here would be my wish list for improving the editability of table cells.

1) Allow dropdowns as well. Doesn't have to be fancy, just an array of strings, or whatever.

2) The ability to style the input controls. Right now the controls use the standard Win32 appearance, which is beveled. It would be preferable to be able to use a flat style, in keeping with the appearance of many nodes. It would furthermore be useful to be able to color the border, the background, and very importantly the *highlight* color when text is highlighted. Lastly, the ability to have rounded corners on the input controls (text and dropdown) would be an invaluable step in providing us the ability to make a UI that is consistent. Most nodes are rounded, most controls are not.

I have tried incorporating 3rd party controls that are rounded and offer these styling properties. The problem is I have yet to find both a combo box and a text box from the same vendor with the same set of properties. I got close, but no drop downs have rounded corners that I have been able to find, and neither allow you to change the text highlight color, which will often clash with the color scheme of the UI I am implementing.

I guess a lot of this is pipe dreams, but I offer them up for your consideration nonetheless.

Many thanks!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: There a way to have a tablenode handle its eve
Reply #6 - Mar 19th, 2008 at 9:22am
Print Post  
https://mindfusion.eu/_beta/fcnet503.zip

We have added CreateEditControl and DestroyEditControl events to the DiagramView class. With them, the InteractiveTable sample looks like this

Code
Select All
private void diagram_CellClicked(object sender, CellEventArgs e)
{
	_comboBox.SelectedIndex = 0;
	_row = e.Row;
	_col = e.Column;
	_table = e.Table;
	diagramView.BeginEdit(e.Cell);
}

private void diagramView_CreateEditControl(object sender, InPlaceEditEventArgs e)
{
	TableNode.Cell cell = e.Item as TableNode.Cell;
	if (cell != null)
	{
		RectangleF docRect = e.Item.GetEditRect(PointF.Empty);
		_comboBox.Bounds = diagramView.DocToClient(docRect);
		_comboBox.Visible = true;
		e.EditControl = _comboBox;

		for (int i = 0; i < _comboBox.Items.Count; i++)
		{
			if (_comboBox.Items[i].ToString() == cell.Text)
			{
				_comboBox.SelectedIndex = i;
				break;
			}
		}
	}
}

private void diagramView_DestroyEditControl(object sender, InPlaceEditEventArgs e)
{
	if (_col != -1 && _row != -1 && _table != null)
	{
		_table[_col, _row].Text =
			_comboBox.Items[_comboBox.SelectedIndex].ToString();
	}
	_comboBox.Visible = false;
}
 



The events let you use any Windows Forms control as an editor for nodes, links and table cells. I'm afraid we don't have plans to develop combo and edit controls ourselves, so you still need to find some 3rd party controls to use as editors.

Stoyan
  
Back to top
 
IP Logged
 
consolejoker
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Dec 17th, 2007
Re: There a way to have a tablenode handle its eve
Reply #7 - Mar 19th, 2008 at 12:55pm
Print Post  
Thanks! That is a lot less code and much cleaner than what I'm currently doing.

Do you know how possible/practical it would be use WPF controls for editing? Is that unreasonably heavy? Any rendering issues that might arise? I imagine it shouldn't be too heavy given that only one will be shown at a time while editing, but not sure about the rendering issues.

Thank you SO much for such a swift resolution!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: There a way to have a tablenode handle its eve
Reply #8 - Mar 19th, 2008 at 1:08pm
Print Post  
I suppose it shouldn't be a problem to return an ElementHost control as an editor, and host a WPF control in it. However, I don't know if the ElementHost can be made transparent, which you might need in order to implement rounded corners for text and combo boxes.

Stoyan
  
Back to top
 
IP Logged
 
consolejoker
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Dec 17th, 2007
Re: There a way to have a tablenode handle its eve
Reply #9 - Mar 19th, 2008 at 1:24pm
Print Post  
Stoyo wrote on Mar 19th, 2008 at 1:08pm:
I suppose it shouldn't be a problem to return an ElementHost control as an editor, and host a WPF control in it. However, I don't know if the ElementHost can be made transparent, which you might need in order to implement rounded corners for text and combo boxes.

Stoyan


Hmm, well let me see if I'm following you. If you set the background of the element host to the background color of the table node, say gray, and then draw the combobox/textbox within the element host with rounded corners, there is no need for transparency since it's in effect simulated no? If the background color of the element host is the same as the table node I am supposing it should look as if it is transparent.

Or maybe I am missing something because I have not done much WPF at all, I have found the toolchain very very confusing, but I'm at this point desperate to get the consistent rounded look so I will do almost anything.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: There a way to have a tablenode handle its eve
Reply #10 - Mar 19th, 2008 at 1:29pm
Print Post  
If there are some text characters or cell border lines drawn just under the transparent part of the rounded corners, the ElementHost background would hide them and I guess it won't look nice. Anyway, first try setting the ElementHost color to Transparent, and if it doesn't work, try with the table's fill color.

Stoyan
  
Back to top
 
IP Logged
 
consolejoker
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Dec 17th, 2007
Re: There a way to have a tablenode handle its eve
Reply #11 - Mar 19th, 2008 at 1:40pm
Print Post  
Stoyo wrote on Mar 19th, 2008 at 1:29pm:
If there are some text characters or cell border lines drawn just under the transparent part of the rounded corners, the ElementHost background would hide them and I guess it won't look nice. Anyway, first try setting the ElementHost color to Transparent, and if it doesn't work, try with the table's fill color.

Stoyan


I see what you're saying, if there's anything on the table node cell itself or the table node that is underneath the element host, and if it cuts into the rounded area outside the rounded curve, then it will get overwritten? yes that wouldn't look good, although in my usage scenario I plan on having a very clean setup and there should in theory be nothing around those areas.

Now I guess my next question is Off Topic, does anyone know of any good wpf textboxes and comboboxes that are rounded?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: There a way to have a tablenode handle its eve
Reply #12 - Mar 19th, 2008 at 1:51pm
Print Post  
You should be able to replace the WPF's TextBox.Template with a rounded Rectangle visual - whose RadiusX and RadiusY properties are set to a value greater than 0. Another option is to place the TextBox inside a Border control and set the border's CornerRadius property.

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


I love YaBB 1G - SP1!

Posts: 74
Joined: Dec 17th, 2007
Re: There a way to have a tablenode handle its eve
Reply #13 - Mar 19th, 2008 at 2:41pm
Print Post  
Stoyo wrote on Mar 19th, 2008 at 1:51pm:
You should be able to replace the WPF's TextBox.Template with a rounded Rectangle visual - whose RadiusX and RadiusY properties are set to a value greater than 0. Another option is to place the TextBox inside a Border control and set the border's CornerRadius property.

I hope that helps,
Stoyan


I suspect the combo box will not be as easy?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: There a way to have a tablenode handle its eve
Reply #14 - Mar 19th, 2008 at 2:57pm
Print Post  
You'll just need to change two templates instead of one. This guide shows how to do that using Blend:
http://www.designerwpf.com/2008/02/07/the-wpf-designers-guide-to-styling-the-com...

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint