public NewProjectDialog() { // Initialize model and view. newProjectProperties = new NewProjectProperties(); newProjectPropertiesViewModel = new NewProjectPropertiesViewModel(newProjectProperties); // Set data context for this window. DataContext = newProjectPropertiesViewModel; InitializeComponent(); // Set item source of type combo box. mapTypeComboBox.ItemsSource = Enum.GetValues(typeof(MapType)).Cast <MapType>(); }
/// <summary> /// Build new tile map project from given project properties. /// </summary> public static Project BuildTileMapProject(NewProjectProperties properties, IntPtr windowHandle) { TileEngine tileEngine = new TileEngine(new Point(properties.MapWidth, properties.MapHeight), new Point(properties.TileWidth, properties.TileHeight)); TileEditor editor = new TileEditor(tileEngine); EditorGame game = new EditorGame(windowHandle, editor); return(new Project(new TileEditorGUIConfigurer(editor), game, editor, properties.ProjectName, properties.MapName, properties.MapType.ToString())); }
private void TileMapDebug() { // TODO: copy paste from event handler, just for debug purposes. // Dispose old project and show warning dialog to the user. if (project != null) { if (MessageBox.Show("All unsaved work will be lost, continue?", "Warning", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; } CleanupLastProject(); } // Create new project. NewProjectProperties properties = new NewProjectProperties() { MapHeight = 32, MapWidth = 32, MapName = "debug", ProjectName = "debug", TileHeight = 64, TileWidth = 64, MapType = MapType.Tile }; switch (properties.MapType) { case MapType.Tile: project = ProjectBuilder.BuildTileMapProject(properties, xnaControl.Handle); break; case MapType.Object: case MapType.Hex: default: throw new NotImplementedException("Feature is not implemented."); } // Initialize the project. InitializeNewProject(); // Set resolution. // TODO: set resolution once its XNA controls size valid. project.Game.ChangeGraphics(1280, 720); }
private void newProjectMenuItem_Click(object sender, RoutedEventArgs e) { NewProjectDialog newProjectDialog = new NewProjectDialog(); // Show new project dialog to the user. if (newProjectDialog.ShowDialog().Value) { // Dialog OK, got some correct properties for creating editor. // Dispose old project and show warning dialog to the user. if (project != null) { if (MessageBox.Show("All unsaved work will be lost, continue?", "Warning", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; } CleanupLastProject(); } // Create new project. NewProjectProperties properties = newProjectDialog.NewProjectProperties; switch (properties.MapType) { case MapType.Tile: project = ProjectBuilder.BuildTileMapProject(properties, xnaControl.Handle); break; case MapType.Object: case MapType.Hex: default: throw new NotImplementedException("Feature is not implemented."); } // Initialize the project. InitializeNewProject(); // Set resolution. // TODO: set resolution once its XNA controls size valid. project.Game.ChangeGraphics(1280, 720); } // Invalid results, continue. }