コード例 #1
0
ファイル: LoadSaveHelper.cs プロジェクト: JeanNguon/Projet
        //private static Dictionary<string, string> _types = new Dictionary<string, int>(){{"ProtOn", "pon"},{"All", "*"}};
        /// <summary>
        /// Load the file and renavigate into the the app to refresh it (with GUI)
        /// </summary>
        /// <param name="synchronizationService"></param>
        /// <param name="eventAggregator"></param>
        /// <param name="navigationService"></param>
        public static void LoadFromFile(SynchronizationService synchronizationService, IEventAggregator eventAggregator, NavigationService navigationService)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Multiselect = false;
            dlg.Filter = "ProtOn (*.pon)|*.pon";

            bool? userClickedOK = dlg.ShowDialog();
            if (userClickedOK == true)
            {
                string data = String.Empty;

                using (ZipFile zip = ZipFile.Read(dlg.File.OpenRead()))
                {
                    if (zip.Any(f => f.FileName.EndsWith(_fileEnd)))
                    {
                        zip.Password = _unzipperPass;
                        using (Stream fileStream = zip.First(f => f.FileName.EndsWith(_fileEnd)).OpenReader())
                        {
                            using (StreamReader reader = new StreamReader(fileStream))
                            {
                                string lineOfData = String.Empty;
                                while ((lineOfData = reader.ReadLine()) != null)
                                    data += lineOfData;

                                OfflineStorage.SaveToIsoStore(data);

                                synchronizationService.ImporterContext(data);
                                if (synchronizationService.ImportedContextChanged)
                                    OfflineStorage.SaveToIsoStore(synchronizationService.domainContext);

                                RefreshContext(synchronizationService, eventAggregator, navigationService);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Fichier erroné !", "Le fichier sélectionné est vide.", MessageBoxButton.OK);
                    }
                }
            }
        }
コード例 #2
0
ファイル: LoadSaveHelper.cs プロジェクト: JeanNguon/Projet
 /// <summary>
 /// Reload the screen to the first element loaded
 /// </summary>
 /// <param name="navigationService"></param>
 public static void Refresh(NavigationService navigationService)
 {
     navigationService.DesactivateCurrentView();
     navigationService.Navigate(0, true);
 }
コード例 #3
0
ファイル: LoadSaveHelper.cs プロジェクト: JeanNguon/Projet
 /// <summary>
 /// Reload the page by navigating and setting the tournée label
 /// </summary>
 /// <param name="synchronizationService"></param>
 /// <param name="eventAggregator"></param>
 /// <param name="navigationService"></param>
 private static void RefreshContext(SynchronizationService synchronizationService, IEventAggregator eventAggregator, NavigationService navigationService)
 {
     eventAggregator.Publish("FilAriane".AsViewNavigationArgs().AddNamedParameter("Title", synchronizationService.LibelleTournee));
     Refresh(navigationService);
 }
コード例 #4
0
ファイル: LoadSaveHelper.cs プロジェクト: JeanNguon/Projet
 /// <summary>
 /// Reload the data existing in the IsoStorage and refresh the page
 /// </summary>
 /// <param name="synchronizationService"></param>
 /// <param name="eventAggregator"></param>
 /// <param name="navigationService"></param>
 public static void ReloadFromIsoStore(SynchronizationService synchronizationService, IEventAggregator eventAggregator, NavigationService navigationService)
 {
     if (synchronizationService.domainContext.RestoreFromIsoStore())
     {
         RefreshContext(synchronizationService, eventAggregator, navigationService);
     }
     else
     {
         MessageBox.Show("Pas de fichier dans le cache Silverlight.", "Fichier inexistant", MessageBoxButton.OK);
     }
 }