Esempio n. 1
0
        private void MenuFileOpen_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter           = "MyCartographyObj files(*.az) | *.az";
            openFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            openFile.ShowDialog();

            //openFile.di

            MyPersonalMapData personneTMP = null;

            try
            {
                personneTMP = MyPersonalMapData.LoadFile(openFile.FileName);
            }
            catch (LoadSaveException messageErreurLoadFile)
            {
                MessageBox.Show(messageErreurLoadFile.Message, "ERREUR OUVERTURE", MessageBoxButton.OK, MessageBoxImage.Error);
                personneTMP = null;
            }

            if (personneTMP != null)
            {
                MessageBox.Show("OUVERTURE REUSSIE", "", MessageBoxButton.OK, MessageBoxImage.Information);
                PersonneConnectee = personneTMP;
                UpdateListBox();
            }
        }
Esempio n. 2
0
        private void MenuFileOpen_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter           = "MyCartographyObj files(*.az) | *.az";
            openFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            openFile.ShowDialog();

            MyPersonalMapData personneTMP;

            if ((personneTMP = MyPersonalMapData.LoadFile(openFile.FileName)) == null)
            {
                MessageBox.Show("ERREUR OUVERTURE", "", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                MessageBox.Show("OUVERTURE REUSSIE", "", MessageBoxButton.OK, MessageBoxImage.Information);
                PersonneConnectee = personneTMP;
                TextDebug.Content = PersonneConnectee.ToString();
            }
        }
Esempio n. 3
0
        private void QuitterSauvegarde()
        {
            MyPersonalMapData personneTMP = null;
            bool modif = true;

            if (DossierDeTravail != null && PersonneConnectee.Emplacement == null)
            {
                PersonneConnectee.Emplacement = DossierDeTravail;
            }

            if (PersonneConnectee.Emplacement != null)
            {
                try
                {
                    personneTMP = MyPersonalMapData.LoadFile(PersonneConnectee.Emplacement);
                }
                catch (LoadSaveException messageErreurLoadFile)
                {
                    //MessageBox.Show("ERREUR OUVERTURE", messageErreurLoadFile.Message, MessageBoxButton.OK, MessageBoxImage.Error);
                    Console.WriteLine("(QuitterSauvegarde) ERREUR OUVERTURE : " + messageErreurLoadFile.Message);
                    personneTMP = null;
                }

                if (personneTMP != null)
                {
                    if (personneTMP.ObservableCollection.Equals(PersonneConnectee.ObservableCollection))
                    {
                        modif = false;
                    }
                }
            }

            if (modif)
            {
                MessageBoxResult resultNewClient = MessageBox.Show("Voulez-vous sauvegarder vos modifications ?", "", MessageBoxButton.YesNo, MessageBoxImage.Question);
                switch (resultNewClient)
                {
                case MessageBoxResult.Yes:
                    try
                    {
                        personneTMP = MyPersonalMapData.SavePersonne(PersonneConnectee, PersonneConnectee.Emplacement);
                    }
                    catch (LoadSaveException messageErreurSave)
                    {
                        MessageBox.Show(messageErreurSave.Message, "ERREUR SAUVEGARDE", MessageBoxButton.OK, MessageBoxImage.Error);
                        personneTMP = null;
                    }
                    if (personneTMP != null)
                    {
                        PersonneConnectee = personneTMP;
                        MessageBox.Show("SAUVEGARDE REUSSIE", "", MessageBoxButton.OK, MessageBoxImage.Information);
                        this.Close();
                    }
                    break;

                    /*case MessageBoxResult.No:
                     *
                     *  break;*/
                }
            }
            else
            {
                this.Close();
            }
        }