X-Aim

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ HEAD  →  ?path2? @ 1
File deleted
\ No newline at end of file
/trunk/X-Aim/Controls/BindableToolStripMenuItem.cs
File deleted
\ No newline at end of file
/trunk/X-Aim/app.manifest
/trunk/X-Aim/About.cs
@@ -1,5 +1,4 @@
using System;
using System.Reflection;
using System.Reflection;
using System.Windows.Forms;
 
namespace X_Aim
@@ -11,9 +10,7 @@
InitializeComponent();
}
 
#region Event Handlers
 
private void OnLoad(object sender, EventArgs e)
private void OnLoad(object sender, System.EventArgs e)
{
label1.Text = $"v{Assembly.GetEntryAssembly().GetName().Version}";
 
@@ -24,7 +21,5 @@
richTextBox1.LoadFile(manifestResourceStream, RichTextBoxStreamType.RichText);
}
}
 
#endregion
}
}
/trunk/X-Aim/App.config
@@ -1,25 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
 
<configuration>
<configSections>
<sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="X_Aim.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<X_Aim.Properties.Settings>
<setting name="Enable" serializeAs="String">
<value>True</value>
</setting>
<setting name="StartWithWindows" serializeAs="String">
<value>False</value>
</setting>
</X_Aim.Properties.Settings>
</userSettings>
</configuration>
/trunk/X-Aim/Form1.Designer.cs
@@ -1,6 +1,4 @@
using X_Aim.Controls;
 
namespace X_Aim
namespace X_Aim
{
partial class Form1
{
@@ -34,13 +32,8 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.enableToolStripMenuItem = new X_Aim.Controls.BindableToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.settingsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.startWithWindowsToolStripMenuItem = new X_Aim.Controls.BindableToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
@@ -54,54 +47,19 @@
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.enableToolStripMenuItem,
this.toolStripSeparator2,
this.settingsToolStripMenuItem1,
this.toolStripSeparator1,
this.aboutToolStripMenuItem,
this.quitToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(144, 104);
this.contextMenuStrip1.Size = new System.Drawing.Size(144, 48);
//
// enableToolStripMenuItem
// quitToolStripMenuItem
//
this.enableToolStripMenuItem.Checked = global::X_Aim.Properties.Settings.Default.Enable;
this.enableToolStripMenuItem.CheckOnClick = true;
this.enableToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
this.enableToolStripMenuItem.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::X_Aim.Properties.Settings.Default, "Enable", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
this.enableToolStripMenuItem.Name = "enableToolStripMenuItem";
this.enableToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
this.enableToolStripMenuItem.Text = "Enable";
this.enableToolStripMenuItem.CheckStateChanged += new System.EventHandler(this.Enable_OnCheckStateChanged);
this.quitToolStripMenuItem.Image = global::X_Aim.Properties.Resources.quit;
this.quitToolStripMenuItem.Name = "quitToolStripMenuItem";
this.quitToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
this.quitToolStripMenuItem.Text = "Quit";
this.quitToolStripMenuItem.Click += new System.EventHandler(this.quitToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(140, 6);
//
// settingsToolStripMenuItem1
//
this.settingsToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.startWithWindowsToolStripMenuItem});
this.settingsToolStripMenuItem1.Name = "settingsToolStripMenuItem1";
this.settingsToolStripMenuItem1.Size = new System.Drawing.Size(143, 22);
this.settingsToolStripMenuItem1.Text = "Settings";
//
// startWithWindowsToolStripMenuItem
//
this.startWithWindowsToolStripMenuItem.Checked = global::X_Aim.Properties.Settings.Default.StartWithWindows;
this.startWithWindowsToolStripMenuItem.CheckOnClick = true;
this.startWithWindowsToolStripMenuItem.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::X_Aim.Properties.Settings.Default, "StartWithWindows", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
this.startWithWindowsToolStripMenuItem.Name = "startWithWindowsToolStripMenuItem";
this.startWithWindowsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.startWithWindowsToolStripMenuItem.Text = "Start with Windows";
this.startWithWindowsToolStripMenuItem.CheckStateChanged += new System.EventHandler(this.StartWithWindows_OnCheckStateChanged);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(140, 6);
//
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Image = global::X_Aim.Properties.Resources.help;
@@ -110,14 +68,6 @@
this.aboutToolStripMenuItem.Text = "Help / About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
//
// quitToolStripMenuItem
//
this.quitToolStripMenuItem.Image = global::X_Aim.Properties.Resources.quit;
this.quitToolStripMenuItem.Name = "quitToolStripMenuItem";
this.quitToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
this.quitToolStripMenuItem.Text = "Quit";
this.quitToolStripMenuItem.Click += new System.EventHandler(this.quitToolStripMenuItem_Click);
//
// Form1
//
this.AllowDrop = true;
@@ -138,7 +88,6 @@
this.Text = "Form1";
this.TopMost = true;
this.TransparencyKey = System.Drawing.Color.White;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing);
this.Load += new System.EventHandler(this.OnLoad);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.OnDragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnDragEnter);
@@ -156,11 +105,6 @@
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem quitToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private BindableToolStripMenuItem enableToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem1;
private BindableToolStripMenuItem startWithWindowsToolStripMenuItem;
}
}
 
/trunk/X-Aim/Form1.cs
@@ -8,47 +8,23 @@
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Win32;
using X_Aim.Properties;
 
namespace X_Aim
{
public partial class Form1 : Form
{
private readonly string _activeCrosshairFilePath =
private readonly string ACTIVE_CROSSHAIR_FILE_PATH =
$"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}/img/activeCrosshair.png";
 
private Point _firstPoint;
private Point firstPoint;
 
private bool _lockedPosition;
private bool lockedPosition;
 
private bool _mouseIsDown;
private bool mouseIsDown;
 
public Form1()
{
InitializeComponent();
 
// Show or hide the form.
switch (Settings.Default["Enable"])
{
case true:
Show();
break;
default:
Hide();
break;
}
 
// Set the application to start with windows.
switch (Settings.Default["StartWithWindows"])
{
case true:
AddApplicationToStartup();
break;
default:
RemoveApplicationFromStartup();
break;
}
}
 
#region Event Handlers
@@ -63,7 +39,7 @@
 
BackgroundImage = draggedImage;
 
draggedImage.Save(_activeCrosshairFilePath, ImageFormat.Png);
draggedImage.Save(ACTIVE_CROSSHAIR_FILE_PATH, ImageFormat.Png);
}
 
private void OnDragEnter(object sender, DragEventArgs e)
@@ -73,27 +49,27 @@
 
private void OnMouseDown(object sender, MouseEventArgs e)
{
_firstPoint = e.Location;
_mouseIsDown = true;
firstPoint = e.Location;
mouseIsDown = true;
}
 
private void OnMouseUp(object sender, MouseEventArgs e)
{
_mouseIsDown = false;
mouseIsDown = false;
 
if (e.Button == MouseButtons.Right)
{
_lockedPosition = !_lockedPosition;
lockedPosition = !lockedPosition;
 
var resourceImage = _lockedPosition ? "X_Aim.img.locked.png" : "X_Aim.img.unlocked.png";
var resourceImage = lockedPosition ? "X_Aim.img.locked.png" : "X_Aim.img.unlocked.png";
 
#pragma warning disable 4014
#pragma warning disable 4014
Task.Run(() =>
#pragma warning restore 4014
{
Image originalImage = null;
 
Invoke((MethodInvoker) delegate { originalImage = BackgroundImage; });
Invoke((MethodInvoker)delegate { originalImage = BackgroundImage; });
 
Image lockImage;
using (var manifestResourceStream =
@@ -104,15 +80,15 @@
 
foreach (var i in Enumerable.Range(0, 100).Reverse())
{
Invoke((MethodInvoker) delegate
Invoke((MethodInvoker)delegate
{
BackgroundImage = SetImageOpacity(lockImage, (float) i / 100);
BackgroundImage = SetImageOpacity(lockImage, (float)i / 100);
Invalidate();
Refresh();
});
}
 
Invoke((MethodInvoker) delegate { BackgroundImage = originalImage; });
Invoke((MethodInvoker)delegate { BackgroundImage = originalImage; });
});
}
}
@@ -119,14 +95,14 @@
 
private void OnMouseMove(object sender, MouseEventArgs e)
{
if (!_mouseIsDown || _lockedPosition)
if (!mouseIsDown || lockedPosition)
{
return;
}
 
// Get the difference between the two points
var xDiff = _firstPoint.X - e.Location.X;
var yDiff = _firstPoint.Y - e.Location.Y;
var xDiff = firstPoint.X - e.Location.X;
var yDiff = firstPoint.Y - e.Location.Y;
 
// Set the new point
var x = Location.X - xDiff;
@@ -149,69 +125,24 @@
// Set window to top-most.
Natives.AllowSetForegroundWindow((uint) Process.GetCurrentProcess().Id);
Natives.SetForegroundWindow(Handle);
Natives.ShowWindow(Handle, Natives.SwShownormal);
Natives.ShowWindow(Handle, Natives.SW_SHOWNORMAL);
 
// If the default crosshair cannot be found, unpack from resources and load the crosshair.
if (!File.Exists(_activeCrosshairFilePath))
if (!File.Exists(ACTIVE_CROSSHAIR_FILE_PATH))
{
using (var manifestResourceStream =
Assembly.GetExecutingAssembly().GetManifestResourceStream("X_Aim.img.defaultCrosshair.png"))
{
var fileInfo = new FileInfo(_activeCrosshairFilePath);
 
if (!fileInfo.Exists)
using (var fileStream = new FileStream(ACTIVE_CROSSHAIR_FILE_PATH, FileMode.Create))
{
Directory.CreateDirectory(fileInfo.Directory.FullName);
}
 
using (var fileStream = new FileStream(_activeCrosshairFilePath, FileMode.Create))
{
await manifestResourceStream.CopyToAsync(fileStream);
}
}
}
 
using (var fileStream = new FileStream(_activeCrosshairFilePath, FileMode.Open))
{
BackgroundImage = Image.FromStream(fileStream);
}
BackgroundImage = LoadImageFromFile(ACTIVE_CROSSHAIR_FILE_PATH);
}
 
private void OnFormClosing(object sender, FormClosingEventArgs e)
{
Settings.Default.Save();
}
 
private void Enable_OnCheckStateChanged(object sender, EventArgs e)
{
switch (Settings.Default["Enable"])
{
case true:
Show();
break;
default:
Hide();
break;
}
 
Settings.Default.Save();
}
 
private void StartWithWindows_OnCheckStateChanged(object sender, EventArgs e)
{
switch (Settings.Default["StartWithWindows"])
{
case true:
AddApplicationToStartup();
break;
default:
RemoveApplicationFromStartup();
break;
}
 
Settings.Default.Save();
}
 
#endregion
 
/// <summary>
@@ -231,9 +162,10 @@
using (var gfx = Graphics.FromImage(bmp))
{
//create a color matrix object
var matrix = new ColorMatrix {Matrix33 = opacity};
var matrix = new ColorMatrix();
 
//set the opacity
matrix.Matrix33 = opacity;
 
//create image attributes
var attributes = new ImageAttributes();
@@ -255,6 +187,14 @@
}
}
 
private Image LoadImageFromFile(string file)
{
using (var fileStream = new FileStream(file, FileMode.Open))
{
return Image.FromStream(fileStream);
}
}
 
private bool TryGetDragDropImage(DragEventArgs e, out Image image)
{
var file = ((IEnumerable<string>) e.Data.GetData(DataFormats.FileDrop)).FirstOrDefault();
@@ -266,10 +206,7 @@
 
try
{
using (var fileStream = new FileStream(file, FileMode.Open))
{
image = Image.FromStream(fileStream);
}
image = LoadImageFromFile(file);
 
return true;
}
@@ -279,21 +216,5 @@
return false;
}
}
 
public static void AddApplicationToStartup()
{
using (var key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
{
key?.SetValue(Assembly.GetExecutingAssembly().FullName, "\"" + Application.ExecutablePath + "\"");
}
}
 
public static void RemoveApplicationFromStartup()
{
using (var key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
{
key?.DeleteValue(Assembly.GetExecutingAssembly().FullName, false);
}
}
}
}
/trunk/X-Aim/Natives.cs
@@ -5,15 +5,15 @@
{
public static class Natives
{
public const int SwHide = 0;
public const int SW_HIDE = 0;
 
public const int SwShow = 5;
public const int SW_SHOW = 5;
 
public const int SwShownormal = 1;
public const int SW_SHOWNORMAL = 1;
 
public const int SwShowmaximized = 3;
public const int SW_SHOWMAXIMIZED = 3;
 
public const int SwRestore = 9;
public const int SW_RESTORE = 9;
 
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
/trunk/X-Aim/Program.cs
@@ -5,8 +5,6 @@
{
internal static class Program
{
private static Form _form1;
 
/// <summary>
/// The main entry point for the application.
/// </summary>
@@ -15,10 +13,7 @@
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
 
_form1 = new Form1();
 
Application.Run();
Application.Run(new Form1());
}
}
}
/trunk/X-Aim/Properties/Settings.Designer.cs
@@ -8,43 +8,23 @@
// </auto-generated>
//------------------------------------------------------------------------------
 
namespace X_Aim.Properties {
namespace X_Aim.Properties
{
 
 
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
 
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
 
public static Settings Default
{
get
{
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool Enable {
get {
return ((bool)(this["Enable"]));
}
set {
this["Enable"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool StartWithWindows {
get {
return ((bool)(this["StartWithWindows"]));
}
set {
this["StartWithWindows"] = value;
}
}
}
}
/trunk/X-Aim/Properties/Settings.settings
@@ -1,14 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
 
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
GeneratedClassNamespace="X_Aim.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="Enable" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="StartWithWindows" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
/trunk/X-Aim/X-Aim.csproj
@@ -53,9 +53,6 @@
<PropertyGroup>
<StartupObject>X_Aim.Program</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -76,9 +73,6 @@
<Compile Include="About.Designer.cs">
<DependentUpon>About.cs</DependentUpon>
</Compile>
<Compile Include="Controls\BindableToolStripMenuItem.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
@@ -104,7 +98,6 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>