Example #1
0
        /// <summary>
        /// Creates graph from MEOop, or returns it from cache if already there
        /// </summary>
        /// <param name="m">The MEOop object</param>
        /// <returns>Graph object</returns>
        public static Graph MEOopToGraph(MetaEditAPI.MEOop m)
        {
            Hashtable graphTable = (Hashtable)ProjectTable[m.areaID];
            Graph     graph      = null;

            if (graphTable == null)
            {
                graphTable = new Hashtable();
                ProjectTable.Add(m.areaID, graphTable);
            }
            graph = (Graph)graphTable[m.objectID];
            MetaEditAPI.MetaEditAPI port = Launcher.Port;

            if (graph == null)
            {
                MetaEditAPI.METype _graphType = port.type(m);
                string             _typeName  = (string)TypeNameTable[_graphType.name];
                if (_typeName == null)
                {
                    _typeName = port.typeName(_graphType);
                    TypeNameTable.Add(_graphType.name, _typeName);
                }

                graph = new Graph(port.userPrintString(m), _graphType.name, _typeName, m.areaID, m.objectID);
                graphTable.Add(m.objectID, graph);
            }
            return(graph);
        }
Example #2
0
        /// <summary>
        /// Method for checking if API is running.
        /// Simply calls MetaEdit+ and check if it answers.
        /// If no API is connected just return without checking anything until user clicks
        /// "update" or "start metaedit+"
        /// </summary>
        /// <returns>true if API is ok, otherwise false.</returns>
        public static Boolean IsApiOK()
        {
            // Return if known that there is no connection alive.
            // if (!connectionAlive) return connectionAlive;

            string name;

            MetaEditAPI.METype metype = new MetaEditAPI.METype();
            metype.name = "Graph";
            try
            {
                name = Port.typeName(metype);
            }
            catch (System.Net.WebException e)
            {
                if (e.Status == System.Net.WebExceptionStatus.ConnectFailure)
                {
                    connectionAlive = false;
                }
                else if (e.Status == System.Net.WebExceptionStatus.Timeout)
                {
                    connectionAlive = true;
                }
                name = "";
            }
            isInitialized = name.Equals("Graph");
            return(isInitialized);
        }
Example #3
0
 /// <summary>
 /// Gets the MeType of Graph
 /// </summary>
 /// <returns>METype</returns>
 public MetaEditAPI.METype GetMEType()
 {
     MetaEditAPI.METype type = new MetaEditAPI.METype();
     type.name = this.Type;
     return(type);
 }