예제 #1
0
        private async void RemoteMultimediaOpsBus_EventBroadcasted(BusEvent e)
        {
            var dsp = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher;

            if (!dsp.HasThreadAccess)
            {
                await dsp.RunAsync(CoreDispatcherPriority.Normal, () => RemoteMultimediaOpsBus_EventBroadcasted(e));

                return;
            }

            var remoteEvt = e.DataAs <RemoteEvent>();

            if (remoteEvt.Type == RemoteEventType.MultimediaControlSelectionChanged)
            {
                var payload = remoteEvt.Payload as SelectionChangedPayload;
                var vm      = ViewModelMapper.GetViewModel(payload.Context);

                if (vm == ViewModel)
                {
                    _allowSelectionChanged = false;
                    SelectedIndex          = payload.SelectedIndex;
                    _allowSelectionChanged = true;
                }
            }
        }
예제 #2
0
        protected async override void RemoteWindowOperationsBus_EventBroadcasted(BusEvent e)
        {
            var remoteOp = e.DataAs <RemoteWindowOperationEvent>();
            var vm       = remoteOp.ViewModel;

            var wnd = _vmWindowMapping[(ContentItemViewModel)vm];

            var op = WindowOperation.Unlock;

            switch (remoteOp.RemoteEvent.Type)
            {
            case RemoteEventType.MenuClosed:
            case RemoteEventType.MoveMenuTo:
            case RemoteEventType.MenuItemSelected:
                op = WindowOperation.Unknown;
                break;

            case RemoteEventType.WindowClosed:
                op = WindowOperation.Close;
                break;

            case RemoteEventType.WindowLocked:
                op = WindowOperation.Lock;
                break;

            case RemoteEventType.WindowRestored:
                op = WindowOperation.Restore;
                break;

            case RemoteEventType.WindowUnlocked:
                op = WindowOperation.Unlock;
                break;

            default:
                break;
            }

            var opdata = new WindowOperationEventData()
            {
                BusEvent     = e,
                DataObject   = vm,
                WindowObject = wnd,
                Operation    = op
            };

            var dsp = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher;

            if (!dsp.HasThreadAccess)
            {
                await dsp.RunAsync(CoreDispatcherPriority.Normal, () => _wndOpHandlers[op](opdata));

                return;
            }
        }
예제 #3
0
        protected virtual void WindowOperationsBus_EventBroadcasted(BusEvent e)
        {
            var eventData = e.DataAs <WindowOperationEventData>();

            eventData.BusEvent = e;

            if (!_wndOpHandlers.ContainsKey(eventData.Operation))
            {
                Debug.Log($"[WARNING] No mapped handler exists for operation: {eventData.Operation}");
                return;
            }

            _wndOpHandlers[eventData.Operation](eventData);
        }
예제 #4
0
        private void WindowOperationsBus_EventBroadcasted(BusEvent e)
        {
            if (!AreSizingEventsEnabled)
            {
                return;
            }

            /* For future implementation:
             * Create another EventBus-like called Channel
             * This object will basically emit to objects that share the same context
             * Example:
             * Window creates a channel for it's vm (let's say a MultimediaVM)
             * the content (when it's created) gets the channel for that VM and all events are only between the window and content
             *
             * Shared content might be interesting for network situations
             */

            var winOpData = e.DataAs <WindowOperationEventData>();

            if (winOpData.DataObject == ViewModel)
            {
                if (winOpData.Operation == WindowOperation.Lock)
                {
                    _parentWindowLocked = true;
                }

                if (winOpData.Operation == WindowOperation.Unlock)
                {
                    _parentWindowLocked = false;
                }

                if (winOpData.Operation == WindowOperation.Lock ||
                    winOpData.Operation == WindowOperation.Fullscreen)
                {
                    IsHitTestVisible = true;
                }

                if (winOpData.Operation == WindowOperation.Unlock ||
                    winOpData.Operation == WindowOperation.Restore)
                {
                    IsHitTestVisible = false;
                }

                if (winOpData.Operation == WindowOperation.Restore && _parentWindowLocked)
                {
                    IsHitTestVisible = true;
                }
            }
        }
예제 #5
0
        private void RemoteEventBus_EventBroadcasted(BusEvent e)
        {
            if (SelectedTarget == null)
            {
                if (_handler.OnlineClients.Count == 0)
                {
                    return;
                }

                SelectedTarget = _handler.OnlineClients[0]; //TODO: temp
            }

            var eData = e.DataAs <RemoteEvent>();
            var seri  = _eventSerializer.Serialize(eData);

            Connection.SendAsync(nameof(IRelayHub.RelayMessage), SelectedTarget, seri);
        }