コード例 #1
0
        /// <summary>
        /// Preserves state associated with this page in case the application is suspended or the
        /// page is discarded from the navigation cache.  Values must conform to the serialization
        /// requirements of <see cref="SuspensionManager.SessionState"/>.
        /// </summary>
        /// <param name="sender">The source of the event; typically <see cref="NavigationHelper"/></param>
        /// <param name="e">Event data that provides an empty dictionary to be populated with
        /// serializable state.</param>
        private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e)
        {
            // reset the logic
            I_am_a_the_host = false;
            finished_connecting_to_peers = false;
            is_initial_connect = true;
            finalizing_connection = false;
            // stop the peerfinder on this specific page
            PeerFinder.ConnectionRequested -= PeerFinder_ConnectionRequested;

            PeerFinder.Stop();
        }
コード例 #2
0
 /// <summary>
 /// Preserves state associated with this page in case the application is suspended or the
 /// page is discarded from the navigation cache.  Values must conform to the serialization
 /// requirements of <see cref="SuspensionManager.SessionState"/>.
 /// </summary>
 /// <param name="sender">The source of the event; typically <see cref="NavigationHelper"/></param>
 /// <param name="e">Event data that provides an empty dictionary to be populated with
 /// serializable state.</param>
 private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e)
 {
 }
コード例 #3
0
        /// <summary>
        /// Preserves state associated with this page in case the application is suspended or the
        /// page is discarded from the navigation cache.  Values must conform to the serialization
        /// requirements of <see cref="SuspensionManager.SessionState"/>.
        /// </summary>
        /// <param name="sender">The source of the event; typically <see cref="NavigationHelper"/></param>
        /// <param name="e">Event data that provides an empty dictionary to be populated with
        /// serializable state.</param>
        private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e)
        {
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
            HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
            myGeolocator.PositionChanged -= OnPositionChanged;
            if (peerWatcher != null)
            {
                // Remove event handlers.
                peerWatcher.Added -= PeerWatcher_Added;
                peerWatcher.Removed -= PeerWatcher_Removed;
                peerWatcher.Updated -= PeerWatcher_Updated;
                peerWatcher.EnumerationCompleted -= PeerWatcher_EnumerationCompleted;
                peerWatcher.Stopped -= PeerWatcher_Stopped;


                peerWatcher = null;
            }
            string display_name = localSettings.Values[setting_phone_no] as string;

            // check if somehow the phone number is less than 4 chars long. This will be functionally invalid, in the settings page, there should be a check that makes you enter a phone number that's at least valid.
            if (display_name.Length >= 4)
            {
                display_name = display_name.Substring(display_name.Length - 4, 4);
            }
            else
            {
                // padd it until it is of length 4
                for (int i = 0; i < (4 - display_name.Length); i++)
                {
                    display_name += "0";
                }
            }

            display_name = "[" + display_name + "]" + (localSettings.Values[setting_username] as string);

            PeerFinder.DisplayName = display_name;
            PeerFinder.Stop();
            peerFinderStarted = false;
        }