Esempio n. 1
0
        private async void PinButton_Click(object sender, RoutedEventArgs e)
        {
            // Prepare package images for the tile sizes in our tile to be pinned as well as for the square30x30 logo used in the Apps view.
            Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
            Uri wide310x150Logo   = new Uri("ms-appx:///Assets/wide310x150Tile-sdk.png");
            Uri square310x310Logo = new Uri("ms-appx:///Assets/square310x310Tile-sdk.png");

            // During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation,
            // so that the app knows which tile the user is launching. In this sample, we'll pass in the date and time the secondary tile was pinned.
            string tileActivationArguments = MainPage.logoSecondaryTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

            // Create a Secondary tile with all the required arguments.
            // Note the last argument specifies what size the Secondary tile should show up as by default in the Pin to start fly out.
            // It can be set to TileSize.Square150x150, TileSize.Wide310x150, or TileSize.Default.
            // If set to TileSize.Wide310x150, then the asset for the wide size must be supplied as well.
            // TileSize.Default will default to the wide size if a wide size is provided, and to the medium size otherwise.
            SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId,
                                                            "Title text shown on the tile",
                                                            tileActivationArguments,
                                                            square150x150Logo,
                                                            TileSize.Square150x150);

            secondaryTile.VisualElements.Wide310x150Logo   = wide310x150Logo;
            secondaryTile.VisualElements.Square310x310Logo = square310x310Logo;

            // The display of the secondary tile name can be controlled for each tile size.
            // The default is false.
            secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
            secondaryTile.VisualElements.ShowNameOnWide310x150Logo   = true;
            secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;

            // Specify a foreground text value.
            // The tile background color is inherited from the parent unless a separate value is specified.
            secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

            // Set this to false if roaming doesn't make sense for the secondary tile.
            // The default is true.
            secondaryTile.RoamingEnabled = false;

            // The tile is created and we can now attempt to pin the tile.
            // Note that the status message is updated when the async operation to pin the tile completes.
            bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect(sender), Windows.UI.Popups.Placement.Below);

            if (isPinned)
            {
                rootPage.NotifyUser("Secondary tile successfully pinned.", NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("Secondary tile not pinned.", NotifyType.ErrorMessage);
            }
        }
        private void ShowContactCardWithPlacement_Click(object sender, RoutedEventArgs e)
        {
            Contact contact = rootPage.CreateContactFromUserInput(EmailAddress, PhoneNumber);

            if (contact != null)
            {
                // Show the contact card next to the button.
                Rect rect = MainPage.GetElementRect(sender as FrameworkElement);

                // Show with preferred placement to the right.
                ContactManager.ShowContactCard(contact, rect, Placement.Right);
            }
        }
Esempio n. 3
0
        private async void ShowContactCard_Click(object sender, RoutedEventArgs e)
        {
            Contact contact = CreatePlaceholderContact();

            // Show the contact card next to the button.
            Rect rect = MainPage.GetElementRect(sender as FrameworkElement);

            // The contact card placement can change when it is updated with more data. For improved user experience, specify placement
            // of the card so that it has space to grow and will not need to be repositioned. In this case, default placement first places
            // the card above the button because the card is small, but after the card is updated with more data, the operating system moves
            // the card below the button to fit the card's expanded size. Specifying that the contact card is placed below at the beginning
            // avoids this repositioning.
            Placement placement = Placement.Below;

            // For demonstration purposes, we ask for the Enterprise contact card.
            ContactCardOptions options = new ContactCardOptions()
            {
                HeaderKind = ContactCardHeaderKind.Enterprise
            };

            using (ContactCardDelayedDataLoader dataLoader = ContactManager.ShowDelayLoadedContactCard(contact, rect, placement, options))
            {
                if (dataLoader != null)
                {
                    // Simulate downloading more data from the network for the contact.
                    this.rootPage.NotifyUser("Simulating download...", NotifyType.StatusMessage);

                    Contact fullContact = await DownloadContactDataAsync(contact);

                    if (fullContact != null)
                    {
                        // Update the contact card with the full set of contact data.
                        dataLoader.SetData(fullContact);
                        this.rootPage.NotifyUser("Contact has been updated with downloaded data.", NotifyType.StatusMessage);
                    }
                    else
                    {
                        this.rootPage.NotifyUser("No further information available.", NotifyType.StatusMessage);
                    }
                }
                else
                {
                    this.rootPage.NotifyUser("ShowDelayLoadedContactCard is not supported by this device.", NotifyType.ErrorMessage);
                }
                // The "using" statement will dispose the dataLoader for us.
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Replace an appointment on the user's calendar using the default appointments provider app.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Replace_Click(object sender, RoutedEventArgs e)
        {
            // The appointment id argument for ReplaceAppointmentAsync is typically retrieved from AddAppointmentAsync and stored in app data.
            String appointmentIdOfAppointmentToReplace = AppointmentIdTextBox.Text;

            if (String.IsNullOrEmpty(appointmentIdOfAppointmentToReplace))
            {
                rootPage.NotifyUser("The appointment id cannot be empty", NotifyType.ErrorMessage);
            }
            else
            {
                // The Appointment argument for ReplaceAppointmentAsync should contain all of the Appointment's properties including those that may have changed.
                var appointment = new Windows.ApplicationModel.Appointments.Appointment();

                // Get the selection rect of the button pressed to replace this appointment
                var rect = MainPage.GetElementRect(sender as FrameworkElement);

                // ReplaceAppointmentAsync returns an updated appointment id when the appointment was successfully replaced.
                // The updated id may or may not be the same as the original one retrieved from AddAppointmentAsync.
                // An optional instance start time can be provided to indicate that a specific instance on that date should be replaced
                // in the case of a recurring appointment.
                // If the appointment id returned is an empty string, that indicates that the appointment was not replaced.
                String updatedAppointmentId;
                if (InstanceStartDateCheckBox.IsChecked.Value)
                {
                    // Replace a specific instance starting on the date provided.
                    var instanceStartDate = InstanceStartDateDatePicker.Date;
                    updatedAppointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowReplaceAppointmentAsync(appointmentIdOfAppointmentToReplace, appointment, rect, Windows.UI.Popups.Placement.Default, instanceStartDate);
                }
                else
                {
                    // Replace an appointment that occurs only once or in the case of a recurring appointment, replace the entire series.
                    updatedAppointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowReplaceAppointmentAsync(appointmentIdOfAppointmentToReplace, appointment, rect, Windows.UI.Popups.Placement.Default);
                }

                if (updatedAppointmentId != String.Empty)
                {
                    rootPage.NotifyUser("Updated Appointment Id: " + updatedAppointmentId, NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Appointment not replaced.", NotifyType.ErrorMessage);
                }
            }
        }
        private void ShowContactCardWithOptions_Click(object sender, RoutedEventArgs e)
        {
            Contact contact = rootPage.CreateContactFromUserInput(EmailAddress, PhoneNumber);

            if (contact != null)
            {
                // Show the contact card next to the button.
                Rect rect = MainPage.GetElementRect(sender as FrameworkElement);

                // Ask for the initial tab to be Phone.
                ContactCardOptions options = new ContactCardOptions()
                {
                    InitialTabKind = ContactCardTabKind.Phone
                };

                // Show with default placement.
                ContactManager.ShowContactCard(contact, rect, Placement.Default, options);
            }
        }
Esempio n. 6
0
        private async void PinLiveTile_Click(object sender, RoutedEventArgs e)
        {
            // Prepare the images for our tile to be pinned.
            Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
            Uri wide310x150Logo   = new Uri("ms-appx:///Assets/wide310x150Tile-sdk.png");

            // During creation of the secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
            // These arguments should be meaningful to the application. In this sample, we'll pass in the date and time the secondary tile was pinned.
            string tileActivationArguments = MainPage.dynamicTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

            // Create a Secondary tile with all the required properties and sets perfered size to Wide310x150.
            SecondaryTile secondaryTile = new SecondaryTile(MainPage.dynamicTileId,
                                                            "A Live Secondary Tile",
                                                            tileActivationArguments,
                                                            square150x150Logo,
                                                            TileSize.Wide310x150);

            // Adding the wide tile logo.
            secondaryTile.VisualElements.Wide310x150Logo = wide310x150Logo;

            // The display of the app name can be controlled for each tile size.
            secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
            secondaryTile.VisualElements.ShowNameOnWide310x150Logo   = true;

            // Specify a foreground text value.
            // The tile background color is inherited from the parent unless a separate value is specified.
            secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

            // OK, the tile is created and we can now attempt to pin the tile.
            // Note that the status message is updated when the async operation to pin the tile completes.
            bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect(sender), Windows.UI.Popups.Placement.Below);

            if (isPinned)
            {
                rootPage.NotifyUser("Secondary tile successfully pinned.", NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("Secondary tile not pinned.", NotifyType.ErrorMessage);
            }
        }
        /// <summary>
        /// Removes the appointment associated with a particular appointment id string from the defaul appointment provider app.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Remove_Click(object sender, RoutedEventArgs e)
        {
            // The appointment id argument for ShowRemoveAppointmentAsync is typically retrieved from AddAppointmentAsync and stored in app data.
            String appointmentId = AppointmentIdTextBox.Text;

            // The appointment id cannot be null or empty.
            if (String.IsNullOrEmpty(appointmentId))
            {
                rootPage.NotifyUser("The appointment id cannot be empty", NotifyType.ErrorMessage);
            }
            else
            {
                // Get the selection rect of the button pressed to remove this appointment
                var rect = MainPage.GetElementRect(sender as FrameworkElement);

                // ShowRemoveAppointmentAsync returns a boolean indicating whether or not the appointment related to the appointment id given was removed.
                // An optional instance start time can be provided to indicate that a specific instance on that date should be removed
                // in the case of a recurring appointment.
                bool removed;
                if (InstanceStartDateCheckBox.IsChecked.Value)
                {
                    // Remove a specific instance starting on the date provided.
                    var instanceStartDate = InstanceStartDateDatePicker.Date;
                    removed = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowRemoveAppointmentAsync(appointmentId, rect, Windows.UI.Popups.Placement.Default, instanceStartDate);
                }
                else
                {
                    // Remove an appointment that occurs only once or in the case of a recurring appointment, replace the entire series.
                    removed = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowRemoveAppointmentAsync(appointmentId, rect, Windows.UI.Popups.Placement.Default);
                }

                if (removed)
                {
                    rootPage.NotifyUser("Appointment removed", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Appointment not removed", NotifyType.ErrorMessage);
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Adds an appointment to the default appointment provider app.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Add_Click(object sender, RoutedEventArgs e)
        {
            // Create an Appointment that should be added the user's appointments provider app.
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();

            // Get the selection rect of the button pressed to add this appointment
            var rect = MainPage.GetElementRect(sender as FrameworkElement);

            // ShowAddAppointmentAsync returns an appointment id if the appointment given was added to the user's calendar.
            // This value should be stored in app data and roamed so that the appointment can be replaced or removed in the future.
            // An empty string return value indicates that the user canceled the operation before the appointment was added.
            String appointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Windows.UI.Popups.Placement.Default);

            if (appointmentId != String.Empty)
            {
                rootPage.NotifyUser("Appointment Id: " + appointmentId, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("Appointment not added.", NotifyType.ErrorMessage);
            }
        }
        private async void UnpinSecondaryTile_Click(object sender, RoutedEventArgs e)
        {
            if (SecondaryTile.Exists(MainPage.logoSecondaryTileId))
            {
                // First prepare the tile to be unpinned
                SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId);
                // Now make the delete request.
                bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(MainPage.GetElementRect(sender), Windows.UI.Popups.Placement.Below);

                if (isUnpinned)
                {
                    rootPage.NotifyUser("Secondary tile successfully unpinned.", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Secondary tile not unpinned.", NotifyType.ErrorMessage);
                }
            }
            else
            {
                rootPage.NotifyUser(MainPage.logoSecondaryTileId + " is not currently pinned.", NotifyType.ErrorMessage);
            }
        }
        async void PinToAppBar_Click(object sender, RoutedEventArgs e)
        {
            this.SecondaryTileCommandBar.IsSticky = true;

            // Let us first verify if we need to pin or unpin
            if (SecondaryTile.Exists(MainPage.appbarTileId))
            {
                // First prepare the tile to be unpinned
                SecondaryTile secondaryTile = new SecondaryTile(MainPage.appbarTileId);

                // Now make the delete request.
                bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above);

                if (isUnpinned)
                {
                    Message.Text = MainPage.appbarTileId + " was unpinned.";
                }
                else
                {
                    Message.Text = MainPage.appbarTileId + " was not unpinned.";
                }

                UpdateAppBarButton();
            }
            else
            {
                // Prepare package images for the medium tile size in our tile to be pinned
                Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");

                // During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation,
                // so that the app knows which tile the user is launching. In this sample, we'll pass in the date and time the secondary tile was pinned.
                string tileActivationArguments = MainPage.appbarTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

                // Create a Secondary tile with all the required arguments.
                // Note the last argument specifies what size the Secondary tile should show up as by default in the Pin to start fly out.
                // It can be set to TileSize.Square150x150, TileSize.Wide310x150, or TileSize.Default.
                // If set to TileSize.Wide310x150, then the asset for the wide size must be supplied as well.
                // TileSize.Default will default to the wide size if a wide size is provided, and to the medium size otherwise.
                SecondaryTile secondaryTile = new SecondaryTile(MainPage.appbarTileId,
                                                                "Secondary tile pinned via AppBar",
                                                                tileActivationArguments,
                                                                square150x150Logo,
                                                                TileSize.Square150x150);

                // Whether or not the app name should be displayed on the tile can be controlled for each tile size.  The default is false.
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;

                // Specify a foreground text value.
                // The tile background color is inherited from the parent unless a separate value is specified.
                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

                // OK, the tile is created and we can now attempt to pin the tile.
                // Note that the status message is updated when the async operation to pin the tile completes.
                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(MainPage.GetElementRect(sender), Windows.UI.Popups.Placement.Above);

                if (isPinned)
                {
                    Message.Text = MainPage.appbarTileId + " was successfully pinned.";
                }
                else
                {
                    Message.Text = MainPage.appbarTileId + " was not pinned.";
                }

                UpdateAppBarButton();
            }

            this.BottomAppBar.IsSticky = false;
        }