Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkalinee committed Mar 21, 2015
1 parent 988e19b commit d4ca2bd
Show file tree
Hide file tree
Showing 26 changed files with 204 additions and 196 deletions.
13 changes: 7 additions & 6 deletions Hurricane/AppMainWindow/WindowSkins/WindowAdvancedView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@
</MenuItem.Style>
</MenuItem>
</Menu>
<TextBox Grid.ColumnSpan="4" Margin="0,0,10,0" x:Name="txtSearch" VerticalAlignment="Center" controls:TextBoxHelper.ClearTextButton="True" HorizontalAlignment="Right" Width="200" controls:TextBoxHelper.Watermark="{StaticResource Search}" Text="{Binding MusicManager.SelectedPlaylist.SearchText,UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Grid.ColumnSpan="4" Margin="0,0,10,0" VerticalAlignment="Center" controls:TextBoxHelper.ClearTextButton="True" HorizontalAlignment="Right" Width="200" controls:TextBoxHelper.Watermark="{StaticResource Search}" Text="{Binding MusicManager.SelectedPlaylist.SearchText,UpdateSourceTrigger=PropertyChanged}"/>
<ListBox Grid.Row="1" DisplayMemberPath="Name" SelectedItem="{Binding MusicManager.SelectedPlaylist}" Margin="5" ItemsSource="{Binding MusicManager.Playlists}" Background="Transparent"
dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True" dd:DragDrop.DropHandler="{Binding PlaylistListDropHandler}" dd:DragDrop.DragAdornerTemplate="{StaticResource DragAdornerPlaylist}" dd:DragDrop.DefaultDragAdornerOpacity=".8" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListBox.InputBindings>
<KeyBinding Key="Delete" Command="{Binding RemovePlaylist}"/>
</ListBox.InputBindings>
<ListBox.Resources>
<ContextMenu x:Key="contexmenu">
<ContextMenu x:Key="PlaylistContextMenu">
<MenuItem IsEnabled="False" Foreground="{StaticResource BlackBrush}">
<MenuItem.Resources>
<converter:PlaylistInfoConverter x:Key="PlaylistInfoConverter"/>
Expand Down Expand Up @@ -155,12 +155,12 @@
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MetroListBoxItem}">
<Setter Property="ContextMenu" Value="{StaticResource contexmenu}"/>
<Setter Property="ContextMenu" Value="{StaticResource PlaylistContextMenu}"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<Rectangle Grid.Column="1" Width="1" Fill="Gray" Grid.Row="1"/>
<Grid Grid.Column="2" Margin="5" x:Name="gridplaylist" Grid.Row="1">
<Grid Grid.Column="2" Margin="5" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
Expand Down Expand Up @@ -195,6 +195,7 @@
<Separator />
<MenuItem Header="{DynamicResource Remove}" Command="{Binding RemoveSelectedTracks}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type hurricaneControls:AnimatedListView}}, Path=SelectedItems}" InputGestureText="{DynamicResource Del}"/>
</ContextMenu>

<ContextMenu x:Key="StreamContextMenu">
<MenuItem Header="{DynamicResource Play}" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, Path=DataContext.MusicManager.Commands.PlaySelectedTrack}" InputGestureText="Enter"/>
<Separator />
Expand Down Expand Up @@ -670,7 +671,7 @@
</Grid.RowDefinitions>
<Grid Height="69" Margin="0,3,0,3">
<Grid.Resources>
<ContextMenu x:Key="contextMenu">
<ContextMenu x:Key="NotAddedStreamContextMenu">
<MenuItem Header="{DynamicResource AddToExistingPlaylist}" ItemsSource="{Binding MusicManager.Playlists}">
<MenuItem.ItemContainerStyle>
<Style TargetType="MenuItem" BasedOn="{StaticResource MetroMenuItem}">
Expand All @@ -690,7 +691,7 @@
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Visible"/>
<Setter Property="ContextMenu" Value="{StaticResource contextMenu}"/>
<Setter Property="ContextMenu" Value="{StaticResource NotAddedStreamContextMenu}"/>
<Setter Property="Background" Value="{StaticResource WhiteBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding TrackSearcher.PlaylistResult}" Value="{x:Null}">
Expand Down
2 changes: 1 addition & 1 deletion Hurricane/AppMainWindow/WindowSkins/WindowSmartView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</Button>
</Grid>
<DockPanel Grid.Row="1" Margin="5,5,0,0" Visibility="{Binding MusicManager.CSCoreEngine.CurrentTrack,Converter={StaticResource CollapsedOnNullValue}}">
<Polygon Points="0,0 8,5, 0,10" Stroke="{StaticResource AccentColorBrush}" StrokeThickness="2" VerticalAlignment="Center" Margin="0,2,0,0" x:Name="polyplay"/>
<Polygon Points="0,0 8,5, 0,10" Stroke="{StaticResource AccentColorBrush}" StrokeThickness="2" VerticalAlignment="Center" Margin="0,2,0,0" x:Name="PlayPolygon"/>
<Grid Margin="5,0,5,0" VerticalAlignment="Center" MouseEnter="Grid_MouseEnter" MouseLeave="Grid_MouseLeave" Background="{StaticResource WhiteBrush}">
<controls:TransitioningContentControl Transition="Down" x:Name="TitleTransitioningControl" mahAppsExtensions:TransitioningExtensions.DisplayText="{Binding MusicManager.CSCoreEngine.CurrentTrack}">
<controls:TransitioningContentControl.InputBindings>
Expand Down
6 changes: 2 additions & 4 deletions Hurricane/AppMainWindow/WindowSkins/WindowSmartView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using AudioVisualisation;
using Hurricane.Music;
using Hurricane.Utilities;
using Hurricane.ViewModels;
using WPFSoundVisualizationLib;

namespace Hurricane.AppMainWindow.WindowSkins
{
Expand Down Expand Up @@ -43,14 +41,14 @@ private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
var textBlock = TitleTransitioningControl.Content as TextBlock;
if (textBlock == null) return;
CurrentTrackAnimation(textBlock, polyplay, true);
CurrentTrackAnimation(textBlock, PlayPolygon, true);
}

private void Grid_MouseLeave(object sender, MouseEventArgs e)
{
var textBlock = TitleTransitioningControl.Content as TextBlock;
if (textBlock == null) return;
CurrentTrackAnimation(textBlock, polyplay, false);
CurrentTrackAnimation(textBlock, PlayPolygon, false);
}

private void CurrentTrackAnimation(TextBlock txt, Polygon poly, bool inAnimate)
Expand Down
64 changes: 64 additions & 0 deletions Hurricane/Extensions/ContentControlExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;

namespace Hurricane.Extensions
{
class ContentControlExtensions
{
public static readonly DependencyProperty FormattedContentProperty = DependencyProperty.RegisterAttached(
"FormattedContent", typeof (string), typeof (ContentControlExtensions), new PropertyMetadata(default(string), PropertyChangedCallback));

private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
var contentControl = dependencyObject as ContentControl;
if (contentControl == null) return;

var textBlock = new TextBlock();
var values = GetFormatValues(contentControl);

int counter = 0;
foreach (var item in Regex.Split(dependencyPropertyChangedEventArgs.NewValue.ToString(), @"\{.\}"))
{
textBlock.Inlines.Add(new Run(item));

if (values.Length - 1 < counter) continue;
string[] sSplit = values[counter].Split('$');
string text = sSplit[0];
string url = sSplit[1];

var hyperlink = new Hyperlink(new Run(text)) { NavigateUri = new Uri(url) };
hyperlink.RequestNavigate += (s, e) => { Process.Start(e.Uri.AbsoluteUri); };
textBlock.Inlines.Add(hyperlink);
counter++;
}
contentControl.Content = textBlock;
}

public static void SetFormattedContent(DependencyObject element, string value)
{
element.SetValue(FormattedContentProperty, value);
}

public static string GetFormattedContent(DependencyObject element)
{
return (string) element.GetValue(FormattedContentProperty);
}

public static readonly DependencyProperty FormatValuesProperty = DependencyProperty.RegisterAttached(
"FormatValues", typeof (string[]), typeof (ContentControlExtensions), new PropertyMetadata(default(string[])));

public static void SetFormatValues(DependencyObject element, string[] value)
{
element.SetValue(FormatValuesProperty, value);
}

public static string[] GetFormatValues(DependencyObject element)
{
return (string[]) element.GetValue(FormatValuesProperty);
}
}
}

This file was deleted.

4 changes: 1 addition & 3 deletions Hurricane/Hurricane.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
<Compile Include="Extensions\Converter\InvertBooleanConverter.cs" />
<Compile Include="Extensions\Converter\MillisecondsToStringConverter.cs" />
<Compile Include="Extensions\Converter\PlaylistInfoConverter.cs" />
<Compile Include="Extensions\ContentControlExtensions.cs" />
<Compile Include="Extensions\MahApps\TransitioningExtensions.cs" />
<Compile Include="Extensions\Controls\SliderWhichMakesMoves.cs" />
<Compile Include="Extensions\TextBlockTextFormat.cs" />
Expand Down Expand Up @@ -228,9 +229,6 @@
<Compile Include="Extensions\Converter\PlaceholderConverter.cs" />
<Compile Include="Extensions\Converter\TimeSpanProgressConverter.cs" />
<Compile Include="Extensions\Converter\StringArrayToStringConverter.cs" />
<Compile Include="Extensions\Converter\TextWithHyperlinkParametersConverter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Extensions\Converter\TimespanToMinutesSeconds.cs" />
<Compile Include="Extensions\GridViewSort.cs" />
<Compile Include="Extensions\Controls\VectorMenuItem.cs" />
Expand Down
4 changes: 2 additions & 2 deletions Hurricane/Views/EqualizerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:UserControls="clr-namespace:Hurricane.Views.UserControls"
xmlns:userControls="clr-namespace:Hurricane.Views.UserControls"
Title="Equalizer" Height="200" SizeToContent="Width" Width="300" Top="20" IsWindowDraggable="False" ShowInTaskbar="False" ShowTitleBar="False" ShowCloseButton="False" ShowMinButton="False" ShowMaxRestoreButton="False" ShowIconOnTitleBar="False" GlowBrush="{StaticResource AccentColorBrush}" ResizeMode="NoResize">
<UserControls:EqualizerView WantClose="EqualizerView_OnWantClose" ItemSpace="5"/>
<userControls:EqualizerView WantClose="EqualizerView_OnWantClose" ItemSpace="5"/>
</controls:MetroWindow>
32 changes: 14 additions & 18 deletions Hurricane/Views/EqualizerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,27 @@
using System.ComponentModel;
using System.Windows;
using System.Windows.Media.Animation;
using Hurricane.Music;
using Hurricane.Utilities;
using Hurricane.Utilities.Native;
using Hurricane.Views.UserControls;
using MahApps.Metro.Controls;

namespace Hurricane.Views
{
/// <summary>
/// Interaction logic for EqualizerWindow.xaml
/// </summary>
public partial class EqualizerWindow : MetroWindow
public partial class EqualizerWindow
{
public event EventHandler BeginCloseAnimation;

public EqualizerWindow(RECT rect, double width)
{
InitializeComponent();
this.SetPosition(rect, width);
this.Closing += EqualizerWindow_Closing;
SetPosition(rect, width);
Closing += EqualizerWindow_Closing;
}

bool _isClosing = false;
bool _canClose = false;
bool _isClosing;
bool _canClose;
void EqualizerWindow_Closing(object sender, CancelEventArgs e)
{
if (!_canClose)
Expand All @@ -35,39 +32,38 @@ void EqualizerWindow_Closing(object sender, CancelEventArgs e)
{
_isClosing = true;
Storyboard story = new Storyboard();
DoubleAnimation doubleanimation = new DoubleAnimation(IsLeft ? this.Left - 25 : this.Left + 25, TimeSpan.FromMilliseconds(100));
DoubleAnimation doubleanimation = new DoubleAnimation(_isLeft ? Left - 25 : Left + 25, TimeSpan.FromMilliseconds(100));
Storyboard.SetTargetProperty(doubleanimation, new PropertyPath(LeftProperty));
Storyboard.SetTarget(doubleanimation, this);
story.Children.Add(doubleanimation);

story.Completed += (s, es) => { _canClose = true; this.Close(); };
story.Completed += (s, es) => { _canClose = true; Close(); };
story.Begin(this);

if (BeginCloseAnimation != null) BeginCloseAnimation(this, EventArgs.Empty);
}
}
}

protected const double width = 300; //the widht of this window. we can't use this.ActualWidth because the window isn't always initialized
protected bool IsLeft;
private bool _isLeft;
public void SetPosition(RECT parentRecantgle, double windowWidth)
{
this.Top = parentRecantgle.top + 25;
Top = parentRecantgle.top + 25;
if (parentRecantgle.left + windowWidth + windowWidth - WpfScreen.MostRightX > 0) //If left from the parent isn't 300 space
{
this.Left = parentRecantgle.left - windowWidth;
IsLeft = false;
Left = parentRecantgle.left - windowWidth;
_isLeft = false;
}
else
{
this.Left = parentRecantgle.left + windowWidth;
IsLeft = true;
Left = parentRecantgle.left + windowWidth;
_isLeft = true;
}
}

private void EqualizerView_OnWantClose(object sender, EventArgs e)
{
this.Close();
Close();
}
}
}
8 changes: 4 additions & 4 deletions Hurricane/Views/FolderImportWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:converter="clr-namespace:Hurricane.Extensions.Converter"
xmlns:extensions="clr-namespace:Hurricane.Extensions"
Title="{StaticResource AddDirectories}" SizeToContent="Height" Width="400" ResizeMode="NoResize" ShowInTaskbar="False" x:Name="window" WindowStartupLocation="CenterOwner" GlowBrush="{DynamicResource AccentColorBrush}">
Title="{StaticResource AddDirectories}" SizeToContent="Height" Width="400" ResizeMode="NoResize" ShowInTaskbar="False" x:Name="BaseWindow" WindowStartupLocation="CenterOwner" GlowBrush="{DynamicResource AccentColorBrush}">
<Window.Resources>
<converter:FalseOnEmptyString x:Key="FalseOnEmptyString"/>
</Window.Resources>
Expand All @@ -14,18 +14,18 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBox Margin="0,0,10,0" IsReadOnly="True" Text="{Binding ElementName=window,Path=SelectedPath}" x:Name="txt"/>
<TextBox Margin="0,0,10,0" IsReadOnly="True" Text="{Binding ElementName=BaseWindow,Path=SelectedPath}" x:Name="PathTextBox"/>
<Button Grid.Column="1" Content="..." Width="30" Click="Button_Click"/>
</Grid>
<CheckBox Margin="0,10,0,0" Content="{StaticResource IncludeSubfolder}" IsChecked="{Binding ElementName=window,Path=IncludeSubfolder}"/>
<CheckBox Margin="0,10,0,0" Content="{StaticResource IncludeSubfolder}" IsChecked="{Binding ElementName=BaseWindow,Path=IncludeSubfolder}"/>
<Grid Grid.IsSharedSizeScope="True" Margin="0,10,0,0" HorizontalAlignment="Right">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="Buttons"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition SharedSizeGroup="Buttons"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="{StaticResource Cancel}" extensions:ButtonHelper.DialogResult="False"/>
<Button Grid.Column="2" Content="{StaticResource Add}" IsEnabled="{Binding ElementName=txt,Path=Text,Converter={StaticResource FalseOnEmptyString}}" extensions:ButtonHelper.DialogResult="True"/>
<Button Grid.Column="2" Content="{StaticResource Add}" IsEnabled="{Binding ElementName=PathTextBox,Path=Text,Converter={StaticResource FalseOnEmptyString}}" extensions:ButtonHelper.DialogResult="True"/>
</Grid>
</StackPanel>
</controls:MetroWindow>
Loading

0 comments on commit d4ca2bd

Please sign in to comment.