private void Application_MarkerEvent(Application application, int sequence, string context)
        {
            if (application.ActiveDocument.Template.Contains(Information.TemplateName))
            {
                try
                {
                    Selection selection = Application.ActiveWindow.Selection; //event must originate from selected element

                    foreach (Shape s in selection)
                    {
                        if (s.CellExistsU[VisioFormulas.Cell_RationallyType, (short)VisExistsFlags.visExistsAnywhere] == Constants.CellExists)
                        {
                            string identifier = context;
                            if (context.Contains("."))
                            {
                                identifier = context.Split('.')[1];
                                context    = context.Split('.')[0];
                            }
                            Log.Debug("Marker event being handled for: " + s.Name);
                            MarkerEventHandlerRegistry.HandleEvent(s.CellsU[VisioFormulas.Cell_RationallyType].ResultStr[VisioFormulas.Value] + "." + context, s, identifier);
                            ContextMenuEventHandler.Instance.OnContextMenuEvent(application, sequence, context);
                        }
                    }
                }
                catch (COMException e)
                {
                    Log.Error("COMExeption occured:" + e.Message);
                    Log.Error("source: " + e.Source);
                    Log.Error("error code:" + e.ErrorCode);
                    Log.Error("inner exception:\n" + e.InnerException?.StackTrace);
#if DEBUG
                    throw;
#endif
                }
                catch (Exception ex)
                {
                    Log.Error(ex, ex);
#if DEBUG
                    throw;
#endif
                }
            }
        }
        private void Application_ShapeAddedEvent(Shape s)
        {
            Log.Debug("Shape added with name: " + s.Name);
            if (s.Document.Template.Contains(Information.TemplateName) && (s.CellExistsU[VisioFormulas.Cell_RationallyType, (short)VisExistsFlags.visExistsAnywhere] == Constants.CellExists) && !View.ExistsInTree(s))
            {
                try
                {
                    switch (s.CellsU[VisioFormulas.Cell_RationallyType].ResultStr[VisioFormulas.Value])
                    {
                    case "alternativeAddStub":
                        if (!Application.IsUndoingOrRedoing)
                        {
                            int scopeId = Application.BeginUndoScope(Messages.Scope_AddAlternative);
                            s.Delete();
                            AlternativesContainer alternativesContainer = Globals.RationallyAddIn.View.Children.FirstOrDefault(ch => ch is AlternativesContainer) as AlternativesContainer;
                            alternativesContainer?.AddAlternative("Title", default(AlternativeState).GetName());

                            Application.EndUndoScope(scopeId, true);
                        }
                        break;

                    case "forceAddStub":
                        if (!Application.IsUndoingOrRedoing)
                        {
                            int scopeId = Application.BeginUndoScope(Messages.Scope_AddForce);
                            s.Delete();
                            MarkerEventHandlerRegistry.HandleEvent("forces.add", null, null);
                            Application.EndUndoScope(scopeId, true);
                        }
                        break;

                    case "relatedDocumentAddStub":
                        if (!Application.IsUndoingOrRedoing)
                        {
                            int scopeId = Application.BeginUndoScope(Messages.Scope_AddFile);
                            s.Delete();
                            MarkerEventHandlerRegistry.HandleEvent("relatedDocuments.addRelatedFile", null, null);
                            Application.EndUndoScope(scopeId, true);
                        }
                        break;

                    case "relatedUrlAddStub":
                        if (!Application.IsUndoingOrRedoing)
                        {
                            int scopeId = Application.BeginUndoScope(Messages.Scope_AddUrl);
                            s.Delete();
                            MarkerEventHandlerRegistry.HandleEvent("relatedDocuments.addRelatedUrl", null, null);
                            Application.EndUndoScope(scopeId, true);
                        }
                        break;

                    case "stakeholderAddStub":
                        if (!Application.IsUndoingOrRedoing)
                        {
                            int scopeId = Application.BeginUndoScope(Messages.Scope_AddStakeholder);
                            s.Delete();
                            StakeholdersContainer stakeholdersContainer = View.Children.FirstOrDefault(ch => ch is StakeholdersContainer) as StakeholdersContainer;
                            stakeholdersContainer?.AddStakeholder("<<name>>", "<<role>>");

                            Application.EndUndoScope(scopeId, true);
                        }
                        break;

                    case "planningItemStub":
                        if (!Application.IsUndoingOrRedoing)
                        {
                            int scopeId = Application.BeginUndoScope(Messages.Scope_AddPlanningItem);
                            s.Delete();
                            PlanningContainer planningContainer = View.Children.FirstOrDefault(ch => ch is PlanningContainer) as PlanningContainer;
                            planningContainer?.AddPlanningItem();

                            Application.EndUndoScope(scopeId, true);
                        }
                        break;

                    default:
                        View.AddToTree(s, true);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex, ex);
#if DEBUG
                    throw;
#endif
                }
            }
        }