Exemplo n.º 1
0
        //固定联系人
        public static async void PinContact(Contact contact)
        {
            //前面应放置API版本检查代码,仅能实装于16299
            if (await checkContactAsync(contact))
            {
                return;
            }
            await addContactAsync(contact);

            PinnedContactManager contactManager = PinnedContactManager.GetDefault();
            await contactManager.RequestPinContactAsync(contact, PinnedContactSurface.Taskbar);
        }
Exemplo n.º 2
0
        private async void Pin_Click(object sender, RoutedEventArgs e)
        {
            // Get the PinnedContactManager for the current user.
            PinnedContactManager pinnedContactManager = PinnedContactManager.GetDefault();

            // Check whether pinning to the taskbar is supported.
            if (!pinnedContactManager.IsPinSurfaceSupported(PinnedContactSurface.Taskbar))
            {
                // If not, then there is nothing for this program to do.
                rootPage.NotifyUser("The system does not support pinning contacts to the taskbar.", NotifyType.ErrorMessage);
                return;
            }

            // Get the contact list for this app.
            ContactList list = await GetContactListAsync();

            // Check if the sample contact already exists.
            Contact contact = await list.GetContactFromRemoteIdAsync(Constants.ContactRemoteId);

            if (contact == null)
            {
                // Create the sample contact.
                contact           = new Contact();
                contact.FirstName = "John";
                contact.LastName  = "Doe";
                contact.RemoteId  = Constants.ContactRemoteId;
                contact.Emails.Add(new ContactEmail {
                    Address = Constants.ContactEmail
                });
                contact.Phones.Add(new ContactPhone {
                    Number = Constants.ContactPhone
                });
                contact.SourceDisplayPicture = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/LandscapeImage20.jpg"));
                await list.SaveContactAsync(contact);
            }

            // Pin the contact to the taskbar.
            if (!await pinnedContactManager.RequestPinContactAsync(contact, PinnedContactSurface.Taskbar))
            {
                // Contact was not pinned.
                return;
            }

            // It may not be obvious to the user that a contact was pinned if it goes into the overflow.
            // If it looks like we may have gone into the overflow, notify the user that the pin was successful
            // and the contact can still receive notifications.
            if ((await pinnedContactManager.GetPinnedContactIdsAsync()).ContactIds.Count > 3)
            {
                rootPage.NotifyUser("The contact was pinned, but may appear in the overflow. Contacts in the overflow can still receive notifications.", NotifyType.StatusMessage);
            }
        }
Exemplo n.º 3
0
        private async Task PinContactAsync(Contact contact)
        {
            // Get the PinnedContactManager for the current user.
            PinnedContactManager pinnedContactManager = PinnedContactManager.GetDefault();

            // Check whether pinning to the taskbar is supported.
            if (!pinnedContactManager.IsPinSurfaceSupported(PinnedContactSurface.Taskbar))
            {
                // If not, then there is nothing for this program to do.
                rootPage.NotifyUser("The system does not support pinning contacts to the taskbar.", NotifyType.ErrorMessage);
                return;
            }

            // Pin the contact to the taskbar.
            if (!await pinnedContactManager.RequestPinContactAsync(contact, PinnedContactSurface.Taskbar))
            {
                // Contact was not pinned.
                return;
            }
        }
        private async void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
        {
            var menuFlyoutItem = sender as MenuFlyoutItem;
            var appContact     = menuFlyoutItem?.DataContext as AppContact;

            if (appContact != null)
            {
                var contactToPinUnpin = await GetAggregateContactFromAppContactAsync(appContact);

                switch (menuFlyoutItem.Tag)
                {
                case Constants.CONTACT_CONTEXT_MENU_TAG_PIN:
                    await _pinnedContactManager.RequestPinContactAsync(contactToPinUnpin, PinnedContactSurface.Taskbar);

                    break;

                case Constants.CONTACT_CONTEXT_MENU_TAG_UNPIN:
                    await _pinnedContactManager.RequestUnpinContactAsync(contactToPinUnpin, PinnedContactSurface.Taskbar);

                    break;
                }
            }
        }
Exemplo n.º 5
0
        private async void CustomerSupport_Click(object sender, RoutedEventArgs e)
        {
            // Get the PinnedContactManager for the current user.
            PinnedContactManager pinnedContactManager = PinnedContactManager.GetDefault();

            // Check whether pinning to the taskbar is supported.
            if (!pinnedContactManager.IsPinSurfaceSupported(PinnedContactSurface.Taskbar))
            {
                return;
            }

            // Get the contact list for this app.
            ContactList list = await GetContactListAsync();

            // Check if the sample contact already exists.
            Contact contact = await list.GetContactFromRemoteIdAsync(Constants.ContactRemoteId);


            if (contact == null)
            {
                // Create the sample contact.
                contact           = new Contact();
                contact.FirstName = "Clippy";
                contact.LastName  = "";
                contact.RemoteId  = Constants.ContactRemoteId;
                contact.Emails.Add(new ContactEmail {
                    Address = Constants.ContactEmail
                });
                contact.Phones.Add(new ContactPhone {
                    Number = Constants.ContactPhone
                });
                contact.SourceDisplayPicture = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/clippy.jpg"));

                await list.SaveContactAsync(contact);
            }

            if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5))
            {
                // Create a new contact annotation
                ContactAnnotation annotation = new ContactAnnotation();
                annotation.ContactId = contact.Id;

                // Add appId and contact panel support to the annotation
                String appId = "d9714431-a083-4f7c-a89f-fe7a38f759e4_75cr2b68sm664!App";
                annotation.ProviderProperties.Add("ContactPanelAppID", appId);
                annotation.SupportedOperations = ContactAnnotationOperations.ContactProfile;

                // Save annotation to contact annotation list
                // Windows.ApplicationModel.Contacts.ContactAnnotationList
                var annotationList = await GetContactAnnotationList();

                await annotationList.TrySaveAnnotationAsync(annotation);
            }

            // Pin the contact to the taskbar.
            if (!await pinnedContactManager.RequestPinContactAsync(contact, PinnedContactSurface.Taskbar))
            {
                // Contact was not pinned.
                return;
            }
        }
Exemplo n.º 6
0
 private async Task PinAContact(Contact contact)
 {
     PinnedContactManager pinnedContactManager = PinnedContactManager.GetDefault();
     await pinnedContactManager.RequestPinContactAsync(contact, PinnedContactSurface.Taskbar);
 }
Exemplo n.º 7
0
 public static async void PinContact(Contact contact)
 {
     await pinnedContactManager.RequestPinContactAsync(contact, PinnedContactSurface.Taskbar);
 }