display only formats that implement Create method.

This commit is contained in:
morkt 2014-07-27 09:47:49 +04:00
parent 9fb51e57e3
commit ef79d52e02
2 changed files with 8 additions and 2 deletions

View File

@ -42,7 +42,7 @@
<Label Content="{x:Static s:guiStrings.LabelArchiveFormat}" Target="{Binding ElementName=ArchiveFormat}" HorizontalAlignment="Left"
Padding="5,0,5,5"/>
<ComboBox Name="ArchiveFormat" SelectedValuePath="Tag" SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=appArchiveFormat, Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static gr:FormatCatalog.Instance}, Path=ArcFormats, Mode=OneWay}"
ItemsSource="{Binding Path=ArcFormats, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Mode=OneWay}"
SelectionChanged="OnFormatSelect" DisplayMemberPath="Tag"/>
</StackPanel>
</Grid>

View File

@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Microsoft.Win32;
@ -23,10 +24,15 @@ namespace GARbro.GUI
{
var format = this.ArchiveFormat.SelectedItem as ArchiveFormat;
if (null != format)
ArchiveName.Text = Path.ChangeExtension (initial_name, format.Extensions.First());
initial_name = Path.ChangeExtension (initial_name, format.Extensions.First());
}
ArchiveName.Text = initial_name;
}
private readonly IEnumerable<ArchiveFormat> m_formats = FormatCatalog.Instance.ArcFormats.Where (f => f.CanCreate);
public IEnumerable<ArchiveFormat> ArcFormats { get { return m_formats; } }
public ResourceOptions ArchiveOptions { get; private set; }
void Button_Click (object sender, RoutedEventArgs e)