diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-04-15 11:10:12 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-04-15 11:10:12 -0400 |
| commit | 30d6e2cd6ce0702faaec73b7ffb59d9844fb6967 (patch) | |
| tree | 27407208aa35a859659ab77451e0296c3f6ca725 /MediaBrowser.ServerApplication | |
| parent | a4cac9c95df1f169fd3457d25466f6896e12cd3f (diff) | |
made library scan a bit more conservative
Diffstat (limited to 'MediaBrowser.ServerApplication')
5 files changed, 42 insertions, 211 deletions
diff --git a/MediaBrowser.ServerApplication/Controls/ItemUpdateNotification.xaml.cs b/MediaBrowser.ServerApplication/Controls/ItemUpdateNotification.xaml.cs index 1f224f24d..30e39f6b0 100644 --- a/MediaBrowser.ServerApplication/Controls/ItemUpdateNotification.xaml.cs +++ b/MediaBrowser.ServerApplication/Controls/ItemUpdateNotification.xaml.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using System.Linq; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; @@ -159,7 +160,7 @@ namespace MediaBrowser.ServerApplication.Controls DisplayTitle(item); DisplayRating(item); - var path = MultiItemUpdateNotification.GetImagePath(item); + var path = GetImagePath(item); if (string.IsNullOrEmpty(path)) { @@ -211,6 +212,44 @@ namespace MediaBrowser.ServerApplication.Controls } /// <summary> + /// Gets the image path. + /// </summary> + /// <param name="item">The item.</param> + /// <returns>System.String.</returns> + internal static string GetImagePath(BaseItem item) + { + // Try our best to find an image + var path = item.PrimaryImagePath; + + if (string.IsNullOrEmpty(path) && item.BackdropImagePaths != null) + { + path = item.BackdropImagePaths.FirstOrDefault(); + } + + if (string.IsNullOrEmpty(path)) + { + path = item.GetImage(ImageType.Thumb); + } + + if (string.IsNullOrEmpty(path)) + { + path = item.GetImage(ImageType.Art); + } + + if (string.IsNullOrEmpty(path)) + { + path = item.GetImage(ImageType.Logo); + } + + if (string.IsNullOrEmpty(path)) + { + path = item.GetImage(ImageType.Disc); + } + + return path; + } + + /// <summary> /// Displays the rating. /// </summary> /// <param name="item">The item.</param> diff --git a/MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml b/MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml deleted file mode 100644 index 5d3fb785c..000000000 --- a/MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml +++ /dev/null @@ -1,37 +0,0 @@ -<UserControl x:Class="MediaBrowser.ServerApplication.Controls.MultiItemUpdateNotification" - 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" - mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> - - <Grid MaxHeight="400" MaxWidth="600" Margin="20"> - <Border BorderThickness="0" Background="#333333"> - <Border.Effect> - <DropShadowEffect BlurRadius="25" ShadowDepth="0"> - - </DropShadowEffect> - </Border.Effect> - </Border> - <Grid> - <Grid.Background> - <LinearGradientBrush SpreadMethod="Reflect" ColorInterpolationMode="SRgbLinearInterpolation" StartPoint="0,0" EndPoint="0,1" > - <GradientStop Color="#ff222222" Offset="0" /> - <GradientStop Color="#ffbbbbbb" Offset="1" /> - </LinearGradientBrush> - </Grid.Background> - - <Grid Margin="20"> - <Grid.RowDefinitions> - <RowDefinition Height="auto"></RowDefinition> - <RowDefinition Height="*"></RowDefinition> - </Grid.RowDefinitions> - - <TextBlock x:Name="header" FontSize="26" Foreground="White" Grid.Row="0"></TextBlock> - - <UniformGrid x:Name="itemsPanel" Columns="4" Margin="0 20 0 0" Grid.Row="1"></UniformGrid> - </Grid> - </Grid> - </Grid> -</UserControl> diff --git a/MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml.cs b/MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml.cs deleted file mode 100644 index 9d58c0227..000000000 --- a/MediaBrowser.ServerApplication/Controls/MultiItemUpdateNotification.xaml.cs +++ /dev/null @@ -1,151 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Logging; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; - -namespace MediaBrowser.ServerApplication.Controls -{ - /// <summary> - /// Interaction logic for MultiItemUpdateNotification.xaml - /// </summary> - public partial class MultiItemUpdateNotification : UserControl - { - /// <summary> - /// The logger - /// </summary> - private readonly ILogger Logger; - - /// <summary> - /// Gets the children changed event args. - /// </summary> - /// <value>The children changed event args.</value> - private List<BaseItem> Items - { - get { return DataContext as List<BaseItem>; } - } - - /// <summary> - /// Initializes a new instance of the <see cref="MultiItemUpdateNotification" /> class. - /// </summary> - public MultiItemUpdateNotification(ILogger logger) - { - if (logger == null) - { - throw new ArgumentNullException("logger"); - } - - Logger = logger; - - InitializeComponent(); - - Loaded += MultiItemUpdateNotification_Loaded; - } - - /// <summary> - /// Handles the Loaded event of the MultiItemUpdateNotification control. - /// </summary> - /// <param name="sender">The source of the event.</param> - /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> - void MultiItemUpdateNotification_Loaded(object sender, RoutedEventArgs e) - { - header.Text = string.Format("{0} New Items!", Items.Count); - - PopulateItems(); - } - - /// <summary> - /// Populates the items. - /// </summary> - private void PopulateItems() - { - itemsPanel.Children.Clear(); - - var items = Items; - - const int maxItemsToDisplay = 8; - var index = 0; - - foreach (var item in items) - { - if (index >= maxItemsToDisplay) - { - break; - } - - // Try our best to find an image - var path = GetImagePath(item); - - if (string.IsNullOrEmpty(path)) - { - continue; - } - - Image img; - - try - { - img = App.Instance.GetImage(path); - } - catch (FileNotFoundException) - { - Logger.Error("Image file not found {0}", path); - continue; - } - - img.Stretch = Stretch.Uniform; - img.Margin = new Thickness(0, 0, 5, 5); - img.ToolTip = ItemUpdateNotification.GetDisplayName(item, true); - RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.Fant); - itemsPanel.Children.Add(img); - - index++; - } - } - - - - /// <summary> - /// Gets the image path. - /// </summary> - /// <param name="item">The item.</param> - /// <returns>System.String.</returns> - internal static string GetImagePath(BaseItem item) - { - // Try our best to find an image - var path = item.PrimaryImagePath; - - if (string.IsNullOrEmpty(path) && item.BackdropImagePaths != null) - { - path = item.BackdropImagePaths.FirstOrDefault(); - } - - if (string.IsNullOrEmpty(path)) - { - path = item.GetImage(ImageType.Thumb); - } - - if (string.IsNullOrEmpty(path)) - { - path = item.GetImage(ImageType.Art); - } - - if (string.IsNullOrEmpty(path)) - { - path = item.GetImage(ImageType.Logo); - } - - if (string.IsNullOrEmpty(path)) - { - path = item.GetImage(ImageType.Disc); - } - - return path; - } - } -} diff --git a/MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs b/MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs index 4a1f0ac74..ae898f0f9 100644 --- a/MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs +++ b/MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs @@ -109,7 +109,7 @@ namespace MediaBrowser.ServerApplication.EntryPoints } // Show the notification - if (newItems.Count == 1) + if (newItems.Count > 0) { Application.Current.Dispatcher.InvokeAsync(() => { @@ -122,19 +122,6 @@ namespace MediaBrowser.ServerApplication.EntryPoints }, PopupAnimation.Slide, 6000)); }); } - else if (newItems.Count > 1) - { - Application.Current.Dispatcher.InvokeAsync(() => - { - var window = (MainWindow)Application.Current.MainWindow; - - window.Dispatcher.InvokeAsync(() => window.MbTaskbarIcon.ShowCustomBalloon(new MultiItemUpdateNotification(_logger) - { - DataContext = newItems - - }, PopupAnimation.Slide, 6000)); - }); - } } /// <summary> diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index dedc90fe5..38ece1cdb 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -194,10 +194,6 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="Controls\MultiItemUpdateNotification.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> <Page Include="LibraryExplorer.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -221,9 +217,6 @@ <Compile Include="Controls\ItemUpdateNotification.xaml.cs"> <DependentUpon>ItemUpdateNotification.xaml</DependentUpon> </Compile> - <Compile Include="Controls\MultiItemUpdateNotification.xaml.cs"> - <DependentUpon>MultiItemUpdateNotification.xaml</DependentUpon> - </Compile> <Compile Include="Implementations\DotNetZipClient.cs" /> <Compile Include="LibraryExplorer.xaml.cs"> <DependentUpon>LibraryExplorer.xaml</DependentUpon> |
