public static NGWebsite ToNGWebsite(this ContactWebsite website)
        {
            var ngWebsite = new NGWebsite()
            {
                Raw         = website.RawValue,
                Description = website.Description
            };

            return(ngWebsite);
        }
        public static ContactWebsite ToContactWebsite(this NGWebsite website)
        {
            var winWebsite = new ContactWebsite()
            {
                RawValue    = website.Raw,
                Uri         = website.GetUri(),
                Description = website.Description
            };

            return(winWebsite);
        }
Example #3
0
 /// <summary>
 /// Utility method to convert website information from the WinRT ContactWebsite
 /// instance to the representation in the vCard library.
 /// No 1:1 matching is possible between both classes, the method tries to
 /// keep the conversion as accurate as possible.
 /// </summary>
 /// <param name="website">Website information from WinRT.</param>
 /// <returns>The website information from WinRT library converted to a
 /// vCard library class instance.</returns>
 private vCardWebsite ConvertWebsiteToVcard(ContactWebsite website)
 {
     // Can't match description to website type
     return(new vCardWebsite(website.Uri.ToString(), vCardWebsiteTypes.Default));
 }
Example #4
0
 private Abstractions.Website Convert(ContactWebsite contactWebsite)
 {
     Abstractions.Website website = new Abstractions.Website();
     website.Address = contactWebsite.RawValue; // should be replace with Uri?
     return(website);
 }
Example #5
0
 /// <summary>
 /// Utility method to convert website information from the WinRT ContactWebsite 
 /// instance to the representation in the vCard library.
 /// No 1:1 matching is possible between both classes, the method tries to
 /// keep the conversion as accurate as possible.
 /// </summary>
 /// <param name="website">Website information from WinRT.</param>
 /// <returns>The website information from WinRT library converted to a 
 /// vCard library class instance.</returns>
 private vCardWebsite ConvertWebsiteToVcard(ContactWebsite website)
 {
     // Can't match description to website type
     return new vCardWebsite(website.Uri.ToString(), vCardWebsiteTypes.Default);
 }
Example #6
0
        private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // name
            contact.FirstName           = tbFName.Text;
            contact.MiddleName          = tbMName.Text;
            contact.LastName            = tbLName.Text;
            contact.Nickname            = tbNickName.Text;
            contact.HonorificNamePrefix = tbPrefix.Text;
            contact.HonorificNameSuffix = tbSuffix.Text;
            contact.YomiGivenName       = tbFNamePinyin.Text;
            contact.YomiFamilyName      = tbLNamePinyin.Text;

            // website
            ContactWebsite web = new ContactWebsite();

            web.RawValue = tbWeb.Text;
            contact.Websites.Add(web);


            // job
            ContactJobInfo job = new ContactJobInfo();

            job.CompanyName = tbCompany.Text;
            job.Title       = tbPosition.Text;
            job.Office      = tbOfficeLocation.Text;
            contact.JobInfo.Add(job);

            // Significant others
            ContactSignificantOther soSpause = new ContactSignificantOther();

            soSpause.Relationship = ContactRelationship.Spouse;
            soSpause.Name         = tbSpause.Text;
            contact.SignificantOthers.Add(soSpause);
            ContactSignificantOther soChild = new ContactSignificantOther();

            soChild.Relationship = ContactRelationship.Child;
            soChild.Name         = tbChild.Text;
            contact.SignificantOthers.Add(soChild);

            // note
            contact.Notes = tbNote.Text;

            // phone
            ContactPhone cell1        = new ContactPhone();
            ContactPhone cell2        = new ContactPhone();
            ContactPhone home1        = new ContactPhone();
            ContactPhone home2        = new ContactPhone();
            ContactPhone work1        = new ContactPhone();
            ContactPhone work2        = new ContactPhone();
            ContactPhone companyphone = new ContactPhone();
            ContactPhone companyfax   = new ContactPhone();
            ContactPhone homefax      = new ContactPhone();
            ContactPhone bbcall       = new ContactPhone();

            cell1.Kind          = ContactPhoneKind.Mobile;
            cell1.Number        = tbCellphone1.Text;
            cell2.Kind          = ContactPhoneKind.Mobile;
            cell2.Number        = tbCellphone2.Text;
            home1.Kind          = ContactPhoneKind.Home;
            home1.Number        = tbHomephone1.Text;
            home2.Kind          = ContactPhoneKind.Home;
            home2.Number        = tbHomephone2.Text;
            work1.Kind          = ContactPhoneKind.Work;
            work1.Number        = tbWorkphone1.Text;
            work2.Kind          = ContactPhoneKind.Work;
            work2.Number        = tbWorkphone2.Text;
            companyphone.Kind   = ContactPhoneKind.Company;
            companyphone.Number = tbOfficephone.Text;
            companyfax.Kind     = ContactPhoneKind.BusinessFax;
            companyfax.Number   = tbOfficeFax.Text;
            homefax.Kind        = ContactPhoneKind.HomeFax;
            homefax.Number      = tbHomeFax.Text;
            bbcall.Kind         = ContactPhoneKind.Pager;
            bbcall.Number       = tbBBCall.Text;
            contact.Phones.Add(cell1);
            contact.Phones.Add(cell2);
            contact.Phones.Add(home1);
            contact.Phones.Add(home2);
            contact.Phones.Add(work1);
            contact.Phones.Add(work2);
            contact.Phones.Add(companyphone);
            contact.Phones.Add(companyfax);
            contact.Phones.Add(homefax);
            contact.Phones.Add(bbcall);

            // email
            ContactEmail homemail  = new ContactEmail();
            ContactEmail workmail  = new ContactEmail();
            ContactEmail othermail = new ContactEmail();

            homemail.Kind     = ContactEmailKind.Personal;
            homemail.Address  = tbPersonalEmail.Text;
            workmail.Kind     = ContactEmailKind.Work;
            workmail.Address  = tbOfficeEmail.Text;
            othermail.Kind    = ContactEmailKind.Other;
            othermail.Address = tbOtherEmail.Text;
            contact.Emails.Add(homemail);
            contact.Emails.Add(workmail);
            contact.Emails.Add(othermail);

            // pic
            // 還有待研究,猜測因為await關係,必須要等待至檔案讀取完,sampleFile才會存進contact。
            string        path          = System.IO.Directory.GetCurrentDirectory();
            StorageFolder storageFolder = await StorageFolder.GetFolderFromPathAsync(path);

            StorageFile sampleFile = await storageFolder.GetFileAsync("dog.png");

            contact.SourceDisplayPicture = sampleFile;
            contact.Thumbnail            = sampleFile;
        }