Skip to content

Commit

Permalink
handle empty document
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-ward committed Jan 31, 2016
1 parent c383693 commit 858ad0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/MarkdownEdit/Controls/ImageDropDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<Window.Resources>
<local:NullToVisibleConverter x:Key="NullToVisibleConverter" />
<local:NotNullToVisibleConverter x:Key="NotNullToVisibleConverter" />
<local:NullOrEmptyToBooleanConverter x:Key="NullOrEmptyToBooleanConverter" />

<Style x:Key="MenuIconStyle"
TargetType="TextBlock">
Expand Down Expand Up @@ -70,13 +71,14 @@
</MenuItem.Icon>
</MenuItem>

<MenuItem x:Name="AsLocalFile" Header="{i18N:Localize image-drop-as-local-file}">
<MenuItem x:Name="AsLocalFile"
Header="{i18N:Localize image-drop-as-local-file}"
IsEnabled="{Binding DocumentFileName, Converter={StaticResource NullOrEmptyToBooleanConverter}}">
<MenuItem.Icon>
<TextBlock Style="{StaticResource MenuIconStyle}">&#xE16F;</TextBlock>
</MenuItem.Icon>

<Menu x:Name="LocalFoldersMenu"
Background="{DynamicResource MenuItemSelectionFill}"
<Menu Background="{DynamicResource MenuItemSelectionFill}"
ItemsSource="{Binding DoumentFolders}">
<Menu.ItemsPanel>
<ItemsPanelTemplate>
Expand Down
14 changes: 14 additions & 0 deletions src/MarkdownEdit/Controls/ImageDropDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,18 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return (value is Visibility && (Visibility)value == Visibility.Visible);
}
}

public sealed class NullOrEmptyToBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var text = value as string;
return !string.IsNullOrWhiteSpace(text);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
}
3 changes: 0 additions & 3 deletions src/MarkdownEdit/Models/Utility.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Media;
using System.Net.Http;
using System.Reflection;
Expand Down

0 comments on commit 858ad0a

Please sign in to comment.