Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) About ControlNode (Read 1122 times)
Nobu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Nov 27th, 2023
About ControlNode
Jan 10th, 2024 at 2:34am
Print Post  
I have a question about ControlNode drawing.
When I drag and drop, move, or scroll, the drawing of Control in ControlNode is corrupted.

Is there any way to fix or suppress this?

The node in question is configured as follows
CustomContainerNode
  └CustomControlNode
    └Panel
        ├LabelAndRichTextBox(Custom)
        └Label
All backgrounds are transparent.

A sample program is attached.
Select CustomContainerNode from the ListBox at the top of the screen and draw a shape by clicking or dragging and dropping on DiagramView.
  

WinFormsApp1.zip ( 12 KB | 171 Downloads )
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3223
Joined: Oct 19th, 2005
Re: About ControlNode
Reply #1 - Jan 10th, 2024 at 8:33am
Print Post  
Windows Forms does not support transparent control backgrounds all that well. You could repaint the diagram view during drag to clear the label's traces -

Code
Select All
void Diagram_NodeModifying(object? sender, NodeValidationEventArgs e)
{
    diagramView1.Refresh();
} 



Alternatively, you might try adding diagram's NodeLabel outside of ControlNode / RichText instead of a WinForms label inside user control.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3223
Joined: Oct 19th, 2005
Re: About ControlNode
Reply #2 - Jan 10th, 2024 at 8:40am
Print Post  
And if you don't need any of the RichTextBox mixed text formatting, you could replace it with a ShapeNode and start editing its text by calling DiagramView.BeginEdit(e.Node) from NodeClicked event. Transparency shouldn't be a problem then.
  
Back to top
 
IP Logged
 
Nobu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Nov 27th, 2023
Re: About ControlNode
Reply #3 - Jan 11th, 2024 at 12:08am
Print Post  
Thank you for your response.

I will try Replay#1 as I need RichText.

Regards,
Nobu
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3223
Joined: Oct 19th, 2005
Re: About ControlNode
Reply #4 - Jan 11th, 2024 at 10:26am
Print Post  
You could modify RtbToBitmap function here to return the rich-text bitmap as a result -

https://social.msdn.microsoft.com/Forums/en-US/1454d078-c312-4741-88df-aa7eb306f...

and then show the bitmap in ShapeNode, TableNode cell or CompositeNode's ImageComponent. Then you'd be able to use actual RichTextBox only as an editor by handling CreateEditControl event.

We especially created CompositeNode class as better alternative to ControlNodes, since latter don't always play nice with rest of the diagram, e.g. don't integrate well in Z order, can't export or print them very precisely, etc. Also performance won't be great once you add more than a few user controls as children of the DiagramView.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Nobu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Nov 27th, 2023
Re: About ControlNode
Reply #5 - Jan 12th, 2024 at 1:41am
Print Post  
Thanks for the additional response.

I did not see as much improvement with DiagramView.Refresh as I would have liked.
I tried adding it to the scroll event as well, but the ControlNode drawing is corrupted when scrolling.

I will consider the method you have suggested.

Regards,.
Nobu
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3223
Joined: Oct 19th, 2005
Re: About ControlNode
Reply #6 - Jan 12th, 2024 at 9:37am
Print Post  
Or you could set opaque background for the hosted controls. Your test project at least wasn't showing good reason for background to be transparent. If you really need to blend UI controls, you might also try WPF for better experience (you could host our WPF diagram inside a WinForms application by means of System.Windows.Forms.Integration.ElementHost).

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Nobu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Nov 27th, 2023
Re: About ControlNode
Reply #7 - Jan 17th, 2024 at 2:41am
Print Post  
Trying to use ImageComponent.

I have two questions below.
1. about click events
By setting "IsInteractive = true", the ImageComponent now recognizes the click, but is it possible for the ImageComponent to determine which button of the mouse was pressed?

2. about keyboard events
I would like to call CreateEditControl when F2 is pressed, but is it possible to get keyboard events in ImageComponent?

Regards,
Nobu
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3223
Joined: Oct 19th, 2005
Re: About ControlNode
Reply #8 - Jan 17th, 2024 at 7:09am
Print Post  
1. You could detect that from NodeClicked event handler:

Code
Select All
void OnNodeClicked(object sender, NodeEventArgs e)
{
    var composite = e.Node as CompositeNode;
    if (composite != null)
    {
        var image = composite.GetComponentAt(e.MousePosition) as ImageComponent;
        if (image != null && e.MouseButton == MouseButton.Right)
            ....
    }
} 

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3223
Joined: Oct 19th, 2005
Re: About ControlNode
Reply #9 - Jan 17th, 2024 at 7:17am
Print Post  
2. You could handle DiagramView's keyboard events -

Code
Select All
void OnDiagramViewKeyDown(object sender, KeyEventArgs e)
{
	var composite = diagram.ActiveItem as CompositeNode;
	if (e.KeyCode == Keys.F2 && composite != null)
		diagramView.BeginEdit(composite);
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Nobu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Nov 27th, 2023
Re: About ControlNode
Reply #10 - Jan 17th, 2024 at 8:29am
Print Post  
So it has to be handled as an Event in DiagramView or Diagram.

Thank you very much.

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