Преглед на файлове

treeview使用MVVM模式binding数据

tanghai преди 14 години
родител
ревизия
55d6c0d119

+ 35 - 1
CSharp/CSharp.sln

@@ -1,18 +1,52 @@
 
 Microsoft Visual Studio Solution File, Format Version 11.00
 # Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GameEditor", "GameEditor\GameEditor.csproj", "{FA1C18E4-C928-4900-A77B-6944B3443B7E}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "View", "GameEditor\View.csproj", "{FA1C18E4-C928-4900-A77B-6944B3443B7E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Data\Model.csproj", "{3978E513-87FA-44EC-893A-DBD90A5A8808}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViewModel", "ViewModel\ViewModel.csproj", "{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Debug|Mixed Platforms = Debug|Mixed Platforms
 		Debug|x86 = Debug|x86
+		Release|Any CPU = Release|Any CPU
+		Release|Mixed Platforms = Release|Mixed Platforms
 		Release|x86 = Release|x86
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{FA1C18E4-C928-4900-A77B-6944B3443B7E}.Debug|Any CPU.ActiveCfg = Debug|x86
+		{FA1C18E4-C928-4900-A77B-6944B3443B7E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+		{FA1C18E4-C928-4900-A77B-6944B3443B7E}.Debug|Mixed Platforms.Build.0 = Debug|x86
 		{FA1C18E4-C928-4900-A77B-6944B3443B7E}.Debug|x86.ActiveCfg = Debug|x86
 		{FA1C18E4-C928-4900-A77B-6944B3443B7E}.Debug|x86.Build.0 = Debug|x86
+		{FA1C18E4-C928-4900-A77B-6944B3443B7E}.Release|Any CPU.ActiveCfg = Release|x86
+		{FA1C18E4-C928-4900-A77B-6944B3443B7E}.Release|Mixed Platforms.ActiveCfg = Release|x86
+		{FA1C18E4-C928-4900-A77B-6944B3443B7E}.Release|Mixed Platforms.Build.0 = Release|x86
 		{FA1C18E4-C928-4900-A77B-6944B3443B7E}.Release|x86.ActiveCfg = Release|x86
 		{FA1C18E4-C928-4900-A77B-6944B3443B7E}.Release|x86.Build.0 = Release|x86
+		{3978E513-87FA-44EC-893A-DBD90A5A8808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{3978E513-87FA-44EC-893A-DBD90A5A8808}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3978E513-87FA-44EC-893A-DBD90A5A8808}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{3978E513-87FA-44EC-893A-DBD90A5A8808}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{3978E513-87FA-44EC-893A-DBD90A5A8808}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{3978E513-87FA-44EC-893A-DBD90A5A8808}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{3978E513-87FA-44EC-893A-DBD90A5A8808}.Release|Any CPU.Build.0 = Release|Any CPU
+		{3978E513-87FA-44EC-893A-DBD90A5A8808}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{3978E513-87FA-44EC-893A-DBD90A5A8808}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{3978E513-87FA-44EC-893A-DBD90A5A8808}.Release|x86.ActiveCfg = Release|Any CPU
+		{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}.Release|Any CPU.Build.0 = Release|Any CPU
+		{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}.Release|x86.ActiveCfg = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 1 - 1
CSharp/GameEditor/App.xaml

@@ -1,4 +1,4 @@
-<Application x:Class="GameEditor.App"
+<Application x:Class="Egametang.App"
 			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 			 StartupUri="MainWindow.xaml">

+ 1 - 1
CSharp/GameEditor/App.xaml.cs

@@ -5,7 +5,7 @@ using System.Data;
 using System.Linq;
 using System.Windows;
 
-namespace GameEditor
+namespace Egametang
 {
 	/// <summary>
 	/// App.xaml 的交互逻辑

+ 0 - 38
CSharp/GameEditor/BehaviorNode.cs

@@ -1,38 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace GameEditor
-{
-	class BehaviorNode
-	{
-		private int type;
-
-		private List<int> args;
-
-		public int Type
-		{
-			get 
-			{
-				return type; 
-			}
-			set
-			{
-				type = value;
-			}
-		}
-
-		public List<int> Args
-		{
-			get
-			{
-				return args;
-			}
-			set
-			{
-				args = value;
-			}
-		}
-	}
-}

+ 0 - 86
CSharp/GameEditor/GameEditor.csproj

@@ -1,86 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
-    <ProductVersion>8.0.30703</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{FA1C18E4-C928-4900-A77B-6944B3443B7E}</ProjectGuid>
-    <OutputType>WinExe</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>GameEditor</RootNamespace>
-    <AssemblyName>GameEditor</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
-    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
-    <FileAlignment>512</FileAlignment>
-    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
-    <PlatformTarget>x86</PlatformTarget>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
-    <PlatformTarget>x86</PlatformTarget>
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="System.Xaml">
-      <RequiredTargetFramework>4.0</RequiredTargetFramework>
-    </Reference>
-    <Reference Include="WindowsBase" />
-    <Reference Include="PresentationCore" />
-    <Reference Include="PresentationFramework" />
-  </ItemGroup>
-  <ItemGroup>
-    <ApplicationDefinition Include="App.xaml">
-      <Generator>MSBuild:Compile</Generator>
-      <SubType>Designer</SubType>
-    </ApplicationDefinition>
-    <Page Include="MainWindow.xaml">
-      <Generator>MSBuild:Compile</Generator>
-      <SubType>Designer</SubType>
-    </Page>
-    <Compile Include="App.xaml.cs">
-      <DependentUpon>App.xaml</DependentUpon>
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="BehaviorNode.cs" />
-    <Compile Include="MainWindow.xaml.cs">
-      <DependentUpon>MainWindow.xaml</DependentUpon>
-      <SubType>Code</SubType>
-    </Compile>
-  </ItemGroup>
-  <ItemGroup>
-    <AppDesigner Include="Properties\" />
-  </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Properties\" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>

+ 3 - 13
CSharp/GameEditor/MainWindow.xaml

@@ -1,6 +1,7 @@
-<Window x:Class="GameEditor.MainWindow"
+<Window x:Class="Egametang.MainWindow"
 		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+		xmlns:e="clr-namespace:Egametang"
 		Title="MainWindow" Height="800" Width="1280">
 	<Grid>
 		<Grid.RowDefinitions>
@@ -19,18 +20,7 @@
 				<ColumnDefinition Width="Auto" />
 				<ColumnDefinition Width="*" />
 			</Grid.ColumnDefinitions>
-			<TreeView Grid.Column="0"  HorizontalAlignment="Stretch" Name="behaviorTreeView" 
-					VerticalAlignment="Stretch" Padding="0" BorderThickness="0" 
-					ContextMenuOpening="behaviorTreeView_ContextMenuOpening">
-				<TreeView.ContextMenu>
-					<ContextMenu>
-						<MenuItem Name="newMenuItem"  Header="New" Click="newMenuItem_Click" />
-						<MenuItem Name="copyMenuItem" Header="Copy" Click="copyMenuItem_Click" />
-						<MenuItem Name="pasteMenuItem"  Header="Paste" Click="pasteMenuItem_Click" />
-						<MenuItem Name="delMenuItem"  Header="Delete" Click="delMenuItem_Click" />
-					</ContextMenu>
-				</TreeView.ContextMenu>
-			</TreeView>
+			<e:BehaviorTreeView />
 			<GridSplitter Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Stretch" Width="5" />
 			<Canvas />
 		</Grid>

+ 1 - 29
CSharp/GameEditor/MainWindow.xaml.cs

@@ -3,7 +3,7 @@ using System.Windows.Controls;
 using System.Windows.Input;
 using System.Collections;
 
-namespace GameEditor
+namespace Egametang
 {
 	/// <summary>
 	/// MainWindow.xaml 的交互逻辑
@@ -16,33 +16,5 @@ namespace GameEditor
 		{
 			InitializeComponent();
 		}
-
-		private void behaviorTreeView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
-		{
-			newMenuItem.IsEnabled = true;
-			copyMenuItem.IsEnabled = true;
-			pasteMenuItem.IsEnabled = true;
-			delMenuItem.IsEnabled = true;
-		}
-
-		private void newMenuItem_Click(object sender, RoutedEventArgs e)
-		{
-
-		}
-
-		private void delMenuItem_Click(object sender, RoutedEventArgs e)
-		{
-
-		}
-
-		private void copyMenuItem_Click(object sender, RoutedEventArgs e)
-		{
-
-		}
-
-		private void pasteMenuItem_Click(object sender, RoutedEventArgs e)
-		{
-
-		}
 	}
 }