Пример #1
0
 // Saves data into XML
 private void btnSaveMapClick(object sender, RoutedEventArgs e)
 {
     if (map.saveMap(MapWindow.getMapGrid()))
     {
         System.Windows.MessageBox.Show("Map enregitrée !");
     }
 }
Пример #2
0
        // Validates user inputs, creates a tilemap and open editor windows (map & tileset)
        private void BtnOK_Click(object sender, RoutedEventArgs e)
        {
            if (txtWidth.Text != "" && txtHeight.Text != "" && txtTileWidth.Text != "" &&
                txtTileHeight.Text != "" && txtTilemapPath.Text != "" && txtTilemapName.Text != "" &&
                txtElementWidth.Text != "" && txtElementHeight.Text != "" && txtMargin.Text != "" &&
                txtSpacing.Text != "" && txtTilesetFile.Text != "")
            {
                Tilemap theTilemap = new Tilemap
                                     (
                    int.Parse(txtWidth.Text), int.Parse(txtHeight.Text), int.Parse(txtTileWidth.Text),
                    int.Parse(txtTileHeight.Text), txtTilemapPath.Text, txtTilemapName.Text,
                    int.Parse(txtElementWidth.Text), int.Parse(txtElementHeight.Text),
                    int.Parse(txtMargin.Text), int.Parse(txtSpacing.Text), txtTilesetFile.Text
                                     );

                if (theTilemap.initDoc())
                {
                    MapWindow mapWindow = theTilemap.goToEditor();
                    mapWindow.Show();
                    TilemapWindow tilemapWindow = new TilemapWindow(mapWindow, theTilemap.getTileset());
                    tilemapWindow.Show();
                    ToolsWindow tools = new ToolsWindow(mapWindow, theTilemap);
                    tools.Show();
                    this.Close();
                }
            }
            else
            {
                System.Windows.MessageBox.Show("Merci de renseigner tous les champs");
            }
        }
Пример #3
0
        public TilemapWindow(MapWindow map, Tileset myTileset)
        {
            InitializeComponent();

            theTileset = myTileset;
            theMap     = map;

            string directory = System.IO.Directory.GetCurrentDirectory();

            BitmapImage tileset = new BitmapImage();

            tileset.BeginInit();
            tileset.UriSource = new Uri(theTileset.getTilesetFile(), UriKind.Absolute);
            tileset.EndInit();

            Image img = new Image
            {
                Width  = tileset.PixelWidth,
                Height = tileset.PixelHeight
            };

            img.Source = tileset;

            // load tileset into the editor right-side window
            this.tilesetGrid.Children.Add(img);

            this.Height = tileset.PixelHeight + 35;
            this.Width  = tileset.PixelWidth + 15;
            this.Left   = SystemParameters.WorkArea.Width - this.Width;
            this.Top    = (SystemParameters.WorkArea.Bottom - this.Height) / 2;
        }
Пример #4
0
        public ToolsWindow(MapWindow myMapWindow, Tilemap myTilemap)
        {
            InitializeComponent();

            mapWindow = myMapWindow;
            map       = myTilemap;
            this.Left = SystemParameters.WorkArea.Width - this.Width;
            this.Top  = 0;
        }
Пример #5
0
        // Saves data into XML at selected location
        private void btnSaveAsClick(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog folderDialog = new FolderBrowserDialog();

            folderDialog.ShowDialog();

            if (map.saveMap(MapWindow.getMapGrid(), folderDialog.SelectedPath))
            {
                System.Windows.MessageBox.Show("Map enregitrée !");
            }
        }
Пример #6
0
        // Load an existing tilemap
        private void BtnLoadMap_Click(object sender, RoutedEventArgs e)
        {
            // Choose the tilemap file
            FileDialog fileDialog = new OpenFileDialog();

            fileDialog.ShowDialog();

            Tilemap theTilemap = new Tilemap();

            if (theTilemap.initFromXML(fileDialog.FileName))
            {
                MapWindow Map = theTilemap.goToEditor();
                Map.Show();
                TilemapWindow tilemap = new TilemapWindow(Map, theTilemap.getTileset());
                tilemap.Show();
                ToolsWindow tools = new ToolsWindow(Map, theTilemap);
                tools.Show();
                this.Close();
            }
        }
Пример #7
0
        // Close all windows, save possible before close
        private void wdwTools_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            MessageBoxResult answer;

            answer = System.Windows.MessageBox.Show("Sauvegarder avant de quitter ?", "Attention !", MessageBoxButton.YesNoCancel);

            if (answer == MessageBoxResult.Yes)
            {
                if (map.saveMap(MapWindow.getMapGrid()))
                {
                    System.Windows.MessageBox.Show("Map enregitrée !");
                }
                Environment.Exit(0);
            }
            else if (answer == MessageBoxResult.No)
            {
                Environment.Exit(0);
            }
            else if (answer == MessageBoxResult.Cancel)
            {
                e.Cancel = true;
            }
        }
Пример #8
0
        public MapWindow goToEditor()
        {
            MapWindow Map = new MapWindow(this);

            return(Map);
        }