private void OnLoadFile(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.DefaultExt = ".xml"; dlg.Filter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*"; dlg.Multiselect = false; dlg.InitialDirectory = System.IO.Directory.GetCurrentDirectory(); Nullable <bool> result = dlg.ShowDialog(); if (result == true) { ScriptEditor.Script = null; CurrentEnviroment.Game.Clear(); ScriptPlayer.Clear(); Serialization.Load(CurrentEnviroment.Game, dlg.FileName); this.SpriteList.SpriteListView.ItemsSource = CurrentEnviroment.Game.Sprites; if (CurrentEnviroment.Game.Sprites.Count > 0) { this.SpriteList.SpriteListView.SelectedIndex = 0; this.ResourceEditor.Resources = CurrentEnviroment.Game.Sprites[0].Images; } /* * foreach (Resource r in CurrentEnviroment.Game.Background.Images) * { * CurrentEnviroment.BackgroudImages.Add(r.DisplayName); * }*/ ScriptPlayer.DrawScript(); } }
void SpriteListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.ScriptEditor.IsEnabled = true; //this.SpriteList.BackgroundContainer.IsChecked = false; Sprite sp = this.SpriteList.SpriteListView.SelectedValue as Sprite; if (sp == null || SpriteList.SpriteListView.SelectedIndex < 0) { return; } CurrentEnviroment.CurrentSpriteImages.Clear(); foreach (Resource r in sp.Images) { CurrentEnviroment.CurrentSpriteImages.Add(r.DisplayName); } ScriptEditor.Script = sp; this.ScriptTab.Visibility = Visibility.Visible; if (this.SpriteList.SpriteListView.SelectedValue as Sprite == null) { this.ScriptEditor.IsEnabled = false; } else { this.ResourceEditor.IsSprite = true; this.ResourceEditor.Resources = CurrentEnviroment.Game.Sprites[SpriteList.SpriteListView.SelectedIndex].Images; } ScriptPlayer.DrawScript(); }