Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Another new question. (Read 6704 times)
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Another new question.
Mar 4th, 2011 at 6:46pm
Print Post  
Hello Stoyo.
Im working on my custom components one of that is a simple button, you already know that : )

My question is how can close a POPUP opened when touch a button created at runtime by mindfusion.
Dont knwo if my question is clear or no, if not tellme.

Basically the situation is this:
i have popup open, then i create node (button), and when click that butotn need open that popup remain open on main screen.

I know this is more a c# question not specific to mindfusion component, but if you have some answer i apreciate.
Bets regards!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Another new question.
Reply #1 - Mar 5th, 2011 at 7:41am
Print Post  
Hi Pablo,

I'm not sure if I understand this correctly. Are you opening a popup window (or context menu?) and then want to close it from code in response to some event?

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


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Another new question.
Reply #2 - Mar 5th, 2011 at 4:15pm
Print Post  
I basically what i want is close popup already open, and not closed form NODE created, my node is a button. ???
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Another new question.
Reply #3 - Mar 7th, 2011 at 6:58am
Print Post  
Can't you just call popupWindow.Close()?
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Another new question.
Reply #4 - Mar 7th, 2011 at 2:41pm
Print Post  
Not possible, popup no is part of the node (button) Undecided

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Another new question.
Reply #5 - Mar 7th, 2011 at 3:12pm
Print Post  
Why should that matter? If there will be only a single instance of that popup ever shown, keep a reference to it in the main window object, or make it a static member of some class. Then you can call Close through the field that keeps a references to the popup.
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Another new question.
Reply #6 - Mar 7th, 2011 at 9:42pm
Print Post  
Not understand how.
In te main windows of my project i have a popup declared in XAML, isnide the poup i have a custom widnows created act like that popup.

In that way when i wnat show that popup i use:


MyPopup.IsOpen = false;


and when want close i just run:

MyPopup.IsOpen = false;


I not understand how can call MyPopup.IsOpen = false; from a custom node creted.

Please can tellme more, and if possible with some example.... like always Roll Eyes

Bets regards.
« Last Edit: Mar 7th, 2011 at 11:09pm by PDM. »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Another new question.
Reply #7 - Mar 8th, 2011 at 9:53am
Print Post  
Handle NodeCreated like this:

Code
Select All
var nodeAdapter = e.Node as DiagramNodeAdapter;
if (nodeAdapter != null)
{
	Button button = nodeAdapter.UIElement as MyButton;
	if (button != null)
		button.Click += new RoutedEventHandler(OnMyButtonClick); 



where OnMyButtonClick is a member of the main window so you should have access to MyPopup there:

Code
Select All
void OnMyButtonClick(object sender, RoutedEventArgs e)
{
	MyPopup.IsOpen = false;
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Another new question.
Reply #8 - Mar 8th, 2011 at 6:00pm
Print Post  
Then you should pass a reference to the popup window to all controls of yours and close it from whatever handler required.

Or perhaps derive your controls from a common base class that defines a ClosePopup event and raise it in response to any internal events. Then handle ClosePopup in the main window by closing the popup.
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Another new question.
Reply #9 - Mar 9th, 2011 at 12:53am
Print Post  
Thankyou for your help !!
Wink
« Last Edit: Mar 9th, 2011 at 4:26am by PDM. »  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Another new question.
Reply #10 - Mar 10th, 2011 at 9:24am
Print Post  
Hello Stoyo.
I use this way to fire events from my button to mainwindow:

Inisde my custom button:

public static readonly RoutedEvent ButtonClickEvent1 = EventManager.RegisterRoutedEvent("ButtonClick1", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyButton));



public event RoutedEventHandler ButtonClick1

{
add { AddHandler(ButtonClickEvent1, value); }
remove { RemoveHandler(ButtonClickEvent1, value); }
}


No fire the event with some action frm button:

RaiseEvent(new RoutedEventArgs(ButtonClickEvent1));



Now, when i create node onload


var Button = new MyButton();
if (Button != null)
{
Button.ButtonClick1 += new RoutedEventHandler(Click1);
var node = new DiagramNodeAdapter(form, Button);
node.Bounds = new Rect(5, 5, 40, 40);
form.Nodes.Add(node);
}


Then i can listen the event:
void Click1(object sender, RoutedEventArgs e)
{

All this work absolutly perfect, but i find one problem, when save and then load, the events not work.
Again i imagine this have some relation with serialization.
Some suggestion about this?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Another new question.
Reply #11 - Mar 10th, 2011 at 9:58am
Print Post  
Hi Pablo,

Yes, you'll have to subscribe to the event again from your DeserializeControl handler.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint