コード例 #1
0
        private void EnterMapSection(object sender, RoutedEventArgs e)
        {
            this.Hide();
            var button = (Button)sender;
            MapSectionEditor mapSectionEditor = new MapSectionEditor(button.Content.ToString());

            mapSectionEditor.Closed += (s, args) => this.Close();
            mapSectionEditor.Show();
        }
コード例 #2
0
        } //end of DrawCanvas

        // Event for creating a new map section
        private void CreateMapSection(object sender, RoutedEventArgs e)
        {
            SaveFileDialog tableFile = new SaveFileDialog();

            tableFile.FileName         = "NewMapSection";
            tableFile.DefaultExt       = ".csv";
            tableFile.Filter           = "Text documents(.csv)|*.csv";
            tableFile.InitialDirectory = filePath;

            Nullable <bool> result = tableFile.ShowDialog();

            SaveFileDialog decorationelementFile = new SaveFileDialog();

            decorationelementFile.FileName         = "NewMapSection";
            decorationelementFile.DefaultExt       = ".csv";
            decorationelementFile.Filter           = "Text documents(.csv)|*.csv";
            decorationelementFile.InitialDirectory = $@"C:\P4\DecorationElements";

            Nullable <bool> yes = decorationelementFile.ShowDialog();

            using (FileStream fw = File.Create(decorationelementFile.FileName))
            {
                fw.Close();
            }

            using (var writer = new StreamWriter(decorationelementFile.FileName))
            {
                writer.WriteLine("no;type;x;y");
                writer.Close();
            }

            if (result == true && yes == true)
            {
                this.Hide();
                MapSectionEditor mapSectionEditor = new MapSectionEditor(Path.GetFileNameWithoutExtension(tableFile.FileName));
                using (FileStream fw = File.Create(tableFile.FileName))
                {
                    fw.Close();
                }

                using (var writer = new StreamWriter(tableFile.FileName))
                {
                    writer.WriteLine("no;category;x;y");
                    writer.Close();
                }

                mapSectionEditor.Closed += (s, args) => this.Close();
                mapSectionEditor.Show();
            }
        }