예제 #1
0
        private void OpenMenuItem_Click(object sender, RoutedEventArgs e)
        {
            Reset();

            var ofd = new OpenFileDialog();

            ofd.Filter = "Demo files (*.dem)|*.dem";

            if (ofd.ShowDialog(this) == true)
            {
                using (var parser = new DemoParser(ofd.OpenFile()))
                {
                    parser.ParseHeader();

                    try
                    {
                        _demo.Parse(parser);
                    }
                    catch (DemoDataException ex)
                    {
                        MessageBox.Show($"Failed to load demo: {ex.Message}", "Unable to load demo", MessageBoxButton.OK, MessageBoxImage.Error);
                    }

                    minimap.LoadMap(parser.Header.MapName);
                    timeline.Init(_demo.Rounds, _demo.LastTick);
                }
            }
        }