port from perforce
This commit is contained in:
133
aiwaz/Aiwaz.Common/Aiwaz.Common.csproj
Normal file
133
aiwaz/Aiwaz.Common/Aiwaz.Common.csproj
Normal file
@@ -0,0 +1,133 @@
|
||||
<?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>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0F7D7168-08C1-45AE-AAE3-80506939D7E6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Aiwaz.Common</RootNamespace>
|
||||
<AssemblyName>Aiwaz.Common</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</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>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Ionic.Zip, Version=1.8.4.29, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Ionic.Zip.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Animations\AnimateableAttribute.cs" />
|
||||
<Compile Include="Animations\Animation.cs" />
|
||||
<Compile Include="Animations\AnimationManager.cs" />
|
||||
<Compile Include="Animations\CosineValueAnimation.cs" />
|
||||
<Compile Include="Animations\Event.cs" />
|
||||
<Compile Include="Animations\LinearValueAnimation.cs" />
|
||||
<Compile Include="FileSystem.cs" />
|
||||
<Compile Include="HiPerfTimer.cs" />
|
||||
<Compile Include="Win32Console.cs" />
|
||||
<Compile Include="Timeline.cs" />
|
||||
<Compile Include="Animations\ValueAnimation.cs" />
|
||||
<Compile Include="Pair.cs" />
|
||||
<Compile Include="ObjectFactory.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aiwaz.Contracts\Aiwaz.Contracts.csproj">
|
||||
<Project>{DE4D6FE6-D1FB-41A1-8ABA-19635B8FFD7A}</Project>
|
||||
<Name>Aiwaz.Contracts</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</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>
|
||||
13
aiwaz/Aiwaz.Common/Aiwaz.Common.csproj.user
Normal file
13
aiwaz/Aiwaz.Common/Aiwaz.Common.csproj.user
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<PublishUrlHistory />
|
||||
<InstallUrlHistory />
|
||||
<SupportUrlHistory />
|
||||
<UpdateUrlHistory />
|
||||
<BootstrapperUrlHistory />
|
||||
<ErrorReportUrlHistory />
|
||||
<FallbackCulture>en-US</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
12
aiwaz/Aiwaz.Common/Animations/AnimateableAttribute.cs
Normal file
12
aiwaz/Aiwaz.Common/Animations/AnimateableAttribute.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Aiwaz.Common.Animations
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class Animateable : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
16
aiwaz/Aiwaz.Common/Animations/Animation.cs
Normal file
16
aiwaz/Aiwaz.Common/Animations/Animation.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Aiwaz.Common.Animations
|
||||
{
|
||||
abstract public class Animation
|
||||
{
|
||||
public double StartTime { get; set; }
|
||||
public double EndTime { get; set; }
|
||||
public string AnimationName;
|
||||
|
||||
public Animation()
|
||||
{
|
||||
AnimationName = "Erroneous";
|
||||
}
|
||||
|
||||
public abstract void Animate(double time, uint userData);
|
||||
}
|
||||
}
|
||||
164
aiwaz/Aiwaz.Common/Animations/AnimationManager.cs
Normal file
164
aiwaz/Aiwaz.Common/Animations/AnimationManager.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Aiwaz.Common.Animations
|
||||
{
|
||||
struct AnimationInterval
|
||||
{
|
||||
public AnimationInterval(double argBegin, double argEnd)
|
||||
{
|
||||
begin = argBegin;
|
||||
end = argEnd;
|
||||
}
|
||||
|
||||
public double begin;
|
||||
public double end;
|
||||
}
|
||||
|
||||
class ForwardComparer : IComparer<AnimationInterval>
|
||||
{
|
||||
public int Compare(AnimationInterval a, AnimationInterval b)
|
||||
{
|
||||
return a.begin < b.begin ? -1 : (a.begin > b.begin ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
class BackwardComparer : IComparer<AnimationInterval>
|
||||
{
|
||||
public int Compare(AnimationInterval a, AnimationInterval b)
|
||||
{
|
||||
return a.end > b.end ? -1 : (a.end > b.end ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AnimationManager
|
||||
{
|
||||
private static SortedList<AnimationInterval, List<Pair<Animation, uint>>> forwardSortedAnimations = new SortedList<AnimationInterval, List<Pair<Animation, uint>>>(new ForwardComparer());
|
||||
private static SortedList<AnimationInterval, List<Pair<Animation, uint>>> backwardSortedAnimations = new SortedList<AnimationInterval, List<Pair<Animation, uint>>>(new BackwardComparer());
|
||||
private static SortedList<AnimationInterval, List<Pair<Animation, uint>>> realTimeAnimations = new SortedList<AnimationInterval, List<Pair<Animation, uint>>>(new ForwardComparer());
|
||||
private static SortedList<double, List<Pair<Event, uint>>> demoTimeEvents = new SortedList<double, List<Pair<Event, uint>>>();
|
||||
private static SortedList<double, List<Pair<Event, uint>>> realTimeEvents = new SortedList<double, List<Pair<Event, uint>>>();
|
||||
|
||||
private static double previousDemoTime;
|
||||
private static double previousRealTime;
|
||||
|
||||
public static void AddDemoTimeAnimation(double argBeginTime, double argEndTime, Animation argAnimation, uint argUserData)
|
||||
{
|
||||
forwardSortedAnimations[new AnimationInterval(argBeginTime, argEndTime)].Add(new Pair<Animation, uint>(argAnimation, argUserData));
|
||||
backwardSortedAnimations[new AnimationInterval(argBeginTime, argEndTime)].Add(new Pair<Animation, uint>(argAnimation, argUserData));
|
||||
}
|
||||
|
||||
public static void AddRealTimeAnimation(double argBeginTime, double argEndTime, Animation argAnimation, uint argUserData)
|
||||
{
|
||||
realTimeAnimations[new AnimationInterval(argBeginTime, argEndTime)].Add(new Pair<Animation, uint>(argAnimation, argUserData));
|
||||
}
|
||||
|
||||
public static void AddDemoTimeEvent(double argTime, Event argEvent, uint argUserData)
|
||||
{
|
||||
demoTimeEvents[argTime].Add(new Pair<Event, uint>(argEvent, argUserData));
|
||||
}
|
||||
|
||||
public static void AddRealTimeEvent(double argTime, Event argEvent, uint argUserData)
|
||||
{
|
||||
realTimeEvents[argTime].Add(new Pair<Event, uint>(argEvent, argUserData));
|
||||
}
|
||||
|
||||
public static void Animate()
|
||||
{
|
||||
double demoTime = Timeline.DemoTime;
|
||||
double realTime = Timeline.RealTime;
|
||||
|
||||
// Gather all active animations, they are the ones that started before now and end after now.
|
||||
// Do this for both the demo time and real time.
|
||||
List<Pair<Pair<Animation, uint>, double>> lk_ActiveAnimations = new List<Pair<Pair<Animation, uint>, double>>();
|
||||
|
||||
// Demo time animations: Demo time can go backwards, so search from both directions
|
||||
if (Timeline.SpeedAndDirection > 0)
|
||||
{
|
||||
foreach (var entry in forwardSortedAnimations)
|
||||
{
|
||||
if (entry.Key.begin <= demoTime && entry.Key.end >= demoTime)
|
||||
{
|
||||
foreach (var animation in entry.Value)
|
||||
{
|
||||
lk_ActiveAnimations.Add(new Pair<Pair<Animation, uint>, double>(animation, (demoTime - entry.Key.begin) / (entry.Key.end - entry.Key.begin)));
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.Key.begin > demoTime)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (Timeline.SpeedAndDirection < 0)
|
||||
{
|
||||
foreach (var entry in backwardSortedAnimations)
|
||||
{
|
||||
if (entry.Key.end >= demoTime && entry.Key.begin <= demoTime)
|
||||
{
|
||||
foreach (var animation in entry.Value)
|
||||
{
|
||||
lk_ActiveAnimations.Add(new Pair<Pair<Animation, uint>, double>(animation, (demoTime - entry.Key.begin) / (entry.Key.end - entry.Key.begin)));
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.Key.end < demoTime)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Real time animations: The time that we know doesn't allow us to travel to the past, so just check into the future:
|
||||
foreach (var entry in realTimeAnimations)
|
||||
{
|
||||
if (entry.Key.begin <= demoTime && entry.Key.end >= demoTime)
|
||||
{
|
||||
foreach (var animation in entry.Value)
|
||||
{
|
||||
lk_ActiveAnimations.Add(new Pair<Pair<Animation, uint>, double>(animation, (demoTime - entry.Key.begin) / (entry.Key.end - entry.Key.begin)));
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.Key.begin > demoTime)
|
||||
break;
|
||||
}
|
||||
|
||||
// Now that we know what animations correspond to this time, animate them!
|
||||
foreach (var anim in lk_ActiveAnimations)
|
||||
{
|
||||
anim.First.First.Animate(anim.Second, anim.First.Second);
|
||||
}
|
||||
|
||||
// Fire all events that happened since last time:
|
||||
foreach (var entry in demoTimeEvents)
|
||||
{
|
||||
double time = entry.Key;
|
||||
|
||||
foreach (var evt in entry.Value)
|
||||
{
|
||||
if ((Timeline.SpeedAndDirection > 0) && (time >= previousDemoTime && time <= demoTime))
|
||||
{
|
||||
evt.First.Do(evt.Second);
|
||||
}
|
||||
else if ((Timeline.SpeedAndDirection < 0) && (time <= previousDemoTime && time >= demoTime))
|
||||
{
|
||||
evt.First.Undo(evt.Second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var entry in realTimeEvents)
|
||||
{
|
||||
double time = entry.Key;
|
||||
|
||||
foreach (var evt in entry.Value)
|
||||
{
|
||||
if (time >= previousDemoTime && time <= demoTime)
|
||||
{
|
||||
evt.First.Do(evt.Second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
previousDemoTime = demoTime;
|
||||
previousRealTime = realTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
aiwaz/Aiwaz.Common/Animations/CosineValueAnimation.cs
Normal file
22
aiwaz/Aiwaz.Common/Animations/CosineValueAnimation.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Aiwaz.Common.Animations
|
||||
{
|
||||
public class CosineValueAnimation : ValueAnimation
|
||||
{
|
||||
public CosineValueAnimation()
|
||||
: base()
|
||||
{
|
||||
AnimationName = "Cosine";
|
||||
}
|
||||
|
||||
protected override float Calculate(double NormalizedTime)
|
||||
{
|
||||
float Interpolant = (float)((1.0 - Math.Cos(NormalizedTime * Math.PI)) / 2.0);
|
||||
return (StartValue * (1.0f - Interpolant) + EndValue * Interpolant);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
aiwaz/Aiwaz.Common/Animations/Event.cs
Normal file
13
aiwaz/Aiwaz.Common/Animations/Event.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Aiwaz.Common.Animations
|
||||
{
|
||||
abstract public class Event
|
||||
{
|
||||
abstract public Action<uint> Do { get; }
|
||||
abstract public Action<uint> Undo { get; }
|
||||
}
|
||||
}
|
||||
21
aiwaz/Aiwaz.Common/Animations/LinearValueAnimation.cs
Normal file
21
aiwaz/Aiwaz.Common/Animations/LinearValueAnimation.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Aiwaz.Common.Animations
|
||||
{
|
||||
public class LinearValueAnimation : ValueAnimation
|
||||
{
|
||||
public LinearValueAnimation()
|
||||
: base()
|
||||
{
|
||||
AnimationName = "Linear";
|
||||
}
|
||||
|
||||
protected override float Calculate(double NormalizedTime)
|
||||
{
|
||||
return (float)(StartValue * (1.0 - NormalizedTime) + EndValue * NormalizedTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
40
aiwaz/Aiwaz.Common/Animations/ValueAnimation.cs
Normal file
40
aiwaz/Aiwaz.Common/Animations/ValueAnimation.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Aiwaz.Common.Animations
|
||||
{
|
||||
abstract public class ValueAnimation : Animation
|
||||
{
|
||||
public float StartValue { get; set; }
|
||||
public float EndValue { get; set; }
|
||||
|
||||
public Func<float> ValueGetter;
|
||||
public Action<float> ValueSetter;
|
||||
public Func<string> ValueNamer;
|
||||
|
||||
public float Value
|
||||
{
|
||||
get { return ValueGetter(); }
|
||||
set { ValueSetter(value); }
|
||||
}
|
||||
|
||||
public ValueAnimation()
|
||||
: base()
|
||||
{
|
||||
AnimationName = "Erroneous (Value)";
|
||||
}
|
||||
|
||||
public override void Animate(double time, uint userData)
|
||||
{
|
||||
if (time < StartTime || time > EndTime)
|
||||
return;
|
||||
|
||||
double Time = (time - StartTime) / (EndTime - StartTime);
|
||||
Value = Calculate(Time);
|
||||
}
|
||||
|
||||
protected abstract float Calculate(double NormalizedTime);
|
||||
}
|
||||
}
|
||||
120
aiwaz/Aiwaz.Common/FileSystem.cs
Normal file
120
aiwaz/Aiwaz.Common/FileSystem.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Ionic.Zip;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
namespace Aiwaz.Common
|
||||
{
|
||||
public class FileSystem : IDisposable
|
||||
{
|
||||
private Dictionary<string, Action<Stream>> attachedFiles = new Dictionary<string, Action<Stream>>();
|
||||
private ZipFile zipFile;
|
||||
private FileSystemWatcher watcher;
|
||||
private string directory;
|
||||
public FileSystem()
|
||||
{
|
||||
directory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
|
||||
this.watcher = new FileSystemWatcher(directory);
|
||||
this.watcher.NotifyFilter = NotifyFilters.LastWrite;
|
||||
this.watcher.IncludeSubdirectories = true;
|
||||
this.watcher.Changed += watcher_Changed;
|
||||
this.watcher.EnableRaisingEvents = true;
|
||||
if (File.Exists(Path.Combine(directory, "data.pak")))
|
||||
{
|
||||
zipFile = ZipFile.Read(Path.Combine(directory, "data.pak"));
|
||||
}
|
||||
}
|
||||
|
||||
void watcher_Changed(object sender, FileSystemEventArgs e)
|
||||
{
|
||||
foreach (var entry in attachedFiles)
|
||||
{
|
||||
if (e.FullPath == entry.Key)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var stream = new FileStream(e.FullPath, FileMode.Open);
|
||||
entry.Value(stream);
|
||||
break;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~FileSystem()
|
||||
{
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
public void Attach(string argFileName, Action<Stream> onLoaded)
|
||||
{
|
||||
if (File.Exists(Path.Combine(directory, argFileName)))
|
||||
{
|
||||
Stream fileStream = new FileStream(Path.Combine(directory, argFileName), FileMode.Open);
|
||||
if (fileStream != null && onLoaded != null)
|
||||
{
|
||||
var fullPath = Path.Combine(directory, argFileName).Replace('/', '\\');
|
||||
attachedFiles[fullPath] = onLoaded;
|
||||
onLoaded(fileStream);
|
||||
}
|
||||
}
|
||||
else if (zipFile != null)
|
||||
{
|
||||
var file = zipFile[argFileName];
|
||||
if (file != null)
|
||||
{
|
||||
Stream outputStream = new MemoryStream();
|
||||
file.Extract(outputStream);
|
||||
if (onLoaded != null)
|
||||
onLoaded(outputStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new FileNotFoundException(argFileName);
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (zipFile != null)
|
||||
{
|
||||
zipFile.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static class BinaryReaderExtensions
|
||||
{
|
||||
public static string ReadNullTerminatedString(this BinaryReader reader)
|
||||
{
|
||||
string result = string.Empty;
|
||||
char readChar = '\0';
|
||||
do
|
||||
{
|
||||
readChar = reader.ReadChar();
|
||||
if (readChar != '\0')
|
||||
result += readChar;
|
||||
}
|
||||
while (readChar != '\0');
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
44
aiwaz/Aiwaz.Common/HiPerfTimer.cs
Normal file
44
aiwaz/Aiwaz.Common/HiPerfTimer.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aiwaz.Common
|
||||
{
|
||||
public static class HiPerfTimer
|
||||
{
|
||||
[DllImport("Kernel32.dll")]
|
||||
private static extern bool QueryPerformanceCounter(out long performanceCount);
|
||||
[DllImport("Kernel32.dll")]
|
||||
private static extern bool QueryPerformanceFrequency(out long frequency);
|
||||
private static double? startTime;
|
||||
private static double lastTime;
|
||||
|
||||
public static double LastDeltaTime
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public static double ElapsedTime
|
||||
{
|
||||
get
|
||||
{
|
||||
long frequency, performanceCount;
|
||||
QueryPerformanceFrequency(out frequency);
|
||||
QueryPerformanceCounter(out performanceCount);
|
||||
double thisTime = performanceCount / (double)frequency;
|
||||
if (!startTime.HasValue)
|
||||
{
|
||||
startTime = thisTime;
|
||||
lastTime = thisTime;
|
||||
return 0.0;
|
||||
}
|
||||
LastDeltaTime = thisTime - lastTime;
|
||||
lastTime = thisTime;
|
||||
return thisTime - startTime.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
aiwaz/Aiwaz.Common/ObjectFactory.cs
Normal file
70
aiwaz/Aiwaz.Common/ObjectFactory.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Aiwaz.Common
|
||||
{
|
||||
public class ObjectFactory
|
||||
{
|
||||
private Dictionary<Type, Type> m_Patterns = new Dictionary<Type, Type>();
|
||||
private Dictionary<Type, Dictionary<string, object>> m_StoredObjects = new Dictionary<Type, Dictionary<string, object>>();
|
||||
|
||||
public void RegisterPattern<O>()
|
||||
{
|
||||
var patternObject = typeof(O);
|
||||
var patternInterface = patternObject.GetInterface("I" + patternObject.Name);
|
||||
m_Patterns.Add(patternInterface, patternObject);
|
||||
}
|
||||
|
||||
public void RegisterPattern<I, O>()
|
||||
{
|
||||
m_Patterns.Add(typeof(I), typeof(O));
|
||||
}
|
||||
|
||||
public T CreateInstance<T>(params object[] args)
|
||||
{
|
||||
var creationType = m_Patterns.First(argPattern => argPattern.Key == typeof(T)).Value;
|
||||
Type[] creationArguments = null;
|
||||
if (args != null && args.Length > 0)
|
||||
creationArguments = args.Select(arg => arg.GetType()).ToArray();
|
||||
|
||||
var constructor = creationType.GetConstructor(creationArguments == null ?
|
||||
System.Type.EmptyTypes : creationArguments);
|
||||
|
||||
var construct = (T)constructor.Invoke(args);
|
||||
return construct;
|
||||
}
|
||||
|
||||
public T CreateNamedInstance<T>(string argName, params object[] args)
|
||||
{
|
||||
var construct = CreateInstance<T>(args);
|
||||
|
||||
var storage = m_StoredObjects.FirstOrDefault(type => type.Key == typeof(T)).Value;
|
||||
if (storage == null)
|
||||
{
|
||||
m_StoredObjects.Add(typeof(T), new Dictionary<string, object>());
|
||||
storage = m_StoredObjects.FirstOrDefault(type => type.Key == typeof(T)).Value;
|
||||
}
|
||||
storage.Add(argName, construct);
|
||||
|
||||
return construct;
|
||||
}
|
||||
|
||||
public T FindNamedInstance<T>(string argName)
|
||||
{
|
||||
var storage = m_StoredObjects.FirstOrDefault(type => type.Key == typeof(T)).Value;
|
||||
if (storage == null || !storage.ContainsKey(argName))
|
||||
return default(T);
|
||||
return (T)storage[argName];
|
||||
}
|
||||
|
||||
public void RemoveNamedInstance<T>(string argName)
|
||||
{
|
||||
var storage = m_StoredObjects.FirstOrDefault(type => type.Key == typeof(T)).Value;
|
||||
if (storage == null)
|
||||
return;
|
||||
storage.Remove(argName);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
aiwaz/Aiwaz.Common/Pair.cs
Normal file
23
aiwaz/Aiwaz.Common/Pair.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Aiwaz.Common
|
||||
{
|
||||
public class Pair<T, U>
|
||||
{
|
||||
public Pair()
|
||||
{
|
||||
}
|
||||
|
||||
public Pair(T first, U second)
|
||||
{
|
||||
this.First = first;
|
||||
this.Second = second;
|
||||
}
|
||||
|
||||
public T First { get; set; }
|
||||
public U Second { get; set; }
|
||||
}
|
||||
}
|
||||
36
aiwaz/Aiwaz.Common/Properties/AssemblyInfo.cs
Normal file
36
aiwaz/Aiwaz.Common/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AiwazCommon")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("AiwazCommon")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("e686f0df-9858-4478-a7fb-dea091646ff0")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
22
aiwaz/Aiwaz.Common/Timeline.cs
Normal file
22
aiwaz/Aiwaz.Common/Timeline.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Aiwaz.Common.Animations;
|
||||
|
||||
namespace Aiwaz.Common
|
||||
{
|
||||
public static class Timeline
|
||||
{
|
||||
private static double realTime;
|
||||
public static double RealTime { get { return realTime; } }
|
||||
private static double demoTime;
|
||||
public static double DemoTime { get { return demoTime; } }
|
||||
public static double SpeedAndDirection { get; set; }
|
||||
private static double lastRealDeltaTime;
|
||||
|
||||
public static void Advance(double argSeconds)
|
||||
{
|
||||
lastRealDeltaTime = argSeconds;
|
||||
realTime += argSeconds;
|
||||
demoTime += argSeconds * SpeedAndDirection;
|
||||
AnimationManager.Animate();
|
||||
}
|
||||
}
|
||||
}
|
||||
42
aiwaz/Aiwaz.Common/Win32Console.cs
Normal file
42
aiwaz/Aiwaz.Common/Win32Console.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
namespace Aiwaz.Common
|
||||
{
|
||||
public class Win32Console : IDisposable
|
||||
{
|
||||
[DllImport("kernel32.dll", EntryPoint = "FreeConsole", SetLastError = true, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int FreeConsole();
|
||||
[DllImport("kernel32.dll", EntryPoint = "GetStdHandle", SetLastError = true, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||
private static extern IntPtr GetStdHandle(int nStdHandle);
|
||||
[DllImport("kernel32.dll", EntryPoint = "AllocConsole", SetLastError = true, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||
private static extern int AllocConsole();
|
||||
|
||||
private const int STD_OUTPUT_HANDLE = -11;
|
||||
private const int MY_CODE_PAGE = 437;
|
||||
|
||||
public Win32Console()
|
||||
{
|
||||
AllocConsole();
|
||||
IntPtr stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SafeFileHandle safeFileHandle = new SafeFileHandle(stdHandle, true);
|
||||
FileStream fileStream = new FileStream(safeFileHandle, FileAccess.Write);
|
||||
Encoding encoding = System.Text.Encoding.GetEncoding(MY_CODE_PAGE);
|
||||
StreamWriter standardOutput = new StreamWriter(fileStream, encoding);
|
||||
standardOutput.AutoFlush = true;
|
||||
Console.SetOut(standardOutput);
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
FreeConsole();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
BIN
aiwaz/Aiwaz.Common/bin/Debug/Aiwaz.Common.dll
Normal file
BIN
aiwaz/Aiwaz.Common/bin/Debug/Aiwaz.Common.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/bin/Debug/Aiwaz.Common.pdb
Normal file
BIN
aiwaz/Aiwaz.Common/bin/Debug/Aiwaz.Common.pdb
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/bin/Debug/Aiwaz.Contracts.dll
Normal file
BIN
aiwaz/Aiwaz.Common/bin/Debug/Aiwaz.Contracts.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/bin/Debug/Aiwaz.Contracts.pdb
Normal file
BIN
aiwaz/Aiwaz.Common/bin/Debug/Aiwaz.Contracts.pdb
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/bin/Debug/Ionic.Zip.dll
Normal file
BIN
aiwaz/Aiwaz.Common/bin/Debug/Ionic.Zip.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/bin/Debug/SlimDX.dll
Normal file
BIN
aiwaz/Aiwaz.Common/bin/Debug/SlimDX.dll
Normal file
Binary file not shown.
43576
aiwaz/Aiwaz.Common/bin/Debug/SlimDX.xml
Normal file
43576
aiwaz/Aiwaz.Common/bin/Debug/SlimDX.xml
Normal file
File diff suppressed because it is too large
Load Diff
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/Aiwaz.Common.dll
Normal file
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/Aiwaz.Common.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/Aiwaz.Common.pdb
Normal file
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/Aiwaz.Common.pdb
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/Aiwaz.Contracts.dll
Normal file
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/Aiwaz.Contracts.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/Aiwaz.Contracts.pdb
Normal file
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/Aiwaz.Contracts.pdb
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/Ionic.Zip.dll
Normal file
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/Ionic.Zip.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/SlimDX.dll
Normal file
BIN
aiwaz/Aiwaz.Common/bin/x86/Debug/SlimDX.dll
Normal file
Binary file not shown.
43576
aiwaz/Aiwaz.Common/bin/x86/Debug/SlimDX.xml
Normal file
43576
aiwaz/Aiwaz.Common/bin/x86/Debug/SlimDX.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Common\obj\Debug\ResolveAssemblyReference.cache
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\Aiwaz.Common.dll
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\Aiwaz.Common.pdb
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\Aiwaz.Contracts.dll
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\Aiwaz.Contracts.pdb
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Common\obj\Debug\Aiwaz.Common.dll
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Common\obj\Debug\Aiwaz.Common.pdb
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\Ionic.Zip.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\Aiwaz.Common.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\Aiwaz.Common.pdb
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\Aiwaz.Contracts.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\Ionic.Zip.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\SlimDX.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\Aiwaz.Contracts.pdb
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\Debug\SlimDX.xml
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\obj\Debug\Aiwaz.Common.csprojResolveAssemblyReference.cache
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\obj\Debug\Aiwaz.Common.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\obj\Debug\Aiwaz.Common.pdb
|
||||
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/obj/Debug/Aiwaz.Common.dll
Normal file
BIN
aiwaz/Aiwaz.Common/obj/Debug/Aiwaz.Common.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/obj/Debug/Aiwaz.Common.pdb
Normal file
BIN
aiwaz/Aiwaz.Common/obj/Debug/Aiwaz.Common.pdb
Normal file
Binary file not shown.
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/obj/Debug/Refactor/Aiwaz.Common.dll
Normal file
BIN
aiwaz/Aiwaz.Common/obj/Debug/Refactor/Aiwaz.Common.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/obj/Debug/ResolveAssemblyReference.cache
Normal file
BIN
aiwaz/Aiwaz.Common/obj/Debug/ResolveAssemblyReference.cache
Normal file
Binary file not shown.
Binary file not shown.
0
aiwaz/Aiwaz.Common/obj/Release/build.force
Normal file
0
aiwaz/Aiwaz.Common/obj/Release/build.force
Normal file
@@ -0,0 +1,10 @@
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\x86\Debug\Aiwaz.Common.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\x86\Debug\Aiwaz.Common.pdb
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\x86\Debug\Aiwaz.Contracts.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\x86\Debug\Ionic.Zip.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\x86\Debug\SlimDX.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\x86\Debug\Aiwaz.Contracts.pdb
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\bin\x86\Debug\SlimDX.xml
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\obj\x86\Debug\Aiwaz.Common.csprojResolveAssemblyReference.cache
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\obj\x86\Debug\Aiwaz.Common.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Common\obj\x86\Debug\Aiwaz.Common.pdb
|
||||
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/obj/x86/Debug/Aiwaz.Common.dll
Normal file
BIN
aiwaz/Aiwaz.Common/obj/x86/Debug/Aiwaz.Common.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Common/obj/x86/Debug/Aiwaz.Common.pdb
Normal file
BIN
aiwaz/Aiwaz.Common/obj/x86/Debug/Aiwaz.Common.pdb
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
147
aiwaz/Aiwaz.Contracts/Aiwaz.Contracts.csproj
Normal file
147
aiwaz/Aiwaz.Contracts/Aiwaz.Contracts.csproj
Normal file
@@ -0,0 +1,147 @@
|
||||
<?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>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{DE4D6FE6-D1FB-41A1-8ABA-19635B8FFD7A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Aiwaz.Contracts</RootNamespace>
|
||||
<AssemblyName>Aiwaz.Contracts</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</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>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="SlimDX, Version=2.0.8.42, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Extern\SlimDX\x86\SlimDX.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase">
|
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Resource.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EngineStates.cs" />
|
||||
<Compile Include="IBone.cs" />
|
||||
<Compile Include="ICamera.cs" />
|
||||
<Compile Include="IGeometryBuffer.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="IPickHull.cs" />
|
||||
<Compile Include="IRenderTargetBase.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="IResource.cs" />
|
||||
<Compile Include="IShader.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="IShaderParameterCollection.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ISwapChain.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ITexture.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ITransformationAnimation.cs" />
|
||||
<Compile Include="IUpdatable.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Reference.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</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>
|
||||
14
aiwaz/Aiwaz.Contracts/Aiwaz.Contracts.csproj.user
Normal file
14
aiwaz/Aiwaz.Contracts/Aiwaz.Contracts.csproj.user
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
<PublishUrlHistory />
|
||||
<InstallUrlHistory />
|
||||
<SupportUrlHistory />
|
||||
<UpdateUrlHistory />
|
||||
<BootstrapperUrlHistory />
|
||||
<ErrorReportUrlHistory />
|
||||
<FallbackCulture>en-US</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
10
aiwaz/Aiwaz.Contracts/EngineStates.cs
Normal file
10
aiwaz/Aiwaz.Contracts/EngineStates.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public class EngineStates
|
||||
{
|
||||
public IShader LastShader;
|
||||
public IRenderTargetBase LastRenderTarget;
|
||||
public IGeometryBuffer LastVertexBufferProvider;
|
||||
public IGeometryBuffer LastIndexBufferProvider;
|
||||
};
|
||||
}
|
||||
1
aiwaz/Aiwaz.Contracts/IAnimationManager.cs
Normal file
1
aiwaz/Aiwaz.Contracts/IAnimationManager.cs
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
18
aiwaz/Aiwaz.Contracts/IBone.cs
Normal file
18
aiwaz/Aiwaz.Contracts/IBone.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using SlimDX;
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface IBone
|
||||
{
|
||||
Matrix GetTransformationAtTime(float time, Matrix rootTransformationMatrix);
|
||||
|
||||
Dictionary<int, IBone> BoneIndexList { get; }
|
||||
List<IBone> ChildBones { get; }
|
||||
int Index { get; }
|
||||
Matrix[] MatrixArray { get; }
|
||||
string Name { get; }
|
||||
Matrix PoseTransformation { get; }
|
||||
IBone Parent { get; set; }
|
||||
ITransformationAnimation TransformationAnimation { get; set; }
|
||||
}
|
||||
}
|
||||
31
aiwaz/Aiwaz.Contracts/ICamera.cs
Normal file
31
aiwaz/Aiwaz.Contracts/ICamera.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using SlimDX;
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public class ViewFrustum
|
||||
{
|
||||
public Plane[] Plane = new Plane[6];
|
||||
};
|
||||
|
||||
public interface ICamera
|
||||
{
|
||||
Matrix ProjectionMatrix { get; }
|
||||
Matrix ViewMatrix { get; }
|
||||
|
||||
float FarClip { get; set; }
|
||||
float NearClip { get; set; }
|
||||
|
||||
ViewFrustum ViewFrustum { get; }
|
||||
};
|
||||
|
||||
public interface IPerspectiveCamera
|
||||
{
|
||||
float Fov { get; set; }
|
||||
float AspectRatio { get; set; }
|
||||
};
|
||||
|
||||
public interface IOrthographicCamera
|
||||
{
|
||||
float Width { get; set; }
|
||||
float Height { get; set; }
|
||||
};
|
||||
}
|
||||
97
aiwaz/Aiwaz.Contracts/ICommandUser.cs
Normal file
97
aiwaz/Aiwaz.Contracts/ICommandUser.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public enum CommandFlags : byte
|
||||
{
|
||||
None = 0x00,
|
||||
SubChainStart = 0x01, // Command will start a new command chain (UseShader for example)
|
||||
SubChainEnd = 0x02, // Command will end a command chain (Render)
|
||||
Unique = 0x04, // Similar commands should not be reduced to one Command
|
||||
StartChain = 0x08, // Command will generate a new command chain
|
||||
EndChain = 0x10, // Command will end the command chain (RenderGeometry for example)
|
||||
FlushChain = 0x20, // Command will end the command chain (RenderGeometry for example)
|
||||
}
|
||||
|
||||
public class Command
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct CommandInfoUnion
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public uint RawValue;
|
||||
[FieldOffset(0)]
|
||||
public byte Priority;
|
||||
[FieldOffset(1)]
|
||||
public byte SubPriority;
|
||||
[FieldOffset(2)]
|
||||
public CommandFlags Flags;
|
||||
[FieldOffset(3)]
|
||||
public byte Type;
|
||||
}
|
||||
|
||||
public Command(ICommandUser argOwner, CommandFlags argFlags, byte argType)
|
||||
: this(argOwner, argFlags, argType, 0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
public Command(ICommandUser argOwner, CommandFlags argFlags, byte argType, byte argPriority)
|
||||
: this(argOwner, argFlags, argType, argPriority, 0)
|
||||
{
|
||||
}
|
||||
|
||||
public Command(ICommandUser argOwner, CommandFlags argFlags, byte argType, byte argPriority, byte argSubPriority)
|
||||
{
|
||||
CommandInfo.RawValue = 0;
|
||||
Owner = argOwner;
|
||||
Flags = argFlags;
|
||||
Priority = argPriority;
|
||||
SubPriority = argSubPriority;
|
||||
Type = argType;
|
||||
}
|
||||
|
||||
|
||||
public CommandInfoUnion CommandInfo;
|
||||
public byte Priority { get { return CommandInfo.Priority; } set { CommandInfo.Priority = value; } }
|
||||
public byte SubPriority { get { return CommandInfo.SubPriority; } set { CommandInfo.SubPriority = value; } }
|
||||
public CommandFlags Flags { get { return CommandInfo.Flags; } set { CommandInfo.Flags = value; } }
|
||||
public byte Type { get { return CommandInfo.Type; } set { CommandInfo.Type = value; } }
|
||||
|
||||
public ICommandUser Owner;
|
||||
};
|
||||
|
||||
public enum CommandExecuteResult
|
||||
{
|
||||
None, // Execution done, proceed to the next Command
|
||||
RetrySubChain, // Execution should start from a previous "SubChainStart"-flagged Command
|
||||
RetrySubChainSkipHead // Equal to the above result but skips the as "SubChainStart"-flagged Command
|
||||
};
|
||||
|
||||
public interface ICommandUser
|
||||
{
|
||||
List<Command> Commands { get; }
|
||||
|
||||
CommandExecuteResult ExecuteCommand(byte argCommandType, ICommandBuffer argCurrentBuffer, int argCurrentPositon);
|
||||
|
||||
void AssignToRenderCommandNode(IRenderCommandNode argNode);
|
||||
void UnassignFromRenderCommandNode(IRenderCommandNode argNode);
|
||||
|
||||
// Commands should be applied before all following commands
|
||||
bool IsPreconditionForNextCommands { get; set; }
|
||||
};
|
||||
|
||||
|
||||
public interface ICommandBuffer
|
||||
{
|
||||
void Clear();
|
||||
void Perform(bool argUseOptimizedList);
|
||||
void Optimize();
|
||||
void AddChildCommandBuffer(ICommandBuffer argCommandBuffer);
|
||||
void RemoveChildCommandBuffer(ICommandBuffer argCommandBuffer);
|
||||
|
||||
List<Command> BufferedCommands { get; }
|
||||
List<ICommandBuffer> ChildCommandBuffers { get; }
|
||||
ICommandBuffer ParentBuffer { get; set; }
|
||||
};
|
||||
|
||||
}
|
||||
54
aiwaz/Aiwaz.Contracts/IDeviceEnumerator.cs
Normal file
54
aiwaz/Aiwaz.Contracts/IDeviceEnumerator.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections.Generic;
|
||||
using SlimDX.DXGI;
|
||||
using System.Drawing;
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface IDeviceEnumerator
|
||||
{
|
||||
bool HasEnumerated { get; }
|
||||
List<IDisplayAdapter> DeviceAdapters { get; }
|
||||
|
||||
bool TryEnumerate(uint? argDesiredWidth, uint? argDesiredHeight, uint? argDesiredRefreshRate, DataFormat? argDesiredFormat);
|
||||
IDisplayAdapter FindBestAdapter(bool argAllowToEnumerate, uint? argDesiredWidth, uint? argDesiredHeight, uint? argDesiredRefreshRate, DataFormat? argDesiredFormat);
|
||||
IOutputDevice FindBestOutput(bool argAllowToEnumerate, uint? argDesiredWidth, uint? argDesiredHeight, uint? argDesiredRefreshRate, DataFormat? argDesiredFormat);
|
||||
IDisplayMode FindBestDisplayMode(bool argAllowToEnumerate, uint? argDesiredWidth, uint? argDesiredHeight, uint? argDesiredRefreshRate, DataFormat? argDesiredFormat);
|
||||
|
||||
void Verbose();
|
||||
};
|
||||
|
||||
public interface IDisplayAdapter
|
||||
{
|
||||
long DedicatedSystemMemory { get; }
|
||||
long DedicatedVideoMemory { get; }
|
||||
long SharedSystemMemory { get; }
|
||||
List<IOutputDevice> DeviceOutputs { get; }
|
||||
bool HasEnumerated { get; }
|
||||
Adapter Adapter { get; }
|
||||
string Name { get; }
|
||||
|
||||
bool TryEnumerate(uint? argDesiredWidth, uint? argDesiredHeight, uint? argDesiredRefreshRate, DataFormat? argDesiredFormat);
|
||||
IOutputDevice FindBestOutput(bool argAllowToEnumerate, uint? argDesiredWidth, uint? argDesiredHeight, uint? argDesiredRefreshRate, DataFormat? argDesiredFormat);
|
||||
IDisplayMode FindBestDisplayMode(bool argAllowToEnumerate, uint? argDesiredWidth, uint? argDesiredHeight, uint? argDesiredRefreshRate, DataFormat? argDesiredFormat);
|
||||
};
|
||||
|
||||
public interface IOutputDevice
|
||||
{
|
||||
bool IsAttachedToDesktop { get; }
|
||||
object MonitorHandle { get; }
|
||||
Rectangle DesktopCoordinates { get; }
|
||||
List<IDisplayMode> DisplayModes { get; }
|
||||
bool HasEnumerated { get; }
|
||||
string Name { get; }
|
||||
|
||||
bool TryEnumerate(uint? argDesiredWidth, uint? argDesiredHeight, uint? argDesiredRefreshRate, DataFormat? argDesiredFormat);
|
||||
IDisplayMode FindBestDisplayMode(bool argAllowToEnumerate, uint? argDesiredWidth, uint? argDesiredHeight, uint? argDesiredRefreshRate, DataFormat? argDesiredFormat);
|
||||
};
|
||||
|
||||
public interface IDisplayMode
|
||||
{
|
||||
uint Width { get; }
|
||||
uint Height { get; }
|
||||
uint RefreshRate { get; }
|
||||
DataFormat Format { get; }
|
||||
};
|
||||
}
|
||||
27
aiwaz/Aiwaz.Contracts/IFileSystem.cs
Normal file
27
aiwaz/Aiwaz.Contracts/IFileSystem.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface IFile
|
||||
{
|
||||
byte[] Buffer { get; }
|
||||
uint BufferLength { get; }
|
||||
long BufferPosition { get; set; }
|
||||
string FileName { get; }
|
||||
bool Eof { get; }
|
||||
|
||||
string ReadString();
|
||||
float ReadFloat();
|
||||
int ReadInt();
|
||||
byte[] ReadDataArray(uint argBytes);
|
||||
|
||||
void Rewind();
|
||||
void SaveAs(string argFileName);
|
||||
};
|
||||
|
||||
public interface IFileSystem
|
||||
{
|
||||
void InitializeFromDirectory(string argDirectory);
|
||||
void InitializeFromZipFile(string argZipFile);
|
||||
|
||||
IFile Open(string argFileName);
|
||||
};
|
||||
}
|
||||
158
aiwaz/Aiwaz.Contracts/IGeometryBuffer.cs
Normal file
158
aiwaz/Aiwaz.Contracts/IGeometryBuffer.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public struct VertexElement
|
||||
{
|
||||
public enum Format
|
||||
{
|
||||
Position,
|
||||
PositionT,
|
||||
Normal,
|
||||
Binormal,
|
||||
Tangent,
|
||||
Color,
|
||||
BlendWeight,
|
||||
BlendIndices,
|
||||
Texture2D,
|
||||
Texture3D,
|
||||
Texture4D,
|
||||
PointSize
|
||||
};
|
||||
|
||||
public VertexElement(Format argFormat)
|
||||
: this(argFormat, 0)
|
||||
{
|
||||
|
||||
}
|
||||
public VertexElement(Format argFormat, int argNameIndex)
|
||||
{
|
||||
NameIndex = argNameIndex;
|
||||
WellKnownFormat = argFormat;
|
||||
switch (argFormat)
|
||||
{
|
||||
case Format.PositionT:
|
||||
{
|
||||
SemanticName = "POSITIONT";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32G32B32A32_Float;
|
||||
Size = 4 * sizeof(float);
|
||||
break;
|
||||
}
|
||||
case Format.Normal:
|
||||
{
|
||||
SemanticName = "NORMAL";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32G32B32_Float;
|
||||
Size = 3 * sizeof(float);
|
||||
break;
|
||||
}
|
||||
case Format.Binormal:
|
||||
{
|
||||
SemanticName = "BINORMAL";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32G32B32_Float;
|
||||
Size = 3 * sizeof(float);
|
||||
break;
|
||||
}
|
||||
case Format.Tangent:
|
||||
{
|
||||
SemanticName = "TANGENT";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32G32B32_Float;
|
||||
Size = 3 * sizeof(float);
|
||||
break;
|
||||
}
|
||||
case Format.Color:
|
||||
{
|
||||
SemanticName = "COLOR";
|
||||
ElementFormat = SlimDX.DXGI.Format.R8G8B8A8_UNorm;
|
||||
Size = 4 * sizeof(byte);
|
||||
break;
|
||||
}
|
||||
case Format.BlendWeight:
|
||||
{
|
||||
SemanticName = "BLENDWEIGHT";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32G32B32A32_Float;
|
||||
Size = 4 * sizeof(float);
|
||||
break;
|
||||
}
|
||||
case Format.BlendIndices:
|
||||
{
|
||||
SemanticName = "BLENDINDICES";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32G32B32A32_SInt;
|
||||
Size = 4 * sizeof(int);
|
||||
break;
|
||||
}
|
||||
case Format.Texture2D:
|
||||
{
|
||||
SemanticName = "TEXCOORD";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32G32_Float;
|
||||
Size = 2 * sizeof(float);
|
||||
break;
|
||||
}
|
||||
case Format.Texture3D:
|
||||
{
|
||||
SemanticName = "TEXCOORD";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32G32B32_Float;
|
||||
Size = 3 * sizeof(float);
|
||||
break;
|
||||
}
|
||||
case Format.Texture4D:
|
||||
{
|
||||
SemanticName = "TEXCOORD";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32G32B32A32_Float;
|
||||
Size = 4 * sizeof(float);
|
||||
break;
|
||||
}
|
||||
case Format.PointSize:
|
||||
{
|
||||
SemanticName = "PSIZE";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32_Float;
|
||||
Size = 1 * sizeof(float);
|
||||
break;
|
||||
}
|
||||
case Format.Position:
|
||||
default:
|
||||
{
|
||||
SemanticName = "POSITION";
|
||||
ElementFormat = SlimDX.DXGI.Format.R32G32B32_Float;
|
||||
Size = 3 * sizeof(float);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string SemanticName;
|
||||
public SlimDX.DXGI.Format ElementFormat;
|
||||
public Format WellKnownFormat;
|
||||
public int NameIndex;
|
||||
public int Size;
|
||||
};
|
||||
|
||||
public interface IGeometryBuffer
|
||||
{
|
||||
void ConvertToAdjacency();
|
||||
void DeleteIndexData();
|
||||
void DeleteVertexData();
|
||||
|
||||
int IndexBufferLength { get; }
|
||||
int IndexBufferOffset { get; set; }
|
||||
int IndexBufferUsableLength { get; set; }
|
||||
|
||||
void SetIndexData(IEnumerable<uint> argIndexData, bool argNeedsDynamicAccess);
|
||||
void SetIndexData(int argIndexCount, SlimDX.DataStream argIndexData, bool argNeedsDynamicAccess);
|
||||
void SetVertexData<TVertex>(IEnumerable<TVertex> argVertexData, VertexElement[] argVertexElements, bool argNeedsDynamicAccess) where TVertex : struct;
|
||||
void SetVertexData(int argVertexCount, SlimDX.DataStream argVertexData, VertexElement[] argVertexElements, bool argNeedsDynamicAccess);
|
||||
|
||||
SlimDX.DataStream MapIndexBufferRaw(SlimDX.Direct3D10.MapMode argAccessMode);
|
||||
uint[] MapIndexBuffer(SlimDX.Direct3D10.MapMode argAccessMode);
|
||||
SlimDX.DataStream MapVertexBufferRaw(SlimDX.Direct3D10.MapMode argAccessMode);
|
||||
TVertex[] MapVertexBuffer<TVertex>(SlimDX.Direct3D10.MapMode argAccessMode) where TVertex : struct;
|
||||
|
||||
void UnmapIndexBuffer();
|
||||
void UnmapVertexBuffer();
|
||||
|
||||
SlimDX.Direct3D10.PrimitiveTopology PrimitiveTopology { get; set; }
|
||||
|
||||
int VertexBufferLength { get; }
|
||||
bool IsPickable { get; set; }
|
||||
IPickHull PickHull { get; }
|
||||
}
|
||||
}
|
||||
15
aiwaz/Aiwaz.Contracts/IObjectFactory.cs
Normal file
15
aiwaz/Aiwaz.Contracts/IObjectFactory.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface IObjectFactory
|
||||
{
|
||||
T CreateInstance<T>(params object[] args);
|
||||
T CreateNamedInstance<T>(string argName, params object[] args);
|
||||
T FindNamedInstance<T>(string argName);
|
||||
|
||||
void RegisterPattern<O>();
|
||||
void RegisterPattern<I, O>();
|
||||
void RemoveNamedInstance<T>(string argName);
|
||||
}
|
||||
}
|
||||
16
aiwaz/Aiwaz.Contracts/IPickHull.cs
Normal file
16
aiwaz/Aiwaz.Contracts/IPickHull.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SlimDX;
|
||||
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface IPickHull
|
||||
{
|
||||
bool TryPick(Ray pickRay, Matrix worldMatrix, out float distance);
|
||||
|
||||
BoundingSphere CalcBoundingSphere(Matrix worldMatrix);
|
||||
BoundingBox CalcBoundingBox(Matrix worldMatrix);
|
||||
}
|
||||
}
|
||||
12
aiwaz/Aiwaz.Contracts/IPingPongBuffer.cs
Normal file
12
aiwaz/Aiwaz.Contracts/IPingPongBuffer.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
|
||||
interface IPingPongBuffer
|
||||
{
|
||||
ITexture InputTexture { get; set; }
|
||||
ITexture OutputTexture { get; }
|
||||
PingPongBufferDescription Descriptor { get; set; }
|
||||
IRenderCommandNode RootNode { get; }
|
||||
IRenderCommandNode PreProcessNode { get; }
|
||||
};
|
||||
}
|
||||
18
aiwaz/Aiwaz.Contracts/IRenderCommandNode.cs
Normal file
18
aiwaz/Aiwaz.Contracts/IRenderCommandNode.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface IRenderCommandNode
|
||||
{
|
||||
List<ICommandUser> CommandUsers { get; }
|
||||
bool IsDirty { get; }
|
||||
IRenderCommandNode Parent { get; set; }
|
||||
|
||||
void MarkDirty();
|
||||
void Add(ICommandUser argCommandUser);
|
||||
void Remove(ICommandUser argCommandUser);
|
||||
void ProcessCommands();
|
||||
|
||||
void GenerateDeviceCommands();
|
||||
ICommandBuffer CommandBuffer { get; }
|
||||
};
|
||||
}
|
||||
60
aiwaz/Aiwaz.Contracts/IRenderTargetBase.cs
Normal file
60
aiwaz/Aiwaz.Contracts/IRenderTargetBase.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using SlimDX;
|
||||
using SlimDX.Direct3D10;
|
||||
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public class ViewPort
|
||||
{
|
||||
public ViewPort()
|
||||
{
|
||||
MaxDepth = 1.0f;
|
||||
}
|
||||
|
||||
public int TopLeftX;
|
||||
public int TopLeftY;
|
||||
public int Width;
|
||||
public int Height;
|
||||
public float MinDepth;
|
||||
public float MaxDepth;
|
||||
|
||||
public static implicit operator SlimDX.Direct3D10.Viewport(ViewPort vp)
|
||||
{
|
||||
return new SlimDX.Direct3D10.Viewport(vp.TopLeftX, vp.TopLeftY, vp.Width, vp.Height, vp.MinDepth, vp.MaxDepth);
|
||||
}
|
||||
};
|
||||
|
||||
public enum BindFlags
|
||||
{
|
||||
None = 0x000,
|
||||
ClearDepthStencil = 0x001,
|
||||
ClearColor = 0x002,
|
||||
ClearAll = 0x00F,
|
||||
BindAdditionalTexture0 = 0x010,
|
||||
BindAdditionalTexture1 = 0x020,
|
||||
BindAdditionalTexture2 = 0x040,
|
||||
BindAdditionalTexture3 = 0x080,
|
||||
BindBaseTexture = 0x100,
|
||||
BindAllTextures = 0xFF0,
|
||||
Default = ClearAll | BindAllTextures
|
||||
};
|
||||
|
||||
public interface IRenderTargetBase
|
||||
{
|
||||
float ClearDepth { get; set; }
|
||||
byte ClearStencil { get; set; }
|
||||
Color4 ClearColor { get; set; }
|
||||
ViewPort ViewPort { get; set; }
|
||||
int RenderTargetWidth { get; }
|
||||
int RenderTargetHeight { get; }
|
||||
SlimDX.DXGI.Format RenderTargetFormat { get; }
|
||||
bool HasDepthStencilBuffer { get; set; }
|
||||
RenderTargetView DX10RenderTargetView { get; }
|
||||
DepthStencilView DX10DepthStencilView { get; }
|
||||
|
||||
void AddAdditionalRenderTarget(IRenderTargetBase target);
|
||||
void RemoveAdditionalRenderTarget(IRenderTargetBase target);
|
||||
|
||||
void Bind(BindFlags bindFlags);
|
||||
void UnbindAllRenderTargets();
|
||||
};
|
||||
}
|
||||
8
aiwaz/Aiwaz.Contracts/IRenderTargetTexture.cs
Normal file
8
aiwaz/Aiwaz.Contracts/IRenderTargetTexture.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface IRenderTargetTexture
|
||||
{
|
||||
void Resize(int argWidth, int argHeight);
|
||||
ITexture Texture { get; }
|
||||
};
|
||||
}
|
||||
21
aiwaz/Aiwaz.Contracts/IResource.cs
Normal file
21
aiwaz/Aiwaz.Contracts/IResource.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface ICreationParams
|
||||
{
|
||||
}
|
||||
|
||||
public interface IResource
|
||||
{
|
||||
ICreationParams CreationParams { get; }
|
||||
string WellKnownName { get; set; }
|
||||
|
||||
IResource Parent { get; set; }
|
||||
ObservableCollection<IResource> Children { get; }
|
||||
}
|
||||
}
|
||||
14
aiwaz/Aiwaz.Contracts/IShader.cs
Normal file
14
aiwaz/Aiwaz.Contracts/IShader.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using SlimDX.Direct3D10;
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface IShader
|
||||
{
|
||||
string TechniqueName { get; set; }
|
||||
EffectTechnique Technique { get; }
|
||||
byte Priority { get; set; }
|
||||
int CurrentPass { get; }
|
||||
Effect Effect { get; }
|
||||
bool Changed { get; set; }
|
||||
};
|
||||
}
|
||||
32
aiwaz/Aiwaz.Contracts/IShaderParameterCollection.cs
Normal file
32
aiwaz/Aiwaz.Contracts/IShaderParameterCollection.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using SlimDX.Direct3D10;
|
||||
using SlimDX;
|
||||
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public enum ParameterBindType
|
||||
{
|
||||
BindBySemantic,
|
||||
BindByVariable
|
||||
};
|
||||
|
||||
public interface IShaderParameter
|
||||
{
|
||||
ParameterBindType ParameterNameType { get; }
|
||||
void ApplyValue(EffectVariable argVariable);
|
||||
};
|
||||
|
||||
public interface IShaderParameterSet
|
||||
{
|
||||
bool IsPreconditionForFollowingShaders { get; set; }
|
||||
|
||||
void SetParameter(string argParameterName, IShaderParameter ar_Parameter_);
|
||||
void SetParameter(string argParameterName, ITexture argParameter, ParameterBindType argParamNameType);
|
||||
void SetParameter(string argParameterName, float argParameter, ParameterBindType argParamNameType);
|
||||
void SetParameter(string argParameterName, Vector3 ar_Parameter_, ParameterBindType argParamNameType);
|
||||
void SetParameter(string argParameterName, Vector4 ar_Parameter_, ParameterBindType argParamNameType);
|
||||
void SetParameter(string argParameterName, Matrix argParameter, ParameterBindType argParamNameType);
|
||||
void SetParameter(string argParameterName, bool argParameter, ParameterBindType argParamNameType);
|
||||
void SetParameter(string argParameterName, Reference argParameter, ParameterBindType argParamNameType);
|
||||
void RemoveParameter(string argParameterName);
|
||||
};
|
||||
}
|
||||
11
aiwaz/Aiwaz.Contracts/ISwapChain.cs
Normal file
11
aiwaz/Aiwaz.Contracts/ISwapChain.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface ISwapChain
|
||||
{
|
||||
void Resize(int argWidth, int argHeight);
|
||||
void Present();
|
||||
|
||||
bool Fullscreen { get; set; }
|
||||
bool VSync { get; set; }
|
||||
}
|
||||
}
|
||||
82
aiwaz/Aiwaz.Contracts/ITexture.cs
Normal file
82
aiwaz/Aiwaz.Contracts/ITexture.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using SlimDX.Direct3D10;
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public struct LockedTextureData
|
||||
{
|
||||
public byte[] Data;
|
||||
public int RowPitch;
|
||||
};
|
||||
|
||||
public class TextureInitialData
|
||||
{
|
||||
public TextureInitialData(byte[] Data, int Pitch)
|
||||
{
|
||||
this.Data = Data;
|
||||
this.Pitch = Pitch;
|
||||
}
|
||||
|
||||
public byte[] Data;
|
||||
public int Pitch;
|
||||
};
|
||||
|
||||
public struct CreateTextureDescriptor
|
||||
{
|
||||
public int Width;
|
||||
public int Height;
|
||||
public int Elements;
|
||||
public int MipLevels;
|
||||
public SlimDX.DXGI.Format Format;
|
||||
public ResourceUsage AccessType;
|
||||
public TextureInitialData InitialData;
|
||||
|
||||
public static CreateTextureDescriptor AsSingleTexture(int Width, int Height, SlimDX.DXGI.Format Format, int MipLevels)
|
||||
{
|
||||
return AsSingleTexture(Width, Height, Format, MipLevels, null, ResourceUsage.Default);
|
||||
}
|
||||
|
||||
public static CreateTextureDescriptor AsSingleTexture(int Width, int Height, SlimDX.DXGI.Format Format, int MipLevels, TextureInitialData InitialData, ResourceUsage AccessType)
|
||||
{
|
||||
CreateTextureDescriptor Desc = new CreateTextureDescriptor();
|
||||
|
||||
Desc.Width = Width;
|
||||
Desc.Height = Height;
|
||||
Desc.Elements = 0;
|
||||
Desc.Format = Format;
|
||||
Desc.AccessType = AccessType;
|
||||
Desc.InitialData = InitialData;
|
||||
Desc.MipLevels = MipLevels;
|
||||
|
||||
return Desc;
|
||||
}
|
||||
|
||||
public static CreateTextureDescriptor AsArrayTexture(int Width, int Height, int Elements, SlimDX.DXGI.Format Format, int MipLevels, TextureInitialData InitialData)
|
||||
{
|
||||
CreateTextureDescriptor Desc = new CreateTextureDescriptor();
|
||||
|
||||
Desc.Width = Width;
|
||||
Desc.Height = Height;
|
||||
Desc.Elements = Elements;
|
||||
Desc.Format = Format;
|
||||
Desc.AccessType = ResourceUsage.Default;
|
||||
Desc.InitialData = InitialData;
|
||||
Desc.MipLevels = MipLevels;
|
||||
|
||||
return Desc;
|
||||
}
|
||||
};
|
||||
|
||||
public interface ITexture
|
||||
{
|
||||
string BindingName { get; set; }
|
||||
int TextureWidth { get; }
|
||||
int TextureHeight { get; }
|
||||
int TextureArraySize { get; }
|
||||
SlimDX.DXGI.Format TextureFormat { get; }
|
||||
ShaderResourceView ResourceView { get; }
|
||||
Texture2D Texture2D { get; }
|
||||
|
||||
SlimDX.DataRectangle MapTextureBuffer(MapMode mode);
|
||||
SlimDX.DataRectangle MapTextureBuffer(MapMode mode, int arrayElement);
|
||||
void UnmapTextureBuffer();
|
||||
};
|
||||
}
|
||||
12
aiwaz/Aiwaz.Contracts/ITimeLine.cs
Normal file
12
aiwaz/Aiwaz.Contracts/ITimeLine.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface ITimeline
|
||||
{
|
||||
double DeltaTime { get; }
|
||||
double RealTime { get; }
|
||||
double DemoTime { get; }
|
||||
double SpeedAndDirection { get; set; }
|
||||
|
||||
void Advance(double argSeconds);
|
||||
}
|
||||
}
|
||||
32
aiwaz/Aiwaz.Contracts/ITransformationAnimation.cs
Normal file
32
aiwaz/Aiwaz.Contracts/ITransformationAnimation.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using SlimDX;
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public enum KeyFrameTarget
|
||||
{
|
||||
Position = 0,
|
||||
Rotation,
|
||||
Scale
|
||||
}
|
||||
|
||||
public struct KeyFrame
|
||||
{
|
||||
KeyFrame(KeyFrameTarget argTarget, Vector3 argValue, float argTime)
|
||||
{
|
||||
Target = argTarget;
|
||||
Value = argValue;
|
||||
Time = argTime;
|
||||
}
|
||||
|
||||
KeyFrameTarget Target;
|
||||
Vector3 Value;
|
||||
float Time;
|
||||
}
|
||||
|
||||
public interface ITransformationAnimation
|
||||
{
|
||||
float Duration { get; }
|
||||
|
||||
void AddKeyFrame(KeyFrame argKeyFrame);
|
||||
Matrix GetTransformationAtTime(float argT); // [0.0] - [1.0]
|
||||
};
|
||||
}
|
||||
8
aiwaz/Aiwaz.Contracts/IUpdatable.cs
Normal file
8
aiwaz/Aiwaz.Contracts/IUpdatable.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface IUpdatable
|
||||
{
|
||||
void Update(bool argForceUpdate);
|
||||
bool WantsUpdate { get; }
|
||||
};
|
||||
}
|
||||
15
aiwaz/Aiwaz.Contracts/IWindow.cs
Normal file
15
aiwaz/Aiwaz.Contracts/IWindow.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public interface IWindow
|
||||
{
|
||||
void Initialize(string argTitle, int argWidth, int argHeight, bool argFullscreen);
|
||||
void SwapBuffers();
|
||||
|
||||
bool Active { get; set; }
|
||||
bool Fullscreen { get; set; }
|
||||
bool VSync { get; set; }
|
||||
string Title { get; set; }
|
||||
object Handle { get; }
|
||||
ISwapChain SwapChain { get; }
|
||||
}
|
||||
}
|
||||
36
aiwaz/Aiwaz.Contracts/Properties/AssemblyInfo.cs
Normal file
36
aiwaz/Aiwaz.Contracts/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Aiwaz.Contracts")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("Aiwaz.Contracts")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("0413d7de-46a8-4b64-bdee-e4427bf03026")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
31
aiwaz/Aiwaz.Contracts/Reference.cs
Normal file
31
aiwaz/Aiwaz.Contracts/Reference.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public class Reference
|
||||
{
|
||||
public Reference(object inValue)
|
||||
{
|
||||
this.RawValue = inValue;
|
||||
}
|
||||
|
||||
public Reference()
|
||||
{
|
||||
}
|
||||
|
||||
public object RawValue { get; set; }
|
||||
}
|
||||
|
||||
public class ReferenceT<T> : Reference
|
||||
{
|
||||
public ReferenceT(T inValue)
|
||||
{
|
||||
this.RawValue = inValue;
|
||||
}
|
||||
|
||||
public ReferenceT()
|
||||
{
|
||||
}
|
||||
|
||||
public T Value { get { return (T)this.RawValue; } set { this.RawValue = value; } }
|
||||
}
|
||||
}
|
||||
114
aiwaz/Aiwaz.Contracts/Resource.cs
Normal file
114
aiwaz/Aiwaz.Contracts/Resource.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
namespace Aiwaz.Contracts
|
||||
{
|
||||
public class AiwazResourceAttribute : System.Attribute
|
||||
{
|
||||
public string Name { get; protected set;}
|
||||
public string Description { get; protected set; }
|
||||
public AiwazResourceAttribute(string name, string description)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Description = description;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DataFormatByteSize
|
||||
{
|
||||
public static uint GetByteSize(this SlimDX.DXGI.Format argFormat)
|
||||
{
|
||||
switch (argFormat)
|
||||
{
|
||||
case SlimDX.DXGI.Format.Unknown: return 0;
|
||||
case SlimDX.DXGI.Format.R32G32B32A32_Typeless: return 16;
|
||||
case SlimDX.DXGI.Format.R32G32B32A32_Float: return 16;
|
||||
case SlimDX.DXGI.Format.R32G32B32A32_UInt: return 16;
|
||||
case SlimDX.DXGI.Format.R32G32B32A32_SInt: return 16;
|
||||
case SlimDX.DXGI.Format.R32G32B32_Typeless: return 12;
|
||||
case SlimDX.DXGI.Format.R32G32B32_Float: return 12;
|
||||
case SlimDX.DXGI.Format.R32G32B32_UInt: return 12;
|
||||
case SlimDX.DXGI.Format.R32G32B32_SInt: return 12;
|
||||
case SlimDX.DXGI.Format.R16G16B16A16_Typeless: return 8;
|
||||
case SlimDX.DXGI.Format.R16G16B16A16_Float: return 8;
|
||||
case SlimDX.DXGI.Format.R16G16B16A16_UNorm: return 8;
|
||||
case SlimDX.DXGI.Format.R16G16B16A16_UInt: return 8;
|
||||
case SlimDX.DXGI.Format.R16G16B16A16_SNorm: return 8;
|
||||
case SlimDX.DXGI.Format.R16G16B16A16_SInt: return 8;
|
||||
case SlimDX.DXGI.Format.R32G32_Typeless: return 8;
|
||||
case SlimDX.DXGI.Format.R32G32_Float: return 8;
|
||||
case SlimDX.DXGI.Format.R32G32_UInt: return 8;
|
||||
case SlimDX.DXGI.Format.R32G32_SInt: return 8;
|
||||
case SlimDX.DXGI.Format.R32G8X24_Typeless: return 8;
|
||||
case SlimDX.DXGI.Format.D32_Float_S8X24_UInt: return 8;
|
||||
case SlimDX.DXGI.Format.R32_Float_X8X24_Typeless: return 8;
|
||||
case SlimDX.DXGI.Format.X32_Typeless_G8X24_UInt: return 8;
|
||||
case SlimDX.DXGI.Format.R10G10B10A2_Typeless: return 4;
|
||||
case SlimDX.DXGI.Format.R10G10B10A2_UNorm: return 4;
|
||||
case SlimDX.DXGI.Format.R10G10B10A2_UInt: return 4;
|
||||
case SlimDX.DXGI.Format.R11G11B10_Float: return 4;
|
||||
case SlimDX.DXGI.Format.R8G8B8A8_Typeless: return 4;
|
||||
case SlimDX.DXGI.Format.R8G8B8A8_UNorm: return 4;
|
||||
case SlimDX.DXGI.Format.R8G8B8A8_UNorm_SRGB: return 4;
|
||||
case SlimDX.DXGI.Format.R8G8B8A8_UInt: return 4;
|
||||
case SlimDX.DXGI.Format.R8G8B8A8_SNorm: return 4;
|
||||
case SlimDX.DXGI.Format.R8G8B8A8_SInt: return 4;
|
||||
case SlimDX.DXGI.Format.R16G16_Typeless: return 4;
|
||||
case SlimDX.DXGI.Format.R16G16_Float: return 4;
|
||||
case SlimDX.DXGI.Format.R16G16_UNorm: return 4;
|
||||
case SlimDX.DXGI.Format.R16G16_UInt: return 4;
|
||||
case SlimDX.DXGI.Format.R16G16_SNorm: return 4;
|
||||
case SlimDX.DXGI.Format.R16G16_SInt: return 4;
|
||||
case SlimDX.DXGI.Format.R32_Typeless: return 4;
|
||||
case SlimDX.DXGI.Format.D32_Float: return 4;
|
||||
case SlimDX.DXGI.Format.R32_Float: return 4;
|
||||
case SlimDX.DXGI.Format.R32_UInt: return 4;
|
||||
case SlimDX.DXGI.Format.R32_SInt: return 4;
|
||||
case SlimDX.DXGI.Format.R24G8_Typeless: return 4;
|
||||
case SlimDX.DXGI.Format.D24_UNorm_S8_UInt: return 4;
|
||||
case SlimDX.DXGI.Format.R24_UNorm_X8_Typeless: return 4;
|
||||
case SlimDX.DXGI.Format.X24_Typeless_G8_UInt: return 4;
|
||||
case SlimDX.DXGI.Format.R8G8_Typeless: return 2;
|
||||
case SlimDX.DXGI.Format.R8G8_UNorm: return 2;
|
||||
case SlimDX.DXGI.Format.R8G8_UInt: return 2;
|
||||
case SlimDX.DXGI.Format.R8G8_SNorm: return 2;
|
||||
case SlimDX.DXGI.Format.R8G8_SInt: return 2;
|
||||
case SlimDX.DXGI.Format.R16_Typeless: return 2;
|
||||
case SlimDX.DXGI.Format.R16_Float: return 2;
|
||||
case SlimDX.DXGI.Format.D16_UNorm: return 2;
|
||||
case SlimDX.DXGI.Format.R16_UNorm: return 2;
|
||||
case SlimDX.DXGI.Format.R16_UInt: return 2;
|
||||
case SlimDX.DXGI.Format.R16_SNorm: return 2;
|
||||
case SlimDX.DXGI.Format.R16_SInt: return 2;
|
||||
case SlimDX.DXGI.Format.R8_Typeless: return 1;
|
||||
case SlimDX.DXGI.Format.R8_UNorm: return 1;
|
||||
case SlimDX.DXGI.Format.R8_UInt: return 1;
|
||||
case SlimDX.DXGI.Format.R8_SNorm: return 1;
|
||||
case SlimDX.DXGI.Format.R8_SInt: return 1;
|
||||
case SlimDX.DXGI.Format.A8_UNorm: return 1;
|
||||
case SlimDX.DXGI.Format.R1_UNorm: return 1;
|
||||
case SlimDX.DXGI.Format.R9G9B9E5_SharedExp: return 4;
|
||||
case SlimDX.DXGI.Format.R8G8_B8G8_UNorm: return 4;
|
||||
case SlimDX.DXGI.Format.G8R8_G8B8_UNorm: return 4;
|
||||
case SlimDX.DXGI.Format.BC1_Typeless: return 2;
|
||||
case SlimDX.DXGI.Format.BC1_UNorm: return 2;
|
||||
case SlimDX.DXGI.Format.BC1_UNorm_SRGB: return 2;
|
||||
case SlimDX.DXGI.Format.BC2_Typeless: return 3;
|
||||
case SlimDX.DXGI.Format.BC2_UNorm: return 3;
|
||||
case SlimDX.DXGI.Format.BC2_UNorm_SRGB: return 3;
|
||||
case SlimDX.DXGI.Format.BC3_Typeless: return 4;
|
||||
case SlimDX.DXGI.Format.BC3_UNorm: return 4;
|
||||
case SlimDX.DXGI.Format.BC3_UNorm_SRGB: return 4;
|
||||
case SlimDX.DXGI.Format.BC4_Typeless: return 1;
|
||||
case SlimDX.DXGI.Format.BC4_UNorm: return 1;
|
||||
case SlimDX.DXGI.Format.BC4_SNorm: return 1;
|
||||
case SlimDX.DXGI.Format.BC5_Typeless: return 2;
|
||||
case SlimDX.DXGI.Format.BC5_UNorm: return 2;
|
||||
case SlimDX.DXGI.Format.BC5_SNorm: return 2;
|
||||
case SlimDX.DXGI.Format.B5G6R5_UNorm: return 2;
|
||||
case SlimDX.DXGI.Format.B5G5R5A1_UNorm: return 2;
|
||||
case SlimDX.DXGI.Format.B8G8R8A8_UNorm: return 4;
|
||||
case SlimDX.DXGI.Format.B8G8R8X8_UNorm: return 4;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
BIN
aiwaz/Aiwaz.Contracts/bin/Debug/Aiwaz.Contracts.dll
Normal file
BIN
aiwaz/Aiwaz.Contracts/bin/Debug/Aiwaz.Contracts.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Contracts/bin/Debug/Aiwaz.Contracts.pdb
Normal file
BIN
aiwaz/Aiwaz.Contracts/bin/Debug/Aiwaz.Contracts.pdb
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Contracts/bin/Debug/SlimDX.dll
Normal file
BIN
aiwaz/Aiwaz.Contracts/bin/Debug/SlimDX.dll
Normal file
Binary file not shown.
43576
aiwaz/Aiwaz.Contracts/bin/Debug/SlimDX.xml
Normal file
43576
aiwaz/Aiwaz.Contracts/bin/Debug/SlimDX.xml
Normal file
File diff suppressed because it is too large
Load Diff
BIN
aiwaz/Aiwaz.Contracts/bin/x86/Debug/Aiwaz.Contracts.dll
Normal file
BIN
aiwaz/Aiwaz.Contracts/bin/x86/Debug/Aiwaz.Contracts.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Contracts/bin/x86/Debug/Aiwaz.Contracts.pdb
Normal file
BIN
aiwaz/Aiwaz.Contracts/bin/x86/Debug/Aiwaz.Contracts.pdb
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Contracts/bin/x86/Debug/SlimDX.dll
Normal file
BIN
aiwaz/Aiwaz.Contracts/bin/x86/Debug/SlimDX.dll
Normal file
Binary file not shown.
43576
aiwaz/Aiwaz.Contracts/bin/x86/Debug/SlimDX.xml
Normal file
43576
aiwaz/Aiwaz.Contracts/bin/x86/Debug/SlimDX.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\obj\Debug\ResolveAssemblyReference.cache
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\bin\Debug\Aiwaz.Contracts.dll
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\bin\Debug\Aiwaz.Contracts.pdb
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\obj\Debug\Aiwaz.Contracts.dll
|
||||
D:\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\obj\Debug\Aiwaz.Contracts.pdb
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\bin\Debug\Aiwaz.Contracts.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\bin\Debug\Aiwaz.Contracts.pdb
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\bin\Debug\SlimDX.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\bin\Debug\SlimDX.xml
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\obj\Debug\Aiwaz.Contracts.csprojResolveAssemblyReference.cache
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\obj\Debug\Aiwaz.Contracts.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\obj\Debug\Aiwaz.Contracts.pdb
|
||||
Binary file not shown.
BIN
aiwaz/Aiwaz.Contracts/obj/Debug/Aiwaz.Contracts.dll
Normal file
BIN
aiwaz/Aiwaz.Contracts/obj/Debug/Aiwaz.Contracts.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Contracts/obj/Debug/Aiwaz.Contracts.pdb
Normal file
BIN
aiwaz/Aiwaz.Contracts/obj/Debug/Aiwaz.Contracts.pdb
Normal file
Binary file not shown.
Binary file not shown.
BIN
aiwaz/Aiwaz.Contracts/obj/Debug/Refactor/Aiwaz.Contracts.dll
Normal file
BIN
aiwaz/Aiwaz.Contracts/obj/Debug/Refactor/Aiwaz.Contracts.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Contracts/obj/Debug/ResolveAssemblyReference.cache
Normal file
BIN
aiwaz/Aiwaz.Contracts/obj/Debug/ResolveAssemblyReference.cache
Normal file
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\bin\x86\Debug\Aiwaz.Contracts.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\bin\x86\Debug\Aiwaz.Contracts.pdb
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\bin\x86\Debug\SlimDX.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\bin\x86\Debug\SlimDX.xml
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\obj\x86\Debug\Aiwaz.Contracts.csprojResolveAssemblyReference.cache
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\obj\x86\Debug\Aiwaz.Contracts.dll
|
||||
D:\Private\Frank\Code\blu-flame.org\aiwaz\Aiwaz.Contracts\obj\x86\Debug\Aiwaz.Contracts.pdb
|
||||
Binary file not shown.
BIN
aiwaz/Aiwaz.Contracts/obj/x86/Debug/Aiwaz.Contracts.dll
Normal file
BIN
aiwaz/Aiwaz.Contracts/obj/x86/Debug/Aiwaz.Contracts.dll
Normal file
Binary file not shown.
BIN
aiwaz/Aiwaz.Contracts/obj/x86/Debug/Aiwaz.Contracts.pdb
Normal file
BIN
aiwaz/Aiwaz.Contracts/obj/x86/Debug/Aiwaz.Contracts.pdb
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
128
aiwaz/Aiwaz.Core/Aiwaz.Core.csproj
Normal file
128
aiwaz/Aiwaz.Core/Aiwaz.Core.csproj
Normal file
@@ -0,0 +1,128 @@
|
||||
<?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>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{B7AB4BB3-6FFC-453E-928D-852A6FF8C508}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Aiwaz.Core</RootNamespace>
|
||||
<AssemblyName>Aiwaz.Core</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</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>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="SlimDX, Version=2.0.8.42, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Extern\SlimDX\x86\SlimDX.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DeviceEnumerator\DeviceEnumerator.cs" />
|
||||
<Compile Include="DeviceEnumerator\DisplayAdapter.cs" />
|
||||
<Compile Include="DeviceEnumerator\DisplayMode.cs" />
|
||||
<Compile Include="DeviceEnumerator\OutputDevice.cs" />
|
||||
<Compile Include="Engine\Engine.cs" />
|
||||
<Compile Include="Exception.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aiwaz.Common\Aiwaz.Common.csproj">
|
||||
<Project>{0F7D7168-08C1-45AE-AAE3-80506939D7E6}</Project>
|
||||
<Name>Aiwaz.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Aiwaz.Contracts\Aiwaz.Contracts.csproj">
|
||||
<Project>{DE4D6FE6-D1FB-41A1-8ABA-19635B8FFD7A}</Project>
|
||||
<Name>Aiwaz.Contracts</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</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>
|
||||
13
aiwaz/Aiwaz.Core/Aiwaz.Core.csproj.user
Normal file
13
aiwaz/Aiwaz.Core/Aiwaz.Core.csproj.user
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<PublishUrlHistory />
|
||||
<InstallUrlHistory />
|
||||
<SupportUrlHistory />
|
||||
<UpdateUrlHistory />
|
||||
<BootstrapperUrlHistory />
|
||||
<ErrorReportUrlHistory />
|
||||
<FallbackCulture>en-US</FallbackCulture>
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
144
aiwaz/Aiwaz.Core/DeviceEnumerator/DeviceEnumerator.cs
Normal file
144
aiwaz/Aiwaz.Core/DeviceEnumerator/DeviceEnumerator.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Aiwaz.Contracts;
|
||||
using SlimDX;
|
||||
|
||||
namespace Aiwaz.Core
|
||||
{
|
||||
public class DeviceEnumerator : IDisposable
|
||||
{
|
||||
private SlimDX.DXGI.Factory Factory;
|
||||
internal SlimDX.Direct3D10.Device Device;
|
||||
|
||||
public bool HasEnumerated
|
||||
{
|
||||
get { return EnumeratedAdapters.Count > 0; }
|
||||
}
|
||||
|
||||
public List<DisplayAdapter> EnumeratedAdapters { get; private set;}
|
||||
|
||||
public uint DesiredWidth = 0;
|
||||
public uint DesiredHeight = 0;
|
||||
public uint DesiredRefreshRate = 0;
|
||||
public SlimDX.DXGI.Format DesiredFormat = SlimDX.DXGI.Format.Unknown;
|
||||
|
||||
public DeviceEnumerator(SlimDX.Direct3D10.Device argDevice)
|
||||
{
|
||||
Factory = new SlimDX.DXGI.Factory();
|
||||
Device = argDevice;
|
||||
EnumeratedAdapters = new List<DisplayAdapter>();
|
||||
}
|
||||
|
||||
~DeviceEnumerator()
|
||||
{
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
public bool TryEnumerate()
|
||||
{
|
||||
for (var i = 0; i < Factory.GetAdapterCount(); ++i)
|
||||
{
|
||||
SlimDX.DXGI.Adapter adapter = Factory.GetAdapter(i);
|
||||
if (adapter.IsInterfaceSupported(typeof(SlimDX.Direct3D10.Device)))
|
||||
{
|
||||
DisplayAdapter displayAdapter = new DisplayAdapter(this, adapter);
|
||||
if (displayAdapter.TryEnumerate())
|
||||
EnumeratedAdapters.Add(displayAdapter);
|
||||
else
|
||||
adapter.Dispose();
|
||||
}
|
||||
else
|
||||
adapter.Dispose();
|
||||
}
|
||||
|
||||
return HasEnumerated;
|
||||
}
|
||||
|
||||
public DisplayAdapter FindBestAdapter(bool argAllowToEnumerate)
|
||||
{
|
||||
if (argAllowToEnumerate && !this.TryEnumerate())
|
||||
return null;
|
||||
|
||||
if (!HasEnumerated)
|
||||
return null;
|
||||
|
||||
return EnumeratedAdapters.Last();
|
||||
}
|
||||
|
||||
public OutputDevice FindBestOutput(bool argAllowToEnumerate)
|
||||
{
|
||||
if (argAllowToEnumerate && !this.TryEnumerate())
|
||||
return null;
|
||||
|
||||
if (!HasEnumerated)
|
||||
return null;
|
||||
|
||||
return EnumeratedAdapters.Last().FindBestOutput(argAllowToEnumerate);
|
||||
}
|
||||
|
||||
public DisplayMode FindBestDisplayMode(bool argAllowToEnumerate)
|
||||
{
|
||||
if (argAllowToEnumerate && !this.TryEnumerate())
|
||||
return null;
|
||||
|
||||
if (!HasEnumerated)
|
||||
return null;
|
||||
|
||||
return EnumeratedAdapters.Last().FindBestDisplayMode(argAllowToEnumerate);
|
||||
}
|
||||
|
||||
public virtual void Verbose()
|
||||
{
|
||||
if (!HasEnumerated)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("Enumeration was not executed or no results available.");
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayAdapter displayAdapter = this.FindBestAdapter(false);
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.WriteLine("Adapter: " + displayAdapter.Name);
|
||||
Console.WriteLine("Dedicated System Memory: " + Math.Round(displayAdapter.DedicatedSystemMemory / 1024.0 / 1024.0, 0, MidpointRounding.AwayFromZero).ToString() + "MB");
|
||||
Console.WriteLine("Dedicated Video Memory: " + Math.Round(displayAdapter.DedicatedVideoMemory / 1024.0 / 1024.0, 0, MidpointRounding.AwayFromZero).ToString() + "MB");
|
||||
Console.WriteLine("Shared System Memory: " + Math.Round(displayAdapter.SharedSystemMemory / 1024.0 / 1024.0, 0, MidpointRounding.AwayFromZero).ToString() + "MB");
|
||||
Console.WriteLine();
|
||||
|
||||
for (int i = 0; i < displayAdapter.OutputDevices.Count; ++i)
|
||||
{
|
||||
OutputDevice outputDevice = displayAdapter.OutputDevices[i];
|
||||
if (i == 0)
|
||||
Console.Write("Primary Output: ");
|
||||
else
|
||||
Console.Write("Secondary Output: ");
|
||||
|
||||
Console.WriteLine(outputDevice.Name);
|
||||
|
||||
DisplayMode displayMode = outputDevice.FindBestDisplayMode(false);
|
||||
uint bpp = displayMode.Format.GetByteSize() * 8;
|
||||
|
||||
Console.WriteLine("Display: " + displayMode.Width.ToString() + "x" + displayMode.Height.ToString() + "x" + bpp.ToString() + " @" + displayMode.RefreshRate + "Hz");
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Factory != null)
|
||||
Factory.Dispose();
|
||||
Factory = null;
|
||||
|
||||
if (EnumeratedAdapters != null)
|
||||
foreach (var adapter in EnumeratedAdapters)
|
||||
adapter.Dispose();
|
||||
EnumeratedAdapters = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
108
aiwaz/Aiwaz.Core/DeviceEnumerator/DisplayAdapter.cs
Normal file
108
aiwaz/Aiwaz.Core/DeviceEnumerator/DisplayAdapter.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Aiwaz.Contracts;
|
||||
using SlimDX;
|
||||
|
||||
namespace Aiwaz.Core
|
||||
{
|
||||
public class DisplayAdapter : IDisposable
|
||||
{
|
||||
private DeviceEnumerator deviceEnumerator;
|
||||
|
||||
public SlimDX.DXGI.Adapter Adapter { get; private set; }
|
||||
|
||||
public bool HasEnumerated
|
||||
{
|
||||
get { return OutputDevices.Count > 0; }
|
||||
}
|
||||
|
||||
public long DedicatedSystemMemory
|
||||
{
|
||||
get { return Adapter.Description.DedicatedSystemMemory; }
|
||||
}
|
||||
|
||||
public long DedicatedVideoMemory
|
||||
{
|
||||
get { return Adapter.Description.DedicatedVideoMemory; }
|
||||
}
|
||||
|
||||
public long SharedSystemMemory
|
||||
{
|
||||
get { return Adapter.Description.SharedSystemMemory; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return Adapter.Description.Description; }
|
||||
}
|
||||
|
||||
public List<OutputDevice> OutputDevices { get; private set; }
|
||||
|
||||
public DisplayAdapter(DeviceEnumerator argDeviceEnumerator, SlimDX.DXGI.Adapter argAdapter)
|
||||
{
|
||||
this.deviceEnumerator = argDeviceEnumerator;
|
||||
this.Adapter = argAdapter;
|
||||
this.OutputDevices = new List<OutputDevice>();
|
||||
}
|
||||
|
||||
~DisplayAdapter()
|
||||
{
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
public bool TryEnumerate()
|
||||
{
|
||||
for (var i = 0; i < Adapter.GetOutputCount(); ++i)
|
||||
{
|
||||
var output = Adapter.GetOutput(i);
|
||||
OutputDevice device = new OutputDevice(deviceEnumerator, output);
|
||||
if (device.TryEnumerate())
|
||||
OutputDevices.Add(device);
|
||||
else
|
||||
output.Dispose();
|
||||
}
|
||||
|
||||
return HasEnumerated;
|
||||
}
|
||||
|
||||
public OutputDevice FindBestOutput(bool argAllowToEnumerate)
|
||||
{
|
||||
if (argAllowToEnumerate && !this.TryEnumerate())
|
||||
return null;
|
||||
|
||||
if (!HasEnumerated)
|
||||
return null;
|
||||
|
||||
return OutputDevices.Last();
|
||||
}
|
||||
|
||||
public DisplayMode FindBestDisplayMode(bool argAllowToEnumerate)
|
||||
{
|
||||
if (argAllowToEnumerate && !this.TryEnumerate())
|
||||
return null;
|
||||
|
||||
if (!HasEnumerated)
|
||||
return null;
|
||||
|
||||
return OutputDevices.Last().FindBestDisplayMode(argAllowToEnumerate);
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Adapter != null)
|
||||
Adapter.Dispose();
|
||||
Adapter = null;
|
||||
|
||||
if (OutputDevices != null)
|
||||
foreach (var output in OutputDevices)
|
||||
output.Dispose();
|
||||
OutputDevices = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user