コード例 #1
0
        private void OnStartClick(object sender, RoutedEventArgs e)
        {
            EndAllTools();
            buttonStart.IsEnabled = false;

            World world = GetWorld();

            computation = new TrailsComputation(world);
            computation.ProgressChanged += (_s, _e) => Dispatcher.Invoke(
                () => {
                if (computation != null)
                {
                    textBoxComputationStage.Text = computation.CurrentStage;
                }
            }
                );
            computation.CanGiveUnripeResult            += (_s, _e) => Dispatcher.Invoke(
                () => buttonGiveUnripeResult.Visibility = Visibility.Visible
                );

            computationThread = new Thread(() =>
            {
                try
                {
                    Dispatcher.Invoke(ShowComputationsIsOnGrid);
                    TrailsComputationsOutput output = computation.Run();
                    trampledness   = new Trampledness(output.Graph);
                    unsavedChanges = true;
                    Dispatcher.Invoke(DrawTrampledness);
                }
                catch (IsolatedAttractorsException)
                {
                    MessageBox.Show("Обнаружены изолированные точки", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                catch (ThreadAbortException)
                {
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    Dispatcher.Invoke(() => {
                        gridComputationIsOn.Visibility = Visibility.Collapsed;
                        buttonStart.IsEnabled          = true;
                    });
                    computation       = null;
                    computationThread = null;
                }
            });
            computationThread.IsBackground = true;
            computationThread.Start();
        }
コード例 #2
0
        private void LoadFromSaveFile(SaveFile saveFile)
        {
            ClearAll();

            boundingAreaTool.BoundingArea = saveFile.World.BoundingArea;
            mapObjectLayer.AddRange(saveFile.World.MapObjects);
            attractorLayer.AddRange(saveFile.World.AttractorObjects);

            this.trampledness = saveFile.Trampledness;
            DrawTrampledness();
            checkBoxShowTrampledness.IsChecked = true;

            mapControl.ZoomToBox(saveFile.Viewport.TopLeft, saveFile.Viewport.BottomRight);

            RefreshLayers();
            RefreshButtons();

            unsavedChanges = false;
        }
コード例 #3
0
 private void ClearTrampledness()
 {
     trampledness = null;
     edgeLayer.Clear();
 }