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.SelectedItems0;

}

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"

));

}

}

}

相关推荐
unityのkiven4 小时前
Unity UGUI 实战:动态生成任务面板
unity·游戏引擎
郝学胜-神的一滴5 小时前
中级OpenGL教程 026:Assimp库从编译到实战全攻略
c++·unity·游戏引擎·图形渲染·unreal engine·opengl
心平气和量大福大6 小时前
C#-WPF-控件-LiveChart图表-线性2(LineSeries)-数据绑定
开发语言·c#·wpf
凯尔3151 天前
Unity简单涂料实现
unity·游戏引擎·图形渲染
刘步权1 天前
KY-RTI分布仿真技术:第十三章 基于Unity的多语言三维态势仿真——以 Island Assault(夺岛突击)想定为例
unity·游戏引擎·仿真·态势·ky-rti·hla·rti
whn19771 天前
oracle的节点2无法启动asm实例 提示PMON terminating the instance due to error 481
数据库·oracle·wpf
完美火龙篇 四月的友1 天前
WPF 笔迹延迟优化从硬件到软件的全链路分析
wpf
dalong101 天前
WPF:3D立方体
3d·wpf
Python私教2 天前
Godot图片怎么导入?PNG、压缩、Mipmap与Reimport一次讲清
游戏引擎·godot
寒水馨2 天前
Linux下载、安装godot-4.7.1-stable(附安装包Godot_v4.7.1-stable_linux.x86_64.zip)
linux·游戏引擎·godot·游戏开发·2d游戏·3d游戏·godot engine