Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit aaf3d7b

Browse files
author
Michel
committed
created example project
1 parent 7e9dee7 commit aaf3d7b

File tree

10 files changed

+599
-0
lines changed

10 files changed

+599
-0
lines changed

.gitattributes

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27703.2047
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GameOverlayExample", "GameOverlayExample\GameOverlayExample.csproj", "{23F7A2C8-0057-41D5-B24E-2855BC6DB3DA}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{23F7A2C8-0057-41D5-B24E-2855BC6DB3DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{23F7A2C8-0057-41D5-B24E-2855BC6DB3DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{23F7A2C8-0057-41D5-B24E-2855BC6DB3DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{23F7A2C8-0057-41D5-B24E-2855BC6DB3DA}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {BCF648BD-44AC-4E9C-B806-795E919C2264}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
using System;
2+
3+
using GameOverlay.Graphics;
4+
using GameOverlay.Graphics.Primitives;
5+
using GameOverlay.Utilities;
6+
using GameOverlay.Windows;
7+
8+
namespace GameOverlayExample
9+
{
10+
public class Example
11+
{
12+
private OverlayWindow _window;
13+
private D2DDevice _device;
14+
private FrameTimer _frameTimer;
15+
16+
private bool _initializeGraphicObjects;
17+
18+
private D2DColor _backgroundColor;
19+
20+
private D2DFont _font;
21+
22+
private D2DSolidColorBrush _blackBrush;
23+
24+
private D2DSolidColorBrush _redBrush;
25+
private D2DSolidColorBrush _greenBrush;
26+
private D2DSolidColorBrush _blueBrush;
27+
28+
private D2DImage _image;
29+
30+
public Example()
31+
{
32+
SetupInstance();
33+
}
34+
35+
~Example()
36+
{
37+
DestroyInstance();
38+
}
39+
40+
private void SetupInstance()
41+
{
42+
_window = new OverlayWindow(new OverlayOptions()
43+
{
44+
BypassTopmost = false,
45+
Height = 600,
46+
Width = 800,
47+
WindowTitle = "GameOverlayExample",
48+
X = 0,
49+
Y = 0
50+
});
51+
52+
_device = new D2DDevice(new DeviceOptions()
53+
{
54+
AntiAliasing = true,
55+
Hwnd = _window.WindowHandle,
56+
MeasureFps = true,
57+
MultiThreaded = false,
58+
VSync = false
59+
});
60+
61+
_frameTimer = new FrameTimer(_device, 60);
62+
63+
_window.OnWindowBoundsChanged += _window_OnWindowBoundsChanged;
64+
65+
_initializeGraphicObjects = true;
66+
67+
_frameTimer.OnFrameStarting += _frameTimer_OnFrameStarting;
68+
_frameTimer.OnFrame += _frameTimer_OnFrame;
69+
70+
_frameTimer.Start();
71+
}
72+
73+
private void DestroyInstance()
74+
{
75+
_frameTimer.Stop();
76+
77+
_frameTimer.Dispose();
78+
_device.Dispose();
79+
_window.Dispose();
80+
81+
_window = null;
82+
_device = null;
83+
_frameTimer = null;
84+
}
85+
86+
private void _window_OnWindowBoundsChanged(int x, int y, int width, int height)
87+
{
88+
if (_device == null) return;
89+
if (!_device.IsInitialized) return;
90+
91+
_device.Resize(width, height);
92+
}
93+
94+
private void _frameTimer_OnFrameStarting(FrameTimer timer, D2DDevice device)
95+
{
96+
if (!_initializeGraphicObjects) return;
97+
98+
if (!device.IsInitialized) return;
99+
if (device.IsDrawing) return;
100+
101+
_backgroundColor = new D2DColor(0x33, 0x33, 0x33, 0xEF);
102+
103+
_font = _device.CreateFont(new FontOptions()
104+
{
105+
Bold = false,
106+
FontFamilyName = "Arial",
107+
FontSize = 16,
108+
Italic = false,
109+
WordWrapping = true
110+
});
111+
112+
_blackBrush = device.CreateSolidColorBrush(0x0, 0x0, 0x0, 0xFF);
113+
114+
_redBrush = device.CreateSolidColorBrush(0xFF, 0x0, 0x0, 0xFF);
115+
_greenBrush = device.CreateSolidColorBrush(0x0, 0xFF, 0x0, 0xFF);
116+
_blueBrush = device.CreateSolidColorBrush(0x0, 0x0, 0xFF, 0xFF);
117+
118+
_image = device.LoadImage(Properties.Resources.placeholder_image_bytes);
119+
}
120+
121+
private void _frameTimer_OnFrame(FrameTimer timer, D2DDevice device)
122+
{
123+
if (!device.IsDrawing)
124+
{
125+
_initializeGraphicObjects = true;
126+
return;
127+
}
128+
129+
// clear the scene / fill it with our background
130+
131+
device.ClearScene(_backgroundColor);
132+
133+
// text
134+
135+
device.DrawTextWithBackground("FPS: " + device.FramesPerSecond, 10, 10, _font, _redBrush, _blackBrush);
136+
137+
// primitives
138+
139+
device.DrawCircle(100, 100, 50, 2.0f, _redBrush);
140+
device.DrawDashedCircle(250, 100, 50, 2.0f, _greenBrush);
141+
142+
device.DrawRectangle(Rectangle.Create(350, 50, 100, 100), 2.0f, _blueBrush);
143+
device.DrawRoundedRectangle(RoundedRectangle.Create(500, 50, 100, 100, 6.0f), 2.0f, _redBrush);
144+
145+
device.DrawTriangle(650, 150, 750, 150, 700, 50, _greenBrush, 2.0f);
146+
147+
// lines
148+
149+
device.DrawLine(50, 175, 750, 175, 2.0f, _blueBrush);
150+
device.DrawDashedLine(50, 200, 750, 200, 2.0f, _redBrush);
151+
152+
// outlines & filled
153+
154+
device.OutlineCircle(100, 275, 50, 4.0f, _redBrush, _blackBrush);
155+
device.FillCircle(250, 275, 50, _greenBrush);
156+
157+
device.OutlineRectangle(Rectangle.Create(350, 225, 100, 100), 4.0f, _blueBrush, _blackBrush);
158+
device.FillRoundedRectangle(RoundedRectangle.Create(500, 225, 100, 100, 6.0f), _redBrush);
159+
160+
device.FillTriangle(650, 325, 750, 325, 700, 225, _greenBrush);
161+
162+
// images
163+
164+
device.DrawImage(_image, 310, 375);
165+
}
166+
}
167+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{23F7A2C8-0057-41D5-B24E-2855BC6DB3DA}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>GameOverlayExample</RootNamespace>
10+
<AssemblyName>GameOverlayExample</AssemblyName>
11+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AssemblyVersion>1.19.19.6800</AssemblyVersion>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
<Prefer32Bit>false</Prefer32Bit>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="GameOverlay">
37+
<HintPath>..\..\..\GameOverlay\bin\Release\GameOverlay.dll</HintPath>
38+
</Reference>
39+
<Reference Include="System" />
40+
<Reference Include="System.Core" />
41+
<Reference Include="System.Drawing" />
42+
<Reference Include="System.Xml.Linq" />
43+
<Reference Include="System.Data.DataSetExtensions" />
44+
<Reference Include="Microsoft.CSharp" />
45+
<Reference Include="System.Data" />
46+
<Reference Include="System.Net.Http" />
47+
<Reference Include="System.Xml" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<Compile Include="Example.cs" />
51+
<Compile Include="Program.cs" />
52+
<Compile Include="Properties\AssemblyInfo.cs" />
53+
<Compile Include="Properties\Resources.Designer.cs">
54+
<AutoGen>True</AutoGen>
55+
<DesignTime>True</DesignTime>
56+
<DependentUpon>Resources.resx</DependentUpon>
57+
</Compile>
58+
</ItemGroup>
59+
<ItemGroup>
60+
<None Include="App.config" />
61+
<None Include="Resources\placeholder_image_bytes.bin" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<EmbeddedResource Include="Properties\Resources.resx">
65+
<Generator>ResXFileCodeGenerator</Generator>
66+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
67+
</EmbeddedResource>
68+
</ItemGroup>
69+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
70+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
3+
namespace GameOverlayExample
4+
{
5+
public static class Program
6+
{
7+
public static void Main(string[] args)
8+
{
9+
Console.WriteLine("GameOverlay.Net - Test");
10+
11+
Console.WriteLine();
12+
13+
Console.WriteLine("Author: " + GameOverlay.Library.Author);
14+
Console.WriteLine("Library Name: " + GameOverlay.Library.Name);
15+
Console.WriteLine("Project Url: " + GameOverlay.Library.ProjectUrl);
16+
Console.WriteLine("Version: " + GameOverlay.Library.Version);
17+
18+
Console.WriteLine();
19+
20+
Console.WriteLine("Type exit to close this program!");
21+
22+
Example example = new Example();
23+
24+
bool exit = false;
25+
while (!exit)
26+
{
27+
string line = Console.ReadLine();
28+
29+
if(line == null) continue;
30+
31+
if (line.ToLower() == "exit") exit = true;
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)