MainWindow.xaml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <Window x:Class="BmffViewer.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:bmff="clr-namespace:MatrixIO.IO.Bmff;assembly=MatrixIO.IO.Bmff"
  5. xmlns:local="clr-namespace:BmffViewer"
  6. xmlns:Properties="clr-namespace:BmffViewer.Properties"
  7. xmlns:d="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
  8. Title="BmffViewer"
  9. DataContext="{Binding RelativeSource={RelativeSource Self}}"
  10. Height="{Binding MainWindow_Height, Source={x:Static Properties:Settings.Default}, Mode=TwoWay}"
  11. Width="{Binding MainWindow_Width, Source={x:Static Properties:Settings.Default}, Mode=TwoWay}">
  12. <Window.Resources>
  13. <HierarchicalDataTemplate x:Key="Node" ItemsSource="{Binding Children}">
  14. <StackPanel Orientation="Horizontal">
  15. <Image Width="16" Height="16" Source="{Binding Converter={local:BoxToIconConverter}}"/>
  16. <TextBlock Text="{Binding}"/>
  17. </StackPanel>
  18. </HierarchicalDataTemplate>
  19. <DataTemplate x:Key="Leaf">
  20. <StackPanel Orientation="Horizontal">
  21. <Image Width="16" Height="16" Source="{Binding Converter={local:BoxToIconConverter}}"/>
  22. <TextBlock Text="{Binding}"/>
  23. </StackPanel>
  24. </DataTemplate>
  25. <local:TreeBoxDataTemplateSelector x:Key="TreeBoxSelector" Leaf="{StaticResource Leaf}" Node="{StaticResource Node}"/>
  26. <DataTemplate x:Key="BinaryView">
  27. <ListView FontFamily="Consolas" ItemsSource="{Binding Converter={local:BoxToHexConverter}}"/>
  28. </DataTemplate>
  29. <DataTemplate x:Key="TableView">
  30. <!-- DataGrid has several nasty bugs. Whatever you do, don't just enable editing! It'll crash the app in various situations. -->
  31. <DataGrid ItemsSource="{Binding Path=Entries}" CanUserAddRows="False" CanUserDeleteRows="False" LoadingRow="DataGrid_LoadingRow" AutoGenerateColumns="True" IsReadOnly="True" />
  32. </DataTemplate>
  33. <local:ContentViewTemplateSelector x:Key="ContentViewSelector" Binary="{StaticResource BinaryView}" Table="{StaticResource TableView}"/>
  34. </Window.Resources>
  35. <Window.CommandBindings>
  36. <CommandBinding Command="Open" Executed="Open_Executed"/>
  37. <CommandBinding Command="SaveAs" Executed="SaveAs_Executed" CanExecute="SaveAs_CanExecute"/>
  38. <CommandBinding Command="Close" Executed="Close_Executed" CanExecute="Close_CanExecute"/>
  39. <CommandBinding Command="Zoom" Executed="FastStart_Executed" CanExecute="FastStart_CanExecute"/>
  40. <CommandBinding Command="IncreaseZoom" Executed="DecompressMovieHeader_Executed" CanExecute="DecompressMovieHeader_CanExecute"/>
  41. <CommandBinding Command="Favorites" Executed="SupportedBoxes_Executed"/>
  42. <CommandBinding Command="NavigateJournal" Executed="Log_Executed"/>
  43. </Window.CommandBindings>
  44. <Grid>
  45. <Grid.RowDefinitions>
  46. <RowDefinition Height="Auto"/>
  47. <RowDefinition Height="*"/>
  48. </Grid.RowDefinitions>
  49. <Grid.ColumnDefinitions>
  50. <ColumnDefinition Width="{Binding MainWindow_TreeWidth, Source={x:Static Properties:Settings.Default}, Mode=TwoWay}"/>
  51. <ColumnDefinition Width="*"/>
  52. </Grid.ColumnDefinitions>
  53. <Menu Grid.Row="0" Grid.ColumnSpan="2">
  54. <MenuItem Header="_File">
  55. <MenuItem Header="_Open" Command="Open"/>
  56. <MenuItem Header="Save As..." Command="SaveAs" />
  57. <MenuItem Header="_Close" Command="Close"/>
  58. </MenuItem>
  59. <MenuItem Header="_View">
  60. <MenuItem Header="_Supported Boxes" Command="Favorites"/>
  61. <MenuItem Header="_Log" Command="NavigateJournal"/>
  62. </MenuItem>
  63. <MenuItem Header="_Tools">
  64. <MenuItem Header="_FastStart" Command="Zoom"/>
  65. <MenuItem Header="_Decompress Movie Header" Command="IncreaseZoom"/>
  66. </MenuItem>
  67. </Menu>
  68. <TreeView Grid.Row="1" Name="TreeView1" ItemsSource="{Binding Files}" ItemTemplateSelector="{StaticResource TreeBoxSelector}" TreeViewItem.Selected="TreeView1_TreeViewItem_Selected" Margin="0,0,4,0" />
  69. <GridSplitter Grid.Row="1" Width="4"/>
  70. <Grid Grid.Row="1" Grid.Column="1" DataContext="{Binding ElementName=TreeView1, Path=SelectedItem}">
  71. <Grid.RowDefinitions>
  72. <RowDefinition Height="Auto"/>
  73. <RowDefinition Height="{Binding MainWindow_PropertiesHeight, Source={x:Static Properties:Settings.Default}, Mode=TwoWay}"/>
  74. <RowDefinition Height="{Binding MainWindow_ContentHeight, Source={x:Static Properties:Settings.Default}, Mode=TwoWay}"/>
  75. </Grid.RowDefinitions>
  76. <Border BorderBrush="Black" BorderThickness=".25,.25,0,0">
  77. <Border BorderBrush="White" BorderThickness="0,0,.25,.25">
  78. <TextBlock Text="{Binding Converter={local:BoxToDescriptionConverter}}" Background="{x:Static SystemColors.ControlBrush}" Foreground="{x:Static SystemColors.ControlTextBrush}" TextAlignment="Center"/>
  79. </Border>
  80. </Border>
  81. <ListView Grid.Row="1" ItemsSource="{Binding Converter={local:ObjectPropertiesToCollectionViewConverter}}">
  82. <ListView.View>
  83. <GridView>
  84. <GridViewColumn Width="{Binding MainWindow_PropertyNameWidth, Source={x:Static Properties:Settings.Default}, Mode=TwoWay}" Header="Name" DisplayMemberBinding="{Binding Path=Name}"/>
  85. <GridViewColumn Width="{Binding MainWindow_PropertyValueWidth, Source={x:Static Properties:Settings.Default}, Mode=TwoWay}" Header="Value" DisplayMemberBinding="{Binding Path=Value}"/>
  86. </GridView>
  87. </ListView.View>
  88. <ListView.GroupStyle>
  89. <GroupStyle>
  90. <GroupStyle.ContainerStyle>
  91. <Style TargetType="{x:Type GroupItem}">
  92. <Setter Property="Margin" Value="0,0,0,5"/>
  93. <Setter Property="Template">
  94. <Setter.Value>
  95. <ControlTemplate TargetType="{x:Type GroupItem}">
  96. <Expander IsExpanded="True">
  97. <Expander.Header>
  98. <TextBlock FontWeight="Bold" Text="{Binding Path=Name}" Margin="5,0,0,0"/>
  99. </Expander.Header>
  100. <Expander.Content>
  101. <ItemsPresenter />
  102. </Expander.Content>
  103. </Expander>
  104. </ControlTemplate>
  105. </Setter.Value>
  106. </Setter>
  107. </Style>
  108. </GroupStyle.ContainerStyle>
  109. </GroupStyle>
  110. </ListView.GroupStyle>
  111. </ListView>
  112. <GridSplitter Grid.Row="2" Width="Auto" Height="4" ResizeDirection="Rows" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0"/>
  113. <ContentControl Grid.Row="2" Margin="0,4,0,0" ContentTemplateSelector="{StaticResource ContentViewSelector}" Content="{Binding}"/>
  114. </Grid>
  115. </Grid>
  116. </Window>