コード例 #1
0
ファイル: Scene.cs プロジェクト: Alan-Baylis/SeeingSharp
        /// <summary>
        /// Deregisters this scene from ApplicationMessaging logic.
        /// </summary>
        public void DeregisterMessaging()
        {
            if (this.CountViews > 0)
            {
                throw new SeeingSharpGraphicsException("Unable to deregister messaging as long this Scene is associated to a view!");
            }

            if (m_syncContext != null)
            {
                SynchronizationContext syncContext = m_syncContext;
                SeeingSharpMessenger   Messenger   = m_messenger;

                m_syncContext = null;
                Messenger.DiscardGlobalSynchronization();
            }
        }
コード例 #2
0
ファイル: Scene.cs プロジェクト: Alan-Baylis/SeeingSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="Scene" /> class.
        /// </summary>
        /// <param name="name">The global name of this scene.</param>
        /// <param name="registerOnMessenger">
        /// Do register this scene for application messaging?
        /// If true, then the caller has to ensure that the name is only used once
        /// across the currently executed application.
        /// </param>
        public Scene(
            string name = "",
            bool registerOnMessenger = false)
        {
            if (string.IsNullOrEmpty(name))
            {
                name = DEFAULT_SCENE_NAME;
            }
            this.Name = name;

            m_perFrameData = new CBPerFrame();

            m_transformMode2D     = Graphics2DTransformMode.Custom;
            m_customTransform2D   = Matrix3x2.Identity;
            m_virtualScreenSize2D = new Size2F();

            m_sceneLayers = new List <SceneLayer>();
            m_sceneLayers.Add(new SceneLayer(DEFAULT_LAYER_NAME, this));
            m_sceneLayersPublic = new ReadOnlyCollection <SceneLayer>(m_sceneLayers);

            m_drawing2DLayers = new List <Custom2DDrawingLayer>();

            m_sceneComponents = new SceneComponentFlyweight(this);

            m_asyncInvokesBeforeUpdate          = new ThreadSaveQueue <Action>();
            m_asyncInvokesUpdateBesideRendering = new ThreadSaveQueue <Action>();

            m_registeredResourceDicts = new IndexBasedDynamicCollection <ResourceDictionary>();
            m_registeredViews         = new IndexBasedDynamicCollection <ViewInformation>();
            m_renderParameters        = new IndexBasedDynamicCollection <SceneRenderParameters>();

            this.CachedUpdateState = new SceneRelatedUpdateState(this);

            // Try to initialize this scene object
            InitializeResourceDictionaries(false);

            // Register the scene for ApplicationMessaging
            if (registerOnMessenger)
            {
                m_syncContext = new SceneSynchronizationContext(this);
                m_messenger   = new SeeingSharpMessenger();
                m_messenger.ApplyForGlobalSynchronization(
                    SeeingSharpMessageThreadingBehavior.EnsureMainSyncContextOnSyncCalls,
                    this.Name,
                    m_syncContext);
            }
        }