Skip to content

Commit c942b00

Browse files
committed
Added interface and shortcut icon drag-and-drop support to GUI.
Added icons for GUI and console applications. Changed file preview ListBox to hide focus rectangle for items. Fixed a bug where directory text box would wrap long lines in GUI.
1 parent 5cee13d commit c942b00

File tree

9 files changed

+59
-9
lines changed

9 files changed

+59
-9
lines changed

Playlist Generator Console/Playlist Generator Console.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
<ErrorReport>prompt</ErrorReport>
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
34+
<PropertyGroup>
35+
<ApplicationIcon>logo 1.1 grey.ico</ApplicationIcon>
36+
</PropertyGroup>
3437
<ItemGroup>
3538
<Reference Include="System" />
3639
<Reference Include="System.Core" />
@@ -56,6 +59,9 @@
5659
<Name>Playlist Generator</Name>
5760
</ProjectReference>
5861
</ItemGroup>
62+
<ItemGroup>
63+
<Content Include="logo 1.1 grey.ico" />
64+
</ItemGroup>
5965
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6066
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
6167
Other similar extension points exist, see Microsoft.Common.targets.
8.07 KB
Binary file not shown.

Playlist Generator GUI/MainWindow.xaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:local="clr-namespace:PlaylistGenerator" x:Class="PlaylistGenerator.MainWindow"
55
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
6-
Height="431" Width="409" WindowStartupLocation="CenterScreen" UseLayoutRounding="True">
6+
Height="431" Width="409" WindowStartupLocation="CenterScreen" UseLayoutRounding="True" AllowDrop="True" Drop="Window_Drop" PreviewDragOver="Window_PreviewDragOver">
77
<Window.DataContext>
88
<local:MainWindowViewModel/>
99
</Window.DataContext>
1010
<Grid>
1111
<Label Margin="10,7,0,0" Content="Directory" VerticalAlignment="Top" HorizontalAlignment="Left"/>
12-
<TextBox x:Name="directory" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Margin="73,10,86,0" Text="{Binding Directory, UpdateSourceTrigger=PropertyChanged}"/>
12+
<TextBox x:Name="directory" Height="23" VerticalAlignment="Top" Margin="73,10,86,0" Text="{Binding Directory, UpdateSourceTrigger=PropertyChanged}"/>
1313
<Button x:Name="browse" Content="Browse" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Height="23" Click="browse_Click" Width="71"/>
1414
<Label Content="File type" HorizontalAlignment="Left" Margin="10,38,0,0" VerticalAlignment="Top"/>
1515
<ComboBox VerticalAlignment="Top" Margin="69,42,10,0" SelectedValuePath="Key" SelectedValue="{Binding SelectedFileType}" IsEnabled="{Binding Files, TargetNullValue=false}">
@@ -32,12 +32,20 @@
3232
</DataTemplate>
3333
</ComboBox.ItemTemplate>
3434
</ComboBox>
35+
<!-- Read-only ListBox -->
3536
<ListBox ItemsSource="{Binding SelectedFiles}" Margin="10,73,10,66" IsEnabled="{Binding Files, TargetNullValue=false}">
3637
<ListBox.Resources>
38+
<!-- Hide item selection highlight. -->
3739
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="{StaticResource {x:Static SystemColors.ControlTextColorKey}}"/>
38-
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Opacity="0"/>
40+
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Opacity="0"/>
3941
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Opacity="0"/>
4042
</ListBox.Resources>
43+
<ListBox.ItemContainerStyle>
44+
<!-- Hide item focus border. -->
45+
<Style TargetType="{x:Type ListBoxItem}">
46+
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
47+
</Style>
48+
</ListBox.ItemContainerStyle>
4149
</ListBox>
4250
<Button x:Name="generate" Content="Generate" HorizontalAlignment="Center" VerticalAlignment="Bottom" Height="25" IsDefault="True" Margin="0,0,0,31" Click="generate_Click" IsEnabled="{Binding Files, TargetNullValue=false}" Width="80"/>
4351
<StatusBar Height="21" VerticalAlignment="Bottom" BorderThickness="0,1,0,0" BorderBrush="{StaticResource {x:Static SystemColors.ActiveBorderBrushKey}}">

Playlist Generator GUI/MainWindow.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ public MainWindow() {
2727

2828
//Set window title.
2929
Title = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
30+
31+
ParseCommandLineArguments();
32+
}
33+
34+
private void ParseCommandLineArguments() {
35+
var args = Environment.GetCommandLineArgs();
36+
37+
if (args.Length > 1) //Argument 0 is the application path.
38+
//Assume argument 1 is a directory.
39+
ViewModel.Directory = args[1];
3040
}
3141

3242
private void browse_Click(object sender, RoutedEventArgs e) {
@@ -52,5 +62,23 @@ private void generate_Click(object sender, RoutedEventArgs e) {
5262
Generator.Configuration.Contexts[0].FileName
5363
);
5464
}
65+
66+
private void Window_Drop(object sender, DragEventArgs e) {
67+
var d = (DataObject)e.Data;
68+
69+
if (d.ContainsFileDropList())
70+
//Assume first file is a directory.
71+
ViewModel.Directory = d.GetFileDropList()[0];
72+
}
73+
74+
/* PreviewDragOver is required instead of DragOver event for drag to
75+
* work with TextBox controls for some reason. Cursor still glitches
76+
* when passing over TextBox borders. Can't drag over Window chrome. */
77+
private void Window_PreviewDragOver(object sender, DragEventArgs e) {
78+
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
79+
e.Effects = DragDropEffects.Copy;
80+
e.Handled = true;
81+
}
82+
}
5583
}
5684
}

Playlist Generator GUI/Playlist Generator GUI.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</PropertyGroup>
5858
<PropertyGroup />
5959
<PropertyGroup>
60-
<ApplicationIcon>logo.ico</ApplicationIcon>
60+
<ApplicationIcon>logo 1.1 blue.ico</ApplicationIcon>
6161
</PropertyGroup>
6262
<ItemGroup>
6363
<Reference Include="System" />
@@ -150,7 +150,7 @@
150150
</ProjectReference>
151151
</ItemGroup>
152152
<ItemGroup>
153-
<Resource Include="logo.ico" />
153+
<Resource Include="logo 1.1 blue.ico" />
154154
</ItemGroup>
155155
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
156156
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

Playlist Generator GUI/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.0.0.0")]
55-
[assembly: AssemblyFileVersion("1.0.0.0")]
54+
[assembly: AssemblyVersion("1.1.0.0")]
55+
[assembly: AssemblyFileVersion("1.1.0.0")]
9.37 KB
Binary file not shown.

Playlist Generator GUI/logo.ico

-10.4 KB
Binary file not shown.

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ The solution comprises four C# projects:
1212

1313
Compiling
1414
---------
15-
Loading the solution into Visual Studio and hitting *start* should be sufficient to run the GUI application. The console application requires the *Mono.Options* library, which NuGet will download and install automatically, but to the wrong location because [NuGet is shit][2] [by design][3]. Dependency packages are copied to the *packages* folder instead of the respective project folders. You can either reinstall packages using the NuGet Package Manager CLI or uninstall and reinstall using the GUI built into Visual Studio to copy the package files to the project directories.
15+
16+
Loading the solution into Visual Studio and hitting *start* should be sufficient to run the GUI application. The console application requires the *Mono.Options* library, which NuGet will download and install automatically, but to the wrong location because [NuGet is shit][2] [by design][3]. Dependency packages are copied to the *packages* directory instead of the respective project folders. You can either reinstall packages using the NuGet Package Manager CLI or uninstall and reinstall using the GUI built into Visual Studio to copy the package files to the project directories.
1617

1718
The test suite tests the console application and therefore has the same dependencies.
1819

@@ -23,7 +24,14 @@ The application library contains all the application logic and is shared between
2324

2425
The entire project has been designed with extensibilty in mind so feel free to send pull requests with your improvements.
2526

27+
GUI
28+
---
29+
30+
![Playlist Generator GUI v1.1 screenshot](https://raw.github.com/wiki/ScriptFUSION/Playlist-Generator/images/gui%201.1%20screenshot.gif)
31+
32+
Select a directory by using the `Browse` button, editing the path manually or drag-and-drop a directory onto either the interface or application shortcut icon. The file types in the specified directory are listed in descending order of frequency. A preview of the files matching the selected file type are shown. Only one file type can be selected. The `Generate` button writes the file names in the preview to a playlist in the specified directory.
33+
2634

27-
[1]: https://raw.github.com/wiki/ScriptFUSION/Playlist-Generator/images/logo%20grey%20114x.png
35+
[1]: https://raw.github.com/wiki/ScriptFUSION/Playlist-Generator/images/logo%201.1%20grey%20x35.png
2836
[2]: http://stackoverflow.com/questions/14942374/nuget-package-files-not-being-copied-to-project-content-during-build
2937
[3]: http://docs.nuget.org/docs/reference/package-restore

0 commit comments

Comments
 (0)