/// <summary> /// Constructor. /// </summary> /// <param name="viewModel"></param> public CharacterEditor(ViewModel viewModel, Dispatcher uiDispatcher, List<Unit> newRoster = null) { _uiDispatcher = uiDispatcher; DataContext = this; Test = "dhsfuifbvosfbo"; WindowStyle = WindowStyle.ToolWindow; ViewModel = viewModel; // Faction unit lists Factions = ViewModel.Factions; if (newRoster == null) { Factions[1].Units.Add(new Unit(1, BodyType.Enclave, WeaponType.SMG, Stance.Stand, 10, 10, 10, 10, 10, -1, -1, "James")); Factions[2].Units.Add(new Unit(2, BodyType.TribalFemale, WeaponType.Club, Stance.Stand, 10, 10, 10, 10, 10, -1, -1, "John")); } else { foreach (Unit u in newRoster) { Factions[u.OwnerID].Units.Add(u); } } InitializeComponent(); body.ItemsSource = Enum.GetValues(typeof (BodyType)); weapon.ItemsSource = Enum.GetValues(typeof (WeaponType)); }
/// <summary> /// Constructor. /// </summary> public MainWindow() { // Window initialisation SourceInitialized += (s, a) => WindowState = WindowState.Maximized; // Isometry helper _iso = new Isometry(IsometricStyle.Staggered, BaseContentDirectory + "tiles\\mousemap.png"); // Start the ViewModel ViewModel = new ViewModel(Dispatcher, BaseContentDirectory, _iso); // Text filter function for tile picker _filterFX = (p) => p.ToString().Contains(tileFilterTextBox.Text); InitializeComponent(); // Pass an ImageControl reference to the MapCanvas (violating MVVM) ViewModel.MapCanvas.ImageControl = mapCanvasImage; cellOverlayImage.IsHitTestVisible = false; // Tabs for each tileset foreach (var s in ViewModel.TileSets.Keys) { var tab = new TabItem {Header = s}; // Listview of filtered tiles in this tileset var lv = new ListView(); // Style & template from XAML tab.Style = (Style)FindResource("TilePickerTabItemStyle"); lv.Style = (Style)FindResource("TilePickerListViewStyle"); lv.ItemTemplate = (DataTemplate)FindResource("TilePickerListData"); // Use a WrapPanel for content lv.ItemsPanel = new ItemsPanelTemplate( new FrameworkElementFactory( typeof(WrapPanel))); // Set the ListView content & filter function lv.ItemsSource = ViewModel.TileSetViews[s]; ViewModel.TileSetViews[s].Filter = _filterFX; // Action lv.SelectionChanged += TilePickerSelectionChanged; tab.Content = lv; // Add the tab to the TabControl tilePickerTabControl.Items.Add(tab); } _random = new Random(); _characterEditor = new CharacterEditor(ViewModel, Dispatcher); _characterEditor.Show(); _characterEditor.Topmost = true; }