/// <summary>
 /// This is the event handler for the Closed event. It is invoked when the call is
 /// removed from the lock screen by whatever means.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnClosed(object sender, object e)
 {
     QueueOnUIThread(() =>
     {
         callUI = null;
         // Show the "End Call" button in our app.
         EndCallButton.Visibility = Visibility.Visible;
     });
 }
 // When the user leaves the page, throw away the CallUI object and cancel
 // any pending simulated "hang up" operation.
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     callUI = null;
     if (hangUpTimer != null)
     {
         hangUpTimer.Cancel();
         hangUpTimer = null;
     }
     base.OnNavigatedFrom(e);
 }
예제 #3
0
파일: Call.xaml.cs 프로젝트: mbin/Win81App
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var args = e.Parameter as ILaunchActivatedEventArgs;

            // This sample uses the same page for both lock screen calls and normal calls.
            // The OnLaunched method in App.xaml.cs handles normal call activation,
            // and the OnActivated method handles lock screen call activation.
            // Both pass the ILaunchActivatedEventArgs as the page parameter. If activated from
            // a lock screen call, the parameter will be a LockScreenCallActivatedEventArgs,
            // and the CallUI member gives us access to the lock screen.
            // The Arguments member is the toast command string specified in the XML generated
            // in the xmlPayload variable in Toast.xaml.cs. It takes the form
            //   "<call mode> <caller identity> <simulated call duration>"

            string[] callArguments = args.Arguments.Split(new char[] { ' ' });
            string callMode = callArguments[0];
            string callerIdentity = callArguments[1];
            int callDuration = int.Parse(callArguments[2]);

            string imageText = "";
            switch (callerIdentity) {
                case "Dad":
                    imageText = "\ud83d\udc68";
                    break;
                case "Mom":
                    imageText = "\ud83d\udc69";
                    break;
                case "Grandpa":
                    imageText = "\ud83d\udc74";
                    break;
                case "Grandma":
                    imageText = "\ud83d\udc75";
                    break;
            }
            if (callMode == "Voice") {
                imageText = "\ud83d\udd0a";
            }

            string callTitle = callMode + " call from " + callerIdentity;

            var lockScreenArgs = args as LockScreenCallActivatedEventArgs;
            if (lockScreenArgs != null)
            {
                callUI = lockScreenArgs.CallUI;

                // Hide controls since they are not interactive on the lock screen.
                EndCallButton.Visibility = Visibility.Collapsed;

                // Hook up events.
                callUI.EndRequested += OnEndRequested;
                callUI.Closed += OnClosed;

                // Set the title.
                callUI.CallTitle = callTitle;
            }

            CallImage.Text = imageText;

            // Assign a random light background color so that each call looks
            // slightly different.
            LayoutRoot.Background = RandomLightSolidColor();
            
            CallTitle.Text = callTitle;

            if (callDuration > 0)
            {
                hangUpTimer = ThreadPoolTimer.CreateTimer(OtherPartyHangsUp, TimeSpan.FromSeconds(callDuration));
            }
        }
예제 #4
0
파일: Call.xaml.cs 프로젝트: mbin/Win81App
 /// <summary>
 /// This is the event handler for the Closed event. It is invoked when the call is
 /// removed from the lock screen by whatever means.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnClosed(object sender, object e)
 {
     QueueOnUIThread(() =>
     {
         callUI = null;
         // Show the "End Call" button in our app.
         EndCallButton.Visibility = Visibility.Visible;
     });
 }
예제 #5
0
파일: Call.xaml.cs 프로젝트: mbin/Win81App
 // When the user leaves the page, throw away the CallUI object and cancel
 // any pending simulated "hang up" operation.
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     callUI = null;
     if (hangUpTimer != null)
     {
         hangUpTimer.Cancel();
         hangUpTimer = null;
     }
     base.OnNavigatedFrom(e);
 }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var args = e.Parameter as ILaunchActivatedEventArgs;

            // This sample uses the same page for both lock screen calls and normal calls.
            // The OnLaunched method in App.xaml.cs handles normal call activation,
            // and the OnActivated method handles lock screen call activation.
            // Both pass the ILaunchActivatedEventArgs as the page parameter. If activated from
            // a lock screen call, the parameter will be a LockScreenCallActivatedEventArgs,
            // and the CallUI member gives us access to the lock screen.
            // The Arguments member is the toast command string specified in the XML generated
            // in the xmlPayload variable in Toast.xaml.cs. It takes the form
            //   "<call mode> <caller identity> <simulated call duration>"

            string[] callArguments  = args.Arguments.Split(new char[] { ' ' });
            string   callMode       = callArguments[0];
            string   callerIdentity = callArguments[1];
            int      callDuration   = int.Parse(callArguments[2]);

            string imageText = "";

            switch (callerIdentity)
            {
            case "Dad":
                imageText = "\ud83d\udc68";
                break;

            case "Mom":
                imageText = "\ud83d\udc69";
                break;

            case "Grandpa":
                imageText = "\ud83d\udc74";
                break;

            case "Grandma":
                imageText = "\ud83d\udc75";
                break;
            }
            if (callMode == "Voice")
            {
                imageText = "\ud83d\udd0a";
            }

            string callTitle = callMode + " call from " + callerIdentity;

            var lockScreenArgs = args as LockScreenCallActivatedEventArgs;

            if (lockScreenArgs != null)
            {
                callUI = lockScreenArgs.CallUI;

                // Hide controls since they are not interactive on the lock screen.
                EndCallButton.Visibility = Visibility.Collapsed;

                // Hook up events.
                callUI.EndRequested += OnEndRequested;
                callUI.Closed       += OnClosed;

                // Set the title.
                callUI.CallTitle = callTitle;
            }

            CallImage.Text = imageText;

            // Assign a random light background color so that each call looks
            // slightly different.
            LayoutRoot.Background = RandomLightSolidColor();

            CallTitle.Text = callTitle;

            if (callDuration > 0)
            {
                hangUpTimer = ThreadPoolTimer.CreateTimer(OtherPartyHangsUp, TimeSpan.FromSeconds(callDuration));
            }
        }