private void OnPointerPressed( CoreWindow sender, PointerEventArgs args )
        {
            Contract.Requires( args != null );

            var properties = args.CurrentPoint.Properties;

            // ignore button chords with the Left, Right, and Middle buttons
            if ( properties.IsLeftButtonPressed || properties.IsRightButtonPressed || properties.IsMiddleButtonPressed )
                return;

            // if Back or Forward are pressed (but not both) navigate appropriately
            var backPressed = properties.IsXButton1Pressed;
            var forwardPressed = properties.IsXButton2Pressed;
            var mutuallyExclusive = backPressed ^ forwardPressed;

            if ( !mutuallyExclusive )
                return;

            var frame = AssociatedObject.Frame;

            if ( backPressed && frame.CanGoBack )
            {
                frame.GoBack();
                args.Handled = true;
            }
            else if ( forwardPressed && frame.CanGoForward )
            {
                frame.GoForward();
                args.Handled = true;
            }
        }
Example #2
0
 private void Window_PointerPressed(CoreWindow sender, PointerEventArgs args)
 {
     _gestureRecognizer.ProcessDownEvent(args.CurrentPoint);
 }
Example #3
0
        public SwapChainManager(CoreWindow window, CanvasDevice device)
        {
            float currentDpi = DisplayInformation.GetForCurrentView().LogicalDpi;

            SwapChain = CanvasSwapChain.CreateForCoreWindow(device, window, currentDpi);
        }
Example #4
0
        protected virtual void Page_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
        {
            char letterPressed = Convert.ToChar(args.KeyCode);

            ParentShellPageInstance.InteractionOperations.PushJumpChar(letterPressed);
        }
Example #5
0
        public void SetWindow(CoreWindow window)
        {
            ApplicationView.GetForCurrentView().TryEnterFullScreenMode();

            // Initializes DirectX.
            _appCallbacks.SetWindow(window);

            // Initializes webrtc.
            WebRTC.Initialize(CoreApplication.MainView.CoreWindow.Dispatcher);
            Conductor.Instance.ETWStatsEnabled            = false;
            Conductor.Instance.Signaller.OnPeerConnected += (peerId, peerName) =>
            {
                Conductor.Instance.Peers.Add(
                    _selectedPeer = new Peer {
                    Id = peerId, Name = peerName
                });
            };

            Conductor.Instance.Signaller.OnPeerDisconnected += peerId =>
            {
                var peerToRemove = Conductor.Instance.Peers?.FirstOrDefault(p => p.Id == peerId);
                if (peerToRemove != null)
                {
                    Conductor.Instance.Peers.Remove(peerToRemove);
                }
            };

            Conductor.Instance.OnAddRemoteStream    += Conductor_OnAddRemoteStream;
            Conductor.Instance.OnRemoveRemoteStream += Conductor_OnRemoveRemoteStream;
            Conductor.Instance.OnAddLocalStream     += Conductor_OnAddLocalStream;
            if (Conductor.Instance.Peers == null)
            {
                Conductor.Instance.Peers = new ObservableCollection <Peer>();
            }

            Task.Run(() =>
            {
                var videoCodecList = WebRTC.GetVideoCodecs().OrderBy(codec =>
                {
                    switch (codec.Name)
                    {
                    case "VP8": return(1);

                    case "VP9": return(2);

                    case "H264": return(3);

                    default: return(99);
                    }
                });

                //Conductor.Instance.VideoCodec = videoCodecList.FirstOrDefault(x => x.Name.Contains("VP8"));
                Conductor.Instance.VideoCodec = videoCodecList.FirstOrDefault(x => x.Name.Contains("H264"));

                var audioCodecList = WebRTC.GetAudioCodecs();
                string[] incompatibleAudioCodecs = new string[] { "CN32000", "CN16000", "CN8000", "red8000", "telephone-event8000" };
                var audioCodecs = new List <CodecInfo>();
                foreach (var audioCodec in audioCodecList)
                {
                    if (!incompatibleAudioCodecs.Contains(audioCodec.Name + audioCodec.ClockRate))
                    {
                        audioCodecs.Add(audioCodec);
                    }
                }

                if (audioCodecs.Count > 0)
                {
                    Conductor.Instance.AudioCodec = audioCodecs.FirstOrDefault(x => x.Name.Contains("PCMU"));
                }

                Conductor.Instance.DisableLocalVideoStream();
                Conductor.Instance.MuteMicrophone();
            });
        }
Example #6
0
 private void ApplicationView_Activated(CoreApplicationView sender, IActivatedEventArgs args)
 {
     CoreWindow.GetForCurrentThread().Activate();
 }
Example #7
0
 public void Window_PointerReleased(CoreWindow sender, PointerEventArgs args)
 {
     // Delete the drag point
     draggingCameraFrom = null;
 }
Example #8
0
 private void OnCoreWindowOnSizeChanged(CoreWindow sender, WindowSizeChangedEventArgs args)
 {
     ComputeIsActive();
 }
Example #9
0
 public static ViewLifetimeControl CreateForCurrentView()
 {
     return(new ViewLifetimeControl(CoreWindow.GetForCurrentThread()));
 }
Example #10
0
 private void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs e)
 {
     Debug.WriteLine("CoreWindow");
     e.Handled = true;
     Keystroke(e.VirtualKey);
 }
Example #11
0
 public ViewModelBase() : this(CoreWindow.GetForCurrentThread().Dispatcher)
 {
 }
Example #12
0
 private void CoreWindowOnPointerReleased(CoreWindow sender, PointerEventArgs args)
 private void Window_Closed(CoreWindow sender, CoreWindowEventArgs args)
 {
     Game.SuppressDraw();
     Game.Platform.Exit();
 }
        /// <summary>
        /// Runs a process.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="arguments">The arguments.</param>
        /// <param name="workingDirectory">The working directory.</param>
        public async Task StartProcessAsync(string fileName, string arguments, string workingDirectory = null)
        {
            //  Are we showing diagnostics?
            if (ShowDiagnostics)
            {
                await WriteOutputAsync("Preparing to run " + fileName, Color.FromArgb(255, 0, 255, 0));

                if (!string.IsNullOrEmpty(arguments))
                {
                    await WriteOutputAsync(" with arguments " + arguments + "." + Environment.NewLine, Color.FromArgb(255, 0, 255, 0));
                }
                else
                {
                    await WriteOutputAsync("." + Environment.NewLine, Color.FromArgb(255, 0, 255, 0));
                }
            }


            await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                try
                {
                    var result = await ProcessLauncher.RunToCompletionAsync(
                        fileName,
                        arguments,
                        new ProcessLauncherOptions
                    {
                        WorkingDirectory = workingDirectory,
                        StandardOutput   = OutputStream,
                        StandardError    = ErrorStream
                    });

                    using (var outStreamRedirect = OutputStream.GetInputStreamAt(0))
                    {
                        var size = OutputStream.Size;
                        using (var dataReader = new DataReader(outStreamRedirect))
                        {
                            var bytesLoaded = await dataReader.LoadAsync((uint)size);
                            var stringRead  = dataReader.ReadString(bytesLoaded);
                            await WriteOutputAsync(stringRead, Colors.White);
                        }
                    }

                    using (var errStreamRedirect = ErrorStream.GetInputStreamAt(0))
                    {
                        using (var dataReader = new DataReader(errStreamRedirect))
                        {
                            var size        = ErrorStream.Size;
                            var bytesLoaded = await dataReader.LoadAsync((uint)size);
                            var stringRead  = dataReader.ReadString(bytesLoaded);
                            await WriteOutputAsync(stringRead, Colors.Red);
                        }
                    }
                }
                catch (UnauthorizedAccessException uex)
                {
                    await WriteOutputAsync($"Exception Thrown: {uex.Message}{Environment.NewLine}", Colors.Red);
                    await WriteOutputAsync($"Make sure you're allowed to run the specified exe; either{Environment.NewLine}" +
                                           $"\t1) Add the exe to the AppX package, or{Environment.NewLine}" +
                                           $"\t2) Add the absolute path of the exe to the allow list:{Environment.NewLine}" +
                                           $"\t\tHKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\EmbeddedMode\\ProcessLauncherAllowedExecutableFilesList.{Environment.NewLine}{Environment.NewLine}" +
                                           $"Also, make sure the <iot:Capability Name=\"systemManagement\" /> has been added to the AppX manifest capabilities.{Environment.NewLine}", Colors.Red);
                }
                catch (Exception ex)
                {
                    await WriteOutputAsync($"Exception Thrown: {ex.Message}{Environment.NewLine}", Colors.Red);
                    await WriteOutputAsync($"{ex.StackTrace}{Environment.NewLine}", Colors.Red);
                }
            });
        }
Example #15
0
 private void Window_PointerMoved(CoreWindow sender, PointerEventArgs args)
 {
     _gestureRecognizer.ProcessMoveEvents(args.GetIntermediatePoints());
 }
Example #16
0
        /// <summary>
        /// Custom keyboarding logic to enable movement via the arrow keys without triggering selection
        /// until a 'Space' or 'Enter' key is pressed.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyRoutedEventArgs e)
        {
            var focusedItem = FocusManager.GetFocusedElement();

            switch (e.Key)
            {
            case VirtualKey.Up:
                this.TryMoveFocus(FocusNavigationDirection.Up);
                e.Handled = true;
                break;

            case VirtualKey.Down:
                this.TryMoveFocus(FocusNavigationDirection.Down);
                e.Handled = true;
                break;

            case VirtualKey.Tab:
                var shiftKeyState = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Shift);
                var shiftKeyDown  = (shiftKeyState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;

                // If we're on the header item then this will be null and we'll still get the default behavior.
                if (focusedItem is ListViewItem)
                {
                    var  currentItem = (ListViewItem)focusedItem;
                    bool onlastitem  = currentItem != null && this.IndexFromContainer(currentItem) == this.Items.Count - 1;
                    bool onfirstitem = currentItem != null && this.IndexFromContainer(currentItem) == 0;

                    if (!shiftKeyDown)
                    {
                        if (onlastitem)
                        {
                            this.TryMoveFocus(FocusNavigationDirection.Next);
                        }
                        else
                        {
                            this.TryMoveFocus(FocusNavigationDirection.Down);
                        }
                    }
                    else     // Shift + Tab
                    {
                        if (onfirstitem)
                        {
                            this.TryMoveFocus(FocusNavigationDirection.Previous);
                        }
                        else
                        {
                            this.TryMoveFocus(FocusNavigationDirection.Up);
                        }
                    }
                }
                else if (focusedItem is Control)
                {
                    if (!shiftKeyDown)
                    {
                        this.TryMoveFocus(FocusNavigationDirection.Down);
                    }
                    else     // Shift + Tab
                    {
                        this.TryMoveFocus(FocusNavigationDirection.Up);
                    }
                }

                e.Handled = true;
                break;

            case VirtualKey.Space:
            case VirtualKey.Enter:
                // Fire our event using the item with current keyboard focus
                this.InvokeItem(focusedItem);
                e.Handled = true;
                break;

            default:
                base.OnKeyDown(e);
                break;
            }
        }
Example #17
0
        public void this_KeyDown(CoreWindow sender, KeyEventArgs e)
        {
            Key k = Key.NONE;

            if (e.VirtualKey == Windows.System.VirtualKey.N)
            {
                k = Key.N;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.I)
            {
                k = Key.I;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.O)
            {
                k = Key.O;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.C)
            {
                k = Key.C;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.D)
            {
                k = Key.D;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.A)
            {
                k = Key.A;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.K)
            {
                k = Key.K;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.U)
            {
                k = Key.U;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.R)
            {
                k = Key.R;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.Right)
            {
                k = Key.RIGHT;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.Left)
            {
                k = Key.LEFT;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.Up)
            {
                k = Key.UP;
            }
            if (e.VirtualKey == Windows.System.VirtualKey.Down)
            {
                k = Key.DOWN;
            }

            KeyObject kevent = new KeyObject(k, lastMousePosition);

            keymanager.thisKeyDownExec(kevent);
        }
 public AudioRecorder()
 {
     this.InitializeComponent();
     dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
 }
        /// <summary>
        /// Invoked on every mouse click, touch screen tap, or equivalent interaction when this
        /// page is active and occupies the entire window.  Used to detect browser-style next and
        /// previous mouse button clicks to navigate between pages.
        /// </summary>
        /// <param name="sender">Instance that triggered the event.</param>
        /// <param name="e">Event data describing the conditions that led to the event.</param>
        private void CoreWindow_PointerPressed(CoreWindow sender,
            PointerEventArgs e)
        {
            var properties = e.CurrentPoint.Properties;

            // Ignore button chords with the left, right, and middle buttons
            if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed ||
                properties.IsMiddleButtonPressed) return;

            // If back or foward are pressed (but not both) navigate appropriately
            bool backPressed = properties.IsXButton1Pressed;
            bool forwardPressed = properties.IsXButton2Pressed;
            if (backPressed ^ forwardPressed)
            {
                e.Handled = true;
                if (backPressed) this.GoBackCommand.Execute(null);
                if (forwardPressed) this.GoForwardCommand.Execute(null);
            }
        }
Example #20
0
 public void Window_PointerPressed(CoreWindow sender, PointerEventArgs args)
 {
     // Store the current point, to be used in drag calculations
     draggingCameraFrom = args.CurrentPoint;
 }