Skip to content

Commit

Permalink
MainWindow position fix, Log path changed, MessageWIndow implemented,…
Browse files Browse the repository at this point in the history
… Migrated to .NET 6
  • Loading branch information
Haruki1707 committed Feb 8, 2022
1 parent ceac5de commit 48c2003
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 35 deletions.
32 changes: 16 additions & 16 deletions ValorantCC/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ValorantCC" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:Controls="clr-namespace:Xceed.Wpf.AvalonDock.Themes.Controls;assembly=Xceed.Wpf.AvalonDock.Themes.Aero" x:Class="ValorantCC.MainWindow"
xmlns:fa="http://schemas.fontawesome.io/icons/"
mc:Ignorable="d"
Title="vTools - ValorantCC" Height="0" Width="500" SizeToContent="Height" AllowsTransparency="True" WindowStartupLocation="CenterScreen" WindowState="Normal" ResizeMode="CanMinimize" WindowStyle="None" Icon="Resources/vtools-colored.ico"
Background="Transparent"
RenderOptions.BitmapScalingMode="Fant">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ValorantCC" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:Controls="clr-namespace:Xceed.Wpf.AvalonDock.Themes.Controls;assembly=Xceed.Wpf.AvalonDock.Themes.Aero" x:Class="ValorantCC.MainWindow"
xmlns:fa="http://schemas.fontawesome.io/icons/"
mc:Ignorable="d"
Title="vTools - ValorantCC" Height="0" Width="500" SizeToContent="Height" AllowsTransparency="True" WindowStartupLocation="CenterScreen" WindowState="Normal" ResizeMode="CanMinimize" WindowStyle="None" Icon="Resources/vtools-colored.ico"
Background="Transparent"
RenderOptions.BitmapScalingMode="Fant">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down Expand Up @@ -230,13 +230,13 @@

<TextBlock Margin="2,2,2,2" FontWeight="Bold" Grid.Row="4" Grid.Column="0" Foreground="White" FontFamily="Segoe UI Semibold"><Run Text="Sniper Dot Color"/></TextBlock>
<xctk:ColorPicker x:Name="sniper_dot_color" Grid.Row="4" Grid.Column="1" SelectedColorChanged="sniper_dot_color_SelectedColorChanged" UsingAlphaChannel="False" AdvancedTabHeader="Manual" Margin="10,0,4,0" Cursor="Hand" OpacityMask="#FFB82525" Height="23.96" VerticalAlignment="Center" Background="{x:Null}" DisplayColorAndName="True" BorderBrush="#FFDADADA" Foreground="White" HeaderBackground="#FF252526" HeaderForeground="White" TabBackground="#FF252526" TabForeground="#FFFBF9F9" DropDownBorderBrush="#FF252526" DropDownBackground="#FF252526" ShowStandardColors="False"/>

<Rectangle Width="auto" Height="15" Grid.Column="0" Grid.Row="5" Fill="#FF44464F" Grid.ColumnSpan="2" Margin="-2,2,-2,2"/>
<TextBlock FontWeight="Bold" Grid.Column="0" Grid.Row="5" Margin="2,0,2,2" Foreground="White" FontFamily="Segoe UI Semibold" Grid.ColumnSpan="2">
</Grid>
<Border Width="auto" Height="18" Background="#FF44464F" Margin="-2,2,-2,2">
<TextBlock FontWeight="Bold" Margin="6,0,2,2" Foreground="White" FontFamily="Segoe UI Semibold">
<Run Text="Message:"/>
<Run Foreground="Yellow" Text="Waiting for action. . ." FontSize="10" Name="MessageTxt"/>
<Run Foreground="Yellow" Text="Waiting for Valorant or Riot Client. . ." FontSize="10" Name="MessageTxt"/>
</TextBlock>
</Grid>
</Border>
</StackPanel>
</UserControl>
</Border>
Expand Down
12 changes: 5 additions & 7 deletions ValorantCC/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace ValorantCC
{
public partial class MainWindow : Window
{
readonly string LoggingDir = Environment.GetEnvironmentVariable("LocalAppData") + @"\VTools\Logs\";
public Processor DataProcessor = new Processor();
BrushConverter bc = new BrushConverter();
public AuthResponse AuthResponse;
Expand All @@ -28,10 +27,9 @@ public partial class MainWindow : Window
public MainWindow()
{
// Create logging dir
if (!Directory.Exists(LoggingDir)) Directory.CreateDirectory(LoggingDir);
// Replace old logs
string LogFile = LoggingDir + "/logs.txt";
if (File.Exists(LogFile)) File.Move(LogFile, LogFile + ".old", true);
if (!Directory.Exists(Path.GetDirectoryName(Utils.LoggingFile))) Directory.CreateDirectory(Path.GetDirectoryName(Utils.LoggingFile));
// Replace old logs
if (File.Exists(Utils.LoggingFile)) File.Move(Utils.LoggingFile, Utils.LoggingFile + ".old", true);
Version ProgramFileVersion = new Version(FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion);

InitializeComponent();
Expand Down Expand Up @@ -262,7 +260,7 @@ private void ClipboardButtonLeave(object sender, MouseEventArgs e)
private void btnOpenLogs_Click(object sender, RoutedEventArgs e)
{
Process p = new Process();
p.StartInfo = new ProcessStartInfo() { FileName = LoggingDir, UseShellExecute = true };
p.StartInfo = new ProcessStartInfo() { FileName = Path.GetDirectoryName(Utils.LoggingFile), UseShellExecute = true };
p.Start();
MessageTxt.Foreground = Brushes.Lime;
MessageTxt.Text = "Log folder opened! Please include OLD files to your report if exists.";
Expand Down Expand Up @@ -302,7 +300,7 @@ private void btnCommunityProfiles_Click(object sender, RoutedEventArgs e)
Window publicProfiles = Application.Current.Windows.Cast<Window>().Single(window => window.GetType().ToString() == "ValorantCC.ProfilesWindow");
publicProfiles.Activate();
}
catch (Exception ex)
catch (Exception)
{
ProfilesWindow publicProfiles = new ProfilesWindow(SelectedProfile, ValCCAPI);
publicProfiles.Owner = this;
Expand Down
15 changes: 15 additions & 0 deletions ValorantCC/SubWindow/MessageWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Window x:Class="ValorantCC.SubWindow.MessageWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ValorantCC.SubWindow"
mc:Ignorable="d"
Title="MessageWindow" Width="350" Background="#FF232429" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" WindowStyle="None" WindowStartupLocation="CenterOwner" SizeToContent="Height" ResizeMode="NoResize" ShowInTaskbar="False">
<Border BorderBrush="White" BorderThickness="1" Padding="0,10,0,10">
<StackPanel VerticalAlignment="Center">
<TextBox x:Name="Messagetxtbox" TextWrapping="Wrap" Text="Here goes the text to be displayed" Width="Auto" Height="Auto" Foreground="White" FontSize="14" HorizontalContentAlignment="Left" Background="#FF232429" VerticalContentAlignment="Center" BorderThickness="0" Padding="10,0,10,0"/>
<Button x:Name="OKbtn" Style="{DynamicResource RoundButton}" Content="OK" Cursor="Hand" Height="22" Width="84" Background="#FF295FFE" FontFamily="Quicksand" FontSize="14" FontWeight="DemiBold" TextBlock.FontFamily="Segoe UI Semibold" TextBlock.FontWeight="Bold" Margin="0,10,0,0" Click="OKbtn_Click"/>
</StackPanel>
</Border>
</Window>
29 changes: 29 additions & 0 deletions ValorantCC/SubWindow/MessageWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Linq;
using System.Windows;

namespace ValorantCC.SubWindow
{
/// <summary>
/// Lógica de interacción para MessageWindow.xaml
/// </summary>
public partial class MessageWindow : Window
{
public static void Show(string Message)
{
MessageWindow MessageWin = new(Message);
MessageWin.Owner = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive);
MessageWin.Show();
}

public MessageWindow(string Message)
{
InitializeComponent();
Messagetxtbox.Text = Message;
}

private void OKbtn_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}
7 changes: 3 additions & 4 deletions ValorantCC/SubWindow/ProfilesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ValorantCC.SubWindow;

namespace ValorantCC
{
Expand All @@ -25,7 +26,6 @@ public struct PublicProfile
public partial class ProfilesWindow : Window
{
public CrosshairProfile selected;
private BrushConverter bc;
private static API ValCCApi;
private static MainWindow main;
private static List<PublicProfile> PublicProfiles = new List<PublicProfile>();
Expand All @@ -35,7 +35,6 @@ public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
main = (MainWindow)Application.Current.MainWindow;
selected = current;
ValCCApi = ValCCAPI;
bc = new BrushConverter();
}

private async void Border_Loaded(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -113,14 +112,14 @@ public void shareBtnClicked(object sender, RoutedEventArgs e)
{
String shareCode = ((Button)sender).Name.Split('_')[1];
Clipboard.SetText(shareCode);
MessageBox.Show("\"" + shareCode + "\" has been copied to clipboard!");
MessageWindow.Show("\"" + shareCode + "\" has been copied to clipboard!");
}

public void detailsBtnClicked(object sender, RoutedEventArgs e)
{
PublicProfile pressedPubProfile = PublicProfiles[Int32.Parse(((Button)sender).Name.Split('_')[1])];
CrosshairProfile pressedProfile = pressedPubProfile.settings;
MessageBox.Show($"{pressedPubProfile.owner}'s Profile: {pressedProfile.ProfileName}\nPrimary:\n\tInner Lines: {pressedProfile.Primary.InnerLines.Opacity}, {pressedProfile.Primary.InnerLines.LineLength}, {pressedProfile.Primary.InnerLines.LineThickness}, {pressedProfile.Primary.InnerLines.LineOffset}\n\tOuter Lines: {pressedProfile.Primary.OuterLines.Opacity}, {pressedProfile.Primary.OuterLines.LineLength}, {pressedProfile.Primary.OuterLines.LineThickness}, {pressedProfile.Primary.OuterLines.LineOffset}\n\nADS:\n\tInner Lines: {pressedProfile.aDS.InnerLines.Opacity}, {pressedProfile.aDS.InnerLines.LineLength}, {pressedProfile.aDS.InnerLines.LineThickness}, {pressedProfile.aDS.InnerLines.LineOffset}\n\tOuter Lines: {pressedProfile.aDS.OuterLines.Opacity}, {pressedProfile.aDS.OuterLines.LineLength}, {pressedProfile.aDS.OuterLines.LineThickness}, {pressedProfile.aDS.OuterLines.LineOffset}");
MessageWindow.Show($"{pressedPubProfile.owner}'s Profile: {pressedProfile.ProfileName}\nPrimary:\n\tInner Lines: {pressedProfile.Primary.InnerLines.Opacity}, {pressedProfile.Primary.InnerLines.LineLength}, {pressedProfile.Primary.InnerLines.LineThickness}, {pressedProfile.Primary.InnerLines.LineOffset}\n\tOuter Lines: {pressedProfile.Primary.OuterLines.Opacity}, {pressedProfile.Primary.OuterLines.LineLength}, {pressedProfile.Primary.OuterLines.LineThickness}, {pressedProfile.Primary.OuterLines.LineOffset}\n\nADS:\n\tInner Lines: {pressedProfile.aDS.InnerLines.Opacity}, {pressedProfile.aDS.InnerLines.LineLength}, {pressedProfile.aDS.InnerLines.LineThickness}, {pressedProfile.aDS.InnerLines.LineOffset}\n\tOuter Lines: {pressedProfile.aDS.OuterLines.Opacity}, {pressedProfile.aDS.OuterLines.LineLength}, {pressedProfile.aDS.OuterLines.LineThickness}, {pressedProfile.aDS.OuterLines.LineOffset}");
}

public void applyBtnClicked(object sender, RoutedEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions ValorantCC/ValorantCC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Authors>Weedeej</Authors>
<Company>N/A</Company>
Expand All @@ -14,7 +14,7 @@
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<AssemblyVersion></AssemblyVersion>
<FileVersion></FileVersion>
<Version>2.6.6</Version>
<Version>3.0</Version>
<SignAssembly>false</SignAssembly>
</PropertyGroup>

Expand Down
3 changes: 1 addition & 2 deletions ValorantCC/src/Auth.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using Newtonsoft.Json;
using RestSharp;
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Utilities;
using RestSharp;
namespace ValorantCC
{
public partial class AuthTokens
Expand Down
3 changes: 3 additions & 0 deletions ValorantCC/src/BackgroundAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public async void LoopCheck()
{
string LockfilePath = Environment.GetEnvironmentVariable("LocalAppData") + "\\Riot Games\\Riot Client\\Config\\lockfile"; //Copy pasted from Auth.cs because why not?
bool lockfilexists = false;
double OriginalHeight = main.Height;
main.ch_display.Visibility = Visibility.Collapsed;
main.buttons_group.Visibility = Visibility.Collapsed;
main.controls_group.Visibility = Visibility.Collapsed;
Expand Down Expand Up @@ -63,6 +64,8 @@ public async void LoopCheck()
main.buttons_group.Visibility = Visibility.Visible;
main.controls_group.Visibility = Visibility.Visible;
main.spinner.Visibility = Visibility.Collapsed;
main.Top = main.Top - (main.Height - OriginalHeight);

return;
}
await Task.Delay(1500);
Expand Down
4 changes: 2 additions & 2 deletions ValorantCC/src/Processor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Processor
private ProfileList FetchedProfiles;
public int CurrentProfile;

public async Task <AuthResponse> Login()
public async Task<AuthResponse> Login()
{
Utils.Log("Login started");
AuthObj AuthObj = new AuthObj();
Expand Down Expand Up @@ -220,7 +220,7 @@ public async Task<bool> SaveNewColor(List<Color> Colors, int SelectedIndex, stri
Utils.Log("Reconstructing Data");
await Construct();
return true;
}
}
return false;
}
}
Expand Down
5 changes: 3 additions & 2 deletions ValorantCC/src/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace Utilities
class Utils
{
private static StringBuilder StringBuilder = new StringBuilder();
private static WebClient client = new WebClient();
readonly public static string LoggingFile = Environment.GetEnvironmentVariable("LocalAppData") + @"\VTools\ValorantCC\Logs\logs.txt";

public static Data Decompress(string value)
{
Log("Decompressing Response Data");
Expand Down Expand Up @@ -85,7 +86,7 @@ public static Dictionary<string, string> ConstructHeaders(AuthResponse auth)
public static void Log(string Text)
{
StringBuilder.Append($"{DateTimeOffset.Now} | {Text}\n");
File.AppendAllText(Environment.GetEnvironmentVariable("LocalAppData") + "\\VTools\\Logs\\logs.txt", StringBuilder.ToString());
File.AppendAllText(LoggingFile, StringBuilder.ToString());
StringBuilder.Clear();
}
public static string LoginResponse(Processor processor)
Expand Down

0 comments on commit 48c2003

Please # to comment.