Beispiel #1
0
        private void Loading(string path)
        {
            BusyContent = "Загрузка сценария...";
            IsBusy      = true;

            BackgroundWorker bw = new BackgroundWorker();

            bw.RunWorkerCompleted += (s, e) =>
            {
                if (e.Error != null)
                {
                    System.Windows.MessageBox.Show("Сценарий поврежден и не может быть прочитан");
                }

                _sim = new Core.Simulation(_scenario);

                ScenarioLoaded = true;

                if (ViewPortCollection.Count() > 0)
                {
                    ViewPortSelectionChanged(ViewPortCollection.First().Code);
                }

                while (Properties.Settings.Default.LastScenarios.Contains(path))
                {
                    Properties.Settings.Default.LastScenarios.Remove(path);
                }
                Properties.Settings.Default.LastScenarios.Add(path);
                Properties.Settings.Default.Save();

                OnPropertyChanged("WindowTitle");

                IsBusy = false;
            };
            bw.DoWork += (s, e) =>
            {
                string p = (string)e.Argument;
                Scenario.IO.ScenarioStream st = new Scenario.IO.ScenarioStream(p);
                _scenario = st.Read();

                _scenario.Map.Init();
            };
            bw.RunWorkerAsync(path);
        }
Beispiel #2
0
        private void Save()
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Файлы сценария (*.scn)|*.scn";
            if (sfd.ShowDialog() == true)
            {
                using (Scenario.IO.ScenarioStream st = new Scenario.IO.ScenarioStream(sfd.FileName))
                {
                    st.Write(_scenario);
                }
                while (Properties.Settings.Default.LastScenarios.Contains(sfd.FileName))
                {
                    Properties.Settings.Default.LastScenarios.Remove(sfd.FileName);
                }
                Properties.Settings.Default.LastScenarios.Add(sfd.FileName);
                Properties.Settings.Default.Save();
                OnPropertyChanged("WindowTitle");
            }
        }
 private void Save()
 {
     SaveFileDialog sfd = new SaveFileDialog();
     sfd.Filter = "Файлы сценария (*.scn)|*.scn";
     if (sfd.ShowDialog() == true)
     {
         using (Scenario.IO.ScenarioStream st = new Scenario.IO.ScenarioStream(sfd.FileName))
         {
             st.Write(_scenario);
         }
         while (Properties.Settings.Default.LastScenarios.Contains(sfd.FileName))
         {
             Properties.Settings.Default.LastScenarios.Remove(sfd.FileName);
         }
         Properties.Settings.Default.LastScenarios.Add(sfd.FileName);
         Properties.Settings.Default.Save();
         OnPropertyChanged("WindowTitle");
     }
 }
        private void Loading(string path)
        {
            BusyContent = "Загрузка сценария...";
            IsBusy = true;

            BackgroundWorker bw = new BackgroundWorker();
            bw.RunWorkerCompleted += (s, e) =>
            {
                if (e.Error != null)
                {
                    System.Windows.MessageBox.Show("Сценарий поврежден и не может быть прочитан");
                }

                _sim = new Core.Simulation(_scenario);

                ScenarioLoaded = true;

                if (ViewPortCollection.Count() > 0)
                {
                    ViewPortSelectionChanged(ViewPortCollection.First().Code);
                }

                while (Properties.Settings.Default.LastScenarios.Contains(path))
                {
                    Properties.Settings.Default.LastScenarios.Remove(path);
                }
                Properties.Settings.Default.LastScenarios.Add(path);
                Properties.Settings.Default.Save();

                OnPropertyChanged("WindowTitle");

                IsBusy = false;
            };
            bw.DoWork += (s, e) =>
            {
                string p = (string)e.Argument;
                Scenario.IO.ScenarioStream st = new Scenario.IO.ScenarioStream(p);
                _scenario = st.Read();

                _scenario.Map.Init();
            };
            bw.RunWorkerAsync(path);
        }