Example #1
0
 // Callback invoked if the executable startup has failed
 private void ExeStartupFailed(string stderr, string logfilePath)
 {
     // Unhighlight tree and remove item from synced components
     if (LastStartedInstance != null)
     {
         try
         {
             addon.Project.BeginTransactionInNewTerr();
             ISIS.GME.Common.Interfaces.Base model = CyphyMetaLinkUtils.GetComponentAssemblyByGuid(addon.Project, LastStartedInstance.Id);
             if (model == null)
             {
                 model = CyphyMetaLinkUtils.GetComponentByAvmId(addon.Project, LastStartedInstance.Id);
                 SendDisinterest(true, LastStartedInstance.InstanceId);
             }
             if (model != null)
             {
                 AssemblyID = null;
                 HighlightInTree(model, 0);
                 SendDisinterest(true, LastStartedInstance.InstanceId);
             }
             syncedComponents.Remove(LastStartedInstance.Id);
             // FIXME designIdToCadAssemblyXml.Remove(
         }
         finally
         {
             addon.Project.AbortTransaction();
         }
     }
     LastStartedInstance = null;
     ShowStartupDialog(false);
 }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="subject"></param>
        /// <returns></returns>
        public static T CreateObject <T>(IMgaObject subject)
            where T : ISIS.GME.Common.Classes.Base, new()
        {
            // TODO: rename this function
            Contract.Requires(subject != null, "Subject cannot be null.");

            ISIS.GME.Common.Interfaces.Base newObject = null;

            //if (IsObjectCacheEnabled)
            //{
            //  if (ObjectCache.TryGetValue(subject, out newObject) == false)
            //  {
            //    // create new object and put it into the cache
            //    newObject = new T() { Impl = subject as IMgaObject };
            //    ObjectCache.Add(subject, newObject);
            //  }
            //}
            //else
            {
                newObject = new T()
                {
                    Impl = subject as IMgaObject
                };
            }
            return(newObject as T);
        }
Example #3
0
        private void HighlightInTree(ISIS.GME.Common.Interfaces.Base item, int highlight)
        {
            if (TestMode)
            {
                return;
            }

            HighlightInTree(item.Impl, highlight);
        }
Example #4
0
        // traversals
        // DFS with indent
        public static void TraversalDFS(
            ISIS.GME.Common.Interfaces.Base subject,
            Action <ISIS.GME.Common.Interfaces.Base, int> action)
        {
            Contract.Requires(subject != null);

            action(subject, 0);
            ChildTraversalDFS(subject, action, 1);
        }
Example #5
0
 private void ConnectionClosed(Exception e)
 {
     SyncControl.BeginInvoke((System.Action) delegate
     {
         if (addon != null)
         {
             GMEConsole console = GMEConsole.CreateFromProject(addon.Project);
             console.Error.WriteLine("Connection to MetaLink lost.");
             //componentEditMessages.Clear();
             interests.Clear();
             AssemblyID = null;
             CloseMetaLinkBridge();
             if (console.gme != null)
             {
                 // Marshal.FinalReleaseComObject(console.gme); is this needed?
             }
             Enable(false);
             if (syncedComponents.Count > 0)
             {
                 bool inTx = ((addon.Project.ProjectStatus & 8) != 0);
                 if (inTx == false)
                 {
                     addon.Project.BeginTransactionInNewTerr();
                 }
                 try
                 {
                     foreach (string id in syncedComponents.Keys)
                     {
                         ISIS.GME.Common.Interfaces.Base model = CyphyMetaLinkUtils.GetComponentAssemblyByGuid(addon.Project, id);
                         if (model == null)
                         {
                             model = CyphyMetaLinkUtils.GetComponentByAvmId(addon.Project, id);
                         }
                         if (model != null)
                         {
                             HighlightInTree(model, 0);
                         }
                     }
                 }
                 finally
                 {
                     if (inTx == false)
                     {
                         addon.Project.AbortTransaction();
                     }
                 }
                 syncedComponents.Clear();
                 designIdToCadAssemblyXml.Clear();
             }
         }
     });
 }
Example #6
0
        private static void ChildTraversalDFS(
            ISIS.GME.Common.Interfaces.Base subject,
            Action <ISIS.GME.Common.Interfaces.Base, int> action, int indent)
        {
            Contract.Requires(subject != null);

            if (subject is ISIS.GME.Common.Interfaces.Container)
            {
                foreach (ISIS.GME.Common.Classes.Base o in (subject as ISIS.GME.Common.Interfaces.Container).AllChildren.Distinct())
                {
                    action(o, indent);
                    ChildTraversalDFS(o, action, indent + 1);
                }
            }
        }
Example #7
0
        public static IEnumerable <TResult> CastMgaChildren <TResult, TSource>(
            this TSource source, string kind = "")
            where TResult : ISIS.GME.Common.Classes.Base, new()
            where TSource : MgaObjects
        {
            Contract.Requires(source != null);

            IEnumerable <IMgaObject> children = source.Cast <IMgaObject>();

            ISIS.GME.Common.Interfaces.Base newObject = null;

            if (String.IsNullOrEmpty(kind))
            {
                // return all kinds
                foreach (IMgaObject v in source)
                {
                    newObject = new TResult()
                    {
                        Impl = v as IMgaObject
                    };
                    yield return(newObject as TResult);
                }
            }
            else
            {
                // return with the specifed kinds only
                foreach (IMgaObject v in children.Where(x => x.MetaBase.Name == kind))
                {
                    newObject = new TResult()
                    {
                        Impl = v as IMgaObject
                    };
                    yield return(newObject as TResult);
                }
            }
        }