Пример #1
0
        /// <summary>
        /// Cleans up by unregistering the servers corresponding to the specified document,
        /// or all servers if the document is not provided.
        /// </summary>
        /// <param name="document">The document whose servers should be removed, or null.</param>
        /// <param name="updateViews">Update views of the affected document(s).</param>
        private static void unregisterServers(Document document, string _addinId, bool updateViews)
        {
            ExternalServiceId externalDrawerServiceId = ExternalServices.BuiltInExternalServices.DirectContext3DService;
            var externalDrawerService = ExternalServiceRegistry.GetService(externalDrawerServiceId) as MultiServerService;

            if (externalDrawerService == null)
            {
                return;
            }

            foreach (var registeredServerId in externalDrawerService.GetRegisteredServerIds())
            {
                var server = externalDrawerService.GetServer(registeredServerId) as GeometryDrawServer;
                if (server == null)
                {
                    continue;
                }
                if (!sameDoc(document, server) || !sameAddin(_addinId, server))
                {
                    continue;
                }
                externalDrawerService.RemoveServer(registeredServerId);
            }

            Servers.RemoveAll(server => sameAddin(_addinId, server) && sameDoc(document, server));
            if (updateViews)
            {
                UIDocument uidoc = APP.UIApp.ActiveUIDocument;
                if (uidoc != null)
                {
                    uidoc.UpdateAllOpenViews();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Cleans up by unregistering the servers corresponding to the specified document, or all servers if the document is not provided.
        /// </summary>
        /// <param name="document">The document whose servers should be removed, or null.</param>
        /// <param name="updateViews">Update views of the affected document(s).</param>
        public void unregisterServers(Document document, bool updateViews)
        {
            ExternalServiceId externalDrawerServiceId = ExternalServices.BuiltInExternalServices.DirectContext3DService;
            var externalDrawerService = ExternalServiceRegistry.GetService(externalDrawerServiceId) as MultiServerService;

            if (externalDrawerService == null)
            {
                return;
            }

            foreach (var registeredServerId in externalDrawerService.GetRegisteredServerIds())
            {
                var externalDrawServer = externalDrawerService.GetServer(registeredServerId) as RevitElementDrawingServer;
                if (externalDrawServer == null)
                {
                    continue;
                }
                if (document != null && !document.Equals(externalDrawServer.Document))
                {
                    continue;
                }
                externalDrawerService.RemoveServer(registeredServerId);
            }

            if (document != null)
            {
                m_servers.RemoveAll(server => document.Equals(server.Document));

                if (updateViews)
                {
                    UIDocument uidoc = new UIDocument(document);
                    uidoc.UpdateAllOpenViews();
                }

                m_documents.Remove(document);
            }
            else
            {
                m_servers.Clear();

                if (updateViews)
                {
                    foreach (var doc in m_documents)
                    {
                        UIDocument uidoc = new UIDocument(doc);
                        uidoc.UpdateAllOpenViews();
                    }
                }

                m_documents.Clear();
            }
        }
Пример #3
0
        /// <summary>
        /// Unregister this server. Will check if is registered before proceed.
        /// </summary>
        /// <param name="_server"></param>
        public static void UnregisterServer(GeometryDrawServer _server)
        {
            ExternalServiceId externalDrawerServiceId = ExternalServices.BuiltInExternalServices.DirectContext3DService;
            var externalDrawerService = ExternalServiceRegistry.GetService(externalDrawerServiceId) as MultiServerService;

            if (externalDrawerService == null)
            {
                return;
            }
            else
            {
                var id = _server.GetServerId();
                if (externalDrawerService.IsRegisteredServerId(id))
                {
                    externalDrawerService.RemoveServer(id);
                }
            }
        }