Book a Demo

Author Topic: is there any way to know, if the EA being closed?  (Read 4347 times)

burkut

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
is there any way to know, if the EA being closed?
« 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
« Last Edit: October 29, 2009, 03:24:09 am by burkut »

Neocortex

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-0
  • "There is no I in Team America"
    • View Profile
Re: is there any way to know, if the EA being clos
« Reply #1 on: October 29, 2009, 11:11:38 am »
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.

burkut

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: is there any way to know, if the EA being clos
« Reply #2 on: October 30, 2009, 09:41:45 pm »
hallo,

thank you for reply. But they have no effect, if use it in the Automation Interface with c#. f.e. like this:

Code: [Select]
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();
          
        }

    
            }
}
            
            
      

  

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: is there any way to know, if the EA being clos
« Reply #3 on: October 31, 2009, 02:45:23 am »
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

burkut

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: is there any way to know, if the EA being clos
« Reply #4 on: November 02, 2009, 06:45:13 pm »
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

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: is there any way to know, if the EA being clos
« Reply #5 on: November 03, 2009, 08:36:32 am »
Quote
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
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

burkut

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: is there any way to know, if the EA being clos
« Reply #6 on: November 03, 2009, 08:51:05 am »
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
« Last Edit: November 03, 2009, 08:51:27 am by burkut »

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: is there any way to know, if the EA being clos
« Reply #7 on: November 03, 2009, 09:12:26 am »
OK, I see. I'll continue on the other thread ...
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/