Skip to content

Commit

Permalink
Add Parse button to CSVScrobbleView
Browse files Browse the repository at this point in the history
Also a cleanup
  • Loading branch information
SHOEGAZEssb committed Apr 16, 2017
1 parent 80a4c64 commit c0de9e6
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 108 deletions.
2 changes: 1 addition & 1 deletion Last.fm-Scrubbler-WPF/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
10 changes: 4 additions & 6 deletions Last.fm-Scrubbler-WPF/Last.fm-Scrubbler-WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@
<Reference Include="Caliburn.Micro.Platform">
<HintPath>Libs\Caliburn.Micro.Platform.dll</HintPath>
</Reference>
<Reference Include="IF.Lastfm.Core, Version=1.0.0.294, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Inflatable.Lastfm.1.0.0.294\lib\netstandard1.1\IF.Lastfm.Core.dll</HintPath>
<Private>True</Private>
<Reference Include="IF.Lastfm.Core, Version=1.0.1.307, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Inflatable.Lastfm.1.0.1.307\lib\netstandard1.1\IF.Lastfm.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="policy.2.0.taglib-sharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=db62eba44689b5b0, processorArchitecture=MSIL">
<HintPath>..\packages\taglib.2.1.0.0\lib\policy.2.0.taglib-sharp.dll</HintPath>
Expand Down
13 changes: 4 additions & 9 deletions Last.fm-Scrubbler-WPF/ViewModels/LoginViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
using Caliburn.Micro;
using Last.fm_Scrubbler_WPF.Models;
using Last.fm_Scrubbler_WPF.Properties;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Xml;
using System.Xml.Serialization;

namespace Last.fm_Scrubbler_WPF.ViewModels
{
/// <summary>
/// ViewModel for the <see cref="Views.LoginView"/>
/// </summary>
class LoginViewModel : PropertyChangedBase
/// <summary>
/// ViewModel for the <see cref="Views.LoginView"/>
/// </summary>
class LoginViewModel : PropertyChangedBase
{
#region Properties

Expand Down
4 changes: 1 addition & 3 deletions Last.fm-Scrubbler-WPF/ViewModels/PasteYourTasteViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Caliburn.Micro;
using IF.Lastfm.Core.Api.Enums;
using System;
using IF.Lastfm.Core.Api.Enums;
using System.Windows;

namespace Last.fm_Scrubbler_WPF.ViewModels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private set
{
_csvFilePath = value;
NotifyOfPropertyChange(() => CSVFilePath);
NotifyOfPropertyChange(() => CanParse);
}
}
private string _csvFilePath;
Expand All @@ -80,16 +81,13 @@ public CSVScrobbleMode ScrobbleMode
get { return _scrobbleMode; }
set
{
_scrobbleMode = value;

if (Scrobbles.Count > 0)
{
if (MessageBox.Show("Do you want to switch the Scrobble Mode? The CSV file will be parsed again!", "Change Scrobble Mode", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
_scrobbleMode = value;
LoadCSVFile(CSVFilePath);
}
ParseCSVFile();
}
else
_scrobbleMode = value;

NotifyOfPropertyChange(() => ScrobbleMode);
NotifyOfPropertyChange(() => ShowImportModeSettings);
Expand Down Expand Up @@ -157,6 +155,14 @@ public bool CanSelectNone
get { return Scrobbles.Any(i => i.ToScrobble) && EnableControls; }
}

/// <summary>
/// Gets if the "Parse" button is enabled.
/// </summary>
public bool CanParse
{
get { return CSVFilePath != null && CSVFilePath != string.Empty; }
}

/// <summary>
/// Gets if the import mode settings should be visible on the UI.
/// </summary>
Expand Down Expand Up @@ -209,21 +215,19 @@ public void LoadCSVFileDialog()
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "CSV Files|*.csv";
if (ofd.ShowDialog() == DialogResult.OK)
LoadCSVFile(ofd.FileName);
CSVFilePath = ofd.FileName;
}

/// <summary>
/// Loads and parses a csv file.
/// </summary>
/// <param name="path">Path of the csv file to load.</param>
private async void LoadCSVFile(string path)
/// <returns>Task.</returns>
public async Task ParseCSVFile()
{
try
{
EnableControls = false;
OnStatusUpdated("Reading CSV file...");

CSVFilePath = path;
Scrobbles.Clear();

TextFieldParser parser = new TextFieldParser(CSVFilePath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Caliburn.Micro;
using Last.fm_Scrubbler_WPF.Properties;
using Last.fm_Scrubbler_WPF.Views.ScrobbleViews;
using System.ComponentModel;
using System.Linq;
using System.Windows;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Caliburn.Micro;
using IF.Lastfm.Core.Objects;
using Last.fm_Scrubbler_WPF.Models;
using System;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Caliburn.Micro;
using IF.Lastfm.Core.Objects;
using Last.fm_Scrubbler_WPF.Models;
using System;

Expand Down
10 changes: 5 additions & 5 deletions Last.fm-Scrubbler-WPF/Views/CSVDownloaderView.xaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<UserControl x:Class="Last.fm_Scrubbler_WPF.Views.CSVDownloaderView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
Expand All @@ -24,10 +24,10 @@
</Grid.ColumnDefinitions>

<Label Grid.Row="0" Grid.Column="0" Content="Username:"/>
<TextBox Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="3" Text="{Binding Username}" IsEnabled="{Binding EnableControls, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="3" Text="{Binding Username, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding EnableControls}"/>

<Label Grid.Row="2" Grid.Column="0" Content="File Path:"/>
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding FilePath}" IsEnabled="{Binding EnableControls, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding FilePath, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding EnableControls}"/>
<Button Grid.Row="2" Grid.Column="4" Content="..." Width="25" IsEnabled="{Binding EnableControls}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
Expand Down
20 changes: 5 additions & 15 deletions Last.fm-Scrubbler-WPF/Views/CSVDownloaderView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace Last.fm_Scrubbler_WPF.Views
{
Expand All @@ -20,9 +7,12 @@ namespace Last.fm_Scrubbler_WPF.Views
/// </summary>
public partial class CSVDownloaderView : UserControl
{
/// <summary>
/// Constructor.
/// </summary>
public CSVDownloaderView()
{
InitializeComponent();
}
}
}
}
15 changes: 1 addition & 14 deletions Last.fm-Scrubbler-WPF/Views/PasteYourTasteView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace Last.fm_Scrubbler_WPF.Views
{
Expand Down
25 changes: 13 additions & 12 deletions Last.fm-Scrubbler-WPF/Views/ScrobbleViews/CSVScrobbleView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>

<Label Grid.Row="0" Grid.Column="0" Content="CSV File:"/>
Expand All @@ -52,25 +54,24 @@
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Grid.Row="0" Grid.Column="6" Content="Settings">
<Button Grid.Row="0" Grid.Column="6" Content="Parse" IsEnabled="{Binding CanParse}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cal:ActionMessage MethodName="ParseCSVFile"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Grid.Row="0" Grid.Column="8" Content="Settings">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cal:ActionMessage MethodName="OpenCSVParserSettings"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>

<Grid Grid.Row="2" Grid.ColumnSpan="7">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>

<local:SelectScrobblesControl Grid.Column="0" Grid.ColumnSpan="5"/>
</Grid>
<local:SelectScrobblesControl Grid.Row="2" Grid.ColumnSpan="9"/>

<ListView Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="7" ItemsSource="{Binding Scrobbles}" local:GridViewSort.AutoSort="True">
<ListView Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="9" ItemsSource="{Binding Scrobbles}" local:GridViewSort.AutoSort="True">
<ListView.View>
<GridView>
<GridViewColumn Header="Scrobble?" local:GridViewSort.PropertyName="ToScrobble">
Expand Down Expand Up @@ -112,7 +113,7 @@
</ListView.View>
</ListView>

<Grid Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="7">
<Grid Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="9">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="5"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace Last.fm_Scrubbler_WPF.Views
{
Expand Down
14 changes: 1 addition & 13 deletions Last.fm-Scrubbler-WPF/Views/SelectUserView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows;

namespace Last.fm_Scrubbler_WPF.Views
{
Expand Down
4 changes: 2 additions & 2 deletions Last.fm-Scrubbler-WPF/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Extended.Wpf.Toolkit" version="3.0" targetFramework="net452" />
<package id="Inflatable.Lastfm" version="1.0.0.294" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="Inflatable.Lastfm" version="1.0.1.307" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />
<package id="System.Net.Http" version="4.3.1" targetFramework="net452" />
<package id="taglib" version="2.1.0.0" targetFramework="net452" />
</packages>

0 comments on commit c0de9e6

Please sign in to comment.