Subscribe() public method

public Subscribe ( string name, CKWindow window ) : void
name string
window CKWindow
return void
コード例 #1
0
        public void Start()
        {
            Debug.Assert( Dispatcher.CurrentDispatcher == Application.Current.Dispatcher, "This method should only be called by the Application Thread." );

            _vm = new TextualContextPreviewViewModel( TextualContextService );
            _window = new TextualContextPreviewWindow( _vm );
            _window.Width = 600;
            _window.Height = 300;
            _window.Show();

            _subscriber = new WindowManagerSubscriber( WindowManager, WindowBinder );
            _subscriber.OnBinderStarted = () =>
            {
                if( _textualContext != null & _me != null )
                    WindowBinder.Service.Bind( _textualContext, _me, BindingPosition.Top );
            };
            _subscriber.OnBinderStopped = () =>
            {
                if( _textualContext != null & _me != null )
                    WindowBinder.Service.Unbind( _textualContext, _me );
            };
            _subscriber.WindowRegistered = ( e ) =>
            {
                if( e.Window.Name == WindowName )
                {
                    _me = e.Window;
                    _textualContext = WindowManager.Service.GetByName( TextualContextArea.WindowName );
                }
                if( e.Window.Name == TextualContextArea.WindowName ) _textualContext = e.Window;

                _subscriber.OnBinderStarted();
            };
            _subscriber.WindowUnregistered = ( e ) =>
            {
                if( e.Window.Name == TextualContextArea.WindowName ) _subscriber.OnBinderStopped();
            };
            _subscriber.Subscribe( WindowName, _window );
        }