Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

4.8 KB
Raw Blame
<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:Filee.App.ViewModels.Pages"
             xmlns:views="using:Filee.App.Views"
             x:Class="Filee.App.Views.Pages.PresetsPage"
             x:DataType="vm:PresetsPageViewModel">
  <!-- Keep editor columns usable on narrow windows; the page still scrolls vertically in MainWindow. -->
  <ScrollViewer x:Name="EditorScroller" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
    <Grid RowDefinitions="Auto,*" ColumnDefinitions="260,20,*" MinWidth="680" Width="{Binding #EditorScroller.Viewport.Width}" HorizontalAlignment="Left">
      <TextBlock Grid.ColumnSpan="3" Classes="h1" Text="{DynamicResource presets.title}" Margin="0,0,0,18" />

      <!-- List: fits the window height and scrolls on its own (the page itself does not scroll, IFitsWindowHeight) -->
      <DockPanel Grid.Row="1">
        <WrapPanel DockPanel.Dock="Top" Margin="0,0,0,8">
          <!-- An empty preset, or a ready-made one for where the file goes (#553). -->
          <Button x:Name="AddPresetButton" Classes="accent" Margin="0,0,6,6">
            <StackPanel Orientation="Horizontal" Spacing="6">
              <PathIcon Width="12" Height="12" Data="{StaticResource Icon.Plus}" />
              <TextBlock Text="{DynamicResource presets.add}" />
            </StackPanel>
            <Button.Flyout>
              <!-- The ready-made presets are added below the heading from PlacePresets (code-behind). -->
              <MenuFlyout Placement="BottomEdgeAlignedLeft">
                <MenuItem Header="{DynamicResource presets.add_empty}" Command="{Binding AddCommand}" />
                <Separator />
                <MenuItem Header="{DynamicResource presets.add_ready}" IsEnabled="False" />
              </MenuFlyout>
            </Button.Flyout>
          </Button>
          <Button x:Name="DuplicatePresetButton" Command="{Binding DuplicateCommand}" Margin="0,0,6,6"
                  ToolTip.Tip="{DynamicResource presets.duplicate}" AutomationProperties.Name="{DynamicResource presets.duplicate}">
            <PathIcon Width="14" Height="14" Data="{StaticResource Icon.Copy}" />
          </Button>
          <Button x:Name="DeletePresetButton" Command="{Binding DeleteCommand}" Margin="0,0,6,6"
                  ToolTip.Tip="{DynamicResource presets.delete}" AutomationProperties.Name="{DynamicResource presets.delete}">
            <PathIcon Width="14" Height="14" Data="{StaticResource Icon.Delete}" />
          </Button>
        </WrapPanel>
        <TextBox Classes="search clearButton" DockPanel.Dock="Top" Margin="0,0,0,8" Text="{Binding Search}" Watermark="{DynamicResource common.search}">
              <TextBox.InnerLeftContent>
                <PathIcon Width="14" Height="14" Margin="10,0,0,0" Data="{StaticResource Icon.Search}" Foreground="{DynamicResource TextSecondaryBrush}" />
              </TextBox.InnerLeftContent>
        </TextBox>
        <ListBox Classes="soft" ItemsSource="{Binding VisiblePresets}" SelectedItem="{Binding SelectedPreset}">
          <ListBox.ItemTemplate>
            <DataTemplate x:DataType="vm:PresetListItem">
              <StackPanel>
                <TextBlock Text="{Binding Name}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" />
                <TextBlock Classes="caption" Text="{Binding Target}" />
              </StackPanel>
            </DataTemplate>
          </ListBox.ItemTemplate>
        </ListBox>
      </DockPanel>

      <!-- Editor (same control as the donut's preset popup): scrolls on its own, Save stays visible below it -->
      <DockPanel Grid.Row="1" Grid.Column="2">
        <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Spacing="8" HorizontalAlignment="Right" Margin="0,12,0,0"
                    IsVisible="{Binding Editor, Converter={x:Static ObjectConverters.IsNotNull}}">
          <TextBlock Text="{Binding SavedMessage}" VerticalAlignment="Center" Foreground="{DynamicResource SuccessBrush}" FontWeight="Bold" />
          <Button Content="{DynamicResource presets.revert}" Command="{Binding RevertCommand}" />
          <Button Classes="accent" Content="{DynamicResource presets.save}" Command="{Binding SaveCommand}" />
        </StackPanel>
        <ScrollViewer>
          <StackPanel Spacing="12" Margin="0,0,12,0">
            <TextBlock Classes="muted" Text="{DynamicResource presets.select}" IsVisible="{Binding Editor, Converter={x:Static ObjectConverters.IsNull}}" />
            <views:PresetEditorView DataContext="{Binding Editor}" IsVisible="{Binding $parent[UserControl].((vm:PresetsPageViewModel)DataContext).Editor, Converter={x:Static ObjectConverters.IsNotNull}}" />
          </StackPanel>
        </ScrollViewer>
      </DockPanel>
    </Grid>
  </ScrollViewer>
</UserControl>