wpf3d游戏引擎ProjectLayoutView实现

1.ProjectLayoutView.xaml.cs

using PrimalEditor.Components;

using PrimalEditor.GameProject;

using PrimalEditor.Utilities;

using System.Windows;

using System.Windows.Controls;

namespace PrimalEditor.Editors

{

/// <summary>

/// ProjectLayoutView.xaml 的交互逻辑

/// </summary>

public partial class ProjectLayoutView : UserControl

{

public ProjectLayoutView()

{

InitializeComponent();

}

private void OnAddGameEntity_Button_Click(object sender, RoutedEventArgs e)

{

var btn = sender as Button;

var vm = btn.DataContext as Scene;

vm.AddGameEntityCommand.Execute(new GameEntity(vm) { Name = "Empty Game Entity" });

}

private void OnGameEntities_ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)

{

GameEntityView.Instance.DataContext = null;

var listBox = sender as ListBox;

if (e.AddedItems.Count > 0)

{

GameEntityView.Instance.DataContext = listBox.SelectedItems[0];

}

var newSection = listBox.SelectedItems.Cast<GameEntity>().ToList();

var previousSelection = newSection.Except(e.AddedItems.Cast<GameEntity>()).Concat(e.RemovedItems.Cast<GameEntity>()).ToList();

Project.UndoRedo.Add(new UndoRedoAction(

() =>

{

listBox.UnselectAll();

previousSelection.ForEach(x => (listBox.ItemContainerGenerator.ContainerFromItem(x) as ListBoxItem).IsSelected = true);

},

() =>

{

listBox.UnselectAll();

newSection.ForEach(x => (listBox.ItemContainerGenerator.ContainerFromItem(x) as ListBoxItem).IsSelected = true);

},

"Selection changed"

));

}

}

}

相关推荐
听麟8 小时前
HarmonyOS 6.0+ 智慧出行导航APP开发实战:离线地图与多设备位置协同落地
华为·wpf·harmonyos
JIes__11 小时前
Unity(二)——核心系统
unity·游戏引擎
Howrun77712 小时前
虚幻引擎_C++_游戏开始菜单
游戏·游戏引擎·虚幻
速冻鱼Kiel12 小时前
虚幻状态树解析
ue5·游戏引擎·虚幻
天人合一peng15 小时前
Unity 中 Text-TextMeshPro的获取与赋值
unity·游戏引擎
笨蛋不要掉眼泪16 小时前
Spring Boot + RedisTemplate 数据结构的基础操作
java·数据结构·spring boot·redis·wpf
天人合一peng1 天前
Unity中button 和toggle监听事件函数有无参数
前端·unity·游戏引擎
avi91112 天前
Unity Data Excel读取方法+踩坑记;和WPS Excel的一些命令
unity·游戏引擎·excel·wps·data
LcVong2 天前
WPF MediaPlayer获取网络视频流当前帧并展示图片完整范例
网络·wpf
郁闷的网纹蟒2 天前
虚幻5---第12部分---蒙太奇
开发语言·c++·ue5·游戏引擎·虚幻