diff --git a/ValorantCC/SubWindow/ProfilesWindow.xaml b/ValorantCC/SubWindow/ProfilesWindow.xaml
index 66d4e69..af7c185 100644
--- a/ValorantCC/SubWindow/ProfilesWindow.xaml
+++ b/ValorantCC/SubWindow/ProfilesWindow.xaml
@@ -26,12 +26,8 @@
An error has occured while fetching profiles.
-
-
-
-
-
+
diff --git a/ValorantCC/SubWindow/ProfilesWindow.xaml.cs b/ValorantCC/SubWindow/ProfilesWindow.xaml.cs
index f50702a..0684d33 100644
--- a/ValorantCC/SubWindow/ProfilesWindow.xaml.cs
+++ b/ValorantCC/SubWindow/ProfilesWindow.xaml.cs
@@ -2,6 +2,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
@@ -26,9 +27,11 @@ public struct PublicProfile
public partial class ProfilesWindow : MetroWindow
{
public CrosshairProfile selected;
+ private static bool SearchButtonPressed = false;
private static API ValCCApi;
private static MainWindow main;
private static List PublicProfiles = new List();
+ private bool AlreadyFetching = false;
private int _offset = 0;
public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
{
@@ -42,7 +45,6 @@ public ProfilesWindow(CrosshairProfile current, API ValCCAPI)
private async void ShareablesContainer_Loaded(object sender, RoutedEventArgs e)
{
LoadingPlaceHolder.Visibility = Visibility.Visible;
- Pagination.Visibility = Visibility.Collapsed;
fetchErrorTxt.Visibility = Visibility.Collapsed;
try
{
@@ -50,6 +52,7 @@ private async void ShareablesContainer_Loaded(object sender, RoutedEventArgs e)
if (!fetchSucc) fetchErrorTxt.Visibility = Visibility.Visible;
else
{
+ LoadingPlaceHolder.Visibility = Visibility.Collapsed;
await RenderProfiles();
}
}
@@ -58,20 +61,21 @@ private async void ShareablesContainer_Loaded(object sender, RoutedEventArgs e)
Utilities.Utils.Log(ex.StackTrace.ToString());
}
LoadingPlaceHolder.Visibility = Visibility.Collapsed;
- Pagination.Visibility = Visibility.Visible;
}
///
/// Returns the searched sharecode or the list of shareables depending if sharecode is provided or not.
///
/// Nullable. Searched Code
- private async Task InitialFetch(String sharecode = null)
+ private async Task InitialFetch(String sharecode = null, bool ClearArrays = true)
{
Utilities.Utils.Log("Disabling Search button.");
btnSearchCode.IsEnabled = false;
- Utilities.Utils.Log("Clearing arrays.");
- PublicProfiles.Clear();
- ShareablesContainer.Children.Clear();
+ if (ClearArrays)
+ {
+ Utilities.Utils.Log("Clearing arrays.");
+ PublicProfiles.Clear();
+ }
List Shareables;
if (!string.IsNullOrWhiteSpace(sharecode))
{
@@ -92,10 +96,13 @@ private async Task InitialFetch(String sharecode = null)
FetchResponse fetchResponse = await ValCCApi.Fetch(Offset: _offset);
if (!fetchResponse.success) return false;
Shareables = fetchResponse.data;
- Pagination.Visibility = Visibility.Visible;
}
- if (Shareables.Count == 0) return true;
+ if (Shareables == null || Shareables.Count == 0)
+ {
+ btnSearchCode.IsEnabled = true;
+ return true;
+ }
for (int i = 0; i < Shareables.Count; i++)
{
@@ -111,13 +118,21 @@ private async Task InitialFetch(String sharecode = null)
///
/// Render the PublicProfiles var into frontend.
///
- private async Task RenderProfiles()
+ private async Task RenderProfiles(bool clearChildren = true)
{
UIElementCollection shareablesElement = ShareablesContainer.Children;
if (PublicProfiles.Count == 0) return true;
- for (int i = 0; i < PublicProfiles.Count; i++)
+ int positionToRender = _offset;
+ if (clearChildren)
+ {
+ positionToRender = 0;
+ shareablesElement.Clear();
+ }
+ for (int i = positionToRender; i < PublicProfiles.Count; i++)
{
+ if (SearchButtonPressed)
+ return true;
PublicProfile profile = PublicProfiles[i];
shareablesElement.Add(await this.GenerateRender(profile));
}
@@ -125,15 +140,18 @@ private async Task RenderProfiles()
}
private async void btnSearchCode_Click(object sender, RoutedEventArgs e)
{
+ SearchButtonPressed = true;
LoadingPlaceHolder.Visibility = Visibility.Visible;
- Pagination.Visibility = Visibility.Collapsed;
fetchErrorTxt.Visibility = Visibility.Collapsed;
try
{
bool fetchSucc = await InitialFetch(SearchCode.Text);
if (!fetchSucc) fetchErrorTxt.Visibility = Visibility.Visible;
else
+ {
+ SearchButtonPressed = false;
await RenderProfiles();
+ }
}
catch (Exception ex)
{
@@ -212,50 +230,42 @@ private void LoadingPlaceHolder_IsVisibleChanged(object sender, DependencyProper
WpfAnimatedGif.ImageBehavior.GetAnimationController(LoadingPlaceHolder)?.Pause();
}
- private async void btnNextOffset_MouseUp(object sender, MouseButtonEventArgs e)
+ private async void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
- LoadingPlaceHolder.Visibility = Visibility.Visible;
- Pagination.Visibility = Visibility.Collapsed;
- fetchErrorTxt.Visibility = Visibility.Collapsed;
- _offset += 20;
- try
+ var MaxHeight = ScrollContainer.ScrollableHeight;
+ var ScrollPercentage = ((MaxHeight - ScrollContainer.VerticalOffset) / MaxHeight) *100;
+ var MaxScrollPercentage = 12 - .025*_offset;
+ if(MaxScrollPercentage <= 0) MaxScrollPercentage = .5;
+ System.Diagnostics.Trace.WriteLine(ScrollPercentage);
+ if (ScrollPercentage < MaxScrollPercentage && !AlreadyFetching)
{
- bool fetchSucc = await InitialFetch();
- if (!fetchSucc) fetchErrorTxt.Visibility = Visibility.Visible;
- else
+ AlreadyFetching = true;
+ mouse_event(MOUSEEVENTF_LEFTUP, (uint)Mouse.GetPosition(this).X, (uint)Mouse.GetPosition(this).Y, 0, 0);
+ fetchErrorTxt.Visibility = Visibility.Collapsed;
+ _offset += 20;
+ try
{
- await RenderProfiles();
+ bool fetchSucc = await InitialFetch(null, false);
+ if (!fetchSucc) fetchErrorTxt.Visibility = Visibility.Visible;
+ else
+ {
+ await RenderProfiles(false);
+ }
}
- }
- catch (Exception ex)
- {
- Utilities.Utils.Log(ex.StackTrace.ToString());
- }
- LoadingPlaceHolder.Visibility = Visibility.Collapsed;
- Pagination.Visibility = Visibility.Visible;
- }
-
- private async void btnPreviousOffset_MouseUp(object sender, MouseButtonEventArgs e)
- {
- LoadingPlaceHolder.Visibility = Visibility.Visible;
- Pagination.Visibility = Visibility.Collapsed;
- fetchErrorTxt.Visibility = Visibility.Collapsed;
- if (_offset >= 20) _offset -= 20;
- try
- {
- bool fetchSucc = await InitialFetch();
- if (!fetchSucc) fetchErrorTxt.Visibility = Visibility.Visible;
- else
+ catch (Exception ex)
{
- await RenderProfiles();
+ Utilities.Utils.Log(ex.StackTrace.ToString());
}
+ AlreadyFetching = false;
}
- catch (Exception ex)
- {
- Utilities.Utils.Log(ex.StackTrace.ToString());
- }
- LoadingPlaceHolder.Visibility = Visibility.Collapsed;
- Pagination.Visibility = Visibility.Visible;
}
+
+ //For making left click up, so it doesnt make trouble with auto-fetching
+ [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
+ public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
+ private const int MOUSEEVENTF_LEFTDOWN = 0x02;
+ private const int MOUSEEVENTF_LEFTUP = 0x04;
+ private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
+ private const int MOUSEEVENTF_RIGHTUP = 0x10;
}
}
diff --git a/ValorantCC/ValorantCC.csproj b/ValorantCC/ValorantCC.csproj
index 0f3c9ba..502f1e7 100644
--- a/ValorantCC/ValorantCC.csproj
+++ b/ValorantCC/ValorantCC.csproj
@@ -14,7 +14,7 @@
false
- 3.1.7
+ 3.1.8
true
diff --git a/ValorantCC/src/Crosshair_Parser.cs b/ValorantCC/src/Crosshair_Parser.cs
index 32a996b..c30a3c7 100644
--- a/ValorantCC/src/Crosshair_Parser.cs
+++ b/ValorantCC/src/Crosshair_Parser.cs
@@ -141,7 +141,7 @@ public static void rectangle_redraw(Rectangle Rect, Rectangle RectOT, Position p
if (Rect.Name.Contains("OL"))
line = settings.OuterLines;
- if (line.bShowShootingError)
+ if ((bool)(line?.bShowShootingError))
Margin += 8;
switch (pos)