Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Disable or hide node conectors (Read 6319 times)
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Disable or hide node conectors
Dec 2nd, 2010 at 7:00pm
Print Post  
Is possible disable or just hide node connectors?
How?

Best regards.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Disable or hide node conectors
Reply #1 - Dec 2nd, 2010 at 7:08pm
Print Post  
Set link.Locked = true or link.Visible = false. To prevent the user from drawing new links, set diagram.Behavior = DrawShapes or Modify.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Disable or hide node conectors
Reply #2 - Dec 3rd, 2010 at 7:58pm
Print Post  
Thank you for your suggestion, but i cant make this work.

Im really newbie with wpf, c# and programation world, i testing the example provided called "FormEditor"

I want do 2 things:

1 Disable connectors
2 Im trying to figure how add hotkey, the hotkey is used for enable move and resize.

Basically when i add a button, or any other to the form, only can be moved or resized when hot key is pressed, if not pressed object work like should do usually.

Im not are lazy, but really apreicate if somebody can publish "FormEditor" modificated for do this.

I really apreciate.

Best regards!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Disable or hide node conectors
Reply #3 - Dec 4th, 2010 at 10:49am
Print Post  
1. Replace the Behavior assignment in FormEditor / Window_Loaded with this:

form.Behavior = Behavior.DrawControls;

2. There are several ways to do that. One is to add KeyDown and KeyUp handlers that toggle Behavior between DrawControls and DoNothing. Another one is to use a custom Behavior class as below:

Code
Select All
form.CustomBehavior = new DrawIfKeyDownBehavior(form);

 [code]
class DrawIfKeyDownBehavior : DrawControlsBehavior
{
	protected internal DrawIfKeyDownBehavior(Diagram diagramView) : base(diagramView)
	{
	}

	public override InteractionState StartDraw(Point point)
	{
		if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0)
			return base.StartDraw(point);
		return null;
	}
} 



If you'd like to also prevent selection unless the key is pressed, handle NodeSelecting:

Code
Select All
private void form_NodeSelecting(object sender, NodeValidationEventArgs e)
{
	if ((Keyboard.Modifiers & ModifierKeys.Shift) == 0)
		e.Cancel = true;
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Disable or hide node conectors
Reply #4 - Dec 4th, 2010 at 3:59pm
Print Post  
In first place, thanks so much for repply.


I already tested thsi in formrditor example:

form.Behavior = Behavior.DrawControls;

This not work correctly, after this change example is messed up, if i draw control label, textbox etc etc, not work how should do, only buttons.


Bests regards.
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Disable or hide node conectors
Reply #5 - Dec 4th, 2010 at 4:23pm
Print Post  
Please sorry for this request, but can modificate the code of formeditor example, and upload so i can see how all work included the hotkey?
Please
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Disable or hide node conectors
Reply #6 - Dec 6th, 2010 at 6:42am
Print Post  
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Disable or hide node conectors
Reply #7 - Dec 6th, 2010 at 1:14pm
Print Post  
yes Stoyo, your sample work perfect, but have same problem i have here.

Please use the sample, and try create label or text, you can see not work, the object created is a button always.

Why this happen?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Disable or hide node conectors
Reply #8 - Dec 6th, 2010 at 3:09pm
Print Post  
Now that we use DrawControlsBehavior -derived class, replace all form.CustomNodeType assignments with form.DefaultControlType ones. E.g. this in the Loaded handler:

form.DefaultControlType = typeof(Button);
form.CustomBehavior = new DrawIfKeyDownBehavior(form);

and

private void palette_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
     switch (palette.SelectedIndex)
     {
     case 0:
           form.DefaultControlType = typeof(Button);
           return;
     ...
     }
}

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Disable or hide node conectors
Reply #9 - Dec 7th, 2010 at 12:54am
Print Post  
Thank you so much!! Grin

2 questons please:

1 Mindfusion have some discount for students?

2 Why cant change the text on the button at runtime, or edit label etc etc?
And is possibel save all properties of the any component?

Example, if i create custom components, like my custom buttons, etc etc, all properties can be saved in the xaml in automatic way in the xaml file?
Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Disable or hide node conectors
Reply #10 - Dec 7th, 2010 at 10:05am
Print Post  
1. Yes, you can write to sales@mindfusion.eu to request an academic discount code.

2. If you mean in the property grid used in the sample, it's because the Content property is of type object and that grid does not support editing object values. You could use derived control classes that expose the Content property as string.

3. If your custom components can be saved through XamlWriter, diagram.SaveToXml will save their properties automatically. Otherwise you will have to handle the SerializeControl and DeserializeControl events to implement your own serialization.

Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Disable or hide node conectors
Reply #11 - Dec 7th, 2010 at 1:55pm
Print Post  
Thankyou for the information i contact to sales.

Thankyou for your time.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint