|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace LevelEditor
{
/// <summary>
/// Interaction logic for LevelData.xaml
/// </summary>
public partial class LevelData : Window
{
public delegate void SaveLevel(Level lvl);
public SaveLevel OnSaveLevel;
private Level lvlData;
public LevelData()
{
InitializeComponent();
lvlData = new Level();
lvlData.Height = 480;
this.DataContext = lvlData;
//Backgrounds
cboBakcground.ItemsSource = Enum.GetValues(typeof(BackgroundType));
cboBakcground.SelectedIndex = 0;
}
public LevelData(Level lvlData)
: this()
{
this.DataContext = lvlData;
this.lvlData = lvlData;
this.lblTitle.Text = "EDIT LEVEL";
}
private void btnSave_Click(object sender, RoutedEventArgs e)
{
lvlData.BGType = (BackgroundType)Enum.Parse(typeof(BackgroundType), cboBakcground.SelectedItem.ToString());
OnSaveLevel(lvlData);
this.Close();
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void txtWidth_LostFocus(object sender, RoutedEventArgs e)
{
int Columns = 0;
if (Int32.TryParse(txtWidth.Text.Trim(), out Columns))
{
lblColumns.Text = ((int)(Columns / 32)).ToString();
txtWidth.Text = (((int)(Columns / 32)) * 32).ToString();
}
}
private void cboBakcground_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
lvlData.BGType = (BackgroundType)Enum.Parse(typeof(BackgroundType), cboBakcground.SelectedItem.ToString());
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Love Programming... and games. You can find latest about me over http://www.veloxcore.com/