Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Commit

Permalink
0.3.0 : Fix broken API and download links, "news" section (Twitter), …
Browse files Browse the repository at this point in the history
…show "Done !" when download is done.
  • Loading branch information
Ilshidur committed Aug 26, 2016
1 parent 83fd935 commit 83514c5
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

0.3.0 (BREAKING RELEASE)
* Fix : broken API and download links
* "News" section (Twitter)
* Show "Done !" when download is done

0.2.0
* Migrated to WPF design ([Metro Framework](https://github.com/viperneo/winforms-modernui) by [Sven Walter](https://github.com/viperneo) no longer maintained).
* Errors printed in a log file.
Expand Down
15 changes: 15 additions & 0 deletions LoL item sets/models/CurrentPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LoL_item_sets.models
{
class CurrentPatch
{
public string version { get; set; }
public DateTime generationDate { get; set; }
public string err { get; set; }
}
}
13 changes: 13 additions & 0 deletions LoL item sets/models/News.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LoL_item_sets.models
{
class News
{
public string text { get; set; }
}
}
3 changes: 3 additions & 0 deletions Lol item sets/LoL item sets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.2.4.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
Expand Down Expand Up @@ -145,6 +146,8 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="models\CurrentPatch.cs" />
<Compile Include="models\News.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
Expand Down
27 changes: 16 additions & 11 deletions Lol item sets/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Class="LoL_item_sets_XAML.MainWindow"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
mc:Ignorable="d"
Title="LoL item sets" Height="300" Width="300" Background="{x:Null}" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" BorderThickness="0" Foreground="{x:Null}" HorizontalAlignment="Center" VerticalAlignment="Center" Icon="Resources/icon.png" Closing="MainForm_Closing">
Title="LoL item sets" Height="351.027" Width="300" Background="{x:Null}" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" BorderThickness="0" Foreground="{x:Null}" HorizontalAlignment="Center" VerticalAlignment="Center" Icon="Resources/icon.png" Closing="MainForm_Closing">
<Window.Resources>
<Image x:Key="folder" Source="Resources/folder.png"/>
<Image x:Key="icon" Source="Resources/icon.png"/>
</Window.Resources>
<Grid RenderTransformOrigin="1,1" Background="White">
<Grid RenderTransformOrigin="1,1" Background="White" Margin="0,0,0,-6">
<Grid.RowDefinitions>
<RowDefinition Height="262*"/>
<RowDefinition Height="33*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="76*"/>
<ColumnDefinition Width="217*"/>
</Grid.ColumnDefinitions>
<Label x:Name="lblCurrentPatchVersion" HorizontalContentAlignment="Center" Content="Current patch : N/A" Margin="10,10,9.6,0" VerticalAlignment="Top" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" FontSize="16" Width="274" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" Grid.ColumnSpan="2">
<Label x:Name="lblCurrentPatchVersion" HorizontalContentAlignment="Center" Content="Current patch : N/A" Margin="10,10,10,0" VerticalAlignment="Top" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" FontSize="16" Width="274" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" Grid.ColumnSpan="2">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="1"/>
Expand All @@ -31,15 +35,16 @@
<CheckBox x:Name="cbMinimizeOnClose" Content="Minimize on close" HorizontalAlignment="Left" Margin="10,61,0,0" VerticalAlignment="Top" Checked="cbMinimizeOnClose_Checked" FontFamily="/LoL item sets;component/#Lato" Grid.ColumnSpan="2" Unchecked="cbMinimizeOnClose_Checked"/>
<CheckBox x:Name="cbAutoUpdate" Content="Auto update (min. 60s)" HorizontalAlignment="Left" Margin="10,81,0,0" VerticalAlignment="Top" Checked="cbAutoUpdate_Checked" FontFamily="/LoL item sets;component/#Lato" Grid.ColumnSpan="2" Unchecked="cbAutoUpdate_Checked"/>
<Label x:Name="lblNextRefresh" Content="Next auto download in :" HorizontalAlignment="Left" Margin="10,105,0,0" VerticalAlignment="Top" RenderTransformOrigin="3.654,2.853" FontFamily="/LoL item sets;component/#Lato" Grid.ColumnSpan="2"/>
<Label x:Name="lblNextRefreshCooldown" Content="00:00:00" HorizontalAlignment="Left" Margin="75.649,105,0,0" VerticalAlignment="Top" RenderTransformOrigin="3.654,2.853" FontFamily="/LoL item sets;component/#Lato" Grid.Column="1"/>
<Label x:Name="lblNextRefreshCooldown" Content="00:00:00" HorizontalAlignment="Left" Margin="76,105,0,0" VerticalAlignment="Top" RenderTransformOrigin="3.654,2.853" FontFamily="/LoL item sets;component/#Lato" Grid.Column="1"/>
<Button x:Name="btnDownload" Content="Install the sets" HorizontalAlignment="Left" Margin="10,136,0,0" VerticalAlignment="Top" Height="29" FontSize="14.667" Click="btnDownload_Click" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" Width="216" Grid.ColumnSpan="2"/>
<Button x:Name="btnChoosePath" Content="{StaticResource folder}" HorizontalAlignment="Right" Margin="0,136,9.6,0" VerticalAlignment="Top" Width="53" Height="29" RenderTransformOrigin="-0.414,-0.277" Click="btnChoosePath_Click" Grid.Column="1"/>
<xctk:TimeSpanUpDown x:Name="cooldown" Margin="0,76,9.6,0" VerticalAlignment="Top" Height="23" DefaultValue="1:0:0" DisplayDefaultValueOnEmptyText="True" Minimum="0" Maximum="10:0:0" HorizontalAlignment="Right" Width="116" ValueChanged="cooldown_ValueChanged" FontFamily="/LoL item sets;component/#Lato" Grid.Column="1"/>
<Label x:Name="lblDownloading" Content="Downloading ..." Margin="10,170,9.6,0" VerticalAlignment="Top" HorizontalAlignment="Center" FontFamily="/LoL item sets;component/#Lato" Background="White" Foreground="Red" FontWeight="Bold" Width="274" Visibility="Hidden" Grid.ColumnSpan="2"/>
<TextBlock x:Name="lkGoToWebsite" Margin="10,201,0,45" HorizontalAlignment="Left" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" TextDecorations="{x:Null}" FontSize="13.333" Width="134" TextAlignment="Center" Grid.ColumnSpan="2"><Hyperlink Click="lkGoToWebsite_Click">Go to the website</Hyperlink></TextBlock>
<TextBlock x:Name="lkGitHub" Margin="0,202,9.6,46" HorizontalAlignment="Right" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" TextDecorations="{x:Null}" FontSize="13.333" Height="25" Width="134" TextAlignment="Center" Grid.Column="1"><Hyperlink Click="lkGitHub_Click">GitHub repository</Hyperlink></TextBlock>
<Label x:Name="lblAuthor" Content="by Ilshidur" Margin="0,232,9.6,0" VerticalAlignment="Top" HorizontalAlignment="Right" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" FontSize="16" Grid.Column="1"/>
<TextBlock x:Name="lkGoToChangelog" Margin="10,236,0,10" HorizontalAlignment="Left" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" TextDecorations="{x:Null}" FontSize="13.333" Width="134" TextAlignment="Center" Foreground="#FFE66D09" Grid.ColumnSpan="2"><Hyperlink Click="lkGoToChangelog_Click">Changelog</Hyperlink></TextBlock>
<Button x:Name="btnChoosePath" Content="{StaticResource folder}" HorizontalAlignment="Right" Margin="0,136,10,0" VerticalAlignment="Top" Width="53" Height="29" RenderTransformOrigin="-0.414,-0.277" Click="btnChoosePath_Click" Grid.Column="1"/>
<xctk:TimeSpanUpDown x:Name="cooldown" Margin="0,76,10,0" VerticalAlignment="Top" Height="23" DefaultValue="1:0:0" DisplayDefaultValueOnEmptyText="True" Minimum="0" Maximum="10:0:0" HorizontalAlignment="Right" Width="116" ValueChanged="cooldown_ValueChanged" FontFamily="/LoL item sets;component/#Lato" Grid.Column="1"/>
<Label x:Name="lblDownloading" Content="Downloading ..." Margin="10,170,10,0" VerticalAlignment="Top" HorizontalAlignment="Center" FontFamily="/LoL item sets;component/#Lato" Background="White" Foreground="Red" FontWeight="Bold" Width="274" Visibility="Hidden" Grid.ColumnSpan="2"/>
<TextBlock x:Name="lkGoToWebsite" Margin="10,201,0,11.683" HorizontalAlignment="Left" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" TextDecorations="{x:Null}" FontSize="13.333" Width="134" TextAlignment="Center" Grid.ColumnSpan="2"><Hyperlink Click="lkGoToWebsite_Click">Go to the website</Hyperlink></TextBlock>
<TextBlock x:Name="lkGitHub" Margin="0,199,10,67" HorizontalAlignment="Right" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" TextDecorations="{x:Null}" FontSize="13.333" Height="25" Width="134" TextAlignment="Center" Grid.Column="1"><Hyperlink Click="lkGitHub_Click">GitHub repository</Hyperlink></TextBlock>
<Label x:Name="lblAuthor" Content="by Ilshidur" Margin="0,232,10,0" VerticalAlignment="Top" HorizontalAlignment="Right" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" FontSize="16" Grid.Column="1"/>
<TextBlock x:Name="lkGoToChangelog" Margin="10,236,0,10" HorizontalAlignment="Left" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" TextDecorations="{x:Null}" FontSize="13.333" Width="134" TextAlignment="Center" Foreground="#FFE66D09" Grid.ColumnSpan="2" Grid.RowSpan="2"><Hyperlink Click="lkGoToChangelog_Click">Changelog</Hyperlink></TextBlock>
<TextBlock x:Name="lblNews" HorizontalAlignment="Left" TextWrapping="WrapWithOverflow" FontFamily="/LoL item sets;component/#Lato" FontWeight="Bold" TextDecorations="{x:Null}" FontSize="13.333" Width="274" TextAlignment="Center" Foreground="#FFE66D09" Grid.ColumnSpan="2" Margin="10,265,0,10" Grid.RowSpan="2">Follow us on Twitter for more updates !</TextBlock>
</Grid>
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands>
Expand Down
49 changes: 43 additions & 6 deletions Lol item sets/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using LoL_item_sets.models;

// TODO: Add ClickOnce support

Expand Down Expand Up @@ -97,8 +98,16 @@ private async void init()
{
using (WebClient client = new WebClient())
{
string currentPatchVersion = client.DownloadString("http://www.lol-item-sets-generator.org/?version");
this.lblCurrentPatchVersion.Content = String.Format("Current patch : {0}", currentPatchVersion);
string response = client.DownloadString("https://lol-item-sets-generator.org/api/patch");
CurrentPatch patch = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<CurrentPatch>(response);
if (patch.err == null)
{
this.lblCurrentPatchVersion.Content = String.Format("Current patch : {0}", patch.version);
}
else
{
this.lblCurrentPatchVersion.Content = String.Format("Patch not found : {0}", patch.err);
}
}
}
catch (WebException e)
Expand All @@ -114,7 +123,36 @@ private async void init()
return;
}

updateRefresh();
try
{
using (WebClient client = new WebClient())
{
string response = client.DownloadString("https://lol-item-sets-generator.org/api/news");
News news = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<News>(response);
if (news.text != "")
{
this.lblNews.Text = news.text;
}
else
{
this.lblNews.Text = "Follow us on Twitter for more updates !";
}
}
}
catch (WebException e)
{
Trace.TraceError(e.Message);
await this.ShowMessageAsync("Error", "The website appears to be down.");
return;
}
catch (Exception e)
{
Trace.TraceError(e.Message);
await this.ShowMessageAsync("Error", "Unknown error : " + e.Message);
return;
}

updateRefresh();
}

#endregion
Expand Down Expand Up @@ -330,8 +368,7 @@ private async void downloadAndInstallSets()
{
using (var client = new WebClient())
{
client.DownloadFile("http://www.lol-item-sets-generator.org/clicks/click.php?id=dl_sets_from_application", savePath);
// This link is a redirection. It helps to count the downloads.
client.DownloadFile("https://lol-item-sets-generator.org/downloads/sets-from-app", savePath);
}
}
catch (WebException e)
Expand Down Expand Up @@ -392,7 +429,7 @@ private async void downloadAndInstallSets()
this.lblDownloading.Content = "Deleting archive ...";
System.IO.File.Delete(savePath);

this.lblDownloading.Visibility = Visibility.Hidden;
this.lblDownloading.Content = "Done !";

downloading = false;
}
Expand Down
4 changes: 2 additions & 2 deletions Lol item sets/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.0.0")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyFileVersion("0.3.0.0")]
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ TODO
* Notify the user when a new version is available (and use ClickOnce)
* Better error messages
* Downloading : progressbar and "downloading ..." messages in a "Progress dialog" dialog.
* Add some Twitter ads (NON INTRUSIVE)
* Add a pop-up warning the user when a new patch came out

BACKERS
Expand Down

0 comments on commit 83514c5

Please sign in to comment.