Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: burkut on October 29, 2009, 03:23:28 am
-
hallo,
i am programming an AddIN with Automation Interface in c#. i want to know, how can i know, that EA being closed. f.e. the User has pressed the close_Symbol on the right upper side of the window?
thanks
burkut
-
I would try the following application events:
void EA_FileClose(Repository EA.Repository) { ... }
void EA_Disconnect() { ... }
both of these events are triggered when the application is closed.
-
hallo,
thank you for reply. But they have no effect, if use it in the Automation Interface with c#. f.e. like this:
using System;
using System.Windows.Forms;
using RemotingHub;
using ClientConnector;
using System.Threading;
namespace CS_AddinFramework
{
public class Main
{
private bool m_ShowFullMenus = false;
public Form1 theForm;
EAAdapterConnection eaaCon = new EAAdapterConnection();
Thread t;
//Called Before EA starts to check Add-In Exists
public String EA_Connect(EA.Repository Repository)
{
try
{
//StartClient();
//No special processing required.
return "EA Adapter wurde mit Hub-Server verbunden.";
}
catch (Exception e)
{
//No special processing required.
return "EA Adapter wurde nicht mit Hub-Server verbunden.";
}
}
//Called when user Click Add-Ins Menu item from within EA.
//Populates the Menu with our desired selections.
public object EA_GetMenuItems(EA.Repository Repository, string Location, string MenuName)
{
EA.Package aPackage = Repository.GetTreeSelectedPackage();
switch( MenuName )
{
case "":
return "-&CS AddinFramework";
case "-&CS AddinFramework":
string[] ar = { "&Calculator", "&Menu2", "About..." };
return ar;
}
return "";
}
//Sets the state of the menu depending if there is an active project or not
bool IsProjectOpen(EA.Repository Repository)
{
try
{
EA.Collection c = Repository.Models;
return true;
}
catch
{
return false;
}
}
//Called once Menu has been opened to see what menu items are active.
public void EA_GetMenuState(EA.Repository Repository, string Location, string MenuName, string ItemName, ref bool IsEnabled, ref bool IsChecked)
{
if( IsProjectOpen(Repository) )
{
if( ItemName == "Calculator" )
IsChecked = m_ShowFullMenus;
else if( ItemName == "Menu2")
IsEnabled = m_ShowFullMenus;
}
else
// If no open project, disable all menu options
IsEnabled = false;
}
//Called when user makes a selection in the menu.
//This is your main exit point to the rest of your Add-in
public void EA_MenuClick(EA.Repository Repository, string Location, string MenuName, string ItemName)
{
switch( ItemName )
{
case "&Calculator":
{
//StartClient();
//System.Threading.Thread.Sleep(3000);
//myTest();
//t = new Thread(new ThreadStart(EAAdapterConnection.sendEvent ) );
//t.Name = "myThread";
//t.Start();
openForm();
}
break;
case "&Menu2":
break;
case "About...":
MessageBox.Show(
"Created by Sparx Systems as a guide for anyone\n"+
"wanting to develop a C#.NET Add-In for Enterprise \n"+
"Architect\n [email protected]\n"+
"http://www.sparxsystems.com.au",
"About Enterprise Architekt",
MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
break;
}
}
void EA_FileClose( EA.Repository repo) {
MessageBox.Show("file Close!!!!");
}
void EA_Disconnect() {
MessageBox.Show(" EA Disconnected!!!!");
}
private void openForm()
{
theForm = new Form1();
theForm.ShowDialog();
}
}
}
-
Hi,
Make the event handler methods public. That was the most common mistake I have made when introducing new event handlers to main, and wondered why they hadn't any effect.
HTH
Günther
-
hallo Günther,
Thank you for Help. It worked, as i tried to use what you have suggested to.
by the way, i have an another question: Do you know, which Unit or Komponent (i mean it may be a thread or process) that processes (or receives ) an external message that ist f. e. fired from an external Application. you can suppose that an external Application connected with EA over an Automation AddIn Interface?
Thank you again.
burkut
-
Do you know, which Unit or Komponent (i mean it may be a thread or process) that processes (or receives ) an external message that ist f. e. fired from an external Application. you can suppose that an external Application connected with EA over an Automation AddIn Interface?
Hmm, not really. But should be possible to develop an AddIn that serves as bridge between EA and other applications steered using their automation interfaces. Some people here on the forum wrote such addins already, e.g. for M$ Word or other Office programs.
What exactly did you have in mind?
WBR
Günther
-
hello Günther,
thank you very much for your Reply again. If you want to know, what realy i want to do, please visit the Link first http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1256730611. I think i have described there clearly what i want to.
The main problem is that i couldn't get my external Message because of the EA.exe und another Main thread that includes my Client. I think my message is accepted by the EA or EA.exe, but not reached or switched to my main Thread.....
May be it is usefull for me, if there is an Example like that or Suggestions what you did yesterday....
Thank you for your time again...
Burkut
-
OK, I see. I'll continue on the other thread ...