Эх сурвалжийг харах

编辑器改用mvvmlight来做

tanghai 14 жил өмнө
parent
commit
70eba71e86

+ 11 - 35
CSharp/CSharp.sln

@@ -1,11 +1,7 @@
 
 
 Microsoft Visual Studio Solution File, Format Version 11.00
 Microsoft Visual Studio Solution File, Format Version 11.00
 # Visual Studio 2010
 # Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "View", "View\View.csproj", "{FA1C18E4-C928-4900-A77B-6944B3443B7E}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{3978E513-87FA-44EC-893A-DBD90A5A8808}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViewModel", "ViewModel\ViewModel.csproj", "{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Editor", "Editor\Editor.csproj", "{8C049112-56BF-42E3-8E91-30EABDB86B16}"
 EndProject
 EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,36 +13,16 @@ Global
 		Release|x86 = Release|x86
 		Release|x86 = Release|x86
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 	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
+		{8C049112-56BF-42E3-8E91-30EABDB86B16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{8C049112-56BF-42E3-8E91-30EABDB86B16}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{8C049112-56BF-42E3-8E91-30EABDB86B16}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{8C049112-56BF-42E3-8E91-30EABDB86B16}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{8C049112-56BF-42E3-8E91-30EABDB86B16}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{8C049112-56BF-42E3-8E91-30EABDB86B16}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{8C049112-56BF-42E3-8E91-30EABDB86B16}.Release|Any CPU.Build.0 = Release|Any CPU
+		{8C049112-56BF-42E3-8E91-30EABDB86B16}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{8C049112-56BF-42E3-8E91-30EABDB86B16}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{8C049112-56BF-42E3-8E91-30EABDB86B16}.Release|x86.ActiveCfg = Release|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE

+ 16 - 0
CSharp/Editor/App.xaml

@@ -0,0 +1,16 @@
+<Application x:Class="Editor.App"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:vm="clr-namespace:Editor.ViewModel"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+             StartupUri="MainWindow.xaml"
+             mc:Ignorable="d">
+    
+    <Application.Resources>
+        <!--Global View Model Locator-->
+        <vm:ViewModelLocator x:Key="Locator"
+                             d:IsDataSource="True" />
+    </Application.Resources>
+    
+</Application>

+ 16 - 0
CSharp/Editor/App.xaml.cs

@@ -0,0 +1,16 @@
+using System.Windows;
+using GalaSoft.MvvmLight.Threading;
+
+namespace Editor
+{
+	/// <summary>
+	/// Interaction logic for App.xaml
+	/// </summary>
+	public partial class App : Application
+	{
+		static App()
+		{
+			DispatcherHelper.Initialize();
+		}
+	}
+}

+ 16 - 0
CSharp/Editor/Design/DesignDataService.cs

@@ -0,0 +1,16 @@
+using System;
+using Editor.Model;
+
+namespace Editor.Design
+{
+	public class DesignDataService : IDataService
+	{
+		public void GetData(Action<DataItem, Exception> callback)
+		{
+			// Use this to create design time data
+
+			var item = new DataItem("Welcome to MVVM Light [design]");
+			callback(item, null);
+		}
+	}
+}

+ 56 - 35
CSharp/View/View.csproj → CSharp/Editor/Editor.csproj

@@ -2,22 +2,21 @@
 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <ProductVersion>8.0.30703</ProductVersion>
     <ProductVersion>8.0.30703</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{FA1C18E4-C928-4900-A77B-6944B3443B7E}</ProjectGuid>
+    <ProjectGuid>{8C049112-56BF-42E3-8E91-30EABDB86B16}</ProjectGuid>
     <OutputType>WinExe</OutputType>
     <OutputType>WinExe</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Egametang</RootNamespace>
-    <AssemblyName>View</AssemblyName>
+    <RootNamespace>Editor</RootNamespace>
+    <AssemblyName>Editor</AssemblyName>
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <TargetFrameworkProfile>Client</TargetFrameworkProfile>
     <TargetFrameworkProfile>Client</TargetFrameworkProfile>
     <FileAlignment>512</FileAlignment>
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <WarningLevel>4</WarningLevel>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
-    <PlatformTarget>x86</PlatformTarget>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <Optimize>false</Optimize>
@@ -25,9 +24,9 @@
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <WarningLevel>4</WarningLevel>
+    <RunCodeAnalysis>true</RunCodeAnalysis>
   </PropertyGroup>
   </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
-    <PlatformTarget>x86</PlatformTarget>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
     <OutputPath>bin\Release\</OutputPath>
@@ -36,6 +35,22 @@
     <WarningLevel>4</WarningLevel>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   </PropertyGroup>
   <ItemGroup>
   <ItemGroup>
+    <Reference Include="GalaSoft.MvvmLight.WPF4">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WPF4\GalaSoft.MvvmLight.WPF4.dll</HintPath>
+    </Reference>
+    <Reference Include="GalaSoft.MvvmLight.Extras.WPF4">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WPF4\GalaSoft.MvvmLight.Extras.WPF4.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.ServiceLocation">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WPF4\Microsoft.Practices.ServiceLocation.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Windows.Interactivity">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WPF4\System.Windows.Interactivity.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System" />
     <Reference Include="System.Data" />
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />
     <Reference Include="System.Xml" />
@@ -55,14 +70,13 @@
       <Generator>MSBuild:Compile</Generator>
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     </ApplicationDefinition>
-    <Page Include="BehaviorNodeDialog.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
-    <Page Include="BehaviorTreeView.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
+    <Compile Include="Design\DesignDataService.cs" />
+    <Compile Include="Model\BehaviorNode.cs" />
+    <Compile Include="Model\DataItem.cs" />
+    <Compile Include="Model\DataService.cs" />
+    <Compile Include="Model\IDataService.cs" />
+    <Compile Include="ViewModel\MainViewModel.cs" />
+    <Compile Include="ViewModel\ViewModelLocator.cs" />
     <Page Include="MainWindow.xaml">
     <Page Include="MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
@@ -71,33 +85,40 @@
       <DependentUpon>App.xaml</DependentUpon>
       <DependentUpon>App.xaml</DependentUpon>
       <SubType>Code</SubType>
       <SubType>Code</SubType>
     </Compile>
     </Compile>
-    <Compile Include="BehaviorNodeDialog.xaml.cs">
-      <DependentUpon>BehaviorNodeDialog.xaml</DependentUpon>
-    </Compile>
-    <Compile Include="BehaviorTreeView.xaml.cs">
-      <DependentUpon>BehaviorTreeView.xaml</DependentUpon>
-    </Compile>
     <Compile Include="MainWindow.xaml.cs">
     <Compile Include="MainWindow.xaml.cs">
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
       <SubType>Code</SubType>
     </Compile>
     </Compile>
+    <Page Include="Skins\MainSkin.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
     <AppDesigner Include="Properties\" />
     <AppDesigner Include="Properties\" />
   </ItemGroup>
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Properties\" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Model\Model.csproj">
-      <Project>{3978E513-87FA-44EC-893A-DBD90A5A8808}</Project>
-      <Name>Model</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\ViewModel\ViewModel.csproj">
-      <Project>{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}</Project>
-      <Name>ViewModel</Name>
-    </ProjectReference>
-  </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
   <!-- 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.
        Other similar extension points exist, see Microsoft.Common.targets.

+ 24 - 0
CSharp/Editor/MainWindow.xaml

@@ -0,0 +1,24 @@
+<Window x:Class="Editor.MainWindow"
+		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+		xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+		mc:Ignorable="d"
+		Height="600"
+		Width="800"
+		Title=""
+		DataContext="{Binding Main, Source={StaticResource Locator}}">
+
+	<Window.Resources>
+		<ResourceDictionary>
+			<ResourceDictionary.MergedDictionaries>
+				<ResourceDictionary Source="Skins/MainSkin.xaml" />
+			</ResourceDictionary.MergedDictionaries>
+		</ResourceDictionary>
+	</Window.Resources>
+
+	<TabControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" FlowDirection="LeftToRight" BorderThickness="0">
+		<TabItem Header="Main" Name="mainTabItem" Padding="10,2" Margin="0">
+		</TabItem>
+	</TabControl>
+</Window>

+ 20 - 0
CSharp/Editor/MainWindow.xaml.cs

@@ -0,0 +1,20 @@
+using System.Windows;
+using Editor.ViewModel;
+
+namespace Editor
+{
+	/// <summary>
+	/// Interaction logic for MainWindow.xaml
+	/// </summary>
+	public partial class MainWindow : Window
+	{
+		/// <summary>
+		/// Initializes a new instance of the MainWindow class.
+		/// </summary>
+		public MainWindow()
+		{
+			InitializeComponent();
+			Closing += (s, e) => ViewModelLocator.Cleanup();
+		}
+	}
+}

+ 0 - 0
CSharp/Model/BehaviorNode.cs → CSharp/Editor/Model/BehaviorNode.cs


+ 21 - 0
CSharp/Editor/Model/DataItem.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Editor.Model
+{
+	public class DataItem
+	{
+		public DataItem(string title)
+		{
+			Title = title;
+		}
+
+		public string Title
+		{
+			get;
+			private set;
+		}
+	}
+}

+ 15 - 0
CSharp/Editor/Model/DataService.cs

@@ -0,0 +1,15 @@
+using System;
+
+namespace Editor.Model
+{
+	public class DataService : IDataService
+	{
+		public void GetData(Action<DataItem, Exception> callback)
+		{
+			// Use this to connect to the actual data service
+
+			var item = new DataItem("Welcome to MVVM Light");
+			callback(item, null);
+		}
+	}
+}

+ 12 - 0
CSharp/Editor/Model/IDataService.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Editor.Model
+{
+	public interface IDataService
+	{
+		void GetData(Action<DataItem, Exception> callback);
+	}
+}

+ 4 - 0
CSharp/Editor/Skins/MainSkin.xaml

@@ -0,0 +1,4 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    
+</ResourceDictionary>

+ 75 - 0
CSharp/Editor/ViewModel/MainViewModel.cs

@@ -0,0 +1,75 @@
+using GalaSoft.MvvmLight;
+using Editor.Model;
+
+namespace Editor.ViewModel
+{
+	/// <summary>
+	/// This class contains properties that the main View can data bind to.
+	/// <para>
+	/// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
+	/// </para>
+	/// <para>
+	/// See http://www.galasoft.ch/mvvm/getstarted
+	/// </para>
+	/// </summary>
+	public class MainViewModel : ViewModelBase
+	{
+		private readonly IDataService dataService;
+
+		/// <summary>
+		/// The <see cref="WelcomeTitle" /> property's name.
+		/// </summary>
+		public const string WelcomeTitlePropertyName = "WelcomeTitle";
+
+		private string welcomeTitle = string.Empty;
+
+		/// <summary>
+		/// Gets the WelcomeTitle property.
+		/// Changes to that property's value raise the PropertyChanged event. 
+		/// </summary>
+		public string WelcomeTitle
+		{
+			get
+			{
+				return welcomeTitle;
+			}
+
+			set
+			{
+				if (welcomeTitle == value)
+				{
+					return;
+				}
+
+				welcomeTitle = value;
+				RaisePropertyChanged(WelcomeTitlePropertyName);
+			}
+		}
+
+		/// <summary>
+		/// Initializes a new instance of the MainViewModel class.
+		/// </summary>
+		public MainViewModel(IDataService dataService)
+		{
+			this.dataService = dataService;
+			this.dataService.GetData(
+				(item, error) =>
+				{
+					if (error != null)
+					{
+						// Report error here
+						return;
+					}
+
+					WelcomeTitle = item.Title;
+				});
+		}
+
+		////public override void Cleanup()
+		////{
+		////    // Clean up if needed
+
+		////    base.Cleanup();
+		////}
+	}
+}

+ 69 - 0
CSharp/Editor/ViewModel/ViewModelLocator.cs

@@ -0,0 +1,69 @@
+/*
+  In App.xaml:
+  <Application.Resources>
+	  <vm:ViewModelLocatorTemplate xmlns:vm="clr-namespace:Editor.ViewModel"
+								   x:Key="Locator" />
+  </Application.Resources>
+  
+  In the View:
+  DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"
+*/
+
+using GalaSoft.MvvmLight;
+using GalaSoft.MvvmLight.Ioc;
+using Microsoft.Practices.ServiceLocation;
+using Editor.Model;
+
+namespace Editor.ViewModel
+{
+	/// <summary>
+	/// This class contains static references to all the view models in the
+	/// application and provides an entry point for the bindings.
+	/// <para>
+	/// Use the <strong>mvvmlocatorproperty</strong> snippet to add ViewModels
+	/// to this locator.
+	/// </para>
+	/// <para>
+	/// See http://www.galasoft.ch/mvvm/getstarted
+	/// </para>
+	/// </summary>
+	public class ViewModelLocator
+	{
+		static ViewModelLocator()
+		{
+			ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
+
+			if (ViewModelBase.IsInDesignModeStatic)
+			{
+				SimpleIoc.Default.Register<IDataService, Design.DesignDataService>();
+			}
+			else
+			{
+				SimpleIoc.Default.Register<IDataService, DataService>();
+			}
+
+			SimpleIoc.Default.Register<MainViewModel>();
+		}
+
+		/// <summary>
+		/// Gets the Main property.
+		/// </summary>
+		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
+			"CA1822:MarkMembersAsStatic",
+			Justification = "This non-static member is needed for data binding purposes.")]
+		public MainViewModel Main
+		{
+			get
+			{
+				return ServiceLocator.Current.GetInstance<MainViewModel>();
+			}
+		}
+
+		/// <summary>
+		/// Cleans up all the resources.
+		/// </summary>
+		public static void Cleanup()
+		{
+		}
+	}
+}

+ 0 - 56
CSharp/Model/Model.csproj

@@ -1,56 +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)' == '' ">AnyCPU</Platform>
-    <ProductVersion>8.0.30703</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{3978E513-87FA-44EC-893A-DBD90A5A8808}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Data</RootNamespace>
-    <AssemblyName>Data</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <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|AnyCPU' ">
-    <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.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="BehaviorNode.cs" />
-  </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>

+ 0 - 7
CSharp/View/App.xaml

@@ -1,7 +0,0 @@
-<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">
-	<Application.Resources>
-	</Application.Resources>
-</Application>

+ 0 - 16
CSharp/View/App.xaml.cs

@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Linq;
-using System.Windows;
-
-namespace Egametang
-{
-	/// <summary>
-	/// App.xaml 的交互逻辑
-	/// </summary>
-	public partial class App : Application
-	{
-	}
-}

+ 0 - 9
CSharp/View/BehaviorNodeDialog.xaml

@@ -1,9 +0,0 @@
-<Window x:Class="Egametang.BehaviorNodeDialog"
-			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-			 mc:Ignorable="d" 
-			 d:DesignHeight="300" d:DesignWidth="300">
-	<Grid></Grid>
-</Window>

+ 0 - 29
CSharp/View/BehaviorNodeDialog.xaml.cs

@@ -1,29 +0,0 @@
-using System.Windows;
-
-namespace Egametang
-{
-	/// <summary>
-	/// BehaviorNodeDialog.xaml 的交互逻辑
-	/// </summary>
-	public partial class BehaviorNodeDialog : Window
-	{
-		private BehaviorNode node;
-
-		public BehaviorNode Node
-		{
-			get 
-			{ 
-				return node; 
-			}
-			set 
-			{ 
-				node = value; 
-			}
-		}
-
-		public BehaviorNodeDialog()
-		{
-			InitializeComponent();
-		}
-	}
-}

+ 0 - 45
CSharp/View/BehaviorTreeView.xaml

@@ -1,45 +0,0 @@
-<UserControl x:Class="Egametang.BehaviorTreeView"
-		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-		xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-		xmlns:vm="clr-namespace:Egametang;assembly=ViewModel"
-		mc:Ignorable="d" 
-		d:DesignHeight="300" d:DesignWidth="300">
-	<UserControl.DataContext>
-		<vm:BehaviorTreeViewModel />
-	</UserControl.DataContext>
-	<Grid>
-		<TreeView Grid.Column="0"  HorizontalAlignment="Stretch" Name="behaviorTreeView" 
-				VerticalAlignment="Stretch" Padding="0" BorderThickness="0" 
-				ContextMenuOpening="behaviorTreeView_ContextMenuOpening"
-				ItemsSource="{Binding Path=Children}" >
-			<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.ItemContainerStyle>
-				<Style TargetType="{x:Type TreeViewItem}">
-					<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
-					<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
-					<Setter Property="FontWeight" Value="Normal" />
-					<Style.Triggers>
-						<Trigger Property="IsSelected" Value="True">
-							<Setter Property="FontWeight" Value="Bold" />
-						</Trigger>
-					</Style.Triggers>
-				</Style>
-			</TreeView.ItemContainerStyle>-->
-			<TreeView.ItemTemplate>
-				<HierarchicalDataTemplate ItemsSource="{Binding Children}" >
-					<TextBlock Text="{Binding Name}" />
-				</HierarchicalDataTemplate>
-			</TreeView.ItemTemplate>
-		</TreeView>
-	</Grid>
-</UserControl>

+ 0 - 41
CSharp/View/BehaviorTreeView.xaml.cs

@@ -1,41 +0,0 @@
-using System.Windows;
-using System.Windows.Controls;
-
-namespace Egametang
-{
-	/// <summary>
-	/// BehaviorTreeView.xaml 的交互逻辑
-	/// </summary>
-	public partial class BehaviorTreeView : UserControl
-	{
-		public BehaviorTreeView()
-		{
-			InitializeComponent();
-		}
-
-		private void newMenuItem_Click(object sender, RoutedEventArgs e)
-		{
-			BehaviorNodeDialog dlg = new BehaviorNodeDialog();
-		}
-
-		private void copyMenuItem_Click(object sender, RoutedEventArgs e)
-		{
-
-		}
-
-		private void pasteMenuItem_Click(object sender, RoutedEventArgs e)
-		{
-
-		}
-
-		private void delMenuItem_Click(object sender, RoutedEventArgs e)
-		{
-
-		}
-
-		private void behaviorTreeView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
-		{
-
-		}
-	}
-}

+ 0 - 28
CSharp/View/MainWindow.xaml

@@ -1,28 +0,0 @@
-<Window x:Class="Egametang.MainWindow"
-		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-		xmlns:v="clr-namespace:Egametang"
-		Title="MainWindow" Height="800" Width="1280">
-	<Grid>
-		<Grid.RowDefinitions>
-			<RowDefinition Height="Auto" />
-			<RowDefinition Height="*"/>
-		</Grid.RowDefinitions>
-		<Grid Grid.Row="0">
-			<Menu>
-				<MenuItem Height="24">
-				</MenuItem>
-			</Menu>
-		</Grid>
-		<Grid Grid.Row="1">
-			<Grid.ColumnDefinitions>
-				<ColumnDefinition Width="150" />
-				<ColumnDefinition Width="Auto" />
-				<ColumnDefinition Width="*" />
-			</Grid.ColumnDefinitions>
-			<v:BehaviorTreeView />
-			<GridSplitter Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Stretch" Width="5" />
-			<Canvas />
-		</Grid>
-	</Grid>
-</Window>

+ 0 - 16
CSharp/View/MainWindow.xaml.cs

@@ -1,16 +0,0 @@
-using System.Windows;
-using System.Collections;
-
-namespace Egametang
-{
-	/// <summary>
-	/// MainWindow.xaml 的交互逻辑
-	/// </summary>
-	public partial class MainWindow : Window
-	{
-		public MainWindow()
-		{
-			InitializeComponent();
-		}
-	}
-}

+ 0 - 99
CSharp/ViewModel/BehaviorNodeViewModel.cs

@@ -1,99 +0,0 @@
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-
-namespace Egametang
-{
-	public class BehaviorNodeViewModel : INotifyPropertyChanged
-	{
-		private BehaviorNode node;
-		private BehaviorNodeViewModel parent;
-		private ObservableCollection<BehaviorNodeViewModel> children = 
-			new ObservableCollection<BehaviorNodeViewModel>();
-
-		private bool isExpanded;
-		private bool isSelected;
-
-		public BehaviorNodeViewModel(BehaviorNode node, BehaviorNodeViewModel parent)
-		{
-			this.node = node;
-			this.parent = parent;
-		}
-
-		public ObservableCollection<BehaviorNodeViewModel> Children
-		{
-			get
-			{
-				return children;
-			}
-			set
-			{
-				children = value; 
-			}
-		}
-
-		public string Name
-		{
-			get
-			{
-				return node.Name;
-			}
-		}
-
-		public bool IsSelected
-		{
-			get 
-			{ 
-				return isSelected; 
-			}
-			set
-			{
-				if (value != isSelected)
-				{
-					isSelected = value;
-					this.OnPropertyChanged("IsSelected");
-				}
-			}
-		}
-
-		public bool IsExpanded
-		{
-			get 
-			{ 
-				return isExpanded; 
-			}
-			set
-			{
-				if (value != isExpanded)
-				{
-					isExpanded = value;
-					this.OnPropertyChanged("IsExpanded");
-				}
-
-				if (isExpanded && parent != null)
-				{
-					parent.IsExpanded = true;
-				}
-
-				this.LoadChildren();
-			}
-		}
-
-		protected void LoadChildren()
-		{
-			foreach (var child in node.Children)
-			{
-				children.Add(new BehaviorNodeViewModel(child, this));
-			}
-		}
-
-		public event PropertyChangedEventHandler PropertyChanged;
-
-		protected virtual void OnPropertyChanged(string propertyName)
-		{
-			if (this.PropertyChanged != null)
-			{
-				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
-			}
-		}
-	}
-}

+ 0 - 34
CSharp/ViewModel/BehaviorTreeViewModel.cs

@@ -1,34 +0,0 @@
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-
-namespace Egametang
-{
-	public class BehaviorTreeViewModel : INotifyPropertyChanged
-	{
-		private BehaviorNode root = new BehaviorNode();
-		private ObservableCollection<BehaviorNodeViewModel> children =
-			new ObservableCollection<BehaviorNodeViewModel>();
-
-		public BehaviorTreeViewModel()
-		{
-		}
-
-		public ObservableCollection<BehaviorNodeViewModel> Children
-		{
-			get
-			{
-				return children;
-			}
-		}
-
-		public event PropertyChangedEventHandler PropertyChanged;
-
-		protected virtual void OnPropertyChanged(string propertyName)
-		{
-			if (this.PropertyChanged != null)
-			{
-				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
-			}
-		}
-	}
-}

+ 0 - 63
CSharp/ViewModel/ViewModel.csproj

@@ -1,63 +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)' == '' ">AnyCPU</Platform>
-    <ProductVersion>8.0.30703</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{E55C43C7-4CE2-4384-AE8A-39E074F2FC0B}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Egametang</RootNamespace>
-    <AssemblyName>ViewModel</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <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|AnyCPU' ">
-    <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.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="BehaviorNodeViewModel.cs" />
-    <Compile Include="BehaviorTreeViewModel.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Model\Model.csproj">
-      <Project>{3978E513-87FA-44EC-893A-DBD90A5A8808}</Project>
-      <Name>Model</Name>
-    </ProjectReference>
-  </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>

+ 9 - 6
Cpp/CMakeLists.txt

@@ -2,6 +2,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
 
 SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cmake)
 SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cmake)
 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
+IF(NOT CMAKE_BUILD_TYPE )
+	SET(CMAKE_BUILD_TYPE "Debug")
+ENDIF()
 
 
 PROJECT(Cpp)
 PROJECT(Cpp)
 
 
@@ -63,12 +66,12 @@ MESSAGE(STATUS "${ThirdPartyLibs}")
 
 
 IF(MSVC)
 IF(MSVC)
 	SET(CMAKE_CXX_FLAGS_DEBUG "/MTd")
 	SET(CMAKE_CXX_FLAGS_DEBUG "/MTd")
-	SET(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} /NODEFAULTLIB:libc.lib")
-	SET(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} /NODEFAULTLIB:libcmt.lib")
-	SET(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} /NODEFAULTLIB:msvcrt.lib")
-	SET(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} /NODEFAULTLIB:libcd.lib")
-	SET(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} /NODEFAULTLIB:libcmtd.lib")
-	ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB -DBOOST_PYTHON_STATIC_LIB )
+	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libc.lib")
+	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libcmt.lib")
+	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:msvcrt.lib")
+	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libcd.lib")
+	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libcmtd.lib")
+	ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB -DBOOST_PYTHON_STATIC_LIB -DWIN64)
 ENDIF()
 ENDIF()
 
 
 ADD_SUBDIRECTORY(Platform)
 ADD_SUBDIRECTORY(Platform)