Skip to content

Commit

Permalink
Added Partner slider and view
Browse files Browse the repository at this point in the history
Added switch to turn off slider
  • Loading branch information
Firewolf1337 committed Jun 4, 2024
1 parent f48d0c7 commit d33dbe1
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 10 deletions.
3 changes: 3 additions & 0 deletions RCRPlanner/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<setting name="SortDate" serializeAs="String">
<value>False</value>
</setting>
<setting name="PartnerSlider" serializeAs="String">
<value>True</value>
</setting>
</RCRPlanner.Properties.Settings>
</userSettings>
</configuration>
10 changes: 5 additions & 5 deletions RCRPlanner/FetchData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public async Task<int> Login_API(byte[] Email, byte[] Password, bool forcelogin)
cookies.Add(cookie);
}
int theCookie = cookies.FindIndex(c => c.Name == "authtoken_members");
if (theCookie != -1)
if (theCookie != -1 && forcelogin == false)
{
if (cookies[theCookie].Expires > (DateTime.Now.AddMinutes(10)) && forcelogin == false)
if (cookies[theCookie].Expires > (DateTime.Now.AddMinutes(10)))
{
try
{
Expand All @@ -92,8 +92,8 @@ public async Task<int> Login_API(byte[] Email, byte[] Password, bool forcelogin)
}
else
{
// if (handler.CookieContainer.Count == 0 || forcelogin)
// {
if (handler.CookieContainer.Count == 0 || forcelogin)
{
try
{
handler = new HttpClientHandler
Expand All @@ -117,7 +117,7 @@ public async Task<int> Login_API(byte[] Email, byte[] Password, bool forcelogin)
}
}
}
// }
}
return 0;
}

Expand Down
9 changes: 7 additions & 2 deletions RCRPlanner/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,11 @@
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>

<DataGrid x:Name="gridPartner" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="6" Style="{StaticResource DefaultDataGrid50hStyle}"
AutoGenerateColumns="False" RowHeight="50" GridLinesVisibility="Horizontal" Visibility="Hidden"
SelectionChanged="dataGrid_SelectionChanged" SelectionMode="Single" ScrollViewer.CanContentScroll="False">

</DataGrid>
<!-- Autostart applications view-->
<DataGrid x:Name="gridAutoStart" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="6" Style="{StaticResource DefaultDataGrid50hStyle}"
AutoGenerateColumns="False" MinColumnWidth="50" GridLinesVisibility="Horizontal" Visibility="Hidden"
Expand Down Expand Up @@ -1440,7 +1444,7 @@
<DoubleAnimation x:Name="daSlider" From="{DynamicResource CanvasRightCalc}" To="0" Duration="{DynamicResource AnimationTime}"
Storyboard.TargetProperty="X"
Storyboard.TargetName="transferCurreny"
RepeatBehavior="Forever"/>
RepeatBehavior="{DynamicResource RepeatBehavior}" Completed="daSlider_Completed"/>
</Storyboard>
</StackPanel.Resources>
<StackPanel.RenderTransform>
Expand Down Expand Up @@ -1759,6 +1763,7 @@
</DockPanel>
<Button x:Name="btnPartStats" Grid.Row="9" Grid.Column="0" Content="Participation Statistics" Click="btnPartStats_Click" ToolTip="Create view of participation in a series."/>
<Button x:Name="btniRatingStats" Grid.Row="10" Grid.Column="0" Content="iRating Statistics" Click="btniRatingStats_Click" ToolTip="Create view of iratings in a series."/>
<Button x:Name="btnParnter" Grid.Row="11" Grid.Column="0" Content="Partner" ToolTip="View Partner" Click="btnParnter_Click"/>
<DockPanel Grid.Row="15" Grid.Column="0" Width="Auto" HorizontalAlignment="Stretch" LastChildFill="true">
<Line X1="0" Y1="7" X2="50" Y2="7" Width="100" Stretch="Fill" Stroke="{StaticResource BrushDarkGray}" StrokeThickness="1" />
<Label Content="Settings" Width="50" Margin="0,-3,0,-3" HorizontalAlignment="Center" FontSize="10" Style="{StaticResource DefaultLabelStyle}"/>
Expand Down
61 changes: 58 additions & 3 deletions RCRPlanner/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ internal string Status
private static readonly string exePath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

private List<partner> partners = new List<partner>();
private bool partnerSliderHide = false;

private readonly string defaultfilter = "cbFilterInOfficial;cbFilterOfficial;cbFilterOpenSetup;cbFilterFixedSetup;cbFilterFormula;cbFilterSports;cbFilterOval;cbFilterDirt;cbFilterDirtOval;cbFilterR;cbFilterD;cbFilterC;cbFilterB;cbFilterA;cbFilterP";

Expand Down Expand Up @@ -925,7 +926,7 @@ private void Style_ProfileIcon(memberInfo.Root info)

private void switchMainGridVisibility(List<System.Windows.Controls.DataGrid> gridToShow, bool Details)
{
List<System.Windows.Controls.DataGrid> allGrids = new List<System.Windows.Controls.DataGrid> { gridSeries, gridCars, gridTracksLayout, gridPurchaseGuide, gridRaces, gridCarDetail, gridTrackDetail, gridAutoStart, gridPartStat, gridiRatingStat };
List<System.Windows.Controls.DataGrid> allGrids = new List<System.Windows.Controls.DataGrid> { gridSeries, gridCars, gridTracksLayout, gridPurchaseGuide, gridRaces, gridCarDetail, gridTrackDetail, gridAutoStart, gridPartStat, gridiRatingStat, gridPartner };

if (Details)
{
Expand Down Expand Up @@ -2142,8 +2143,19 @@ private async void generatePartnerSlider()
}
}
}
int sliderTimer = 30 + (partners.Count() * 3);
this.Resources["AnimationTime"] = (Duration)new TimeSpan(0, 0, sliderTimer);
if (Properties.Settings.Default.PartnerSlider)
{
this.Resources["RepeatBehavior"] = RepeatBehavior.Forever;
partnerSliderHide = false;
spPartners.Visibility = Visibility.Visible;

this.Resources["AnimationTime"] = (Duration)new TimeSpan(0, 0, 30 + (partners.Count() * 3));
}
else
{
this.Resources["RepeatBehavior"] = (RepeatBehavior)new RepeatBehavior(2);
}
}

private List<int> getPurchasedItems()
Expand Down Expand Up @@ -2694,7 +2706,29 @@ private void btnLoadSeasonOverview_Click(object sender, RoutedEventArgs e)
gridSeasonOverview.Visibility = Visibility.Visible;
scrollSeasonOverview.Visibility = Visibility.Visible;
}

private void btnParnter_Click(object sender, RoutedEventArgs e)
{
activeGrid = "gridPartner";
btnMenu1.Visibility = Visibility.Hidden;
cbMenu2.Visibility = Visibility.Visible;
tbMenu2.Visibility = Visibility.Hidden;
dpMenu2.Visibility = Visibility.Hidden;
lbMenu2.Visibility = Visibility.Hidden;
cbMenu3.Visibility = Visibility.Hidden;
dpMenu3.Visibility = Visibility.Hidden;
cbMenu4.Visibility = Visibility.Hidden;
cbMenu5.Visibility = Visibility.Hidden;
dpMenu4.Visibility = Visibility.Hidden;
dpMenu5.Visibility = Visibility.Hidden;
cbMenu6.Visibility = Visibility.Hidden;
dpMenu6.Visibility = Visibility.Hidden;
tbMenu6.Visibility = Visibility.Hidden;
cbMenu2.Content = "Run partner slider";
cbMenu2.IsChecked = Properties.Settings.Default.PartnerSlider;
stackPanelMenuClose_MouseDown(null, null);
switchMainGridVisibility(new List<System.Windows.Controls.DataGrid> { gridPartner }, false);

}
private void btnstartPrograms_Click(object sender, RoutedEventArgs e)
{
startPrograms();
Expand Down Expand Up @@ -3205,6 +3239,18 @@ private void cbMenu2_Click(object sender, RoutedEventArgs e)
Properties.Settings.Default.Save();
generateSeasonOverviewGrid(false);
break;
case "gridPartner":
Properties.Settings.Default.PartnerSlider = cbMenu2.IsChecked.Value;
Properties.Settings.Default.Save();
generatePartnerSlider();
try
{
BeginStoryboard storyboardbegin = (BeginStoryboard)(this).sbslidebeg;
storyboardbegin.Storyboard.RepeatBehavior = (RepeatBehavior)this.Resources["RepeatBehavior"];
storyboardbegin.Storyboard.Begin();
}
catch { }
break;
}

}
Expand Down Expand Up @@ -3630,5 +3676,14 @@ private void dpMenu3date_SelectedDateChanged(object sender, SelectionChangedEven
{
generateRaceView();
}

private void daSlider_Completed(object sender, EventArgs e)
{
if (this.Resources["RepeatBehavior"].ToString() != "Forever")
{
spPartners.Visibility = Visibility.Hidden;
partnerSliderHide = true;
}
}
}
}
12 changes: 12 additions & 0 deletions RCRPlanner/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions RCRPlanner/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
<Setting Name="SortDate" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="PartnerSlider" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

0 comments on commit d33dbe1

Please sign in to comment.