├── .gitattributes
├── .gitignore
├── ExternalUtilsCSharp.Injection
├── ExternalUtilsCSharp.Injection.csproj
├── Injectors
│ ├── DllInjectionResult.cs
│ ├── Injector.cs
│ ├── LoadLibraryCRTInjector.cs
│ └── RemoteThreadResult.cs
└── Properties
│ └── AssemblyInfo.cs
├── ExternalUtilsCSharp.JSONConfigUtils
├── ExternalUtilsCSharp.JSONConfigUtils.csproj
├── JSONConfigUtils.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── ExternalUtilsCSharp.SharpDXRenderer
├── ClassDiagram1.cd
├── ColorExtension.cs
├── Controls
│ ├── Crosshairs
│ │ ├── CircleCrosshair.cs
│ │ └── Crosshair.cs
│ ├── Layouts
│ │ ├── Layout.cs
│ │ ├── LinearLayout.cs
│ │ ├── NoneLayout.cs
│ │ └── TableLayout.cs
│ ├── SharpDXButton.cs
│ ├── SharpDXButtonKey.cs
│ ├── SharpDXCheckBox.cs
│ ├── SharpDXCheckable.cs
│ ├── SharpDXColorControl.cs
│ ├── SharpDXComboValue.cs
│ ├── SharpDXControl.cs
│ ├── SharpDXCursor.cs
│ ├── SharpDXGraph.cs
│ ├── SharpDXLabel.cs
│ ├── SharpDXPanel.cs
│ ├── SharpDXProgressBar.cs
│ ├── SharpDXRadar.cs
│ ├── SharpDXRadioButton.cs
│ ├── SharpDXSpacer.cs
│ ├── SharpDXTabControl.cs
│ ├── SharpDXTrackbar.cs
│ └── SharpDXWindow.cs
├── ExternalUtilsCSharp.SharpDXRenderer.csproj
├── Properties
│ └── AssemblyInfo.cs
├── SharpDXConverter.cs
├── SharpDXOverlay.cs
├── SharpDXRenderer.cs
└── packages.config
├── ExternalUtilsCSharp.sln
├── ExternalUtilsCSharp
├── ConfigObjects
│ └── IniConfigUtils.cs
├── ConfigUtils.cs
├── ExternalUtilsCSharp.csproj
├── InputUtils
│ ├── InputUtilities.cs
│ ├── KeyUtils.cs
│ ├── MouseEventExtArgs.cs
│ └── MouseHook.cs
├── JSONUtils.cs
├── MathObjects
│ ├── Matrix.cs
│ ├── Vector2.cs
│ └── Vector3.cs
├── MathUtils.cs
├── MemObjects
│ ├── PE
│ │ ├── COFFHeader.cs
│ │ ├── DOSHeader.cs
│ │ ├── PEInfo.cs
│ │ └── PEOptHeader.cs
│ └── ScanResult.cs
├── MemUtils.cs
├── MiscObjects
│ ├── CachedField.cs
│ └── CachedObject.cs
├── MiscUtils.cs
├── ProcUtils.cs
├── Properties
│ └── AssemblyInfo.cs
├── UI
│ ├── Control.cs
│ ├── Overlay.cs
│ ├── Renderer.cs
│ └── UIObjects
│ │ ├── Color.cs
│ │ ├── ColorExtension.cs
│ │ └── Rectangle.cs
├── Updater.cs
├── WinAPI.cs
├── classDiagram.cd
└── packages.config
├── OverlayExample
├── App.config
├── OverlayExample.csproj
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── README.md
└── packages
├── Newtonsoft.Json.6.0.8
├── Newtonsoft.Json.6.0.8.nupkg
├── lib
│ ├── net20
│ │ ├── Newtonsoft.Json.dll
│ │ └── Newtonsoft.Json.xml
│ ├── net35
│ │ ├── Newtonsoft.Json.dll
│ │ └── Newtonsoft.Json.xml
│ ├── net40
│ │ ├── Newtonsoft.Json.dll
│ │ └── Newtonsoft.Json.xml
│ ├── net45
│ │ ├── Newtonsoft.Json.dll
│ │ └── Newtonsoft.Json.xml
│ ├── netcore45
│ │ ├── Newtonsoft.Json.dll
│ │ └── Newtonsoft.Json.xml
│ ├── portable-net40+sl5+wp80+win8+wpa81
│ │ ├── Newtonsoft.Json.dll
│ │ └── Newtonsoft.Json.xml
│ └── portable-net45+wp80+win8+wpa81+aspnetcore50
│ │ ├── Newtonsoft.Json.dll
│ │ └── Newtonsoft.Json.xml
└── tools
│ └── install.ps1
├── SharpDX.2.6.3
├── SharpDX.2.6.3.nupkg
├── build
│ └── SharpDX.targets
├── lib
│ └── dummy.txt
└── tools
│ ├── Install.ps1
│ └── UnInstall.ps1
├── SharpDX.DXGI.2.6.3
├── SharpDX.DXGI.2.6.3.nupkg
├── lib
│ └── dummy.txt
└── tools
│ ├── Install.ps1
│ └── UnInstall.ps1
├── SharpDX.Direct2D1.2.6.3
├── SharpDX.Direct2D1.2.6.3.nupkg
├── lib
│ └── dummy.txt
└── tools
│ ├── Install.ps1
│ └── UnInstall.ps1
└── repositories.config
/.gitattributes:
--------------------------------------------------------------------------------
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
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 |
11 | [Dd]ebug/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | [Bb]in/
16 | [Oo]bj/
17 |
18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
19 | !packages/*/build/
20 |
21 | # MSTest test Results
22 | [Tt]est[Rr]esult*/
23 | [Bb]uild[Ll]og.*
24 |
25 | *_i.c
26 | *_p.c
27 | *.ilk
28 | *.meta
29 | *.obj
30 | *.pch
31 | *.pdb
32 | *.pgc
33 | *.pgd
34 | *.rsp
35 | *.sbr
36 | *.tlb
37 | *.tli
38 | *.tlh
39 | *.tmp
40 | *.tmp_proj
41 | *.log
42 | *.vspscc
43 | *.vssscc
44 | .builds
45 | *.pidb
46 | *.log
47 | *.scc
48 |
49 | # Visual C++ cache files
50 | ipch/
51 | *.aps
52 | *.ncb
53 | *.opensdf
54 | *.sdf
55 | *.cachefile
56 |
57 | # Visual Studio profiler
58 | *.psess
59 | *.vsp
60 | *.vspx
61 |
62 | # Guidance Automation Toolkit
63 | *.gpState
64 |
65 | # ReSharper is a .NET coding add-in
66 | _ReSharper*/
67 | *.[Rr]e[Ss]harper
68 |
69 | # TeamCity is a build add-in
70 | _TeamCity*
71 |
72 | # DotCover is a Code Coverage Tool
73 | *.dotCover
74 |
75 | # NCrunch
76 | *.ncrunch*
77 | .*crunch*.local.xml
78 |
79 | # Installshield output folder
80 | [Ee]xpress/
81 |
82 | # DocProject is a documentation generator add-in
83 | DocProject/buildhelp/
84 | DocProject/Help/*.HxT
85 | DocProject/Help/*.HxC
86 | DocProject/Help/*.hhc
87 | DocProject/Help/*.hhk
88 | DocProject/Help/*.hhp
89 | DocProject/Help/Html2
90 | DocProject/Help/html
91 |
92 | # Click-Once directory
93 | publish/
94 |
95 | # Publish Web Output
96 | *.Publish.xml
97 |
98 | # NuGet Packages Directory
99 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
100 | #packages/
101 |
102 | # Windows Azure Build Output
103 | csx
104 | *.build.csdef
105 |
106 | # Windows Store app package directory
107 | AppPackages/
108 |
109 | # Others
110 | sql/
111 | *.Cache
112 | ClientBin/
113 | [Ss]tyle[Cc]op.*
114 | ~$*
115 | *~
116 | *.dbmdl
117 | *.[Pp]ublish.xml
118 | *.pfx
119 | *.publishsettings
120 |
121 | # RIA/Silverlight projects
122 | Generated_Code/
123 |
124 | # Backup & report files from converting an old project file to a newer
125 | # Visual Studio version. Backup files are not needed, because we have git ;-)
126 | _UpgradeReport_Files/
127 | Backup*/
128 | UpgradeLog*.XML
129 | UpgradeLog*.htm
130 |
131 | # SQL Server files
132 | App_Data/*.mdf
133 | App_Data/*.ldf
134 |
135 |
136 | #LightSwitch generated files
137 | GeneratedArtifacts/
138 | _Pvt_Extensions/
139 | ModelManifest.xml
140 |
141 | # =========================
142 | # Windows detritus
143 | # =========================
144 |
145 | # Windows image file caches
146 | Thumbs.db
147 | ehthumbs.db
148 |
149 | # Folder config file
150 | Desktop.ini
151 |
152 | # Recycle Bin used on file shares
153 | $RECYCLE.BIN/
154 |
155 | # Mac desktop service store files
156 | .DS_Store
157 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.Injection/ExternalUtilsCSharp.Injection.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}
8 | Library
9 | Properties
10 | ExternalUtilsCSharp.Injection
11 | ExternalUtilsCSharp.Injection
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | {e294e4f8-de32-42c1-8bfd-a3e488ec5820}
51 | ExternalUtilsCSharp
52 |
53 |
54 |
55 |
56 |
63 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.Injection/Injectors/DllInjectionResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.Injection.Injectors
8 | {
9 | ///
10 | /// Holds data about an attempt to inject a DLL
11 | ///
12 | public struct DllInjectionResult
13 | {
14 | #region VARIABLES
15 | ///
16 | /// Whether the attempt to inject was successful
17 | ///
18 | public bool Success;
19 | ///
20 | /// Message stating what kind of error occured
21 | ///
22 | public string ErrorMessage;
23 | #endregion
24 |
25 | #region CONSTRUCTOR
26 | public DllInjectionResult(bool success = true)
27 | {
28 | Success = success;
29 | ErrorMessage = "";
30 | }
31 | public DllInjectionResult(string errorMessage)
32 | {
33 | Success = false;
34 | ErrorMessage = errorMessage;
35 | }
36 | public DllInjectionResult(string errorMessage, Exception ex)
37 | {
38 | Success = false;
39 | ErrorMessage = string.Format("{0}: [{1}] {2}", errorMessage, ex.GetType().Name, ex.Message);
40 | }
41 | public DllInjectionResult(bool success, string errorMessage)
42 | {
43 | Success = success;
44 | ErrorMessage = errorMessage;
45 | }
46 | #endregion
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.Injection/Injectors/LoadLibraryCRTInjector.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace ExternalUtilsCSharp.Injection.Injectors
10 | {
11 | ///
12 | /// Performs a DLL-injection by calling LoadLibraryA and CreateRemoteThread
13 | /// Credits fly out to evolution536 since I copied large parts of his C# dll injector:
14 | /// https://www.unknowncheats.me/forum/c/82629-basic-c-dll-injector.html
15 | ///
16 | public class LoadLibraryCRTInjector : Injector
17 | {
18 | public string DllPath { get; private set; }
19 |
20 | protected override DllInjectionResult PerformInjection(System.Diagnostics.Process proc, string dllPath)
21 | {
22 | this.DllPath = dllPath;
23 |
24 | ProcUtils = new ProcUtils(proc, WinAPI.ProcessAccessFlags.CreateThread | WinAPI.ProcessAccessFlags.VirtualMemoryOperation | WinAPI.ProcessAccessFlags.VirtualMemoryRead | WinAPI.ProcessAccessFlags.VirtualMemoryWrite | WinAPI.ProcessAccessFlags.QueryInformation);
25 |
26 | MemUtils = new MemUtils();
27 | MemUtils.Handle = ProcUtils.Handle;
28 | MemUtils.UseUnsafeReadWrite = true;
29 |
30 |
31 | if (ProcUtils.Handle == IntPtr.Zero)
32 | {
33 | return new DllInjectionResult("Could not open process", new Win32Exception(Marshal.GetLastWin32Error()));
34 | }
35 |
36 | IntPtr lpLLAddress = WinAPI.GetProcAddress(WinAPI.GetModuleHandle("kernel32.dll"), "LoadLibraryA");
37 |
38 | if (lpLLAddress == IntPtr.Zero)
39 | {
40 | return new DllInjectionResult("Could not find address of LoadLibraryA", new Win32Exception(Marshal.GetLastWin32Error()));
41 | }
42 |
43 | IntPtr lpAddress = WinAPI.VirtualAllocEx(ProcUtils.Handle, (IntPtr)null, (IntPtr)dllPath.Length, (uint)WinAPI.AllocationType.Commit | (uint)WinAPI.AllocationType.Reserve, (uint)WinAPI.MemoryProtection.ExecuteReadWrite);
44 |
45 | if (lpAddress == IntPtr.Zero)
46 | {
47 | return new DllInjectionResult("Could not allocate memory for dllPath", new Win32Exception(Marshal.GetLastWin32Error()));
48 | }
49 |
50 | byte[] bytes = Encoding.ASCII.GetBytes(dllPath);
51 |
52 | try
53 | {
54 | MemUtils.WriteString(lpAddress, dllPath, Encoding.ASCII);
55 | }
56 | catch(Exception ex)
57 | {
58 | return new DllInjectionResult("Failed to write dllPath to memory", ex);
59 | }
60 |
61 | RemoteThreadResult result = this.ExecuteRemoteThread(lpLLAddress, lpAddress);
62 |
63 | if (!result.Success)
64 | {
65 | return new DllInjectionResult(result.ErrorMessage);
66 | }
67 | hModule = (IntPtr)result.ReturnValue;
68 |
69 | if (hModule == IntPtr.Zero)
70 | return new DllInjectionResult("The base-address of the injected module is zero");
71 |
72 | return new DllInjectionResult(true);
73 | }
74 |
75 | public override void ParsePEInfo()
76 | {
77 | this.DllInfo = new MemObjects.PE.PEInfo(this.DllPath);
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.Injection/Injectors/RemoteThreadResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.Injection.Injectors
8 | {
9 | public class RemoteThreadResult
10 | {
11 | #region VARIABLES
12 | ///
13 | /// Whether the attempt to inject was successful
14 | ///
15 | public bool Success;
16 | ///
17 | /// Returnvalue of the thread that was executed
18 | ///
19 | public long ReturnValue;
20 | ///
21 | /// Message stating what kind of error occured
22 | ///
23 | public string ErrorMessage;
24 | #endregion
25 |
26 | #region CONSTRUCTOR
27 | public RemoteThreadResult(bool success)
28 | {
29 | Success = success;
30 | ErrorMessage = "";
31 | ReturnValue = 0;
32 | }
33 | public RemoteThreadResult(long returnValue)
34 | {
35 | Success = true;
36 | ErrorMessage = "";
37 | ReturnValue = returnValue;
38 | }
39 | public RemoteThreadResult(string errorMessage)
40 | {
41 | Success = false;
42 | ErrorMessage = errorMessage;
43 | ReturnValue = 0;
44 | }
45 | public RemoteThreadResult(string errorMessage, Exception ex)
46 | {
47 | Success = false;
48 | ErrorMessage = string.Format("{0}: [{1}] {2}", errorMessage, ex.GetType().Name, ex.Message);
49 | ReturnValue = 0;
50 | }
51 | public RemoteThreadResult(bool success, string errorMessage, long returnValue)
52 | {
53 | Success = success;
54 | ErrorMessage = errorMessage;
55 | ReturnValue = 0;
56 | }
57 | #endregion
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.Injection/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ExternalUtilsCSharp.Injection")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ExternalUtilsCSharp.Injection")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("82cb2fcb-f785-4816-bb81-9426c03818bc")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.JSONConfigUtils/ExternalUtilsCSharp.JSONConfigUtils.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {1E5DD6A0-A8A2-494B-A84E-9170C89A78AA}
8 | Library
9 | Properties
10 | ExternalUtilsCSharp.JSONConfigUtils
11 | ExternalUtilsCSharp.JSONConfigUtils
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll
35 | True
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | {e294e4f8-de32-42c1-8bfd-a3e488ec5820}
55 | ExternalUtilsCSharp
56 |
57 |
58 |
59 |
66 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.JSONConfigUtils/JSONConfigUtils.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace ExternalUtilsCSharp.JSONConfigUtils
10 | {
11 | ///
12 | /// JSON configurations helper classes
13 | /// Basicaly lets you to write any kind of object to file
14 | ///
15 |
16 | #region JsonConfigs
17 | public static class JSONConfigHelper
18 | {
19 | ///
20 | /// Creates new configuration if it does not exists
21 | ///
22 | /// path or name of config
23 | /// Object to write
24 | public static void DefaultConfig(string configName, T objToWrite)
25 | {
26 | if (File.Exists(configName)) return;
27 | JSONConfigManager.WriteFile(objToWrite, configName);
28 | }
29 | ///
30 | /// Read configuration
31 | ///
32 | public static T ReadConfiguration(string configName) where T : new()
33 | {
34 | return JSONConfigManager.ReadFile(configName);
35 | }
36 | ///
37 | /// Rewrites configuration
38 | ///
39 | public static void RewriteConfiguration(string configFileName, T configs)
40 | {
41 | JSONConfigManager.WriteFile(configs, configFileName);
42 | }
43 |
44 | }
45 | #region not static JsonConfigs
46 |
47 | ///
48 | /// Json configs helper which Deserialize Objects from file
49 | ///
50 | /// T is settings Object
51 | public class JsonConfigHelper : ConfigUtils where T : new()
52 | {
53 | public T Settings = new T();
54 | private string lastConfigName;
55 | public JsonConfigHelper() { }
56 | ///
57 | /// Created default config to specified path
58 | ///
59 | public virtual void DefaultConfig(string configName)
60 | {
61 | if (File.Exists(configName)) return;
62 | JSONConfigManager.WriteFile(Settings, configName);
63 | }
64 | ///
65 | /// Use ReadSettingsFromFile(string) method THIS one is not implemented
66 | /// since byte[] data is not required
67 | ///
68 | public override void ReadSettings(byte[] data)
69 | {
70 | throw new NotImplementedException();
71 | }
72 | ///
73 | /// Saves Setings object to latest used configuration
74 | ///
75 | /// return is not required
76 | public override byte[] SaveSettings()
77 | {
78 | JSONConfigManager.WriteFile(Settings, lastConfigName);
79 | return null;
80 | }
81 | ///
82 | /// Reads settings from file and stores it into Settings Object
83 | ///
84 | /// Path of file
85 | public override void ReadSettingsFromFile(string configName)
86 | {
87 | lastConfigName = configName;
88 | Settings = JSONConfigManager.ReadFile(configName);
89 | }
90 | ///
91 | /// Saves Settings object to specified file
92 | ///
93 | /// Path of file
94 | public override void SaveSettingsToFile(string configFileName)
95 | {
96 | lastConfigName = configFileName;
97 | JSONConfigManager.WriteFile(Settings, configFileName);
98 | }
99 |
100 | }
101 | #endregion
102 |
103 | public static class JSONConfigManager
104 | {
105 | public static T ReadFile(string filename) where T : new()
106 | {
107 | string data;
108 | try
109 | {
110 | using (
111 | var sr = new StreamReader(File.Open(filename,
112 | FileMode.Open, FileAccess.Read)))
113 | {
114 | data = sr.ReadToEnd();
115 | }
116 | var temp = JsonConvert.DeserializeObject(data);
117 | return temp;
118 | }
119 | catch (Exception e)
120 | {
121 | throw new Exception("Could not read settings\n", e);
122 | //data = null;
123 | //return new T();
124 | }
125 | }
126 | public static void WriteFile(T objToWrite, string fileName)
127 | {
128 | var temp = JsonConvert.SerializeObject(objToWrite, Formatting.Indented);
129 | using (var file = File.Open(fileName, FileMode.Create, FileAccess.Write))
130 | {
131 | using (var writer = new StreamWriter(file))
132 | {
133 | writer.Write(temp);
134 | }
135 | }
136 | }
137 | }
138 | #endregion
139 | }
140 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.JSONConfigUtils/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ExternalUtilsCSharp.JSONConfigUtils")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ExternalUtilsCSharp.JSONConfigUtils")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("21ed9a7f-826c-4f85-a9df-f9bccb29a7cc")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.JSONConfigUtils/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/ColorExtension.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Reflection;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Microsoft.SqlServer.Server;
9 |
10 | namespace ExternalUtilsCSharp.SharpDXRenderer
11 | {
12 | ///
13 | /// Extension for SharpDX.Color
14 | ///
15 | // TODO test if working. As i only used System.Drawing.Color before
16 | public static class ColorExtension
17 | {
18 | public static readonly List ColorList = ColorStructToList();
19 | public static List ColorStructToList()
20 | {
21 | return typeof(Color).GetFields(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public)
22 | .Select(c => (Color)c.GetValue(null))
23 | .ToList();
24 | }
25 | ///
26 | /// Picks previous Color
27 | ///
28 | /// base color to start with
29 | /// PreviousColor
30 | public static Color PreviousColor(this Color clr)
31 | {
32 | Color color;
33 | var clrID = ColorList.IndexOf(clr) - 1;
34 | color = clrID >= 0 ? ColorList[clrID] : ColorList.Last();
35 | return color;
36 | }
37 | ///
38 | /// Picks next color
39 | ///
40 | /// base color to start with
41 | /// Next color
42 | public static Color NextColor(this Color clr)
43 | {
44 | Color color;
45 | var clrID = ColorList.IndexOf(clr) + 1;
46 | color = clrID < ColorList.Count && clrID != -1 ? ColorList[clrID] : ColorList.First();
47 | return color;
48 | }
49 |
50 |
51 | public static readonly Dictionary ColorDictionary = ColorStructToDictionary();
52 | public static Dictionary ColorStructToDictionary()
53 | {
54 | Dictionary dictionary = new Dictionary();
55 | foreach (var colorInfo in typeof(Color).GetFields(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public)){
56 | dictionary.Add(colorInfo.Name,(Color)colorInfo.GetValue(null));
57 |
58 | }
59 | return dictionary;
60 | }
61 | ///
62 | /// Gets Color name from color dictionary
63 | ///
64 | /// Color object
65 | /// Color name
66 | public static string Name(this Color color){
67 | string name = "";
68 | var pair = ColorDictionary.First(x => x.Value.Equals(color));
69 | name = pair.Key;
70 | return name;
71 | }
72 | ///
73 | /// Converts string to color
74 | ///
75 | /// Color name
76 | /// Color object
77 | public static Color StringToColor(string name)
78 | {
79 | Color color = Color.Zero;
80 | ColorDictionary.TryGetValue(name,out color);
81 | return color;
82 | }
83 | public static System.Drawing.Color ToSystemDrawingColor(this Color color){
84 | return System.Drawing.Color.FromArgb(color.A,color.R,color.G,color.B);;
85 | }
86 | public static Color ToSharpDxColor(this System.Drawing.Color color){
87 | return Color.FromRgba(UI.UIObjects.ColorExtension.ToRGBA(color));;
88 | }
89 |
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/Crosshairs/CircleCrosshair.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls.Crosshairs
9 | {
10 | public class CircleCrosshair : Crosshair
11 | {
12 | #region METHODS
13 | public override void Draw(SharpDXRenderer renderer)
14 | {
15 | base.Draw(renderer);
16 | Vector2 location = this.GetAbsoluteLocation();
17 | float length = (this.Radius + this.Spread * this.SpreadScale) * 2f;
18 | Vector2 size = new Vector2(length, length);
19 |
20 | if (this.Outline)
21 | renderer.DrawEllipse(this.SecondaryColor, location, size, true, this.Width + 2f);
22 | renderer.DrawEllipse(this.PrimaryColor, location, size, true, this.Width);
23 | }
24 | #endregion
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/Crosshairs/Crosshair.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls.Crosshairs
9 | {
10 | public class Crosshair : SharpDXControl
11 | {
12 | #region ENUMS
13 | public enum Types { Default = 0, DefaultTilted, Rectangle, RectangleTilted, Circle };
14 | #endregion
15 |
16 | #region PROPERTIES
17 | public Color PrimaryColor { get; set; }
18 | public Color SecondaryColor { get; set; }
19 | public float Radius { get; set; }
20 | public float SpreadScale { get; set; }
21 | public float Spread { get; set; }
22 | public bool Outline { get; set; }
23 | public Types Type { get; set; }
24 | #endregion
25 |
26 | #region CONSTRUCTOR
27 | public Crosshair() : base()
28 | {
29 | this.PrimaryColor = this.BackColor;
30 | this.SecondaryColor = this.ForeColor;
31 | this.Radius = 10f;
32 | this.SpreadScale = 1f;
33 | this.Spread = 4f;
34 | this.Outline = true;
35 | this.Type = Types.Default;
36 | }
37 | #endregion
38 |
39 | #region METHODS
40 | public override void Draw(SharpDXRenderer renderer)
41 | {
42 | base.Draw(renderer);
43 | Vector2 location = this.GetAbsoluteLocation();
44 | float distance = this.Width / 2f + this.Spread * this.SpreadScale;
45 |
46 | switch (Type)
47 | {
48 | case Types.Default:
49 | for (int i = 0; i < 4; i++)
50 | DrawLine(renderer, location, distance, this.Radius, i * 90f, this.Width, this.Outline);
51 | break;
52 | case Types.DefaultTilted:
53 | for (int i = 0; i < 4; i++)
54 | DrawLine(renderer, location, distance, this.Radius, i * 90f + 45f, this.Width, this.Outline);
55 | break;
56 | case Types.Rectangle:
57 | for (int i = 0; i < 4; i++)
58 | DrawCrossLine(renderer, location, distance, this.Radius, i * 90f + 45f, this.Width, this.Outline);
59 | break;
60 | case Types.RectangleTilted:
61 | for (int i = 0; i < 4; i++)
62 | DrawCrossLine(renderer, location, distance, this.Radius, i * 90f, this.Width, this.Outline);
63 | break;
64 | case Types.Circle:
65 | float length = (this.Radius + this.Spread * this.SpreadScale) * 2f;
66 | Vector2 size = new Vector2(length, length);
67 |
68 | if (this.Outline)
69 | renderer.DrawEllipse(this.SecondaryColor, location, size, true, this.Width + 2f);
70 | renderer.DrawEllipse(this.PrimaryColor, location, size, true, this.Width);
71 | break;
72 | }
73 | }
74 |
75 | protected void DrawLine(SharpDXRenderer renderer, Vector2 center, float distance, float length, float angle, float width, bool outline)
76 | {
77 | ExternalUtilsCSharp.MathObjects.Vector2 vecCenter = SharpDXConverter.Vector2SDXtoEUC(center);
78 | ExternalUtilsCSharp.MathObjects.Vector2 vecRotateA = new MathObjects.Vector2(vecCenter.X + distance, vecCenter.Y);
79 | ExternalUtilsCSharp.MathObjects.Vector2 vecRotateB = new MathObjects.Vector2(vecCenter.X + distance + length, vecCenter.Y);
80 | vecRotateA = ExternalUtilsCSharp.MathUtils.RotatePoint(vecRotateA, vecCenter, angle);
81 | vecRotateB = ExternalUtilsCSharp.MathUtils.RotatePoint(vecRotateB, vecCenter, angle);
82 | Vector2 _vecRotateA = SharpDXConverter.Vector2EUCtoSDX(vecRotateA);
83 | Vector2 _vecRotateB = SharpDXConverter.Vector2EUCtoSDX(vecRotateB);
84 |
85 | if (outline)
86 | renderer.DrawLine(this.SecondaryColor, _vecRotateA, _vecRotateB, width + 2f);
87 | renderer.DrawLine(this.PrimaryColor, _vecRotateA, _vecRotateB, width);
88 | }
89 |
90 | protected void DrawCrossLine(SharpDXRenderer renderer, Vector2 center, float distance, float length, float angle, float width, bool outline)
91 | {
92 | ExternalUtilsCSharp.MathObjects.Vector2 vecCenter = SharpDXConverter.Vector2SDXtoEUC(center);
93 | ExternalUtilsCSharp.MathObjects.Vector2 vecRotateA = new MathObjects.Vector2(vecCenter.X + length, vecCenter.Y);
94 | ExternalUtilsCSharp.MathObjects.Vector2 vecRotateB = new MathObjects.Vector2(vecCenter.X, vecCenter.Y + length);
95 | vecRotateA += new MathObjects.Vector2(distance, distance);
96 | vecRotateB += new MathObjects.Vector2(distance, distance);
97 | vecRotateA = ExternalUtilsCSharp.MathUtils.RotatePoint(vecRotateA, vecCenter, angle);
98 | vecRotateB = ExternalUtilsCSharp.MathUtils.RotatePoint(vecRotateB, vecCenter, angle);
99 | Vector2 _vecRotateA = SharpDXConverter.Vector2EUCtoSDX(vecRotateA);
100 | Vector2 _vecRotateB = SharpDXConverter.Vector2EUCtoSDX(vecRotateB);
101 |
102 | if (outline)
103 | renderer.DrawLine(this.SecondaryColor, _vecRotateA, _vecRotateB, width + 2f);
104 | renderer.DrawLine(this.PrimaryColor, _vecRotateA, _vecRotateB, width);
105 | }
106 | #endregion
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/Layouts/Layout.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls.Layouts
8 | {
9 | ///
10 | /// An abstract class which offers methods to apply certain layouts to contents of a container-control
11 | ///
12 | public abstract class Layout
13 | {
14 | ///
15 | /// Applies a layout to the content of the given container-control
16 | ///
17 | ///
18 | public abstract void ApplyLayout(SharpDXControl parent);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/Layouts/LinearLayout.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls.Layouts
8 | {
9 | public class LinearLayout : Layout
10 | {
11 | #region SINGLETON
12 | private static LinearLayout instance = new LinearLayout();
13 | public static Layout Instance { get { return instance; } }
14 | private LinearLayout() : base()
15 | { }
16 | #endregion
17 |
18 | public override void ApplyLayout(SharpDXControl parent)
19 | {
20 | for (int i = 0; i < parent.ChildControls.Count; i++)
21 | {
22 | var control = parent.ChildControls[i];
23 | if (!control.Visible)
24 | continue;
25 |
26 | if (control.FillParent)
27 | control.Width = parent.Width - parent.MarginLeft - parent.MarginRight - control.MarginLeft - control.MarginRight;
28 |
29 | if (i == 0)
30 | {
31 | control.X = control.MarginLeft + parent.MarginLeft;
32 | control.Y = control.MarginTop;
33 | }
34 | else
35 | {
36 | var lastControl = parent.ChildControls[i - 1];
37 | control.X = lastControl.X;
38 | control.Y = lastControl.Y + lastControl.Height + lastControl.MarginBottom + control.MarginTop;
39 | }
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/Layouts/NoneLayout.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls.Layouts
8 | {
9 | public class NoneLayout : Layout
10 | {
11 | #region SINGLETON
12 | private static NoneLayout instance = new NoneLayout();
13 | public static Layout Instance { get { return instance; } }
14 | private NoneLayout()
15 | : base()
16 | { }
17 | #endregion
18 |
19 | public override void ApplyLayout(SharpDXControl parent)
20 | { }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/Layouts/TableLayout.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls.Layouts
8 | {
9 | public class TableLayout : Layout
10 | {
11 | #region PROPERTIES
12 | public int Columns { get; set; }
13 | public float[] ColumnWidth { get; private set; }
14 | #endregion
15 |
16 | #region SINGLETON
17 | private static TableLayout instanceTwoColumns = new TableLayout(2);
18 | private static TableLayout instanceThreeColumns = new TableLayout(3);
19 | public static Layout TwoColumns { get { return instanceTwoColumns; } }
20 | public static Layout ThreeColumns { get { return instanceThreeColumns; } }
21 | #endregion
22 |
23 | #region CONSTRUCTORS
24 | public TableLayout(int columns)
25 | : base()
26 | {
27 | this.Columns = columns;
28 | this.ColumnWidth = new float[columns];
29 | for (int i = 0; i < columns; i++)
30 | this.ColumnWidth[i] = 1f / this.Columns;
31 | }
32 | public TableLayout() : this(2) { }
33 | #endregion
34 |
35 | public override void ApplyLayout(SharpDXControl parent)
36 | {
37 | float height = 0;
38 |
39 | for (int i = 0; i < parent.ChildControls.Count; i++)
40 | {
41 | var control = parent.ChildControls[i];
42 | if (!control.Visible)
43 | continue;
44 |
45 | float width = parent.Width * this.ColumnWidth[i % this.Columns];
46 | float xSum = 0f;
47 | for(int x = 0; x < i % Columns; x++)
48 | xSum += this.ColumnWidth[x];
49 |
50 | if (control.FillParent)
51 | control.Width = width - parent.MarginLeft - parent.MarginRight - control.MarginLeft - control.MarginRight;
52 |
53 | //if (i % 2 == 0)
54 | // control.X = control.MarginLeft + parent.MarginLeft;
55 | //else
56 | // control.X = control.MarginLeft + parent.MarginLeft + parent.Width / 2f;
57 |
58 | control.X = control.MarginLeft + parent.MarginLeft + parent.Width * xSum;
59 |
60 |
61 | if (i == 0)
62 | {
63 | control.Y = control.MarginTop;
64 | }
65 | else
66 | {
67 | var lastControl = parent.ChildControls[i - 1];
68 | if (i % Columns == 0)
69 | {
70 | control.Y = height; //lastControl.Y + lastControl.Height + lastControl.MarginBottom + control.MarginTop;
71 | }
72 | else
73 | {
74 | control.Y = lastControl.Y;
75 | }
76 | }
77 | if (control.Y + control.Height + control.MarginBottom + control.MarginTop > height)
78 | height = control.Y + control.Height + control.MarginBottom + control.MarginTop;
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXButton.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
9 | {
10 | public class SharpDXButton : SharpDXControl
11 | {
12 | public SharpDXButton()
13 | {
14 | this.FillParent = true;
15 | this.TextAlign = TextAlignment.Center;
16 | this.DrawBackground = true;
17 | }
18 | public override void Draw(SharpDXRenderer renderer)
19 | {
20 | Vector2 location = this.GetAbsoluteLocation();
21 | Vector2 size = this.GetSize();
22 |
23 | if(this.MouseOver || this.DrawBackground)
24 | renderer.FillRectangle(this.BackColor,
25 | new Vector2(location.X - MarginLeft, location.Y - MarginTop),
26 | new Vector2(size.X + MarginLeft + MarginRight, size.Y + MarginTop + MarginBottom));
27 | if(this.DrawBorder)
28 | renderer.DrawRectangle(this.ForeColor,
29 | new Vector2(location.X - MarginLeft, location.Y - MarginTop),
30 | new Vector2(size.X + MarginLeft + MarginRight, size.Y + MarginTop + MarginBottom));
31 |
32 | float fontSize = (float)Math.Ceiling(this.Font.FontSize);
33 | Vector2 textSize = renderer.MeasureString(this.Text, this.Font);
34 |
35 | this.Height = textSize.Y;
36 | switch (this.TextAlign)
37 | {
38 | case TextAlignment.Center:
39 | location.X += this.Width / 2f - textSize.X / 2f;
40 | break;
41 | case TextAlignment.Right:
42 | location.X += this.Width - textSize.X;
43 | break;
44 | }
45 | renderer.DrawText(this.Text,
46 | this.ForeColor,
47 | this.Font,
48 | new Vector2(location.X + MarginLeft, location.Y));
49 |
50 | base.Draw(renderer);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXButtonKey.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 | using ExternalUtilsCSharp.InputUtils;
8 |
9 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
10 | {
11 | public class SharpDXButtonKey : SharpDXButton
12 | {
13 | #region VARIABLES
14 | private int skip;
15 | private bool listen;
16 | private WinAPI.VirtualKeyShort key;
17 | #endregion
18 |
19 | #region PROPERTIES
20 | public WinAPI.VirtualKeyShort Key
21 | {
22 | get { return this.key; }
23 | set
24 | {
25 | if(this.key != value)
26 | {
27 | this.key = value;
28 | OnKeyChangedEvent(new EventArgs());
29 | }
30 | }
31 | }
32 | #endregion
33 |
34 |
35 | #region EVENTS
36 | public event EventHandler KeyChangedEvent;
37 | protected virtual void OnKeyChangedEvent(EventArgs e)
38 | {
39 | if (KeyChangedEvent != null)
40 | KeyChangedEvent(this, e);
41 | }
42 | #endregion
43 |
44 | #region CONSTRUCTOR
45 | public SharpDXButtonKey() : base()
46 | {
47 | listen = false;
48 | this.key = WinAPI.VirtualKeyShort.XBUTTON1;
49 | this.MouseClickEventUp += SharpDXButtonKey_MouseClickEventUp;
50 | }
51 | #endregion
52 |
53 | #region METHODS
54 | void SharpDXButtonKey_MouseClickEventUp(object sender, MouseEventExtArgs e)
55 | {
56 | if (e.Button != MouseButtons.Left)
57 | return;
58 | listen = true;
59 | skip = 10;
60 | }
61 |
62 | public override void Draw(SharpDXRenderer renderer)
63 | {
64 | string text = null;
65 | string orig = this.Text;
66 | if (listen)
67 | text = string.Format("{0} ", this.Text);
68 | else
69 | text = string.Format("{0} {1}", this.Text, this.Key);
70 | this.Text = text;
71 | base.Draw(renderer);
72 | this.Text = orig;
73 | }
74 |
75 | public override void Update(double secondsElapsed, InputUtilities keyUtils, SharpDX.Vector2 cursorPoint, bool checkMouse = false)
76 | {
77 | base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse);
78 | if (listen)
79 | {
80 | if(skip > 0)
81 | {
82 | skip--;
83 | return;
84 | }
85 | WinAPI.VirtualKeyShort[] buttons = keyUtils.Keys.KeysThatWentUp();
86 | if (buttons.Length > 0)
87 | {
88 | Key = buttons[0];
89 | listen = false;
90 | }
91 | }
92 | }
93 |
94 | public override void ApplySettings(ConfigUtils config)
95 | {
96 | if (this.Tag != null)
97 | if (config.HasKey(this.Tag.ToString()))
98 | this.Key = config.GetValue(this.Tag.ToString());
99 | }
100 | #endregion
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXCheckBox.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 | using ExternalUtilsCSharp.InputUtils;
9 |
10 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
11 | {
12 | ///
13 | /// A simple checkbox
14 | ///
15 | public class SharpDXCheckBox : SharpDXCheckable
16 | {
17 | #region CONSTRUCTOR
18 | public SharpDXCheckBox()
19 | : base()
20 | {
21 | this.Text = "";
22 | this.MouseClickEventUp += SharpDXCheckBox_MouseClickEventUp;
23 | this.FillParent = true;
24 | }
25 | #endregion
26 | #region METHODS
27 |
28 | void SharpDXCheckBox_MouseClickEventUp(object sender, MouseEventExtArgs e)
29 | {
30 | if (e.Button == MouseButtons.Left)
31 | this.Checked = !this.Checked;
32 | }
33 | public override void Draw(SharpDXRenderer renderer)
34 | {
35 | base.Draw(renderer);
36 | float fontSize = (float)Math.Ceiling(this.Font.FontSize);
37 | Vector2 size = renderer.MeasureString(this.Text, this.Font);
38 | if (!this.FillParent)
39 | this.Width = size.X + fontSize;
40 | this.Height = size.Y;
41 | Vector2 location = this.GetAbsoluteLocation();
42 | Vector2 box = new Vector2(fontSize, fontSize);
43 | Vector2 boxLocation = new Vector2(location.X, location.Y + this.Height / 2f - box.Y / 2f);
44 |
45 | if(this.MouseOver)
46 | renderer.FillRectangle(this.BackColor,
47 | new Vector2(location.X - MarginLeft, location.Y - MarginTop),
48 | new Vector2(this.Width + MarginLeft + MarginRight, this.Height + MarginTop + MarginBottom));
49 |
50 | renderer.DrawRectangle(this.ForeColor, boxLocation, box);
51 |
52 | if (this.Checked)
53 | renderer.FillRectangle(this.ForeColor, boxLocation + Vector2.One * 2, box - Vector2.One * 4);
54 |
55 | renderer.DrawText(this.Text,
56 | this.ForeColor,
57 | this.Font,
58 | new Vector2(location.X + box.X + MarginLeft, location.Y));
59 | }
60 |
61 | public override void ApplySettings(ConfigUtils config)
62 | {
63 | if (this.Tag != null)
64 | if (config.HasKey(this.Tag.ToString()))
65 | this.Checked = config.GetValue(this.Tag.ToString());
66 | }
67 | #endregion
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXCheckable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
8 | {
9 | public abstract class SharpDXCheckable : SharpDXControl
10 | {
11 | #region VARIABLES
12 | private bool isChecked;
13 | #endregion
14 |
15 | #region PROPERTIES
16 | public bool Checked
17 | {
18 | get { return isChecked; }
19 | set
20 | {
21 | if (isChecked != value)
22 | {
23 | isChecked = value;
24 | OnCheckedChangedEvent(new EventArgs());
25 | }
26 | }
27 | }
28 | #endregion
29 |
30 | #region EVENTS
31 | public event EventHandler CheckedChangedEvent;
32 | protected virtual void OnCheckedChangedEvent(EventArgs e)
33 | {
34 | if (CheckedChangedEvent != null)
35 | CheckedChangedEvent(this, e);
36 | }
37 | #endregion
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXColorControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
8 | {
9 | public class SharpDXColorControl : SharpDXPanel
10 | {
11 | #region VARIABLES
12 | private UI.UIObjects.Color color;
13 | private SharpDXTrackbar A, R, G, B;
14 | private SharpDXButton preview;
15 | #endregion
16 |
17 | #region PROPERTIES
18 | public SharpDX.Color SDXColor { get; private set; }
19 | public UI.UIObjects.Color Color
20 | {
21 | get { return this.color; }
22 | set
23 | {
24 | if(value.ToARGB() != color.ToARGB())
25 | {
26 | this.color = value;
27 | SDXColor = new SharpDX.Color(color.R, color.G, color.B, color.A);
28 | this.A.SetValue(this.color.A / 255f);
29 | this.R.SetValue(this.color.R / 255f);
30 | this.G.SetValue(this.color.G / 255f);
31 | this.B.SetValue(this.color.B / 255f);
32 | this.preview.BackColor = SDXColor;
33 | this.preview.ForeColor = new SharpDX.Color(255 - SDXColor.R, 255 - SDXColor.G, 255 - SDXColor.B);
34 | this.OnColorChangedEvent(new EventArgs());
35 | }
36 | }
37 | }
38 | #endregion
39 |
40 | #region EVENTS
41 | public event EventHandler ColorChangedEvent;
42 | protected virtual void OnColorChangedEvent(EventArgs e)
43 | {
44 | if (ColorChangedEvent != null)
45 | ColorChangedEvent(this, e);
46 | }
47 | #endregion
48 |
49 | #region CONSTRUCTORS
50 | public SharpDXColorControl() : base()
51 | {
52 | this.color = new UI.UIObjects.Color(0, 0, 0, 0);
53 | this.TextChangedEvent += SharpDXColorControl_TextChangedEvent;
54 | this.DynamicWidth = false;
55 | this.FillParent = true;
56 |
57 | preview = new SharpDXButton();
58 | preview.FillParent = true;
59 | preview.Text = "";
60 | this.AddChildControl(preview);
61 |
62 | SetupChannel(ref this.A, "Alpha-channel", this.color.A);
63 | SetupChannel(ref this.R, "R-channel", this.color.R);
64 | SetupChannel(ref this.G, "G-channel", this.color.G);
65 | SetupChannel(ref this.B, "B-channel", this.color.B);
66 |
67 | this.Color = new UI.UIObjects.Color(1f, 1f, 1f, 1f);
68 | }
69 |
70 | void SharpDXColorControl_TextChangedEvent(object sender, EventArgs e)
71 | {
72 | preview.Text = this.Text;
73 | }
74 | #endregion
75 |
76 | #region METHODS
77 | private void SetupChannel(ref SharpDXTrackbar control, string channel, byte value)
78 | {
79 | control = new SharpDXTrackbar();
80 | control.Minimum = 0;
81 | control.Maximum = 1;
82 | control.NumberOfDecimals = 4;
83 | control.Value = value / 255f;
84 | control.ValueChangedEvent += control_ValueChangedEvent;
85 | control.FillParent = true;
86 | control.Text = channel;
87 | this.AddChildControl(control);
88 | }
89 |
90 | void control_ValueChangedEvent(object sender, EventArgs e)
91 | {
92 | this.Color = new UI.UIObjects.Color(A.Value, R.Value, G.Value, B.Value);
93 | }
94 |
95 | public override void ApplySettings(ConfigUtils config)
96 | {
97 | if (this.Tag != null)
98 | if (config.HasKey(this.Tag.ToString()))
99 | this.Color = UI.UIObjects.Color.FromFormat(config.GetValue(this.Tag.ToString()), UI.UIObjects.Color.ColorFormat.RGBA);
100 | }
101 | #endregion
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXComboValue.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using ExternalUtilsCSharp.InputUtils;
8 |
9 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
10 | {
11 | public class SharpDXComboValue : SharpDXControl
12 | {
13 | #region VARIABLES
14 | private int selectedIndex;
15 | #endregion
16 |
17 | #region PROPERTIES
18 | public Tuple[] Values { get; set; }
19 | public int SelectedIndex
20 | {
21 | get { return this.selectedIndex; }
22 | set
23 | {
24 | if(this.selectedIndex != value)
25 | {
26 | if (value >= Values.Length)
27 | value %= Values.Length;
28 | if (value < 0)
29 | value = Values.Length + value % Values.Length;
30 | this.selectedIndex = value;
31 | this.OnSelectedIndexChangedEvent(new ComboValueEventArgs(this.Tag, this.Value));
32 | }
33 | }
34 | }
35 | public T Value
36 | {
37 | get { return Values[this.SelectedIndex].Item2; }
38 | }
39 | #endregion
40 |
41 | #region EVENTS
42 | public class ComboValueEventArgs : EventArgs
43 | {
44 | public object Tag { get; private set; }
45 | public object Value { get; private set; }
46 | public ComboValueEventArgs(object tag, object value)
47 | {
48 | this.Tag = tag;
49 | this.Value = value;
50 | }
51 | }
52 | public event EventHandler SelectedIndexChangedEvent;
53 | protected virtual void OnSelectedIndexChangedEvent(ComboValueEventArgs e)
54 | {
55 | if (SelectedIndexChangedEvent != null)
56 | SelectedIndexChangedEvent(this, e);
57 | }
58 | #endregion
59 |
60 | #region CONSTRUCTORS
61 | public SharpDXComboValue() : base()
62 | {
63 | this.FillParent = true;
64 | this.TextAlign = TextAlignment.Center;
65 | this.MouseClickEventUp += SharpDXComboValue_MouseClickEventUp;
66 | }
67 |
68 | void SharpDXComboValue_MouseClickEventUp(object sender, MouseEventExtArgs e)
69 | {
70 | Vector2 location = this.GetAbsoluteLocation();
71 | Vector2 size = this.GetSize();
72 |
73 | Vector2 clickPoint = (Vector2)e.PosOnForm - location;
74 | if (clickPoint.X < size.X / 2f)
75 | this.SelectedIndex--;
76 | else
77 | this.SelectedIndex++;
78 | }
79 | #endregion
80 |
81 | #region METHODS
82 | public override void Draw(SharpDXRenderer renderer)
83 | {
84 |
85 | Vector2 location = this.GetAbsoluteLocation();
86 | Vector2 size = this.GetSize();
87 |
88 | if (this.MouseOver)
89 | renderer.FillRectangle(this.BackColor,
90 | new Vector2(location.X - MarginLeft, location.Y - MarginTop),
91 | new Vector2(size.X + MarginLeft + MarginRight, size.Y + MarginTop + MarginBottom));
92 |
93 | renderer.DrawRectangle(this.ForeColor,
94 | new Vector2(location.X - MarginLeft, location.Y - MarginTop),
95 | new Vector2(size.X + MarginLeft + MarginRight, size.Y + MarginTop + MarginBottom));
96 |
97 | float fontSize = (float)Math.Ceiling(this.Font.FontSize);
98 | string display = string.Format("{0}: {1}", this.Text, this.Values != null ? this.Values[this.SelectedIndex].Item1 : "");
99 | Vector2 textSize = renderer.MeasureString(display, this.Font);
100 | Vector2 textLocation = location;
101 | this.Height = textSize.Y;
102 | switch (this.TextAlign)
103 | {
104 | case TextAlignment.Center:
105 | textLocation.X += this.Width / 2f - textSize.X / 2f;
106 | break;
107 | case TextAlignment.Right:
108 | textLocation.X += this.Width - textSize.X;
109 | break;
110 | }
111 | renderer.DrawText(display,
112 | this.ForeColor,
113 | this.Font,
114 | new Vector2(textLocation.X + MarginLeft, textLocation.Y));
115 |
116 | renderer.DrawText("<", this.ForeColor, this.Font, location);
117 | textSize = renderer.MeasureString(">", this.Font);
118 | textLocation = location + Vector2.UnitX * size.X - Vector2.UnitX * textSize.X;
119 | renderer.DrawText(">", this.ForeColor, this.Font, textLocation);
120 | base.Draw(renderer);
121 | }
122 |
123 | public override void ApplySettings(ConfigUtils config)
124 | {
125 | if (this.Tag != null)
126 | {
127 | if (config.HasKey(this.Tag.ToString()))
128 | {
129 | T value = config.GetValue(this.Tag.ToString());
130 | for (int i = 0; i < Values.Length; i++)
131 | {
132 | if (Values[i].Item2.Equals(value))
133 | {
134 | this.SelectedIndex = i;
135 | break;
136 | }
137 | }
138 | }
139 | }
140 | }
141 | #endregion
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXControl.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using SharpDX.DirectWrite;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using ExternalUtilsCSharp.InputUtils;
9 |
10 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
11 | {
12 | public abstract class SharpDXControl : ExternalUtilsCSharp.UI.Control
13 | {
14 | #region PROPERTIES
15 | ///
16 | /// Whether to draw the border of this control
17 | ///
18 | public bool DrawBorder { get; set; }
19 | ///
20 | /// Whether to draw the background of this control
21 | ///
22 | public bool DrawBackground { get; set; }
23 | #endregion
24 |
25 | #region CONSTRUCTOR
26 | public SharpDXControl()
27 | {
28 | this.ForeColor = new Color(0.2f, 0.2f, 0.2f, 0.8f);
29 | this.BackColor = new Color(0.8f, 0.8f, 0.8f, 0.9f);
30 | this.MarginBottom = 2f;
31 | this.MarginLeft = 2f;
32 | this.MarginRight = 2f;
33 | this.MarginTop = 2f;
34 | this.DrawBackground = true;
35 | this.DrawBorder = true;
36 | }
37 | #endregion
38 | #region METHODS
39 | public override bool CheckMouseOver(Vector2 cursorPoint)
40 | {
41 | Vector2 location = this.GetAbsoluteLocation();
42 | return
43 | cursorPoint.X >= location.X && cursorPoint.X <= location.X + this.Width &&
44 | cursorPoint.Y >= location.Y && cursorPoint.Y <= location.Y + this.Height;
45 | }
46 |
47 | public override Vector2 GetAbsoluteLocation()
48 | {
49 | if (this.Parent == null)
50 | return new Vector2(this.X, this.Y);
51 | else
52 | return this.Parent.GetAbsoluteLocation() + new Vector2(this.X, this.Y);
53 | }
54 |
55 | public override void Update(double secondsElapsed, InputUtilities keyUtils, Vector2 cursorPoint, bool checkMouse = false)
56 | {
57 | //if (this.FillParent && this.Parent != null)
58 | // this.Width = Parent.Width - Parent.MarginLeft - Parent.MarginRight - this.MarginLeft - this.MarginRight;
59 | base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse);
60 | }
61 |
62 | public override Vector2 GetSize()
63 | {
64 | return new Vector2(this.Width, this.Height);
65 | }
66 |
67 | public virtual void ApplySettings(ConfigUtils config)
68 | { }
69 | #endregion
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXCursor.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using ExternalUtilsCSharp.InputUtils;
8 |
9 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
10 | {
11 | public class SharpDXCursor : SharpDXControl
12 | {
13 | #region PROPERTIES
14 | private Vector2 LastCursorPoint { get; set; }
15 | public float Angle { get; set; }
16 | public float AngleRotation { get; set; }
17 | #endregion
18 |
19 | #region CONSTRUCTORS
20 | public SharpDXCursor() : base()
21 | {
22 | this.Angle = 36.9f;
23 | this.AngleRotation = 25.6f;
24 | this.Width = 28f;
25 | this.LastCursorPoint = Vector2.Zero;
26 | }
27 | #endregion
28 |
29 | public override bool CheckMouseOver(SharpDX.Vector2 cursorPoint)
30 | {
31 | return false;
32 | }
33 |
34 | public override void Update(double secondsElapsed, InputUtilities keyUtils, Vector2 cursorPoint, bool checkMouse = false)
35 | {
36 | this.LastCursorPoint = cursorPoint;
37 | base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse);
38 | }
39 |
40 | public override void Draw(SharpDXRenderer renderer)
41 | {
42 | Vector2 center = this.LastCursorPoint;
43 | Vector2 right = this.LastCursorPoint + Vector2.UnitX * this.Width;
44 | Vector2 left = SharpDXConverter.Vector2EUCtoSDX(MathUtils.RotatePoint(
45 | SharpDXConverter.Vector2SDXtoEUC(right),
46 | SharpDXConverter.Vector2SDXtoEUC(center),
47 | Angle));
48 |
49 | right = SharpDXConverter.Vector2EUCtoSDX(MathUtils.RotatePoint(
50 | SharpDXConverter.Vector2SDXtoEUC(right),
51 | SharpDXConverter.Vector2SDXtoEUC(center),
52 | AngleRotation));
53 | left = SharpDXConverter.Vector2EUCtoSDX(MathUtils.RotatePoint(
54 | SharpDXConverter.Vector2SDXtoEUC(left),
55 | SharpDXConverter.Vector2SDXtoEUC(center),
56 | AngleRotation));
57 |
58 | renderer.FillPolygon(this.BackColor, left, center, right);
59 | renderer.DrawPolygon(this.ForeColor, left, center, right);
60 | base.Draw(renderer);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXGraph.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
9 | {
10 | public class SharpDXGraph : SharpDXControl
11 | {
12 | #region VARIABLES
13 | private long minimum, maximum, numberofvalues;
14 | #endregion
15 |
16 | #region PROPERTIES
17 | public long NumberOfValues
18 | {
19 | get { return numberofvalues; }
20 | set
21 | {
22 | if (numberofvalues != value)
23 | {
24 | numberofvalues = value;
25 | long[] newValues = new long[numberofvalues];
26 | if (this.Values == null)
27 | this.Values = newValues;
28 | else if (this.Values.Length > newValues.Length)
29 | Array.Copy(this.Values, 0, newValues, 0, newValues.Length);
30 | else if (this.Values.Length < newValues.Length)
31 | Array.Copy(this.Values, 0, newValues, 0, this.Values.Length);
32 |
33 | this.Values = newValues;
34 | }
35 | }
36 | }
37 | public long Minimum
38 | {
39 | get { return minimum; }
40 | set
41 | {
42 | if(minimum != value)
43 | {
44 | minimum = value;
45 | this.Values = this.Values.Select(x => x < minimum ? minimum : x).ToArray();
46 | }
47 | }
48 | }
49 | public long Maximum
50 | {
51 | get { return maximum; }
52 | set
53 | {
54 | if (maximum != value)
55 | {
56 | maximum = value;
57 | this.Values = this.Values.Select(x => x > maximum ? maximum : x).ToArray();
58 | }
59 | }
60 | }
61 | public bool DynamicMaximum { get; set; }
62 | public long LastValue { get; set; }
63 | private long[] Values { get; set; }
64 | #endregion
65 |
66 | #region CONSTRUCTOR
67 | public SharpDXGraph(): base()
68 | {
69 | this.NumberOfValues = 100;
70 | this.Minimum = 0;
71 | this.Maximum = 100;
72 | this.DynamicMaximum = false;
73 | }
74 | #endregion
75 |
76 | #region METHODS
77 | public void AddValue(long value)
78 | {
79 | long nextValue = value - LastValue;
80 | LastValue = value;
81 |
82 | long[] newValues = new long[NumberOfValues];
83 | Array.Copy(Values, 1, newValues, 0, NumberOfValues - 1);
84 | newValues[newValues.Length - 1] = nextValue;
85 |
86 | this.Values = newValues;
87 | }
88 |
89 | public override void Draw(SharpDXRenderer renderer)
90 | {
91 | Vector2 location = this.GetAbsoluteLocation();
92 | Vector2 size = this.GetSize();
93 |
94 | renderer.FillRectangle(this.BackColor, location, size);
95 | renderer.DrawRectangle(this.ForeColor, location, size);
96 |
97 | Vector2[] points = new Vector2[NumberOfValues];
98 | long max = DynamicMaximum ? this.Values.Max() : this.Maximum;
99 | for (int i = 0; i < points.Length; i++)
100 | {
101 | points[i] = location + new Vector2(this.Width / (points.Length - 1) * i, this.Height - (this.Height - this.MarginTop - this.MarginBottom) / max * this.Values[i]);
102 | }
103 | renderer.DrawLines(this.ForeColor, points);
104 |
105 | string maxString = MiscUtils.GetUnitFromSize(max, true);
106 | Vector2 maxSize = renderer.MeasureString(maxString, this.Font);
107 | Vector2 maxLocation = location + new Vector2(this.Width - maxSize.X, 0);
108 | renderer.DrawText(maxString, this.ForeColor, this.Font, maxLocation);
109 | renderer.DrawText(this.Text, this.ForeColor, this.Font, location);
110 | base.Draw(renderer);
111 | }
112 | #endregion
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXLabel.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
9 | {
10 | ///
11 | /// A label displaying text
12 | ///
13 | public class SharpDXLabel : SharpDXControl
14 | {
15 | #region PROPERTIES
16 | public bool FixedWidth { get; set; }
17 | #endregion
18 |
19 | #region CONSTRUCTOR
20 | public SharpDXLabel()
21 | : base()
22 | {
23 | this.Text = "";
24 | this.FixedWidth = false;
25 | this.TextAlign = SharpDXLabel.TextAlignment.Left;
26 | }
27 | #endregion
28 |
29 | #region METHODS
30 | public override void Draw(SharpDXRenderer renderer)
31 | {
32 | base.Draw(renderer);
33 | float fontSize = (float)Math.Ceiling(this.Font.FontSize);
34 | Vector2 size = renderer.MeasureString(this.Text, this.Font);
35 | if (!this.FillParent && !this.FixedWidth)
36 | this.Width = size.X;
37 | this.Height = size.Y;
38 | Vector2 location = this.GetAbsoluteLocation();
39 | switch (this.TextAlign)
40 | {
41 | case TextAlignment.Center:
42 | location.X += this.Width / 2f - size.X / 2f;
43 | break;
44 | case TextAlignment.Right:
45 | location.X += this.Width - size.X;
46 | break;
47 | }
48 | renderer.DrawText(this.Text,
49 | this.ForeColor,
50 | this.Font,
51 | new Vector2(location.X + MarginLeft, location.Y));
52 | }
53 | #endregion
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXPanel.cs:
--------------------------------------------------------------------------------
1 | using ExternalUtilsCSharp.SharpDXRenderer.Controls.Layouts;
2 | using ExternalUtilsCSharp.UI;
3 | using SharpDX;
4 | using SharpDX.DirectWrite;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using ExternalUtilsCSharp.InputUtils;
11 |
12 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
13 | {
14 | ///
15 | /// A panel which repositions its childcontrols in the order they were added
16 | ///
17 | public class SharpDXPanel : SharpDXControl
18 | {
19 | #region PROPERTIES
20 | ///
21 | /// Whether this panel tightly wraps around its childcontrols or has a fixed width
22 | ///
23 | public bool DynamicWidth { get; set; }
24 | ///
25 | /// Whether this panel tightly wraps around its childcontrols or has a fixed height
26 | ///
27 | public bool DynamicHeight { get; set; }
28 | ///
29 | /// The layout used to automatically relocating childcontrols
30 | ///
31 | public Layout ContentLayout { get; set; }
32 | #endregion
33 |
34 | #region CONSTUCTOR
35 | public SharpDXPanel()
36 | : base()
37 | {
38 | this.DynamicWidth = true;
39 | this.DynamicHeight = true;
40 | this.BackColor = new Color(0.9f, 0.9f, 0.9f, 1f);
41 | this.ContentLayout = LinearLayout.Instance;
42 | this.FontChangedEvent += SharpDXPanel_FontChangedEvent;
43 | }
44 |
45 | void SharpDXPanel_FontChangedEvent(object sender, EventArgs e)
46 | {
47 | foreach (SharpDXControl control in this.ChildControls)
48 | control.Font = this.Font;
49 | }
50 | #endregion
51 |
52 | #region METHODS
53 | public override void Update(double secondsElapsed, InputUtilities keyUtils, SharpDX.Vector2 cursorPoint, bool checkMouse = false)
54 | {
55 | base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse);
56 | if (this.Visible)
57 | {
58 | this.ContentLayout.ApplyLayout(this);
59 | float width = 0, height = 0;
60 | Control lastControl = null;
61 |
62 | for (int i = 0; i < this.ChildControls.Count; i++)
63 | {
64 | var control = this.ChildControls[i];
65 | if (!control.Visible)
66 | continue;
67 |
68 | lastControl = control;
69 | if (this.DynamicWidth)
70 | if (control.Width + control.MarginLeft + control.MarginRight > width)
71 | width = control.Width + control.MarginLeft + control.MarginRight;
72 | }
73 |
74 | if (this.DynamicHeight)
75 | {
76 | if(ChildControls.Count(x=>x.Visible)>0)
77 | height = ChildControls.Where(x => x.Visible).Max(x => x.Y + x.Height);
78 | }
79 | //if (lastControl != null)
80 | // height = lastControl.Y + lastControl.Height + lastControl.MarginBottom;
81 | if (this.DynamicWidth)
82 | this.Width = width + this.MarginLeft + this.MarginRight;
83 | if (this.DynamicHeight)
84 | this.Height = height + this.MarginBottom;
85 | }
86 | else
87 | {
88 | this.Height = 0;
89 | }
90 | }
91 |
92 | public override void Draw(SharpDXRenderer renderer)
93 | {
94 | Vector2 location = this.GetAbsoluteLocation();
95 | Vector2 boxLocation = new Vector2(location.X - this.MarginLeft, location.Y - this.MarginTop);
96 | Vector2 boxSize = new Vector2(this.Width + this.MarginLeft + this.MarginRight, this.Height + this.MarginBottom + this.MarginTop);
97 | if(this.DrawBackground)
98 | renderer.FillRectangle(this.BackColor,
99 | boxLocation,
100 | boxSize);
101 | if(this.DrawBackground)
102 | renderer.DrawRectangle(this.ForeColor,
103 | boxLocation,
104 | boxSize);
105 | base.Draw(renderer);
106 | }
107 |
108 | public void InsertSpacer()
109 | {
110 | this.AddChildControl(new SharpDXSpacer());
111 | }
112 |
113 | public override void ApplySettings(ConfigUtils config)
114 | {
115 | base.ApplySettings(config);
116 | foreach (SharpDXControl control in ChildControls)
117 | control.ApplySettings(config);
118 | }
119 | #endregion
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXProgressBar.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
9 | {
10 | public class SharpDXProgressBar : SharpDXControl
11 | {
12 | #region Variables
13 | private float minimum, maximum, curValue;
14 | #endregion
15 |
16 | #region PROPERTIES
17 | public float Maximum
18 | {
19 | get { return maximum; }
20 | set
21 | {
22 | if (value > Minimum)
23 | {
24 | maximum = value;
25 | if (Value > Maximum)
26 | curValue = Maximum;
27 | }
28 | }
29 | }
30 | public float Minimum
31 | {
32 | get { return minimum; }
33 | set
34 | {
35 | if(value < Maximum)
36 | {
37 | minimum = value;
38 | if (Value < Minimum)
39 | curValue = Minimum;
40 | }
41 | }
42 | }
43 | public float Value
44 | {
45 | get { return curValue; }
46 | set
47 | {
48 | if (Minimum > value)
49 | curValue = Minimum;
50 | else if (Maximum < value)
51 | curValue = Maximum;
52 | else
53 | curValue = value;
54 | }
55 | }
56 | public Color FillColor { get; set; }
57 | #endregion
58 |
59 | #region CONSTRUCTOR
60 | public SharpDXProgressBar()
61 | {
62 | minimum = 0;
63 | curValue = 50;
64 | maximum = 100;
65 | this.FillColor = new Color(0.2f, 0.9f, 0.2f, 0.9f);
66 | this.Height = 14f;
67 | }
68 | #endregion
69 |
70 | #region METHODS
71 | public override void Draw(SharpDXRenderer renderer)
72 | {
73 | Vector2 location = this.GetAbsoluteLocation();
74 | Vector2 size = this.GetSize();
75 | Vector2 fillSize = new Vector2(size.X * (this.Value / this.Maximum), size.Y);
76 |
77 | renderer.FillRectangle(this.BackColor, location, size);
78 | renderer.FillRectangle(this.FillColor, location, fillSize);
79 | renderer.DrawRectangle(this.ForeColor, location, size);
80 |
81 | this.FillParent = true;
82 | base.Draw(renderer);
83 | }
84 | #endregion
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXRadar.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
9 | {
10 | public class SharpDXRadar : SharpDXControl
11 | {
12 | #region PROPERTIES
13 | public Vector2[] Enemies { get; set; }
14 | public Vector2[] Allies { get; set; }
15 | public Vector2 CenterCoordinate { get; set; }
16 | public bool Rotating { get; set; }
17 | public float Scaling { get; set; }
18 | public Color EnemiesColor { get; set; }
19 | public Color AlliesColor { get; set; }
20 | public float DotRadius { get; set; }
21 | public float RotationDegrees { get; set; }
22 | #endregion
23 |
24 | #region CONSTRUCTORS
25 | public SharpDXRadar()
26 | : base()
27 | {
28 | this.Enemies = null;
29 | this.Allies = null;
30 | this.EnemiesColor = Color.Red;
31 | this.AlliesColor = Color.Blue;
32 | this.CenterCoordinate = Vector2.Zero;
33 | this.Rotating = true;
34 | this.RotationDegrees = 0f;
35 | this.DotRadius = 4f;
36 | }
37 | #endregion
38 |
39 | #region METHODS
40 | public override void Draw(SharpDXRenderer renderer)
41 | {
42 | Vector2 location = this.GetAbsoluteLocation();
43 | Vector2 size = this.GetSize();
44 | Vector2 controlCenter = location + size / 2f;
45 | Vector2 dotSize = new Vector2(DotRadius * 2, DotRadius * 2);
46 | //Background
47 | renderer.FillRectangle(this.BackColor, location, size);
48 | renderer.DrawRectangle(this.ForeColor, location, size);
49 | //Zoom
50 | renderer.DrawText(string.Format("Zoom: {0}", Math.Round(Scaling, 4)), this.ForeColor, this.Font, location);
51 | //Grid
52 | renderer.DrawLine(this.ForeColor, location + Vector2.UnitX * size.X / 2f, location + Vector2.UnitX * size.X / 2f + Vector2.UnitY * size.Y);
53 | renderer.DrawLine(this.ForeColor, location + Vector2.UnitY * size.Y / 2f, location + Vector2.UnitY * size.Y / 2f + Vector2.UnitX * size.X);
54 | //Enemies
55 | if (Enemies != null)
56 | foreach (Vector2 coord in Enemies)
57 | DrawDot(renderer, coord, EnemiesColor, controlCenter, dotSize);
58 | //Allies
59 | if (Allies != null)
60 | foreach (Vector2 coord in Allies)
61 | DrawDot(renderer, coord, AlliesColor, controlCenter, dotSize);
62 | //Center
63 | renderer.FillEllipse(this.ForeColor, controlCenter, dotSize, true);
64 |
65 | base.Draw(renderer);
66 | }
67 |
68 | protected virtual void DrawDot(SharpDXRenderer renderer, Vector2 coordinate, Color color, Vector2 controlCenter, Vector2 dotSize)
69 | {
70 | Vector2 delta = (coordinate - CenterCoordinate) * Scaling;
71 | delta.X *= -1;
72 | if (Rotating)
73 | {
74 | delta = SharpDXConverter.Vector2EUCtoSDX(
75 | MathUtils.RotatePoint(
76 | SharpDXConverter.Vector2SDXtoEUC(delta),
77 | ExternalUtilsCSharp.MathObjects.Vector2.Zero,
78 | RotationDegrees));
79 | }
80 | if (Math.Abs(delta.X) + DotRadius > this.Width / 2f)
81 | if (delta.X > 0)
82 | delta.X = this.Width / 2f - DotRadius;
83 | else
84 | delta.X = -this.Width / 2f + DotRadius;
85 | if (Math.Abs(delta.Y) + DotRadius > this.Height / 2f)
86 | if (delta.Y > 0)
87 | delta.Y = this.Height / 2f - DotRadius;
88 | else
89 | delta.Y = -this.Height / 2f + DotRadius;
90 |
91 | renderer.FillEllipse(color, controlCenter + delta, dotSize, true);
92 | renderer.DrawEllipse(this.ForeColor, controlCenter + delta, dotSize, true);
93 | }
94 | #endregion
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXRadioButton.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 | using ExternalUtilsCSharp.InputUtils;
9 |
10 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
11 | {
12 | public class SharpDXRadioButton : SharpDXCheckable
13 | {
14 | #region PROPERTIES
15 | public string GroupName { get; set; }
16 | #endregion
17 |
18 | #region CONSTRUCTOR
19 | public SharpDXRadioButton()
20 | : base()
21 | {
22 | this.Text = "";
23 | this.FillParent = true;
24 | this.MouseClickEventUp += SharpDXRadioButton_MouseClickEventUp;
25 | this.CheckedChangedEvent += SharpDXRadioButton_CheckedChangedEvent;
26 | }
27 | #endregion
28 |
29 | #region METHODS
30 | void SharpDXRadioButton_CheckedChangedEvent(object sender, EventArgs e)
31 | {
32 | if(this.Checked && this.Parent != null)
33 | {
34 | foreach (SharpDXControl control in this.Parent.ChildControls)
35 | {
36 | if (control == this)
37 | continue;
38 | if(control is SharpDXRadioButton)
39 | {
40 | SharpDXRadioButton rdb = (SharpDXRadioButton)control;
41 | if (rdb.Checked && rdb.GroupName == this.GroupName)
42 | rdb.Checked = false;
43 | }
44 | }
45 | }
46 | }
47 |
48 | void SharpDXRadioButton_MouseClickEventUp(object sender, MouseEventExtArgs e)
49 | {
50 | if (e.Button == MouseButtons.Left && !this.Checked)
51 | {
52 | this.Checked = true;
53 | }
54 | }
55 |
56 | public override void Draw(SharpDXRenderer renderer)
57 | {
58 | base.Draw(renderer);
59 | float fontSize = (float)Math.Ceiling(this.Font.FontSize);
60 | Vector2 size = renderer.MeasureString(this.Text, this.Font);
61 | if (!this.FillParent)
62 | this.Width = size.X + fontSize;
63 | this.Height = size.Y;
64 | Vector2 location = this.GetAbsoluteLocation();
65 | Vector2 box = new Vector2(fontSize, fontSize);
66 | Vector2 boxLocation = new Vector2(location.X, location.Y + this.Height / 2f - box.Y / 2f);
67 | if (this.MouseOver)
68 | renderer.FillRectangle(this.BackColor,
69 | new Vector2(location.X - MarginLeft, location.Y - MarginTop),
70 | new Vector2(this.Width + MarginLeft + MarginRight, this.Height + MarginTop + MarginBottom));
71 |
72 | renderer.DrawEllipse(this.ForeColor, boxLocation, box);
73 |
74 | if (this.Checked)
75 | renderer.FillEllipse(this.ForeColor, boxLocation + Vector2.One * 2, box - Vector2.One * 4);
76 |
77 | renderer.DrawText(this.Text,
78 | this.ForeColor,
79 | this.Font,
80 | new Vector2(location.X + box.X + MarginLeft, location.Y));
81 | }
82 |
83 | public override void ApplySettings(ConfigUtils config)
84 | {
85 | if (this.Tag != null)
86 | if (config.HasKey(this.Tag.ToString()))
87 | this.Checked = config.GetValue(this.Tag.ToString());
88 | }
89 | #endregion
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXSpacer.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using ExternalUtilsCSharp.InputUtils;
8 |
9 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
10 | {
11 | ///
12 | /// Serves as a spacer between controls in a container (like a panel)
13 | ///
14 | public class SharpDXSpacer : SharpDXControl
15 | {
16 | public SharpDXSpacer() : base()
17 | {
18 | this.Height = 2f;
19 | }
20 | public override void Draw(SharpDXRenderer renderer)
21 | {
22 | renderer.FillRectangle(
23 | this.ForeColor,
24 | this.GetAbsoluteLocation(),
25 | this.GetSize());
26 | base.Draw(renderer);
27 | }
28 |
29 | public override void Update(double secondsElapsed, InputUtilities keyUtils, SharpDX.Vector2 cursorPoint, bool checkMouse = false)
30 | {
31 | if (this.Parent != null)
32 | this.Width = Parent.Width - this.MarginLeft - this.MarginRight - Parent.MarginLeft - Parent.MarginRight;
33 | base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXTabControl.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 | using ExternalUtilsCSharp.InputUtils;
9 |
10 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
11 | {
12 | public class SharpDXTabControl : SharpDXPanel
13 | {
14 | #region VARIABLES
15 | private int selectedIndex;
16 | #endregion
17 |
18 | #region PROPERTIES
19 | public float MinimumHeaderWidth { get; set; }
20 | private RectangleF[] TabHeaders { get; set; }
21 | public int SelectedIndex
22 | {
23 | get { return this.selectedIndex; }
24 | set
25 | {
26 | if (this.selectedIndex != value && value >= 0 && value < ChildControls.Count)
27 | {
28 | foreach (SharpDXControl panel in ChildControls)
29 | panel.Visible = false;
30 | this.selectedIndex = value;
31 | ChildControls[this.selectedIndex].Visible = true;
32 | }
33 | }
34 | }
35 | #endregion
36 |
37 | #region CONSTRUCTORS
38 | public SharpDXTabControl() : base()
39 | {
40 | this.MouseClickEventUp += SharpDXTabControl_MouseClickEventUp;
41 | this.FontChangedEvent += SharpDXTabControl_FontChangedEvent;
42 | this.MinimumHeaderWidth = 50f;
43 | }
44 |
45 | void SharpDXTabControl_FontChangedEvent(object sender, EventArgs e)
46 | {
47 | foreach (SharpDXControl control in this.ChildControls)
48 | control.Font = this.Font;
49 | }
50 | #endregion
51 |
52 | #region METHODS
53 |
54 | void SharpDXTabControl_MouseClickEventUp(object sender, MouseEventExtArgs e)
55 | {
56 | if (e.Button != MouseButtons.Left)
57 | return;
58 | if (TabHeaders == null)
59 | return;
60 |
61 | Vector2 cursorPoint = (Vector2)e.PosOnForm - this.GetAbsoluteLocation();
62 | RectangleF cursor = new RectangleF(cursorPoint.X, cursorPoint.Y, 1, 1);
63 | for(int i = 0; i < TabHeaders.Length; i++)
64 | {
65 | if (TabHeaders[i].Intersects(cursor))
66 | {
67 | this.SelectedIndex = i;
68 | break;
69 | }
70 | }
71 | }
72 | public override void Update(double secondsElapsed, InputUtilities inputUtils, SharpDX.Vector2 cursorPoint, bool checkMouse = false)
73 | {
74 | base.Update(secondsElapsed, inputUtils, cursorPoint, checkMouse);
75 | if (TabHeaders == null)
76 | return;
77 |
78 | float maxHeight = TabHeaders.Max(x => x.Height);
79 | this.Height = ChildControls[this.SelectedIndex].Height + maxHeight;
80 | this.ChildControls[this.SelectedIndex].Y = maxHeight;
81 | this.Width = TabHeaders[TabHeaders.Length - 1].X + TabHeaders[TabHeaders.Length - 1].Width;
82 | }
83 |
84 | public override void Draw(SharpDXRenderer renderer)
85 | {
86 | base.Draw(renderer);
87 |
88 | if (this.ChildControls.Count == 0)
89 | return;
90 |
91 | TabHeaders = new RectangleF[ChildControls.Count];
92 | int idx = 0;
93 | Vector2 location = this.GetAbsoluteLocation();
94 |
95 | foreach (SharpDXControl panel in ChildControls)
96 | {
97 | Vector2 size = renderer.MeasureString(panel.Text, this.Font);
98 | if (idx == 0)
99 | TabHeaders[idx] = new RectangleF(0, 0, (float)Math.Max(MinimumHeaderWidth, size.X + this.MarginLeft + this.MarginRight), size.Y);
100 | else
101 | TabHeaders[idx] = new RectangleF(TabHeaders[idx - 1].X + TabHeaders[idx - 1].Width, TabHeaders[idx - 1].Y, (float)Math.Max(MinimumHeaderWidth, size.X + this.MarginLeft + this.MarginRight), size.Y);
102 |
103 | Vector2 tabLocation = location + new Vector2(TabHeaders[idx].X, TabHeaders[idx].Y);
104 |
105 | renderer.FillRectangle(this.BackColor, tabLocation, new Vector2(TabHeaders[idx].Width, TabHeaders[idx].Height));
106 |
107 | if (this.SelectedIndex == idx)
108 | renderer.FillRectangle(this.ForeColor * 0.1f, tabLocation, new Vector2(TabHeaders[idx].Width, TabHeaders[idx].Height));
109 |
110 | renderer.DrawRectangle(this.ForeColor, tabLocation, new Vector2(TabHeaders[idx].Width, TabHeaders[idx].Height));
111 | renderer.DrawText(panel.Text, this.ForeColor, this.Font, tabLocation + Vector2.UnitX * this.MarginLeft);
112 | idx++;
113 | }
114 | }
115 |
116 | public override void AddChildControl(UI.Control control)
117 | {
118 | base.AddChildControl(control);
119 | control.Visible = this.SelectedIndex == this.ChildControls.IndexOf(control);
120 | }
121 | #endregion
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Controls/SharpDXWindow.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 | using ExternalUtilsCSharp.InputUtils;
9 |
10 | namespace ExternalUtilsCSharp.SharpDXRenderer.Controls
11 | {
12 | public class SharpDXWindow : SharpDXPanel
13 | {
14 | #region VARIABLES
15 | private bool mouseDown;
16 | #endregion
17 |
18 | #region PROPERTIES
19 | public Vector2 TitleBarSize { get; set; }
20 | public SharpDXLabel Caption { get; set; }
21 | public SharpDXPanel Panel { get; set; }
22 | #endregion
23 |
24 | #region CONSTRUCTORS
25 | public SharpDXWindow() : base()
26 | {
27 | this.Caption = new SharpDXLabel();
28 | this.Panel = new SharpDXPanel();
29 | this.Panel.DrawBackground = false;
30 | this.Panel.DrawBorder = false;
31 | this.mouseDown = false;
32 | //this.DynamicHeight = false;
33 | //this.DynamicWidth = false;
34 |
35 | this.AddChildControl(this.Caption);
36 | this.AddChildControl(this.Panel);
37 |
38 | this.MouseClickEventUp += SharpDXWindow_MouseClickEventUp;
39 | this.MouseClickEventDown += SharpDXWindow_MouseClickEventDown;
40 | this.MouseLeftEvent += SharpDXWindow_MouseLeftEvent;
41 | this.MouseMovedEvent += SharpDXWindow_MouseMovedEvent;
42 | this.TextChangedEvent += SharpDXWindow_TextChangedEvent;
43 | }
44 |
45 | void SharpDXWindow_TextChangedEvent(object sender, EventArgs e)
46 | {
47 | this.Caption.Text = this.Text;
48 | }
49 | #endregion
50 |
51 | #region METHODS
52 | public override void Draw(SharpDXRenderer renderer)
53 | {
54 | Vector2 location = this.GetAbsoluteLocation();
55 |
56 | Vector2 boxLocation = new Vector2(location.X - this.MarginLeft, location.Y - this.MarginTop);
57 | Vector2 boxSize = new Vector2(this.Width + this.MarginLeft + this.MarginRight, this.Height + this.MarginBottom + this.MarginTop);
58 | renderer.FillRectangle(this.BackColor,
59 | boxLocation,
60 | boxSize);
61 | renderer.DrawRectangle(this.ForeColor,
62 | boxLocation,
63 | boxSize);
64 |
65 | Vector2 textLocation = location + Vector2.UnitX * this.MarginLeft * 2 + Vector2.UnitY * this.MarginTop;
66 | Vector2 textSize = renderer.MeasureString(this.Text, this.Font);
67 | renderer.DrawText(this.Text, this.ForeColor, this.Font, textLocation);
68 |
69 | Vector2 spacerLocation = location + Vector2.UnitY * textSize.Y + this.MarginTop * 3 * Vector2.UnitY - Vector2.UnitY * this.MarginLeft;
70 | Vector2 spacerSize = new Vector2(this.Width, 2f);
71 | renderer.FillRectangle(this.ForeColor, spacerLocation, spacerSize);
72 |
73 | base.Draw(renderer);
74 | }
75 |
76 | void SharpDXWindow_MouseMovedEvent(object sender, MouseEventExtArgs e)
77 | {
78 | if (mouseDown)
79 | {
80 | var lastpos = (Vector2)e.PosOnForm;
81 | Vector2 offset = new Vector2(lastpos.X - this.LastMousePos.X, lastpos.Y - this.LastMousePos.Y);
82 | this.X += offset.X;
83 | this.Y += offset.Y;
84 | }
85 | }
86 |
87 | void SharpDXWindow_MouseLeftEvent(object sender, EventArgs e)
88 | {
89 | mouseDown = false;
90 | }
91 |
92 | void SharpDXWindow_MouseClickEventDown(object sender, MouseEventExtArgs e)
93 | {
94 | if (e.Button == MouseButtons.Left)
95 | mouseDown = true;
96 | }
97 |
98 | void SharpDXWindow_MouseClickEventUp(object sender, MouseEventExtArgs e)
99 | {
100 | if (e.Button == MouseButtons.Left)
101 | mouseDown = false;
102 | }
103 |
104 | public override void Update(double secondsElapsed, InputUtilities keyUtils, Vector2 cursorPoint, bool checkMouse = false)
105 | {
106 | base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse);
107 | }
108 | #endregion
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/ExternalUtilsCSharp.SharpDXRenderer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {C6C9429E-9AAD-4497-B589-A4C58B98EFA5}
8 | Library
9 | Properties
10 | ExternalUtilsCSharp.SharpDXRenderer
11 | ExternalUtilsCSharp.SharpDXRenderer
12 | v4.5
13 | 512
14 | c637f8aa
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | False
36 | $(SharpDXPackageBinDir)\SharpDX.dll
37 |
38 |
39 | False
40 | $(SharpDXPackageBinDir)\SharpDX.Direct2D1.dll
41 |
42 |
43 | False
44 | $(SharpDXPackageBinDir)\SharpDX.DXGI.dll
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | Form
85 |
86 |
87 |
88 |
89 |
90 |
91 | {e294e4f8-de32-42c1-8bfd-a3e488ec5820}
92 | ExternalUtilsCSharp
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
105 |
106 |
107 |
108 |
115 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ExternalUtilsCSharp.SharpDXRenderer")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ExternalUtilsCSharp.SharpDXRenderer")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("77430f14-6f2e-4dee-8d63-723b3b116965")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/SharpDXConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ExternalUtilsCSharp;
7 |
8 | namespace ExternalUtilsCSharp.SharpDXRenderer
9 | {
10 | ///
11 | /// Converting SharpDX Vector to/from ExternalUtilsCS Vector
12 | ///
13 | public static class SharpDXConverter
14 | {
15 | public static MathObjects.Vector2 Vector2SDXtoEUC(this SharpDX.Vector2 vec)
16 | {
17 | return new MathObjects.Vector2(vec.X, vec.Y);
18 | }
19 | public static SharpDX.Vector2 Vector2EUCtoSDX(this MathObjects.Vector2 vec)
20 | {
21 | return new SharpDX.Vector2(vec.X, vec.Y);
22 | }
23 | public static MathObjects.Vector3 Vector3SDXtoEUC(this SharpDX.Vector3 vec)
24 | {
25 | return new MathObjects.Vector3(vec.X, vec.Y, vec.Z);
26 | }
27 | public static SharpDX.Vector3 Vector3EUCtoSDX(this MathObjects.Vector3 vec)
28 | {
29 | return new SharpDX.Vector3(vec.X, vec.Y, vec.Z);
30 | }
31 |
32 |
33 | public static MathObjects.Vector2[] Vector2SDXtoEUC(this SharpDX.Vector2[] vec)
34 | {
35 | MathObjects.Vector2[] vecs = new MathObjects.Vector2[vec.Length];
36 | for (int i = 0; i < vecs.Length; i++)
37 | vecs[i] = Vector2SDXtoEUC(vec[i]);
38 | return vecs;
39 | }
40 | public static SharpDX.Vector2[] Vector2EUCtoSDX(this MathObjects.Vector2[] vec)
41 | {
42 | SharpDX.Vector2[] vecs = new SharpDX.Vector2[vec.Length];
43 | for (int i = 0; i < vecs.Length; i++)
44 | vecs[i] = Vector2EUCtoSDX(vec[i]);
45 | return vecs;
46 | }
47 | public static MathObjects.Vector3[] Vector3SDXtoEUC(this SharpDX.Vector3[] vec)
48 | {
49 | MathObjects.Vector3[] vecs = new MathObjects.Vector3[vec.Length];
50 | for (int i = 0; i < vecs.Length; i++)
51 | vecs[i] = Vector3SDXtoEUC(vec[i]);
52 | return vecs;
53 | }
54 | public static SharpDX.Vector3[] Vector3EUCtoSDX(this MathObjects.Vector3[] vec)
55 | {
56 | SharpDX.Vector3[] vecs = new SharpDX.Vector3[vec.Length];
57 | for (int i = 0; i < vecs.Length; i++)
58 | vecs[i] = Vector3EUCtoSDX(vec[i]);
59 | return vecs;
60 | }
61 |
62 | public static SharpDX.Color ColorEUCtoSDX(UI.UIObjects.Color color)
63 | {
64 | return new SharpDX.Color(color.R, color.G, color.B, color.A);
65 | }
66 |
67 | public static UI.UIObjects.Color ColorSDXtoDSX(SharpDX.Color color)
68 | {
69 | return new UI.UIObjects.Color(color.R, color.G, color.B, color.A);
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/SharpDXOverlay.cs:
--------------------------------------------------------------------------------
1 | using SharpDX;
2 | using SharpDX.DirectWrite;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.ComponentModel;
6 | using System.Linq;
7 | using System.Runtime.InteropServices;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using ExternalUtilsCSharp.InputUtils;
11 |
12 | namespace ExternalUtilsCSharp.SharpDXRenderer
13 | {
14 | ///
15 | /// An implementation of the abstract Overlay-class utilizing SharpDX
16 | ///
17 | public class SharpDXOverlay : ExternalUtilsCSharp.UI.Overlay, IDisposable
18 | {
19 | #region CONSTRUCTORS
20 | public SharpDXOverlay() : base()
21 | {
22 | this.Renderer = new SharpDXRenderer();
23 | }
24 | #endregion
25 |
26 | public override void Attach(IntPtr hWnd)
27 | {
28 | WinAPI.WINDOWINFO info = new WinAPI.WINDOWINFO();
29 | if (!WinAPI.GetWindowInfo(hWnd, ref info))
30 | throw new Win32Exception(Marshal.GetLastWin32Error());
31 |
32 | this.hWnd = hWnd;
33 | this.Renderer.InitializeDevice(this.Handle, new Vector2(info.rcClient.Right - info.rcClient.Left, info.rcClient.Bottom - info.rcClient.Top));
34 | base.Attach(hWnd);
35 | }
36 |
37 | public void ChangeHandle(IntPtr hWnd)
38 | {
39 | this.hWnd = hWnd;
40 | }
41 |
42 | public override void Detach()
43 | {
44 | base.Detach();
45 | this.Renderer.DestroyDevice();
46 | }
47 |
48 | protected override void Dispose(bool disposing)
49 | {
50 | if (!disposing)
51 | {
52 | this.Detach();
53 | base.Dispose(disposing);
54 | }
55 | }
56 |
57 | public override void OnResize()
58 | {
59 | this.Renderer.Resize(new Vector2(this.Width, this.Height));
60 | }
61 |
62 | public override void UpdateControls(double secondsElapsed, InputUtilities keys)
63 | {
64 | Vector2 cursor = new Vector2(this.CursorPosition.X, this.CursorPosition.Y);
65 | foreach (ExternalUtilsCSharp.UI.Control control in this.ChildControls)
66 | control.Update(secondsElapsed, keys, cursor, true);
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.SharpDXRenderer/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalUtilsCSharp", "ExternalUtilsCSharp\ExternalUtilsCSharp.csproj", "{E294E4F8-DE32-42C1-8BFD-A3E488EC5820}"
7 | EndProject
8 | <<<<<<< HEAD
9 | =======
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{20B2DC66-F8DC-495A-8E47-E96FB612E8C1}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSGOSample", "CSGOTriggerbot\CSGOSample.csproj", "{0C392DB2-895E-4F2A-B2A0-1D79849FC5B2}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClickerHeroes", "ClickerHeroes\ClickerHeroes.csproj", "{42E7D8B0-97A4-4E33-B98B-50EC3E1C0A88}"
15 | EndProject
16 | >>>>>>> aganonki-master
17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalUtilsCSharp.SharpDXRenderer", "ExternalUtilsCSharp.SharpDXRenderer\ExternalUtilsCSharp.SharpDXRenderer.csproj", "{C6C9429E-9AAD-4497-B589-A4C58B98EFA5}"
18 | EndProject
19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalUtilsCSharp.JSONConfigUtils", "ExternalUtilsCSharp.JSONConfigUtils\ExternalUtilsCSharp.JSONConfigUtils.csproj", "{1E5DD6A0-A8A2-494B-A84E-9170C89A78AA}"
20 | EndProject
21 | <<<<<<< HEAD
22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalUtilsCSharp.Injection", "ExternalUtilsCSharp.Injection\ExternalUtilsCSharp.Injection.csproj", "{67F6A795-871C-4B93-8C30-C00B3D6FC9FD}"
23 | =======
24 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OverlayExample", "OverlayExample\OverlayExample.csproj", "{9BFCEF41-A47E-45DD-8A89-63E096658817}"
25 | >>>>>>> aganonki-master
26 | EndProject
27 | Global
28 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
29 | Debug|Any CPU = Debug|Any CPU
30 | Release|Any CPU = Release|Any CPU
31 | EndGlobalSection
32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
33 | {E294E4F8-DE32-42C1-8BFD-A3E488EC5820}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {E294E4F8-DE32-42C1-8BFD-A3E488EC5820}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {E294E4F8-DE32-42C1-8BFD-A3E488EC5820}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {E294E4F8-DE32-42C1-8BFD-A3E488EC5820}.Release|Any CPU.Build.0 = Release|Any CPU
37 | <<<<<<< HEAD
38 | {E294E4F8-DE32-42C1-8BFD-A3E488EC5820}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
39 | {E294E4F8-DE32-42C1-8BFD-A3E488EC5820}.Release|Mixed Platforms.Build.0 = Release|Any CPU
40 | {E294E4F8-DE32-42C1-8BFD-A3E488EC5820}.Release|Win32.ActiveCfg = Release|Any CPU
41 | =======
42 | {0C392DB2-895E-4F2A-B2A0-1D79849FC5B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {0C392DB2-895E-4F2A-B2A0-1D79849FC5B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {0C392DB2-895E-4F2A-B2A0-1D79849FC5B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {0C392DB2-895E-4F2A-B2A0-1D79849FC5B2}.Release|Any CPU.Build.0 = Release|Any CPU
46 | {42E7D8B0-97A4-4E33-B98B-50EC3E1C0A88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 | {42E7D8B0-97A4-4E33-B98B-50EC3E1C0A88}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 | {42E7D8B0-97A4-4E33-B98B-50EC3E1C0A88}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {42E7D8B0-97A4-4E33-B98B-50EC3E1C0A88}.Release|Any CPU.Build.0 = Release|Any CPU
50 | >>>>>>> aganonki-master
51 | {C6C9429E-9AAD-4497-B589-A4C58B98EFA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52 | {C6C9429E-9AAD-4497-B589-A4C58B98EFA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
53 | {C6C9429E-9AAD-4497-B589-A4C58B98EFA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
54 | {C6C9429E-9AAD-4497-B589-A4C58B98EFA5}.Release|Any CPU.Build.0 = Release|Any CPU
55 | <<<<<<< HEAD
56 | {C6C9429E-9AAD-4497-B589-A4C58B98EFA5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
57 | {C6C9429E-9AAD-4497-B589-A4C58B98EFA5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
58 | {C6C9429E-9AAD-4497-B589-A4C58B98EFA5}.Release|Win32.ActiveCfg = Release|Any CPU
59 | =======
60 | {AC44A559-744A-4813-BA9B-63008B01355C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61 | {AC44A559-744A-4813-BA9B-63008B01355C}.Debug|Any CPU.Build.0 = Debug|Any CPU
62 | {AC44A559-744A-4813-BA9B-63008B01355C}.Release|Any CPU.ActiveCfg = Release|Any CPU
63 | {AC44A559-744A-4813-BA9B-63008B01355C}.Release|Any CPU.Build.0 = Release|Any CPU
64 | >>>>>>> aganonki-master
65 | {1E5DD6A0-A8A2-494B-A84E-9170C89A78AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66 | {1E5DD6A0-A8A2-494B-A84E-9170C89A78AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
67 | {1E5DD6A0-A8A2-494B-A84E-9170C89A78AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
68 | {1E5DD6A0-A8A2-494B-A84E-9170C89A78AA}.Release|Any CPU.Build.0 = Release|Any CPU
69 | <<<<<<< HEAD
70 | {1E5DD6A0-A8A2-494B-A84E-9170C89A78AA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
71 | {1E5DD6A0-A8A2-494B-A84E-9170C89A78AA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
72 | {1E5DD6A0-A8A2-494B-A84E-9170C89A78AA}.Release|Win32.ActiveCfg = Release|Any CPU
73 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
74 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
75 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
76 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
77 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}.Debug|Win32.ActiveCfg = Debug|Any CPU
78 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
79 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}.Release|Any CPU.Build.0 = Release|Any CPU
80 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
81 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
82 | {67F6A795-871C-4B93-8C30-C00B3D6FC9FD}.Release|Win32.ActiveCfg = Release|Any CPU
83 | =======
84 | {9BFCEF41-A47E-45DD-8A89-63E096658817}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
85 | {9BFCEF41-A47E-45DD-8A89-63E096658817}.Debug|Any CPU.Build.0 = Debug|Any CPU
86 | {9BFCEF41-A47E-45DD-8A89-63E096658817}.Release|Any CPU.ActiveCfg = Release|Any CPU
87 | {9BFCEF41-A47E-45DD-8A89-63E096658817}.Release|Any CPU.Build.0 = Release|Any CPU
88 | >>>>>>> aganonki-master
89 | EndGlobalSection
90 | GlobalSection(SolutionProperties) = preSolution
91 | HideSolutionNode = FALSE
92 | EndGlobalSection
93 | <<<<<<< HEAD
94 | =======
95 | GlobalSection(NestedProjects) = preSolution
96 | {0C392DB2-895E-4F2A-B2A0-1D79849FC5B2} = {20B2DC66-F8DC-495A-8E47-E96FB612E8C1}
97 | {42E7D8B0-97A4-4E33-B98B-50EC3E1C0A88} = {20B2DC66-F8DC-495A-8E47-E96FB612E8C1}
98 | {AC44A559-744A-4813-BA9B-63008B01355C} = {20B2DC66-F8DC-495A-8E47-E96FB612E8C1}
99 | {9BFCEF41-A47E-45DD-8A89-63E096658817} = {20B2DC66-F8DC-495A-8E47-E96FB612E8C1}
100 | EndGlobalSection
101 | >>>>>>> aganonki-master
102 | EndGlobal
103 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/ConfigObjects/IniConfigUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.ConfigObjects
8 | {
9 | public class IniConfigUtils : ConfigUtils
10 | {
11 | #region CLASSES
12 | public class ReadingSettingEventArgs : EventArgs
13 | {
14 | public string Name { get; private set; }
15 | public string Value { get; private set; }
16 |
17 | public ReadingSettingEventArgs(string name, string value) : base()
18 | {
19 | this.Name = name;
20 | this.Value = value;
21 | }
22 | }
23 | #endregion
24 |
25 | #region EVENTS
26 | public event EventHandler ReadingSettingEvent;
27 | protected virtual void OnReadingSettingEvent(ReadingSettingEventArgs e)
28 | {
29 | if (ReadingSettingEvent != null)
30 | ReadingSettingEvent(this, e);
31 | }
32 | #endregion
33 |
34 | #region PROPERTIES
35 | public Encoding Encoding { get; set; }
36 | #endregion
37 |
38 | #region CONSTRUCTOR
39 | public IniConfigUtils() : base()
40 | {
41 | this.Encoding = Encoding.ASCII;
42 | }
43 | #endregion
44 |
45 | #region METHODS
46 | public override void ReadSettings(byte[] data)
47 | {
48 | string text = this.Encoding.GetString(data);
49 |
50 | //Split text into lines
51 | string[] lines = text.Contains("\r\n") ? text.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) : text.Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
52 |
53 | foreach (string line in lines)
54 | {
55 | //Trim current line
56 | string tmpLine = line.Trim();
57 | //Skip invalid ones
58 | if (tmpLine.StartsWith("#")) // comment
59 | continue;
60 | else if (!tmpLine.Contains("=")) // it's no key-value pair!
61 | continue;
62 |
63 | //Trim both parts of the key-value pair
64 | string[] parts = tmpLine.Split('=');
65 | parts[0] = parts[0].Trim();
66 | parts[1] = parts[1].Trim();
67 | if (string.IsNullOrEmpty(parts[0]) || string.IsNullOrEmpty(parts[1]))
68 | continue;
69 | if (parts[1].Contains('#')) //If value-part contains comment, split it
70 | parts[1] = parts[1].Split('#')[0];
71 | OnReadingSettingEvent(new ReadingSettingEventArgs(parts[0], parts[1]));
72 | }
73 | }
74 |
75 | public override byte[] SaveSettings()
76 | {
77 | StringBuilder builder = new StringBuilder();
78 | foreach (string key in this.GetKeys())
79 | {
80 | builder.AppendFormat("{0} = {1}\n", key, this.GetValue(key));
81 | }
82 | return this.Encoding.GetBytes(builder.ToString());
83 | }
84 | #endregion
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/ConfigUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Text;
6 |
7 | namespace ExternalUtilsCSharp
8 | {
9 | ///
10 | /// An abstract class that stores key-value pairs, ideal for holding values changed by user at runtime
11 | ///
12 | /// Reading/interpreting settings(-files) is abstract so one can decide whether to use existing formats like XML,
13 | /// JSON or INI or write a custom one.
14 | ///
15 | public abstract class ConfigUtils
16 | {
17 | #region VARIABLES
18 | protected Hashtable settingsStorage;
19 | #endregion
20 |
21 | #region CONSTRUCTOR
22 | ///
23 | /// Initializes a new ConfigUtils
24 | ///
25 | public ConfigUtils()
26 | {
27 | this.settingsStorage = new Hashtable();
28 | }
29 | #endregion
30 |
31 | #region METHODS
32 | protected ICollection GetKeys()
33 | {
34 | return settingsStorage.Keys;
35 | }
36 | ///
37 | /// Returns the value associated with the given key
38 | ///
39 | /// Type of the value
40 | /// Key of the value
41 | ///
42 | public T GetValue(string key)
43 | {
44 | if (HasKey(key))
45 | return (T)settingsStorage[key];
46 | else
47 | throw new KeyNotFoundException();
48 | }
49 | ///
50 | /// Returns the value associated with the given key
51 | ///
52 | /// Key of the value
53 | ///
54 | public Object GetValue(string key)
55 | {
56 | if (HasKey(key))
57 | return settingsStorage[key];
58 | else
59 | throw new KeyNotFoundException();
60 | }
61 | ///
62 | /// Returns whether this ConfigUtils contains the given key
63 | ///
64 | ///
65 | ///
66 | public bool HasKey(string key)
67 | {
68 | return settingsStorage.ContainsKey(key);
69 | }
70 | ///
71 | /// Sets the value of an existing key-value pair or adds a new one if it does not exist yet
72 | ///
73 | ///
74 | ///
75 | public void SetValue(string key, object value)
76 | {
77 | settingsStorage[key] = value;
78 | }
79 | ///
80 | /// Removes the given key from this ConfigUtils
81 | ///
82 | /// The key of the value
83 | /// The value associated with the given key
84 | public Object RemoveKey(string key)
85 | {
86 | if (HasKey(key))
87 | {
88 | Object obj = settingsStorage[key];
89 | settingsStorage.Remove(key);
90 | return obj;
91 | }
92 | throw new KeyNotFoundException();
93 | }
94 | ///
95 | /// Clears all key-value pairs of this ConfigUtils
96 | ///
97 | public void Clear()
98 | {
99 | settingsStorage.Clear();
100 | }
101 | ///
102 | /// Parses the given enum from string to the desired enum-type
103 | ///
104 | /// Type of the desired enum
105 | /// Value of the given enum as string
106 | /// Parsed enum
107 | protected static T ParseEnum(string value)
108 | {
109 | return (T)Enum.Parse(typeof(T), value, true);
110 | }
111 | ///
112 | /// Reads a settings-file from disk
113 | ///
114 | ///
115 | public virtual void ReadSettingsFromFile(string file)
116 | {
117 | if (File.Exists(file))
118 | ReadSettings(File.ReadAllBytes(file));
119 | else
120 | throw new FileNotFoundException("Settings-file not found", file);
121 | }
122 | ///
123 | /// Reads settings from a byte-array
124 | ///
125 | ///
126 | public abstract void ReadSettings(byte[] data);
127 | ///
128 | /// Safes all key-value pairs to disk
129 | ///
130 | ///
131 | public virtual void SaveSettingsToFile(string file)
132 | {
133 | File.WriteAllBytes(file, SaveSettings());
134 | }
135 | ///
136 | /// Saves settings to a byte-array
137 | ///
138 | ///
139 | public abstract byte[] SaveSettings();
140 | #endregion
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/ExternalUtilsCSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E294E4F8-DE32-42C1-8BFD-A3E488EC5820}
8 | Library
9 | Properties
10 | ExternalUtilsCSharp
11 | ExternalUtilsCSharp
12 | v4.5
13 | 512
14 |
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | true
25 | AnyCPU
26 | false
27 |
28 |
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | false
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | Form
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
89 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/InputUtils/InputUtilities.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.InputUtils
8 | {
9 | public class InputUtilities
10 | {
11 | public KeyUtils Keys;
12 | public MouseHook Mouse;
13 |
14 | public InputUtilities()
15 | {
16 | Init();
17 | }
18 |
19 | private void Init()
20 | {
21 | Keys = new KeyUtils();
22 | Mouse = new MouseHook();
23 | Mouse.InstallHook();
24 | }
25 | ///
26 | /// If true mouse changed since last update
27 | ///
28 | public bool MouseChanged = false;
29 |
30 | ///
31 | /// Updates keys and mouse
32 | ///
33 | public void Update()
34 | {
35 | Keys.Update();
36 | MouseChanged = Mouse.Update();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/InputUtils/MouseEventExtArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace ExternalUtilsCSharp.InputUtils
9 | {
10 | public class MouseEventExtArgs : System.Windows.Forms.MouseEventArgs
11 | {
12 | public MouseEventExtArgs()
13 | : base(MouseButtons.None, 0, 0, 0, 0)
14 | {
15 | }
16 |
17 | public MouseEventExtArgs(MouseButtons b, int clickcount, WinAPI.POINT point, int delta)
18 | : base(b, clickcount, point.X, point.Y, delta)
19 | {
20 | }
21 | public MouseEventExtArgs(MouseButtons b, int clickcount, int x, int y, int delta)
22 | : base(b, clickcount, x, y, delta)
23 | {
24 | }
25 |
26 | ///
27 | /// Used by UI to save cursor position on current form
28 | ///
29 | public object PosOnForm;
30 |
31 | ///
32 | /// If mouse wheel moved
33 | ///
34 | public bool Wheel;
35 |
36 | ///
37 | /// Used to check if button is released or pressed
38 | /// If Wheel equals true then shows which way wheel is being turned
39 | ///
40 | public UpDown UpOrDown = UpDown.None;
41 | public enum UpDown
42 | {
43 | None,
44 | Up,
45 | Down
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/JSONUtils.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace ExternalUtilsCSharp
10 | {
11 | ///
12 | /// JSON configurations helper classes
13 | /// Basicaly lets you to write any kind of object to file
14 | ///
15 |
16 | #region JsonConfigs
17 | public static class JSONConfigHelper
18 | {
19 | ///
20 | /// Creates new configuration if it does not exists
21 | ///
22 | /// path or name of config
23 | /// Object to write
24 | public static void DefaultConfig(string configName, T objToWrite)
25 | {
26 | if (File.Exists(configName)) return;
27 | JSONConfigManager.WriteFile(objToWrite, configName);
28 | }
29 | ///
30 | /// Read configuration
31 | ///
32 | public static T ReadConfiguration(string configName) where T : new()
33 | {
34 | return JSONConfigManager.ReadFile(configName);
35 | }
36 | ///
37 | /// Rewrites configuration
38 | ///
39 | public static void RewriteConfiguration( string configFileName,T configs)
40 | {
41 | JSONConfigManager.WriteFile(configs, configFileName);
42 | }
43 |
44 | }
45 | #region not static JsonConfigs
46 |
47 | ///
48 | /// Json configs helper which Deserialize Objects from file
49 | ///
50 | /// T is settings Object
51 | public class JsonConfigHelper : ConfigUtils where T : new()
52 | {
53 | public T Settings = new T();
54 | private string lastConfigName;
55 | public JsonConfigHelper() { }
56 | ///
57 | /// Created default config to specified path
58 | ///
59 | public virtual void DefaultConfig(string configName)
60 | {
61 | if (File.Exists(configName)) return;
62 | JSONConfigManager.WriteFile(Settings, configName);
63 | }
64 | ///
65 | /// Use ReadSettingsFromFile(string) method THIS one is not implemented
66 | /// since byte[] data is not required
67 | ///
68 | public override void ReadSettings(byte[] data)
69 | {
70 | throw new NotImplementedException();
71 | }
72 | ///
73 | /// Saves Setings object to latest used configuration
74 | ///
75 | /// return is not required
76 | public override byte[] SaveSettings()
77 | {
78 | JSONConfigManager.WriteFile(Settings, lastConfigName);
79 | return null;
80 | }
81 | ///
82 | /// Reads settings from file and stores it into Settings Object
83 | ///
84 | /// Path of file
85 | public override void ReadSettingsFromFile(string configName)
86 | {
87 | lastConfigName = configName;
88 | Settings = JSONConfigManager.ReadFile(configName);
89 | }
90 | ///
91 | /// Saves Settings object to specified file
92 | ///
93 | /// Path of file
94 | public override void SaveSettingsToFile(string configFileName)
95 | {
96 | lastConfigName = configFileName;
97 | JSONConfigManager.WriteFile(Settings, configFileName);
98 | }
99 |
100 | }
101 | #endregion
102 |
103 | public static class JSONConfigManager
104 | {
105 | public static T ReadFile(string filename) where T : new()
106 | {
107 | string data;
108 | try
109 | {
110 | using (
111 | var sr = new StreamReader(File.Open(filename,
112 | FileMode.Open, FileAccess.Read)))
113 | {
114 | data = sr.ReadToEnd();
115 | }
116 | var temp = JsonConvert.DeserializeObject(data);
117 | return temp;
118 | }
119 | catch (Exception e)
120 | {
121 | throw new Exception("Could not read settings\n",e);
122 | //data = null;
123 | //return new T();
124 | }
125 | }
126 | public static void WriteFile(T objToWrite, string fileName)
127 | {
128 | var temp = JsonConvert.SerializeObject(objToWrite, Formatting.Indented);
129 | using (var file = File.Open(fileName, FileMode.Create, FileAccess.Write))
130 | {
131 | using (var writer = new StreamWriter(file))
132 | {
133 | writer.Write(temp);
134 | }
135 | }
136 | }
137 | }
138 | #endregion
139 |
140 | ///
141 | /// Class for creating object clone using JSON
142 | ///
143 | public static class ObjectClone
144 | {
145 | ///
146 | /// Perform a deep Copy of the object, using Json as a serialisation method.
147 | ///
148 | /// The type of object being copied.
149 | /// The object instance to copy.
150 | /// The copied object.
151 | public static T CloneJson(this T source)
152 | {
153 | // Don't serialize a null object, simply return the default for that object
154 | if (Object.ReferenceEquals(source, null))
155 | {
156 | return default(T);
157 | }
158 |
159 | return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(source));
160 | }
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MathObjects/Matrix.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ExternalUtilsCSharp.MathObjects
6 | {
7 | ///
8 | /// A matrix.
9 | ///
10 | public class Matrix
11 | {
12 | #region VARIABLES
13 | private float[] data;
14 | private int rows, columns;
15 | #endregion
16 |
17 | #region CONSTRUCTOR
18 | public Matrix(int rows, int columns)
19 | {
20 | this.rows = rows;
21 | this.columns = columns;
22 | this.data = new float[rows * columns];
23 | }
24 | #endregion
25 |
26 | #region METHODS
27 | public void Read(byte[] data)
28 | {
29 | for (int y = 0; y < rows; y++)
30 | for (int x = 0; x < columns; x++)
31 | this[y, x] = BitConverter.ToSingle(data, sizeof(float) * ((y * columns) + x));
32 | }
33 | public byte[] ToByteArray()
34 | {
35 | int sof = sizeof(float);
36 | byte[] data = new byte[this.data.Length * sof];
37 | for (int i = 0; i < this.data.Length; i++)
38 | Array.Copy(BitConverter.GetBytes(this.data[i]), 0, data, i * sof, sof);
39 | return data;
40 | }
41 | #endregion
42 |
43 | #region OPERANDS
44 | public float this[int i]
45 | {
46 | get { return data[i]; }
47 | set { data[i] = value; }
48 | }
49 | public float this[int row, int column]
50 | {
51 | get { return data[row * columns + column]; }
52 | set { data[row * columns + column] = value; }
53 | }
54 | #endregion
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MathObjects/Vector2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ExternalUtilsCSharp.MathObjects
6 | {
7 | ///
8 | /// Class that holds information about a 2d-coordinate and offers some basic operations
9 | ///
10 | public struct Vector2
11 | {
12 | #region VARIABLES
13 | public float X;
14 | public float Y;
15 | #endregion
16 |
17 | #region PROPERTIES
18 | ///
19 | /// Returns a new Vector2 at (0,0)
20 | ///
21 | public static Vector2 Zero
22 | {
23 | get { return new Vector2(0, 0); }
24 | }
25 | ///
26 | /// Returns a new Vector3 at (1,0)
27 | ///
28 | public static Vector2 UnitX
29 | {
30 | get { return new Vector2(1, 0); }
31 | }
32 | ///
33 | /// Returns a new Vector2 at (0,1)
34 | ///
35 | public static Vector2 UnitY
36 | {
37 | get { return new Vector2(0, 1); }
38 | }
39 | #endregion
40 |
41 | #region CONSTRUCTOR
42 | ///
43 | /// Initializes a new Vector2 using the given values
44 | ///
45 | ///
46 | ///
47 | public Vector2(float x, float y)
48 | {
49 | this.X = x;
50 | this.Y = y;
51 | }
52 | ///
53 | /// Initializes a new Vector2 by copying the values of the given Vector2
54 | ///
55 | ///
56 | public Vector2(Vector2 vec) : this(vec.X, vec.Y) { }
57 | ///
58 | /// Initializes a new Vector2 using the given float-array
59 | ///
60 | ///
61 | public Vector2(float[] values) : this(values[0], values[1]) { }
62 | #endregion
63 |
64 | #region METHODS
65 | ///
66 | /// Returns the length of this Vector2
67 | ///
68 | ///
69 | public float Length()
70 | {
71 | return (float)System.Math.Sqrt(System.Math.Pow(X, 2) + System.Math.Pow(Y, 2));
72 | }
73 | ///
74 | /// Returns the distance from this Vector2 to the given Vector2
75 | ///
76 | ///
77 | ///
78 | public float DistanceTo(Vector2 other)
79 | {
80 | return (this + other).Length();
81 | }
82 |
83 | public override bool Equals(object obj)
84 | {
85 | Vector2 vec = (Vector2)obj;
86 | return this.GetHashCode() == vec.GetHashCode();
87 | }
88 |
89 | public override int GetHashCode()
90 | {
91 | return this.X.GetHashCode() ^ this.Y.GetHashCode();
92 | }
93 |
94 | public override string ToString()
95 | {
96 | return string.Format("[X={0}, Y={1}]", this.X.ToString(), this.Y.ToString());
97 | }
98 | #endregion
99 |
100 | #region OPERATORS
101 | public static Vector2 operator +(Vector2 v1, Vector2 v2)
102 | {
103 | return new Vector2(v1.X + v2.X, v1.Y + v2.Y);
104 | }
105 | public static Vector2 operator -(Vector2 v1, Vector2 v2)
106 | {
107 | return new Vector2(v1.X - v2.X, v1.Y - v2.Y);
108 | }
109 | public static Vector2 operator *(Vector2 v1, float scalar)
110 | {
111 | return new Vector2(v1.X * scalar, v1.Y * scalar);
112 | }
113 | public static bool operator ==(Vector2 v1, Vector2 v2)
114 | {
115 | return v1.X == v2.X && v1.Y == v2.Y;
116 | }
117 | public static bool operator !=(Vector2 v1, Vector2 v2)
118 | {
119 | return !(v1 == v2);
120 | }
121 | public float this[int i]
122 | {
123 | get
124 | {
125 | switch (i)
126 | {
127 | case 0:
128 | return this.X;
129 | case 1:
130 | return this.Y;
131 | default:
132 | throw new IndexOutOfRangeException();
133 | }
134 | }
135 | set
136 | {
137 | switch (i)
138 | {
139 | case 0:
140 | this.X = value;
141 | break;
142 | case 1:
143 | this.Y = value;
144 | break;
145 | default:
146 | throw new IndexOutOfRangeException();
147 | }
148 | }
149 | }
150 | #endregion
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MathObjects/Vector3.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ExternalUtilsCSharp.MathObjects
6 | {
7 | ///
8 | /// Class that holds information about a 3d-coordinate and offers some basic operations
9 | ///
10 | public struct Vector3
11 | {
12 | #region VARIABLES
13 | public float X;
14 | public float Y;
15 | public float Z;
16 | #endregion
17 |
18 | #region PROPERTIES
19 | ///
20 | /// Returns a new Vector3 at (0,0,0)
21 | ///
22 | public static Vector3 Zero
23 | {
24 | get { return new Vector3(0, 0, 0); }
25 | }
26 | ///
27 | /// Returns a new Vector3 at (1,0,0)
28 | ///
29 | public static Vector3 UnitX
30 | {
31 | get { return new Vector3(1, 0, 0); }
32 | }
33 | ///
34 | /// Returns a new Vector3 at (0,1,0)
35 | ///
36 | public static Vector3 UnitY
37 | {
38 | get { return new Vector3(0, 1, 0); }
39 | }
40 | ///
41 | /// Returns a new Vector3 at (0,0,1)
42 | ///
43 | public static Vector3 UnitZ
44 | {
45 | get { return new Vector3(0, 0, 1); }
46 | }
47 | #endregion
48 |
49 | #region CONSTRUCTOR
50 | ///
51 | /// Initializes a new Vector3 using the given values
52 | ///
53 | ///
54 | ///
55 | ///
56 | public Vector3(float x, float y, float z)
57 | {
58 | this.X = x;
59 | this.Y = y;
60 | this.Z = z;
61 | }
62 | ///
63 | /// Initializes a new Vector3 by copying the values of the given Vector3
64 | ///
65 | ///
66 | public Vector3(Vector3 vec) : this(vec.X, vec.Y, vec.Z) { }
67 | ///
68 | /// Initializes a new Vector3 using the given float-array
69 | ///
70 | ///
71 | public Vector3(float[] values) : this(values[0], values[1], values[2]) { }
72 | #endregion
73 |
74 | #region METHODS
75 | ///
76 | /// Returns the length of this Vector3
77 | ///
78 | ///
79 | public float Length()
80 | {
81 | return (float)System.Math.Abs(System.Math.Sqrt(System.Math.Pow(X, 2) + System.Math.Pow(Y, 2) + System.Math.Pow(Z, 2)));
82 | }
83 | ///
84 | /// Returns the distance from this Vector3 to the given Vector3
85 | ///
86 | ///
87 | ///
88 | public float DistanceTo(Vector3 other)
89 | {
90 | return (this - other).Length();
91 | }
92 |
93 | public override bool Equals(object obj)
94 | {
95 | Vector3 vec = (Vector3)obj;
96 | return this.GetHashCode() == vec.GetHashCode();
97 | }
98 |
99 | public override int GetHashCode()
100 | {
101 | return this.X.GetHashCode() ^ this.Y.GetHashCode() ^ this.Z.GetHashCode();
102 | }
103 |
104 | public override string ToString()
105 | {
106 | return string.Format("[X={0}, Y={1}, Z={2}]", this.X.ToString(), this.Y.ToString(), this.Z.ToString());
107 | }
108 | #endregion
109 |
110 | #region OPERATORS
111 | public static Vector3 operator +(Vector3 v1, Vector3 v2)
112 | {
113 | return new Vector3(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
114 | }
115 | public static Vector3 operator -(Vector3 v1, Vector3 v2)
116 | {
117 | return new Vector3(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
118 | }
119 | public static Vector3 operator *(Vector3 v1, float scalar)
120 | {
121 | return new Vector3(v1.X * scalar, v1.Y * scalar, v1.Z * scalar);
122 | }
123 | public static bool operator ==(Vector3 v1, Vector3 v2)
124 | {
125 | return v1.X == v2.X && v1.Y == v2.Y && v1.Z == v2.Z;
126 | }
127 | public static bool operator !=(Vector3 v1, Vector3 v2)
128 | {
129 | return !(v1 == v2);
130 | }
131 | public float this[int i]
132 | {
133 | get
134 | {
135 | switch (i)
136 | {
137 | case 0:
138 | return this.X;
139 | case 1:
140 | return this.Y;
141 | case 2:
142 | return this.Z;
143 | default:
144 | throw new IndexOutOfRangeException();
145 | }
146 | }
147 | set
148 | {
149 | switch (i)
150 | {
151 | case 0:
152 | this.X = value;
153 | break;
154 | case 1:
155 | this.Y = value;
156 | break;
157 | case 2:
158 | this.Z = value;
159 | break;
160 | default:
161 | throw new IndexOutOfRangeException();
162 | }
163 | }
164 | }
165 | #endregion
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MemObjects/PE/COFFHeader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.MemObjects.PE
9 | {
10 | ///
11 | /// Source: https://en.wikibooks.org/wiki/X86_Disassembly/Windows_Executable_Files#Code_Sections
12 | ///
13 | [StructLayout(LayoutKind.Sequential)]
14 | public struct COFFHeader
15 | {
16 | short Machine;
17 | short NumberOfSections;
18 | int TimeDateStamp;
19 | int PointerToSymbolTable;
20 | int NumberOfSymbols;
21 | short SizeOfOptionalHeader;
22 | short Characteristics;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MemObjects/PE/DOSHeader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.MemObjects.PE
9 | {
10 | ///
11 | /// Source: https://en.wikibooks.org/wiki/X86_Disassembly/Windows_Executable_Files#Code_Sections
12 | ///
13 | [StructLayout(LayoutKind.Sequential)]
14 | public unsafe struct DOSHeader
15 | {
16 | public short signature;
17 | public short lastsize;
18 | public short nblocks;
19 | public short nreloc;
20 | public short hdrsize;
21 | public short minalloc;
22 | public short maxalloc;
23 | public short ss;
24 | public short sp;
25 | public short checksum;
26 | public short ip;
27 | public short cs;
28 | public short relocpos;
29 | public short noverlay;
30 |
31 | public short reserved1;
32 | public short reserved2;
33 | public short reserved3;
34 | public short reserved4;
35 |
36 | public short oem_id;
37 | public short oem_info;
38 |
39 | public short reserved5;
40 | public short reserved6;
41 | public short reserved7;
42 | public short reserved8;
43 | public short reserved9;
44 | public short reserved10;
45 | public short reserved11;
46 | public short reserved12;
47 | public short reserved13;
48 | public short reserved14;
49 |
50 | public int e_lfanew;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MemObjects/PE/PEInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Runtime.InteropServices;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ExternalUtilsCSharp.MemObjects.PE
11 | {
12 | ///
13 | /// Parses information about a module
14 | ///
15 | public struct PEInfo
16 | {
17 | ///
18 | /// DOS-header of the module
19 | ///
20 | public DOSHeader DOSHeader;
21 |
22 | ///
23 | /// COFF-header of the module
24 | ///
25 | public COFFHeader COFFHeader;
26 |
27 | ///
28 | /// PE optional header of the module
29 | ///
30 | public PEOptHeader PEOptHeader;
31 |
32 | ///
33 | /// Address of the COFF header
34 | ///
35 | public int COFFHeaderAddress;
36 |
37 | ///
38 | /// Address of the PE optional header
39 | ///
40 | public int PEOptHeaderAddress;
41 |
42 | ///
43 | /// Initializes a new PEInfo using the given file-path
44 | ///
45 | /// Path of the module to parse
46 | public PEInfo(string path) : this(File.ReadAllBytes(path))
47 | { }
48 |
49 | ///
50 | /// Initializes a new PEInfo using the given data
51 | ///
52 | /// Byte-array containing the content of the module to parse
53 | public PEInfo(byte[] data)
54 | {
55 | MemUtils memUtils = new ExternalUtilsCSharp.MemUtils();
56 | DOSHeader = memUtils.BytesToT(data);
57 |
58 | COFFHeaderAddress = DOSHeader.e_lfanew + 4;
59 | COFFHeader = memUtils.BytesToT(data, COFFHeaderAddress);
60 |
61 | PEOptHeaderAddress = COFFHeaderAddress + Marshal.SizeOf(typeof(COFFHeader));
62 | PEOptHeader = memUtils.BytesToT(data, PEOptHeaderAddress);
63 | }
64 |
65 | ///
66 | /// Parses a module from memory
67 | ///
68 | /// The module to be parsed
69 | /// MemUtils-instance that is used to dump the module
70 | ///
71 | public static PEInfo FromMemory(ProcessModule module, MemUtils memUtils)
72 | {
73 | return FromMemory(module.BaseAddress, module.ModuleMemorySize, memUtils);
74 | }
75 |
76 | ///
77 | /// Parses a module from memory
78 | ///
79 | /// The address of the module to be parsed
80 | /// The size of the module to be parsed
81 | /// MemUtils-instance that is used to dump the module
82 | ///
83 | public static PEInfo FromMemory(IntPtr baseAddress, int length, MemUtils memUtils)
84 | {
85 | byte[] data = new byte[length];
86 | memUtils.Read(baseAddress, out data, length);
87 | return new PEInfo(data);
88 | }
89 |
90 | ///
91 | /// Reads the _IMAGE_EXPORT_DIRECTORY of this module from live memory
92 | ///
93 | /// MemUtils-instance that is used to read data
94 | /// Base-address pf this module in memory
95 | ///
96 | public _IMAGE_EXPORT_DIRECTORY ReadImageExportDirectory(MemUtils memUtils, IntPtr imageBase)
97 | {
98 | return memUtils.Read<_IMAGE_EXPORT_DIRECTORY>((IntPtr)(imageBase.ToInt64() + this.PEOptHeader.DataDirectory1.VirtualAddress));
99 | }
100 |
101 | ///
102 | /// Reads the name of this module from live-memory
103 | ///
104 | /// MemUtils-instance that is used to read data
105 | /// The _IMAGE_EXPORT_DIRECTORY of this module
106 | /// Base-address pf this module in memory
107 | ///
108 | public string ReadName(MemUtils memUtils, _IMAGE_EXPORT_DIRECTORY ied, IntPtr imageBase)
109 | {
110 | return memUtils.ReadString((IntPtr)(imageBase.ToInt64() + ied.Name), 32, Encoding.ASCII);
111 | }
112 |
113 | ///
114 | /// Reads the Export Address Table (EAT) of this module from live memory
115 | ///
116 | /// MemUtils-instance that is used to read data
117 | /// Base-address pf this module in memory
118 | ///
119 | public Tuple[] ReadExportedFunctions(MemUtils memUtils, IntPtr imageBase)
120 | {
121 | return ReadExportedFunctions(memUtils, imageBase, ReadImageExportDirectory(memUtils, imageBase));
122 | }
123 |
124 | ///
125 | /// Reads the Export Address Table (EAT) of this module from live memory
126 | ///
127 | /// MemUtils-instance that is used to read data
128 | /// Base-address pf this module in memory
129 | /// The _IMAGE_EXPORT_DIRECTORY of this module
130 | ///
131 | public Tuple[] ReadExportedFunctions(MemUtils memUtils, IntPtr imageBase, _IMAGE_EXPORT_DIRECTORY ied)
132 | {
133 | List> functions = new List>();
134 | IntPtr lpFunctions = (IntPtr)(imageBase.ToInt64() + ied.AddressOfFunctions);
135 | IntPtr lpNames = (IntPtr)(imageBase.ToInt64() + ied.AddressOfNames);
136 | for (int i = 0; i < ied.NumberOfFunctions; i++)
137 | {
138 | int address = memUtils.Read((IntPtr)(lpFunctions.ToInt64() + i * 4));
139 | string name = "?";
140 | if (lpFunctions != lpNames)
141 | {
142 | int nameAddress = memUtils.Read((IntPtr)(lpNames.ToInt64() + i * 4));
143 | name = memUtils.ReadString((IntPtr)(imageBase.ToInt64() + nameAddress), 64, Encoding.ASCII);
144 | }
145 | functions.Add(new Tuple(name, address));
146 | }
147 | return functions.ToArray();
148 | }
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MemObjects/PE/PEOptHeader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.MemObjects.PE
9 | {
10 | ///
11 | /// Source: https://en.wikibooks.org/wiki/X86_Disassembly/Windows_Executable_Files#Code_Sections
12 | ///
13 | [StructLayout(LayoutKind.Sequential)]
14 | public struct PEOptHeader
15 | {
16 | public short signature; //decimal number 267 for 32 bit, and 523 for 64 bit.
17 | public char MajorLinkerVersion;
18 | public char MinorLinkerVersion;
19 | public int SizeOfCode;
20 | public int SizeOfInitializedData;
21 | public int SizeOfUninitializedData;
22 | public int AddressOfEntryPoint; //The RVA of the code entry popublic int
23 | public int BaseOfCode;
24 | public int BaseOfData;
25 | public int ImageBase;
26 | public int SectionAlignment;
27 | public int FileAlignment;
28 | public short MajorOSVersion;
29 | public short MinorOSVersion;
30 | public short MajorImageVersion;
31 | public short MinorImageVersion;
32 | public short MajorSubsystemVersion;
33 | public short MinorSubsystemVersion;
34 | public int Reserved;
35 | public int SizeOfImage;
36 | public int SizeOfHeaders;
37 | public int Checksum;
38 | public short Subsystem;
39 | public short DLLCharacteristics;
40 | public int SizeOfStackReserve;
41 | public int SizeOfStackCommit;
42 | public int SizeOfHeapReserve;
43 | public int SizeOfHeapCommit;
44 | public int LoaderFlags;
45 | public int NumberOfRvaAndSizes;
46 | public data_directory DataDirectory1;
47 | public data_directory DataDirectory2;
48 | public data_directory DataDirectory3;
49 | public data_directory DataDirectory4;
50 | public data_directory DataDirectory5;
51 | public data_directory DataDirectory6;
52 | public data_directory DataDirectory7;
53 | public data_directory DataDirectory8;
54 | public data_directory DataDirectory9;
55 | public data_directory DataDirectory10;
56 | public data_directory DataDirectory11;
57 | public data_directory DataDirectory12;
58 | public data_directory DataDirectory13;
59 | public data_directory DataDirectory14;
60 | public data_directory DataDirectory15;
61 | public data_directory DataDirectory16;
62 | }
63 |
64 | [StructLayout(LayoutKind.Sequential)]
65 | public struct data_directory
66 | {
67 | public int VirtualAddress;
68 | public int Size;
69 | }
70 |
71 | [StructLayout(LayoutKind.Sequential)]
72 | public struct _IMAGE_EXPORT_DIRECTORY
73 | {
74 | public int Characteristics; //offset 0x0
75 | public int TimeDateStamp; //offset 0x4
76 | public short MajorVersion; //offset 0x8
77 | public short MinorVersion; //offset 0xa
78 | public int Name; //offset 0xc
79 | public int Base; //offset 0x10
80 | public int NumberOfFunctions; //offset 0x14
81 | public int NumberOfNames; //offset 0x18
82 | public int AddressOfFunctions; //offset 0x1c
83 | public int AddressOfNames; //offset 0x20
84 | public int AddressOfNameOrdinals; //offset 0x24
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MemObjects/ScanResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.MemObjects
8 | {
9 | ///
10 | /// Struct that holds basic data about the outcome of a signature-scan
11 | ///
12 | public struct ScanResult
13 | {
14 | public bool Success;
15 | public IntPtr Address;
16 | public IntPtr Base;
17 | public IntPtr Offset;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MiscObjects/CachedField.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.MiscObjects
8 | {
9 | public class CachedField where T : struct
10 | {
11 | public bool ValueRead { get; protected set; }
12 | public int Offset { get; protected set; }
13 | public T Value { get; protected set; }
14 |
15 | public CachedField()
16 | : this(0)
17 | { }
18 | public CachedField(int offset)
19 | : this(offset, default(T))
20 | { }
21 | public CachedField(int offset, T value)
22 | {
23 | this.Offset = offset;
24 | this.Value = value;
25 | this.ValueRead = false;
26 | }
27 |
28 | public virtual void ReadValue(int baseAddress, MemUtils memUtils)
29 | {
30 | this.Value = memUtils.Read((IntPtr)(baseAddress + this.Offset));
31 | this.ValueRead = true;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MiscObjects/CachedObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.MiscObjects
9 | {
10 | ///
11 | /// An abstract class meant for managing reading and holding data of an object in memory
12 | /// Utilizes a hashtable to manage reading data and cache data
13 | ///
14 | public abstract class CachedObject
15 | {
16 |
17 | #region PROPERTIES
18 | public Hashtable Fields { get; private set; }
19 | public int Address { get; protected set; }
20 | public MemUtils MemUtils { get; set; }
21 | #endregion
22 |
23 | #region CONSTRUCTORS
24 | public CachedObject(int address)
25 | {
26 | this.Address = address;
27 | this.Fields = new Hashtable();
28 | this.SetupFields();
29 | }
30 | public CachedObject()
31 | : this(0)
32 | { }
33 | #endregion
34 |
35 | #region METHODS
36 | public override string ToString()
37 | {
38 | return string.Format("[Entity Address={0}]", this.Address.ToString("X"));
39 | }
40 | #endregion
41 |
42 | #region HELPERS
43 | protected void AddField(string fieldName, int offset, T value = default(T)) where T : struct
44 | {
45 | Fields[fieldName] = new CachedField(offset, value);
46 | }
47 | ///
48 | /// Returns the value of the given field if the field has read its value before
49 | /// Makes the field read its value if it did not do so before
50 | ///
51 | ///
52 | ///
53 | ///
54 | protected T ReadFieldProxy(string fieldName) where T : struct
55 | {
56 | CachedField field = (CachedField)Fields[fieldName];
57 | if (!field.ValueRead)
58 | field.ReadValue(this.Address, this.MemUtils);
59 | return field.Value;
60 | }
61 | ///
62 | /// Copies the fields of one Entity to another one;
63 | /// Used for copy-constructors
64 | ///
65 | ///
66 | ///
67 | protected void CopyFieldsFrom(T other) where T : CachedObject
68 | {
69 | foreach (string key in other.Fields.Keys)
70 | this.Fields[key] = other.Fields[key];
71 | }
72 |
73 | protected virtual void SetupFields()
74 | { }
75 | #endregion
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/MiscUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp
8 | {
9 | public class MiscUtils
10 | {
11 | #region CONSTANTS
12 | private const string FORMAT = "{0} {1}";
13 | private static string[] NAMES_NUMBERS = new string[] { "", "Thousand", "Million", "Billion", "Trillion", "Quadrillion", "Quintillion", "Sextillion", "Septillion", "Octillion", "Nonillion" };
14 | private static string[] NAMES_NUMBERS_ABBREVIATIONS = new string[] { "", "K", "M", "B", "T" };
15 | private static string[] NAMES_SIZES = new string[] { "Byte", "Kilobyte", "Megabyte", "Gigabyte", "Terabyte", "Petabyte", "Exabyte", "Zettabyte", "Yottabyte" };
16 | private static string[] NAMES_SIZESABBREVIATIONS = new string[] { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
17 | private const long DIVIDER_NUMBERS = 1000;
18 | private const long DIVIDER_SIZES = 1024;
19 | #endregion
20 |
21 | #region METHODS
22 | ///
23 | /// Determines which unit can be assigned to a number based on the divider.
24 | /// Returns a string containing the value and the unit using the given format
25 | ///
26 | /// Value
27 | /// Divider of the units
28 | /// Array of the names of units
29 | /// Format to use, where {0} is the calculated value and {1] is the unit
30 | ///
31 | public static string GetUnit(long value, long divider, string[] units, string format = FORMAT)
32 | {
33 | int idx = 0;
34 | while (idx < units.Length && value > divider)
35 | {
36 | idx++;
37 | value /= divider;
38 | }
39 | return string.Format(format, value, units[idx]);
40 | }
41 | ///
42 | /// Shortens down the given value and appends the correct unit to it
43 | ///
44 | ///
45 | /// Whether to use abbreviations of the unit
46 | /// Format to use, where {0} is the calculated value and {1] is the unit
47 | ///
48 | public static string GetUnitFromNumber(long value, bool useAbbreviation = false, string format = FORMAT)
49 | {
50 | return GetUnit(value, DIVIDER_NUMBERS, useAbbreviation ? NAMES_NUMBERS_ABBREVIATIONS : NAMES_NUMBERS, format);
51 | }
52 | ///
53 | /// Shortens down the given value and appends the correct unit to it, representing a size
54 | ///
55 | ///
56 | /// Whether to use abbreviations of the unit
57 | /// Format to use, where {0} is the calculated value and {1] is the unit
58 | ///
59 | public static string GetUnitFromSize(long value, bool useAbbreviation = false, string format = FORMAT)
60 | {
61 | return GetUnit(value, DIVIDER_SIZES, useAbbreviation ? NAMES_SIZESABBREVIATIONS : NAMES_SIZES, format);
62 | }
63 | ///
64 | /// Merges the given arrays to one single array (preserves the order of all elements)
65 | /// Improved version written by aev1tas, about 4x faster(https://www.unknowncheats.me/forum/1264082-post81.html)
66 | ///
67 | ///
68 | /// Arrays to merge
69 | /// A single array containing all elements of the given arrays
70 | public static T[] MergeArrays(params T[][] arrays)
71 | {
72 | int totalLength = 0;
73 | for (int i = 0; i < arrays.GetLength(0); i++)
74 | totalLength += arrays[i].Length;
75 |
76 | T[] result = new T[totalLength];
77 | int idx = 0;
78 | foreach (T[] array in arrays)
79 | {
80 | Array.Copy(array, 0, result, idx, array.Length);
81 | idx += array.Length;
82 | }
83 |
84 | return result;
85 | }
86 | #endregion
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ExternalUtilsCSharp")]
9 | [assembly: AssemblyDescription("A set of utility-classes and -structs to make external gamehacking easier. Created with the help of volounteers who contributed to the github-repository!")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ExternalUtilsCSharp")]
13 | [assembly: AssemblyCopyright("Copyright © Zat 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("2956e524-941e-4d4d-ac6c-b5729f627453")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/UI/UIObjects/Color.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ExternalUtilsCSharp.UI.UIObjects
8 | {
9 | public struct Color
10 | {
11 | #region ENUMS
12 | public enum ColorFormat { ARGB, RGBA };
13 | #endregion
14 | #region PROPERTIES
15 | public byte A;
16 | public byte R;
17 | public byte G;
18 | public byte B;
19 | #endregion
20 |
21 | #region CONSTRUCTOR
22 | ///
23 | /// Initializes a color-object using the given values for its channels
24 | ///
25 | /// Value of the alpha-channel (0-255)
26 | /// Value of the red-channel (0-255)
27 | /// Value of the green-channel (0-255)
28 | /// Value of the blue-channel (0-255)
29 | public Color(byte a, byte r, byte g, byte b)
30 | {
31 | A = a;
32 | R = r;
33 | G = g;
34 | B = b;
35 | }
36 | ///
37 | /// Initializes a color-object using the given values for its channels
38 | ///
39 | /// Value of the alpha-channel (0-1)
40 | /// Value of the red-channel (0-1)
41 | /// Value of the green-channel (0-1)
42 | /// Value of the blue-channel (0-1)
43 | public Color(float a, float r, float g, float b) : this((byte)(255f * a), (byte)(255f * r), (byte)(255f * g), (byte)(255f * b))
44 | { }
45 | public static Color FromFormat(uint color, ColorFormat format)
46 | {
47 | switch(format)
48 | {
49 | case ColorFormat.ARGB:
50 | return new Color((byte)(color >> 24), (byte)(color >> 16), (byte)(color >> 8), (byte)(color));
51 | case ColorFormat.RGBA:
52 | return new Color((byte)(color & 0xFF), (byte)((color & 0xFF000000) >> 24), (byte)((color & 0x00FF0000) >> 16), (byte)((color & 0x0000FF00) >> 8));
53 | default:
54 | throw new ArgumentException();
55 | }
56 | }
57 | #endregion
58 |
59 | #region METHODS
60 | public uint ToARGB()
61 | {
62 | return (uint)B + ((uint)G << 8) + ((uint)R << 16) + ((uint)A << 24);
63 | }
64 | public uint ToRGBA()
65 | {
66 | return (uint)A + ((uint)B << 8) + ((uint)G << 16) + ((uint)R << 24);
67 | }
68 | #endregion
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/UI/UIObjects/ColorExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp.UI.UIObjects
9 | {
10 | ///
11 | /// Extension for System.Drawing.Color
12 | ///
13 | public static class ColorExtension
14 | {
15 | public static List colorList = ColorStructToList();
16 | public static List ColorStructToList()
17 | {
18 | return typeof(System.Drawing.Color).GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public)
19 | .Select(c => (System.Drawing.Color)c.GetValue(null, null))
20 | .ToList();
21 | }
22 | ///
23 | /// Picks previous Color
24 | ///
25 | /// base color to start with
26 | /// PreviousColor
27 | public static System.Drawing.Color PreviousColor(this System.Drawing.Color clr)
28 | {
29 | System.Drawing.Color color;
30 | var clrID = colorList.IndexOf(clr) - 1;
31 | color = clrID >= 0 ? colorList[clrID] : colorList.Last();
32 | return color;
33 | }
34 | ///
35 | /// Picks next color
36 | ///
37 | /// base color to start with
38 | /// Next color
39 | public static System.Drawing.Color NextColor(this System.Drawing.Color clr)
40 | {
41 | System.Drawing.Color color;
42 | var clrID = colorList.IndexOf(clr) + 1;
43 | color = clrID < colorList.Count && clrID != -1 ? colorList[clrID] : colorList.First();
44 | return color;
45 | }
46 | public static int ToRGBA(this System.Drawing.Color clr)
47 | {
48 | return (int)clr.R | ((int)clr.G << 8) | ((int)clr.B << 16) | ((int)clr.A << 24);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/UI/UIObjects/Rectangle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ExternalUtilsCSharp.UI.UIObjects
6 | {
7 | ///
8 | /// A structure that holds information about location and size of a rectangle
9 | ///
10 | public struct Rectangle
11 | {
12 | #region PROPERTIES
13 | public float X;
14 | public float Y;
15 | public float Width;
16 | public float Height;
17 | public float Top { get { return this.Y; } }
18 | public float Bottom { get { return this.Y + this.Height; } }
19 | public float Left { get { return this.X; } }
20 | public float Right { get { return this.X + this.Width; } }
21 | public static Rectangle Empty { get { return new Rectangle(0f, 0f, 0f, 0f); } }
22 | #endregion
23 |
24 | #region CONSTRUCTOR
25 | ///
26 | /// Initializes a new rectangle using the given values
27 | ///
28 | ///
29 | ///
30 | ///
31 | ///
32 | public Rectangle(float x, float y, float width, float height)
33 | {
34 | X = x;
35 | Y = y;
36 | Width = width;
37 | Height = height;
38 | }
39 | ///
40 | /// Initializes a new rectangle by copying the values of the given rectangle
41 | ///
42 | ///
43 | public Rectangle(Rectangle rect) : this(rect.X, rect.Y, rect.Width, rect.Height) { }
44 | #endregion
45 |
46 | #region METHODS
47 | ///
48 | /// Returns whether this rectangle intersects with the given rectangle
49 | ///
50 | ///
51 | ///
52 | public bool IntersectsWith(Rectangle rect)
53 | {
54 | return rect.X < this.X + this.Width && this.X < rect.X + rect.Width && rect.Y < this.Y + this.Height && this.Y < rect.Y + rect.Height;
55 | }
56 | ///
57 | /// Returns the intersection of this rectangle and the given rectangle
58 | ///
59 | ///
60 | ///
61 | public Rectangle Intersect(Rectangle rect)
62 | {
63 | float x = Math.Max(this.X, rect.X);
64 | float width = Math.Min(this.X + this.Width, rect.X + rect.Width);
65 | float y = Math.Max(this.Y, rect.Y);
66 | float height = Math.Min(this.Y + this.Height, rect.Y + rect.Height);
67 | if (width >= x && height >= y)
68 | {
69 | return new Rectangle(x, y, y - x, height - y);
70 | }
71 | return Rectangle.Empty;
72 | }
73 | #endregion
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/Updater.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace ExternalUtilsCSharp
9 | {
10 | public class Updater
11 | {
12 | #region VARIABLES
13 | private Thread thread;
14 | private bool work;
15 | private long lastTick;
16 | private long fpsTick;
17 | private long begin;
18 | #endregion
19 |
20 | #region PROPERTIES
21 | public int Interval { get; set; }
22 | public int TickCount { get; private set; }
23 | public int FrameRate { get; private set; }
24 | public int LastFrameRate { get; private set; }
25 | #endregion
26 |
27 | #region EVENTS
28 | public event EventHandler TickEvent;
29 | public virtual void OnTickEvent(DeltaEventArgs e)
30 | {
31 | if (TickEvent != null)
32 | TickEvent(this, e);
33 | }
34 | public class DeltaEventArgs : EventArgs
35 | {
36 | public double SecondsElapsed { get; private set; }
37 | public DeltaEventArgs(double secondsElapsed) : base()
38 | {
39 | this.SecondsElapsed = secondsElapsed;
40 | }
41 | }
42 | #endregion
43 |
44 | #region CONSTRUCTOR
45 | public Updater(int tickRate)
46 | {
47 | this.Interval = 1000 / tickRate;
48 | this.TickCount = 0;
49 | }
50 | public Updater() : this(60) { }
51 | #endregion
52 |
53 | #region METHODS
54 |
55 | public void StartUpdater()
56 | {
57 | if (thread != null)
58 | StopUpdater();
59 | work = true;
60 | begin = DateTime.Now.Ticks;
61 | this.thread = new Thread(new ThreadStart(Loop));
62 | thread.IsBackground = true;
63 | thread.Priority = ThreadPriority.Highest;
64 | thread.Start();
65 | }
66 |
67 | public void StopUpdater()
68 | {
69 | work = false;
70 | if (thread == null)
71 | return;
72 | if (thread.ThreadState == ThreadState.Running)
73 | thread.Abort();
74 | thread = null;
75 | }
76 |
77 | private void Loop()
78 | {
79 | lastTick = DateTime.Now.Ticks;
80 | while (work)
81 | {
82 | CalculateFPS();
83 | double elapsedSeconds = new TimeSpan(DateTime.Now.Ticks - lastTick).TotalSeconds;
84 | this.OnTickEvent(new DeltaEventArgs(elapsedSeconds));
85 | this.TickCount++;
86 | lastTick = DateTime.Now.Ticks;
87 | Thread.Sleep(this.Interval);
88 | }
89 | }
90 | #endregion
91 | public void CalculateFPS()
92 | {
93 | if (DateTime.Now.Ticks - fpsTick >= TimeSpan.TicksPerSecond)
94 | {
95 | LastFrameRate = FrameRate;
96 | FrameRate = 0;
97 | fpsTick = DateTime.Now.Ticks;
98 | }
99 | FrameRate++;
100 | }
101 | public TimeSpan GetRuntime()
102 | {
103 | return new TimeSpan(DateTime.Now.Ticks - begin);
104 | }
105 | public int GetAverageFPS()
106 | {
107 | return (int)(this.TickCount / this.GetRuntime().TotalSeconds);
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/ExternalUtilsCSharp/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/OverlayExample/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/OverlayExample/OverlayExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {9BFCEF41-A47E-45DD-8A89-63E096658817}
8 | Exe
9 | Properties
10 | OverlayExample
11 | OverlayExample
12 | v4.5
13 | 512
14 | 47b9cfec
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | $(SharpDXPackageBinDir)\SharpDX.dll
38 |
39 |
40 | $(SharpDXPackageBinDir)\SharpDX.Direct2D1.dll
41 |
42 |
43 | $(SharpDXPackageBinDir)\SharpDX.DXGI.dll
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | {1e5dd6a0-a8a2-494b-a84e-9170c89a78aa}
66 | ExternalUtilsCSharp.JSONConfigUtils
67 |
68 |
69 | {c6c9429e-9aad-4497-b589-a4c58b98efa5}
70 | ExternalUtilsCSharp.SharpDXRenderer
71 |
72 |
73 | {e294e4f8-de32-42c1-8bfd-a3e488ec5820}
74 | ExternalUtilsCSharp
75 |
76 |
77 |
78 |
79 |
80 |
81 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
82 |
83 |
84 |
85 |
92 |
--------------------------------------------------------------------------------
/OverlayExample/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("OverlayExample")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("EVRY")]
12 | [assembly: AssemblyProduct("OverlayExample")]
13 | [assembly: AssemblyCopyright("Copyright © EVRY 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("969ee372-3962-46cc-a4ee-81a784268835")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/OverlayExample/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ExternalUtilsCSharp
2 | A set of utility-classes and -structs to make external gamehacking easier.
3 |
4 | For more details, visit http://www.unknowncheats.me/forum/c/146894-externalutilscsharp-utility-classes-and-structs.html
5 |
--------------------------------------------------------------------------------
/packages/Newtonsoft.Json.6.0.8/Newtonsoft.Json.6.0.8.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/Newtonsoft.Json.6.0.8/Newtonsoft.Json.6.0.8.nupkg
--------------------------------------------------------------------------------
/packages/Newtonsoft.Json.6.0.8/lib/net20/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/Newtonsoft.Json.6.0.8/lib/net20/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/packages/Newtonsoft.Json.6.0.8/lib/net35/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/Newtonsoft.Json.6.0.8/lib/net35/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/packages/Newtonsoft.Json.6.0.8/lib/net40/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/Newtonsoft.Json.6.0.8/lib/net40/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/packages/Newtonsoft.Json.6.0.8/lib/net45/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/Newtonsoft.Json.6.0.8/lib/net45/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/packages/Newtonsoft.Json.6.0.8/lib/netcore45/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/Newtonsoft.Json.6.0.8/lib/netcore45/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/packages/Newtonsoft.Json.6.0.8/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/Newtonsoft.Json.6.0.8/lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/packages/Newtonsoft.Json.6.0.8/lib/portable-net45+wp80+win8+wpa81+aspnetcore50/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/Newtonsoft.Json.6.0.8/lib/portable-net45+wp80+win8+wpa81+aspnetcore50/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/packages/Newtonsoft.Json.6.0.8/tools/install.ps1:
--------------------------------------------------------------------------------
1 | param($installPath, $toolsPath, $package, $project)
2 |
3 | # open json.net splash page on package install
4 | # don't open if json.net is installed as a dependency
5 |
6 | try
7 | {
8 | $url = "http://james.newtonking.com/json/install?version=" + $package.Version
9 | $dte2 = Get-Interface $dte ([EnvDTE80.DTE2])
10 |
11 | if ($dte2.ActiveWindow.Caption -eq "Package Manager Console")
12 | {
13 | # user is installing from VS NuGet console
14 | # get reference to the window, the console host and the input history
15 | # show webpage if "install-package newtonsoft.json" was last input
16 |
17 | $consoleWindow = $(Get-VSComponentModel).GetService([NuGetConsole.IPowerConsoleWindow])
18 |
19 | $props = $consoleWindow.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor `
20 | [System.Reflection.BindingFlags]::NonPublic)
21 |
22 | $prop = $props | ? { $_.Name -eq "ActiveHostInfo" } | select -first 1
23 | if ($prop -eq $null) { return }
24 |
25 | $hostInfo = $prop.GetValue($consoleWindow)
26 | if ($hostInfo -eq $null) { return }
27 |
28 | $history = $hostInfo.WpfConsole.InputHistory.History
29 |
30 | $lastCommand = $history | select -last 1
31 |
32 | if ($lastCommand)
33 | {
34 | $lastCommand = $lastCommand.Trim().ToLower()
35 | if ($lastCommand.StartsWith("install-package") -and $lastCommand.Contains("newtonsoft.json"))
36 | {
37 | $dte2.ItemOperations.Navigate($url) | Out-Null
38 | }
39 | }
40 | }
41 | else
42 | {
43 | # user is installing from VS NuGet dialog
44 | # get reference to the window, then smart output console provider
45 | # show webpage if messages in buffered console contains "installing...newtonsoft.json" in last operation
46 |
47 | $instanceField = [NuGet.Dialog.PackageManagerWindow].GetField("CurrentInstance", [System.Reflection.BindingFlags]::Static -bor `
48 | [System.Reflection.BindingFlags]::NonPublic)
49 |
50 | $consoleField = [NuGet.Dialog.PackageManagerWindow].GetField("_smartOutputConsoleProvider", [System.Reflection.BindingFlags]::Instance -bor `
51 | [System.Reflection.BindingFlags]::NonPublic)
52 |
53 | if ($instanceField -eq $null -or $consoleField -eq $null) { return }
54 |
55 | $instance = $instanceField.GetValue($null)
56 |
57 | if ($instance -eq $null) { return }
58 |
59 | $consoleProvider = $consoleField.GetValue($instance)
60 | if ($consoleProvider -eq $null) { return }
61 |
62 | $console = $consoleProvider.CreateOutputConsole($false)
63 |
64 | $messagesField = $console.GetType().GetField("_messages", [System.Reflection.BindingFlags]::Instance -bor `
65 | [System.Reflection.BindingFlags]::NonPublic)
66 | if ($messagesField -eq $null) { return }
67 |
68 | $messages = $messagesField.GetValue($console)
69 | if ($messages -eq $null) { return }
70 |
71 | $operations = $messages -split "=============================="
72 |
73 | $lastOperation = $operations | select -last 1
74 |
75 | if ($lastOperation)
76 | {
77 | $lastOperation = $lastOperation.ToLower()
78 |
79 | $lines = $lastOperation -split "`r`n"
80 |
81 | $installMatch = $lines | ? { $_.StartsWith("------- installing...newtonsoft.json ") } | select -first 1
82 |
83 | if ($installMatch)
84 | {
85 | $dte2.ItemOperations.Navigate($url) | Out-Null
86 | }
87 | }
88 | }
89 | }
90 | catch
91 | {
92 | try
93 | {
94 | $pmPane = $dte2.ToolWindows.OutputWindow.OutputWindowPanes.Item("Package Manager")
95 |
96 | $selection = $pmPane.TextDocument.Selection
97 | $selection.StartOfDocument($false)
98 | $selection.EndOfDocument($true)
99 |
100 | if ($selection.Text.StartsWith("Installing 'Newtonsoft.Json "))
101 | {
102 | $dte2.ItemOperations.Navigate($url) | Out-Null
103 | }
104 | }
105 | catch
106 | {
107 | # stop potential errors from bubbling up
108 | # worst case the splash page won't open
109 | }
110 | }
111 |
112 | # still yolo
--------------------------------------------------------------------------------
/packages/SharpDX.2.6.3/SharpDX.2.6.3.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/SharpDX.2.6.3/SharpDX.2.6.3.nupkg
--------------------------------------------------------------------------------
/packages/SharpDX.2.6.3/build/SharpDX.targets:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | DirectX11
15 | DirectX11_2
16 | DirectX11_2
17 | DirectX11_1
18 |
19 | DirectX11_2
20 |
21 |
22 | net20
23 | net40
24 | winrt
25 | winrt
26 | wp8-x86
27 | wp8-ARM
28 | wp81
29 |
30 |
31 | net40
32 |
33 |
34 | Signed-
35 |
36 |
37 |
38 | $(SharpDXDirectXVersion)-$(SharpDXSigned)$(SharpDXNETFramework)
39 |
40 |
41 | DirectX11-net40
42 |
43 |
44 | $(MSBuildThisFileDirectory)..
45 |
46 |
47 | $(SharpDXPackageDir)\Bin\$(SharpDXPlatform)
48 |
49 |
50 |
51 | $(SharpDXPackageDir)\Bin\$(SharpDXPlatformTool)
52 |
53 |
--------------------------------------------------------------------------------
/packages/SharpDX.2.6.3/lib/dummy.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/SharpDX.2.6.3/lib/dummy.txt
--------------------------------------------------------------------------------
/packages/SharpDX.2.6.3/tools/Install.ps1:
--------------------------------------------------------------------------------
1 | param($installPath, $toolsPath, $package, $project)
2 |
3 | "Installing [{0}] to project [{1}]" -f $package.Id, $project.FullName | Write-Host
4 |
5 | # Load MSBuild assembly if it’s not loaded yet.
6 | Add-Type -AssemblyName "Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
7 |
8 | # Check that SharpDX.targets was correctly imported
9 | $buildProject = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName) | Select-Object -First 1
10 | $importsToRemove = $buildProject.Xml.Imports | Where-Object { $_.Project.Endswith('SharpDX.targets') }
11 | if (!$importsToRemove)
12 | {
13 | throw ("SharpDX.targets import not found in project [{0}]" -f $project.FullName)
14 | }
15 | $sharpdx_package_bin_dir = $buildProject.GetProperty("SharpDXPackageBinDir").EvaluatedValue
16 | $sharpdx_assembly_path = "{0}\{1}.dll" -f $sharpdx_package_bin_dir, $package.Id
17 |
18 | # Add the assembly through the project in order for VS to update correctly the references in the IDE
19 | $project.Object.References.Add($sharpdx_assembly_path)
20 |
21 | # Find the references we just added
22 | $sharpdx_reference = $buildProject.GetItems("Reference") | Where-Object { $_.EvaluatedInclude -eq $package.Id }
23 | if (!$sharpdx_reference)
24 | {
25 | $sharpdx_reference = $buildProject.GetItems("Reference") | Where-Object { $_.EvaluatedInclude.StartsWith("{0}," -f $package.Id) }
26 | }
27 | if (!$sharpdx_reference)
28 | {
29 | throw ("Unable to find reference in project for assembly [{0}]" -f $package.Id)
30 | }
31 |
32 | # Replace the HintPath using the $(SharpDXPackageBinDir) variable provided by the SharpDX.targets
33 | $sharpdx_reference.SetMetadataValue("HintPath", '$(SharpDXPackageBinDir)\{0}.dll' -f $package.Id)
34 |
35 | # Save the project
36 | $project.Save()
37 |
--------------------------------------------------------------------------------
/packages/SharpDX.2.6.3/tools/UnInstall.ps1:
--------------------------------------------------------------------------------
1 | param($installPath, $toolsPath, $package, $project)
2 |
3 | "Uninstalling [{0}] from project [{1}]" -f $package.Id, $project.FullName | Write-Host
4 |
5 | # Retrieve the reference to the package
6 | $sharpdx_reference = $project.Object.References.Item($package.Id)
7 | if ($sharpdx_reference)
8 | {
9 | # Remove the reference
10 | $sharpdx_reference.Remove()
11 | # Save the project
12 | $project.Save()
13 | }
14 |
--------------------------------------------------------------------------------
/packages/SharpDX.DXGI.2.6.3/SharpDX.DXGI.2.6.3.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/SharpDX.DXGI.2.6.3/SharpDX.DXGI.2.6.3.nupkg
--------------------------------------------------------------------------------
/packages/SharpDX.DXGI.2.6.3/lib/dummy.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/SharpDX.DXGI.2.6.3/lib/dummy.txt
--------------------------------------------------------------------------------
/packages/SharpDX.DXGI.2.6.3/tools/Install.ps1:
--------------------------------------------------------------------------------
1 | param($installPath, $toolsPath, $package, $project)
2 |
3 | "Installing [{0}] to project [{1}]" -f $package.Id, $project.FullName | Write-Host
4 |
5 | # Load MSBuild assembly if it’s not loaded yet.
6 | Add-Type -AssemblyName "Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
7 |
8 | # Check that SharpDX.targets was correctly imported
9 | $buildProject = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName) | Select-Object -First 1
10 | $importsToRemove = $buildProject.Xml.Imports | Where-Object { $_.Project.Endswith('SharpDX.targets') }
11 | if (!$importsToRemove)
12 | {
13 | throw ("SharpDX.targets import not found in project [{0}]" -f $project.FullName)
14 | }
15 | $sharpdx_package_bin_dir = $buildProject.GetProperty("SharpDXPackageBinDir").EvaluatedValue
16 | $sharpdx_assembly_path = "{0}\{1}.dll" -f $sharpdx_package_bin_dir, $package.Id
17 |
18 | # Add the assembly through the project in order for VS to update correctly the references in the IDE
19 | $project.Object.References.Add($sharpdx_assembly_path)
20 |
21 | # Find the references we just added
22 | $sharpdx_reference = $buildProject.GetItems("Reference") | Where-Object { $_.EvaluatedInclude -eq $package.Id }
23 | if (!$sharpdx_reference)
24 | {
25 | $sharpdx_reference = $buildProject.GetItems("Reference") | Where-Object { $_.EvaluatedInclude.StartsWith("{0}," -f $package.Id) }
26 | }
27 | if (!$sharpdx_reference)
28 | {
29 | throw ("Unable to find reference in project for assembly [{0}]" -f $package.Id)
30 | }
31 |
32 | # Replace the HintPath using the $(SharpDXPackageBinDir) variable provided by the SharpDX.targets
33 | $sharpdx_reference.SetMetadataValue("HintPath", '$(SharpDXPackageBinDir)\{0}.dll' -f $package.Id)
34 |
35 | # Save the project
36 | $project.Save()
37 |
--------------------------------------------------------------------------------
/packages/SharpDX.DXGI.2.6.3/tools/UnInstall.ps1:
--------------------------------------------------------------------------------
1 | param($installPath, $toolsPath, $package, $project)
2 |
3 | "Uninstalling [{0}] from project [{1}]" -f $package.Id, $project.FullName | Write-Host
4 |
5 | # Retrieve the reference to the package
6 | $sharpdx_reference = $project.Object.References.Item($package.Id)
7 | if ($sharpdx_reference)
8 | {
9 | # Remove the reference
10 | $sharpdx_reference.Remove()
11 | # Save the project
12 | $project.Save()
13 | }
14 |
--------------------------------------------------------------------------------
/packages/SharpDX.Direct2D1.2.6.3/SharpDX.Direct2D1.2.6.3.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/SharpDX.Direct2D1.2.6.3/SharpDX.Direct2D1.2.6.3.nupkg
--------------------------------------------------------------------------------
/packages/SharpDX.Direct2D1.2.6.3/lib/dummy.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigMo/ExternalUtilsCSharp/c590731fc352283113be93d292a4eee15015f650/packages/SharpDX.Direct2D1.2.6.3/lib/dummy.txt
--------------------------------------------------------------------------------
/packages/SharpDX.Direct2D1.2.6.3/tools/Install.ps1:
--------------------------------------------------------------------------------
1 | param($installPath, $toolsPath, $package, $project)
2 |
3 | "Installing [{0}] to project [{1}]" -f $package.Id, $project.FullName | Write-Host
4 |
5 | # Load MSBuild assembly if it’s not loaded yet.
6 | Add-Type -AssemblyName "Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
7 |
8 | # Check that SharpDX.targets was correctly imported
9 | $buildProject = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName) | Select-Object -First 1
10 | $importsToRemove = $buildProject.Xml.Imports | Where-Object { $_.Project.Endswith('SharpDX.targets') }
11 | if (!$importsToRemove)
12 | {
13 | throw ("SharpDX.targets import not found in project [{0}]" -f $project.FullName)
14 | }
15 | $sharpdx_package_bin_dir = $buildProject.GetProperty("SharpDXPackageBinDir").EvaluatedValue
16 | $sharpdx_assembly_path = "{0}\{1}.dll" -f $sharpdx_package_bin_dir, $package.Id
17 |
18 | # Add the assembly through the project in order for VS to update correctly the references in the IDE
19 | $project.Object.References.Add($sharpdx_assembly_path)
20 |
21 | # Find the references we just added
22 | $sharpdx_reference = $buildProject.GetItems("Reference") | Where-Object { $_.EvaluatedInclude -eq $package.Id }
23 | if (!$sharpdx_reference)
24 | {
25 | $sharpdx_reference = $buildProject.GetItems("Reference") | Where-Object { $_.EvaluatedInclude.StartsWith("{0}," -f $package.Id) }
26 | }
27 | if (!$sharpdx_reference)
28 | {
29 | throw ("Unable to find reference in project for assembly [{0}]" -f $package.Id)
30 | }
31 |
32 | # Replace the HintPath using the $(SharpDXPackageBinDir) variable provided by the SharpDX.targets
33 | $sharpdx_reference.SetMetadataValue("HintPath", '$(SharpDXPackageBinDir)\{0}.dll' -f $package.Id)
34 |
35 | # Save the project
36 | $project.Save()
37 |
--------------------------------------------------------------------------------
/packages/SharpDX.Direct2D1.2.6.3/tools/UnInstall.ps1:
--------------------------------------------------------------------------------
1 | param($installPath, $toolsPath, $package, $project)
2 |
3 | "Uninstalling [{0}] from project [{1}]" -f $package.Id, $project.FullName | Write-Host
4 |
5 | # Retrieve the reference to the package
6 | $sharpdx_reference = $project.Object.References.Item($package.Id)
7 | if ($sharpdx_reference)
8 | {
9 | # Remove the reference
10 | $sharpdx_reference.Remove()
11 | # Save the project
12 | $project.Save()
13 | }
14 |
--------------------------------------------------------------------------------
/packages/repositories.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------