Skip to content

Commit

Permalink
fix(gui): added grid to auto buy so that the buttons wont be behind t…
Browse files Browse the repository at this point in the history
…he image

fix(updater): made window non resizable
feat(updater): added common controls to manifest
  • Loading branch information
MurkyYT committed Oct 11, 2024
1 parent c83070d commit 72f3241
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 53 deletions.
8 changes: 3 additions & 5 deletions src/CSAuto/CSAuto.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<ApplicationIcon>Icons\main.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationManifest>csauto.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down Expand Up @@ -220,7 +220,7 @@
<LastGenOutput>Strings.ru.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include=".editorconfig" />
<None Include="app.manifest" />
<None Include="csauto.manifest" />
<None Include="Properties\DebugSettings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>DebugSettings.Designer.cs</LastGenOutput>
Expand Down Expand Up @@ -274,9 +274,7 @@
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>rmdir /q /s $(ProjectDir)$(OutDir)resource
Expand Down
12 changes: 8 additions & 4 deletions src/CSAuto/GUIWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,22 @@
</ItemContainerTemplate>
</TabItem.HeaderTemplate>
<Grid>
<StackPanel x:Name="AutoBuySettingsStack" Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" x:Name="AutoBuySettingsStack" Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,10,0,0">
<CheckBox Content="{x:Static p:Strings.text_enabled}" IsChecked="{Binding Source={x:Static properties:Settings.Default},Path=autoBuyEnabled}" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<CheckBox Content="{x:Static p:Strings.title_rebuy}" IsChecked="{Binding Source={x:Static properties:Settings.Default},Path=autoBuyRebuy}" VerticalAlignment="Top" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top">
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top">
<TabControl Panel.ZIndex="1" x:Name="AutoBuyTab" VerticalAlignment="Top" SelectionChanged="AutoBuyTab_SelectionChanged" mahapps:TabControlHelper.Underlined="SelectedTabItem" mahapps:TabControlHelper.UnderlinePlacement="Bottom" Height="48">
<mahapps:MetroTabItem Header="{x:Static p:Strings.team_ct}"/>
<mahapps:MetroTabItem Header="{x:Static p:Strings.team_t}"/>
</TabControl>
</StackPanel>
<Image Panel.ZIndex="0" x:Name="AutoBuyImage" MouseDown="AutoBuyImage_MouseDown" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,48,0,0"/>
<Grid x:Name="BuyItemProperties" Visibility="Hidden">
<Image Grid.Column="1" Panel.ZIndex="0" x:Name="AutoBuyImage" MouseDown="AutoBuyImage_MouseDown" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,48,0,0"/>
<Grid Grid.Column="0" Grid.ColumnSpan="2" x:Name="BuyItemProperties" Visibility="Hidden">
<StackPanel>
<TextBlock x:Name="BuyItemName" Text="Name"></TextBlock>
<CheckBox x:Name="BuyItemEnabledCheckBox" Content="{x:Static p:Strings.text_enabled}"></CheckBox>
Expand Down
2 changes: 1 addition & 1 deletion src/CSAuto/MainApp.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public partial class MainApp : Window
#region Constants
public const string VER = "2.1.3";
public const string FULL_VER = VER + (DEBUG_REVISION == "" ? "" : " REV "+ DEBUG_REVISION);
const string DEBUG_REVISION = "2";
const string DEBUG_REVISION = "3";
const string GAME_PROCCES_NAME = "cs2";
const string GAME_WINDOW_NAME = "Counter-Strike 2";
const string GAME_CLASS_NAME = "SDL_app";
Expand Down
43 changes: 1 addition & 42 deletions src/CSAuto/NotifyIcon/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;

// ReSharper disable InconsistentNaming

Expand Down Expand Up @@ -53,46 +52,6 @@ public class NotifyIconData
[ResourceExposure(ResourceScope.None)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Shell_NotifyIcon(int message, NotifyIconData pnId);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public extern static bool DestroyIcon(IntPtr handle);
[DllImport("Shell32.dll", SetLastError = false)]
public static extern Int32 SHGetStockIconInfo(SHSTOCKICONID siid, SHGSI uFlags, ref SHSTOCKICONINFO psii);

public enum SHSTOCKICONID : uint
{
SIID_SHIELD = 77
}

[Flags]
public enum SHGSI : uint
{
SHGSI_ICON = 0x000000100,
SHGSI_SMALLICON = 0x000000001
}

[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SHSTOCKICONINFO
{
public UInt32 cbSize;
public IntPtr hIcon;
public Int32 iSysIconIndex;
public Int32 iIcon;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szPath;
}
public delegate void WinEventDelegate(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime);

[DllImport("user32.dll")]
static public extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, uint dwFlags);

public const uint WINEVENT_OUTOFCONTEXT = 0;
public const uint EVENT_SYSTEM_FOREGROUND = 3;

[DllImport("user32.dll")]
static public extern IntPtr GetForegroundWindow();

[DllImport("user32.dll")]
static public extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);

}
}
File renamed without changes.
5 changes: 5 additions & 0 deletions src/Updater/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
if(e.Args.Length == 0)
{
MessageBox.Show("Not enough arguments supplied","Error",MessageBoxButton.OK,MessageBoxImage.Error);
return;
}
if (e.Args[0] == "--cleanup")
{
string[] files = Directory.GetFiles(Log.WorkPath + "\\..", "*.dll");
Expand Down
2 changes: 1 addition & 1 deletion src/Updater/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Updater"
mc:Ignorable="d"
Title="CSAuto updater" Height="80" Width="300">
Title="CSAuto updater" Height="80" Width="300" ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
Expand Down
4 changes: 4 additions & 0 deletions src/Updater/Updater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>updater.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand Down Expand Up @@ -88,6 +91,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="updater.manifest" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
79 changes: 79 additions & 0 deletions src/Updater/updater.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->

<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>


</assembly>

0 comments on commit 72f3241

Please sign in to comment.