Exemplo n.º 1
0
        private static async void LoadQuickPens()
        {
            var folder     = ApplicationData.Current.LocalFolder;
            var serializer = new XmlSerializer(typeof(List <PenModel>));

            try
            {
                List <PenModel> quickPens;
                using (var fileStream = new FileStream(folder.Path + "\\quickPens.xml", FileMode.OpenOrCreate))
                {
                    quickPens = serializer.Deserialize(fileStream) as List <PenModel>;
                }

                QuickPens.Clear();

                foreach (var pen in quickPens)
                {
                    QuickPens.Add(pen);
                }
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }

                var dialog = new MessageDialog("Error loading quick pens list.  If this problem continues please contact support.\r\n" + ex.Message);
                await dialog.ShowAsync();

                QuickPens.Clear();
            }
        }
Exemplo n.º 2
0
        private void RefreshQuickPens()
        {
            if (QuickPens == null)
            {
                QuickPens = new ObservableCollection <PenModel>();
            }

            QuickPens.Clear();

            foreach (var pen in StorageIO.QuickPens)
            {
                QuickPens.Add(pen);
            }
        }