public static async Task <PeriodicTable> LoadTable() { PeriodicTable aTable = null; try { StorageFile sf = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"Chemistry.Elements\XML\Elements.xml"); //Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("PeriodicTable.test.xml"); //XmlDocument doc = new XmlDocument(); //doc.Load(s); // FileStream fs = new FileStream(@"C:\test.xml", FileMode.Open, FileAccess.Read); Type t = typeof(PeriodicTable); XmlSerializer ser = new XmlSerializer(typeof(PeriodicTable)); FileRandomAccessStream stream = (FileRandomAccessStream)await sf.OpenAsync(FileAccessMode.Read); System.IO.Stream st = stream.AsStreamForRead(); aTable = (PeriodicTable)ser.Deserialize(st); } catch (Exception e) { string s = e.Message; aTable = new PeriodicTable(); } foreach (ChemElement e in aTable.Elements) { e.CreatePropertyList(); } return(aTable); }
private async void Application_ContractActivated(object sender, IActivatedEventArgs e) { var filePickerContinuationArgs = e as FileOpenPickerContinuationEventArgs; if (filePickerContinuationArgs != null) { // Handle file here FileOpenPickerContinuationEventArgs args = filePickerContinuationArgs; if (args.Files.Count > 0 && args.Files[0] != null) { using (FileRandomAccessStream stream = (FileRandomAccessStream)await args.Files[0].OpenAsync(FileAccessMode.Read)) { BitmapImage bi = new BitmapImage(); bi.SetSource(stream.AsStreamForRead()); user.UserAvatar = bi; OnPropertyChanged("UserAvatar"); manager.SaveUser(); } } } Microsoft.Phone.Shell.PhoneApplicationService.Current.ContractActivated -= Application_ContractActivated; }