Skip to content

Commit

Permalink
You can now mark episodes as downloaded&watched. Version v0.16
Browse files Browse the repository at this point in the history
Fixed Bugs: "+New" not displayed when going from 0 to 1 episode. Applying Filter discarded thumbnail.
  • Loading branch information
Dreamcooled committed Sep 20, 2014
1 parent 08d2292 commit 273004a
Show file tree
Hide file tree
Showing 10 changed files with 338 additions and 60 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Any contribution would be highly appreciated.


#### Download
Binaries of current version v0.15 (needs .NET 4.5):
Binaries of current version v0.16 (needs .NET 4.5):
#####https://github.com/Dreamcooled/sjupdater/releases/


Expand Down
61 changes: 53 additions & 8 deletions SjUpdater/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,22 @@
</Rectangle.OpacityMask>
</Rectangle>
</Button>
<Button Width="40" VerticalAlignment="Center" ToolTip="Mark all..." Click="MarkAllContextMenuButtonClicked" ContextMenuService.IsEnabled="false"
Height="40"
Style="{DynamicResource MetroCircleButtonStyle}">
<Rectangle Fill="{DynamicResource LabelTextBrush}" Width="17" Height="17">
<Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_checkmark_pencil}" Stretch="Uniform" />
</Rectangle.OpacityMask>
</Rectangle>
<Button.ContextMenu>
<ContextMenu Placement="RelativePoint" VerticalOffset="32" HorizontalOffset="32" DataContext="{Binding Path=PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
<MenuItem Header ="Mark all as Watched" Command="{Binding MarkAllWatchedCommand}" />
<MenuItem Header ="Mark all as Downloaded" Command="{Binding MarkAllDownloadedCommand}" />
<MenuItem Header ="Unmark all" Command="{Binding UnmarkAllCommand}"/>
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button Width="40" VerticalAlignment="Center" Click="ShowDelete" ToolTip="Remove this Show"
Height="40"
Style="{DynamicResource MetroCircleButtonStyle}">
Expand Down Expand Up @@ -327,18 +343,20 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Grid.RowSpan="5" Visibility="{Binding NewEpisodeVisible}" BorderThickness="1" Background="Transparent" BorderBrush="LightGray"/>
<Border Grid.RowSpan="6" Visibility="{Binding NewEpisodeVisible}" BorderThickness="1" Background="Transparent" BorderBrush="LightGray"/>

<Image Grid.Row="0" Source="{Binding Thumbnail.ImageSource}" Stretch="UniformToFill"
Grid.RowSpan="5" Opacity="{Binding ImageOpacity}" Visibility="{Binding BackgroundImageVisibility}"/>
Grid.RowSpan="6" Opacity="{Binding ImageOpacity}" Visibility="{Binding BackgroundImageVisibility}"/>


<!---Border Grid.RowSpan="4" Background="#A0010101" /-->



<TextBlock Grid.Row="0" Text="{Binding Title}" TextWrapping="Wrap" Foreground="{Binding Foreground}"
Margin="5,0,0,0" FontSize="20" />
Margin="5,0,0,0" FontSize="20" />
<TextBlock Grid.Row="1" Text="{Binding Languages}" Foreground="{Binding Foreground}" FontSize="10"
Margin="5,0,0,0" />
<TextBlock Grid.Row="2" Text="{Binding Formats}" Foreground="{Binding Foreground}" FontSize="10"
Expand All @@ -355,6 +373,19 @@
Visibility="{Binding NewUpdateVisible}"
Foreground="{Binding Foreground}" FontWeight="Bold">
</TextBlock>

<StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,5,5">
<Rectangle Width="16" Height="16" Visibility="{Binding DownloadedCheckVisibility}">
<Rectangle.Fill>
<VisualBrush Visual="{StaticResource appbar_check}" />
</Rectangle.Fill>
</Rectangle>
<Rectangle Width="16" Height="16" Visibility="{Binding WatchedCheckVisibility}">
<Rectangle.Fill>
<VisualBrush Visual="{StaticResource appbar_check}" />
</Rectangle.Fill>
</Rectangle>
</StackPanel>

</Grid>

Expand Down Expand Up @@ -423,12 +454,26 @@
</Button>
<Label FontFamily="Segoe UI Symbol" FontSize="24" Foreground="{DynamicResource LabelTextBrush}" Content="{Binding Title}"
VerticalAlignment="Center" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="10,0,0,0" Visibility="{Binding MarkStuffVisibility}">
<Rectangle Width="24" Height="24" Visibility="{Binding DownloadedCheckVisibility}" ToolTip="Downloaded" Fill="{DynamicResource LabelTextBrush}">
<Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_check}" Stretch="Fill" />
</Rectangle.OpacityMask>
</Rectangle>
<Rectangle Width="24" Height="24" Visibility="{Binding WatchedCheckVisibility}" ToolTip="Watched" Fill="{DynamicResource LabelTextBrush}">
<Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_check}" Stretch="Fill" />
</Rectangle.OpacityMask>
</Rectangle>
</StackPanel>
</StackPanel>
<Image Margin="10" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Source="{Binding Thumbnail.ImageSource}"
Stretch="UniformToFill" Height="105" />
<Button Grid.Column="0" Grid.Row="1" Content="Show Review" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="10,10,10,10" Command="{Binding ReviewCommand}" />

<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="1" VerticalAlignment="Top" >
<Button Content="Show Review" Margin="10,10,10,10" Command="{Binding ReviewCommand}" />
<Button Content="{Binding ButtonStateChangeText}" Margin="10,10,10,10" Command="{Binding StateChangeCommand }" Visibility="{Binding MarkStuffVisibility}"/>
</StackPanel>

<ListView x:Name="EpisodeDataList" Margin="10,10,10,10" ItemsSource="{Binding Downloads}" Grid.Column="0"
Grid.Row="2" Grid.ColumnSpan="2">
<ListView.View>
Expand Down Expand Up @@ -497,8 +542,8 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Margin="4" Padding="4,0" Background="{DynamicResource LabelTextBrush}"
Command="{Binding DownloadCommand, ElementName=Window}" ToolTip="{Binding Key}"
<Button Margin="4" Padding="4,0"
Command="{Binding DataContext.DownloadCommand, ElementName=EpisodeGrid}" ToolTip="{Binding Key}"
CommandParameter="{Binding Value}" >
<ContentPresenter Content="{Binding Key,Converter={StaticResource StringToFaviconConverter}}" >
<ContentPresenter.ContentTemplate>
Expand Down
31 changes: 9 additions & 22 deletions SjUpdater/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public MainWindow()
Application.Current.SessionEnding += Current_SessionEnding;

//Commands
DownloadCommand = new SimpleCommand<object, String>(DownloadCommandExecute);
EpisodeClickedCommand = new SimpleCommand<object, EpisodeViewModel>(OnEpisodeViewClicked);
ShowClickedCommand = new SimpleCommand<object, ShowViewModel>(OnShowViewClicked);
SettingsCommand = new SimpleCommand<object, object>(SettingsClicked);
Expand Down Expand Up @@ -175,25 +174,6 @@ private void IconClicked(object obj)
Activate(); //"Bring to front"
}

private void DownloadCommandExecute(string s)
{
for (int i = 0; i < 10; i++)
{
try
{
Clipboard.SetText(s);
Clipboard.Flush();
Stats.TrackAction(Stats.TrackActivity.Download);
return;
}
catch
{
//nah
}
Thread.Sleep(10);
}
MessageBox.Show("Couldn't Copy link to clipboard.\n" + s);
}

private Accent _currentAccent;

Expand Down Expand Up @@ -227,10 +207,10 @@ public String CurrentTheme
public ICommand SettingsCommand { get; private set; }
public ICommand EpisodeClickedCommand { get; private set; }
public ICommand ShowClickedCommand { get; private set; }
public ICommand DownloadCommand { get; private set; }
public ICommand IconClickedCommand { get; private set; }
public ICommand TerminateCommand { get; private set; }


private int CurrentPage()
{
return TabControl.SelectedIndex;
Expand Down Expand Up @@ -316,13 +296,13 @@ private void OpenHomepage(object sender, RoutedEventArgs e)
p.Start();
Stats.TrackAction(Stats.TrackActivity.Browse, "Home");
}

private void ShowDelete(object sender, RoutedEventArgs e)
{
_setti.TvShows.Remove(((ShowViewModel) ShowGrid.DataContext).Show);
SwitchPage(0);
}


private void EpisodeDataBack(object sender, RoutedEventArgs e)
{
SwitchPage(1);
Expand Down Expand Up @@ -499,5 +479,12 @@ private void restartButton_Click(object sender, RoutedEventArgs e)
cmd.Start();
Terminate(null);
}

private void MarkAllContextMenuButtonClicked(object sender, RoutedEventArgs e)
{
var em = (e.Source as FrameworkElement);
em.ContextMenu.PlacementTarget = em;
em.ContextMenu.IsOpen = true;
}
}
}
27 changes: 27 additions & 0 deletions SjUpdater/Model/FavEpisodeData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class FavEpisodeData : PropertyChangedImpl
private int _number;
private bool _newEpisode;
private bool _newUpdate;
private bool _watched;
private bool _downloaded;
private ObservableCollection<DownloadData> _downloads;
private FavSeasonData _season;
private SjDeReview _reviewInfoReview;
Expand All @@ -23,6 +25,8 @@ public FavEpisodeData()
_reviewInfoReview = null;
_newEpisode = false;
_newUpdate = false;
_downloaded = false;
_watched = false;
}

public SjDeReview ReviewInfoReview
Expand Down Expand Up @@ -65,6 +69,29 @@ public int Number
}
}

public bool Watched
{
get { return _watched; }
set
{
if (value == _watched)
return;
_watched = value;
OnPropertyChanged();
}
}
public bool Downloaded
{
get { return _downloaded; }
set
{
if (value == _downloaded)
return;
_downloaded = value;
OnPropertyChanged();
}
}

/// <summary>
/// Is set to true when the episode is new. Reset this to false, yourself
/// </summary>
Expand Down
40 changes: 32 additions & 8 deletions SjUpdater/Model/FavShowData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Windows.Documents;
using System.Xml.Serialization;
using Amib.Threading;
using MahApps.Metro.Converters;
using SjUpdater.Utils;

namespace SjUpdater.Model
Expand Down Expand Up @@ -37,10 +38,12 @@ public class FavShowData : PropertyChangedImpl
private bool? _filterShowNonEpisode;
private string _infoUrl;
private List<DownloadData> _allDownloads;
private readonly bool _isNewShow; //=false

public FavShowData(ShowData show, bool autofetch= false) :this()
{
_show = show;
_isNewShow = true;
_name = show.Name;
if (autofetch)
{
Expand Down Expand Up @@ -118,9 +121,15 @@ public void ApplyFilter(bool reset=true)
SeasonData currentSeasonData = null;
int seasonNr = -1;

reset = reset || Seasons.Count == 0; //0 seasons is also considered as "reset".
if(reset) //start from scratch?
Seasons.Clear();
ObservableCollection<FavSeasonData> oldSeasons = null;

reset = reset || _isNewShow;
if (reset)
{
//start from scratch?
oldSeasons = new ObservableCollection<FavSeasonData>(Seasons);
Seasons.Clear();
}

UploadData currentUpload = null;
bool ignoreCurrentUpload = false;
Expand Down Expand Up @@ -283,13 +292,28 @@ public void ApplyFilter(bool reset=true)
}
}
currentFavSeason.Episodes.Add(currentFavEpisode);
if (!String.IsNullOrWhiteSpace(InfoUrl))

if (oldSeasons != null && currentFavSeason.Number!=-1 && currentFavEpisode.Number!=-1) //old data possible
{
var oldSeason = oldSeasons.FirstOrDefault(s => s.Number == currentFavSeason.Number);
if (oldSeason != null)
{
var oldEpisode = oldSeason.Episodes.FirstOrDefault(e => e.Number == currentFavEpisode.Number);
if (oldEpisode != null) //we can copy old data to current episode
{
currentFavEpisode.Watched = oldEpisode.Watched;
currentFavEpisode.Downloaded = oldEpisode.Downloaded;
currentFavEpisode.ReviewInfoReview = oldEpisode.ReviewInfoReview;
}
}
}

if (!String.IsNullOrWhiteSpace(InfoUrl) && currentFavEpisode.ReviewInfoReview == null)
{
StaticInstance.ThreadPool.QueueWorkItem(() =>
{
currentFavEpisode.ReviewInfoReview = SjInfo.ParseSjDeSite(InfoUrl,
currentFavEpisode.Season.Number, currentFavEpisode.Number);
});
{
currentFavEpisode.ReviewInfoReview = SjInfo.ParseSjDeSite(InfoUrl, currentFavEpisode.Season.Number, currentFavEpisode.Number);
});
}
currentFavEpisode.Downloads.Add(download);
}
Expand Down
4 changes: 2 additions & 2 deletions SjUpdater/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.15.6.0")]
[assembly: AssemblyFileVersion("0.15.6.0")]
[assembly: AssemblyVersion("0.16.0.0")]
[assembly: AssemblyFileVersion("0.16.0.0")]
[assembly: GuidAttribute("7CE08AB1-B0EE-4D6F-9AB0-28C2F23CB155")]
20 changes: 5 additions & 15 deletions SjUpdater/Utils/FavIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Principal;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml.Serialization;
using Brushes = System.Windows.Media.Brushes;
using SjUpdater.Properties;
using Brush = System.Drawing.Brush;

namespace SjUpdater.Utils
{
Expand Down Expand Up @@ -100,9 +102,6 @@ private static BitmapImage Get(String value)

private static BitmapImage GetFromLetters(String value)
{



Bitmap bmp = new Bitmap(48,48);
RectangleF rectf = new RectangleF(0,0,48,48);
Graphics g = Graphics.FromImage(bmp);
Expand All @@ -114,8 +113,8 @@ private static BitmapImage GetFromLetters(String value)
StringFormat format = new StringFormat();
format.LineAlignment = StringAlignment.Center;
format.Alignment = StringAlignment.Center;
g.DrawString(""+value.ToUpper().First(), new Font("Tahoma", 40,FontStyle.Bold,GraphicsUnit.Pixel), System.Drawing.Brushes.Blue, rectf, format);

System.Windows.Media.Color c = ((SolidColorBrush)App.Current.FindResource("LabelTextBrush")).Color; // ye i know, it's hacky but it works
g.DrawString(""+value.ToUpper().First(), new Font("Tahoma", 40,FontStyle.Bold,GraphicsUnit.Pixel), new SolidBrush(System.Drawing.Color.FromArgb(c.A, c.R, c.G, c.B)), rectf, format);
g.Flush();
MemoryStream ms = new MemoryStream();
bmp.Save(ms,ImageFormat.Png);
Expand All @@ -124,11 +123,6 @@ private static BitmapImage GetFromLetters(String value)
}







private static BitmapImage GetFromCache(string value)
{
value.ToLower();
Expand All @@ -143,10 +137,6 @@ private static BitmapImage GetFromCache(string value)
return null;
}





static String FindUrl(string value)
{
if (!value.StartsWith("http"))
Expand Down
Loading

0 comments on commit 273004a

Please sign in to comment.