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.

13.1 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:app="using:Filee.App.ViewModels"
             x:Class="Filee.App.Views.Pages.HomePage"
             x:DataType="vm:HomePageViewModel">
  <UserControl.Styles>
    <Style Selector="Border#DropZone">
      <Setter Property="Transitions">
        <Transitions>
          <BrushTransition Property="Background" Duration="0:0:0.2" />
          <TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.3" Easing="BackEaseOut" />
        </Transitions>
      </Setter>
    </Style>
    <Style Selector="Border#DropZone.over">
      <Setter Property="Background" Value="{DynamicResource AccentSoftBrush}" />
      <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
      <Setter Property="RenderTransform" Value="scale(1.015)" />
    </Style>
    <Style Selector="PathIcon.chevron">
      <Setter Property="RenderTransform" Value="rotate(0deg)" />
    </Style>
    <Style Selector="PathIcon.chevron.open">
      <Setter Property="RenderTransform" Value="rotate(90deg)" />
    </Style>
  </UserControl.Styles>

  <StackPanel Spacing="22">
    <TextBlock Classes="h1" Text="{DynamicResource home.title}" />

    <!-- macOS without Accessibility permission: the drag gesture can't work yet. Gone once it is given. -->
    <Border IsVisible="{Binding NeedsAccessibility}" Background="{DynamicResource AccentFaintBrush}"
            BorderBrush="{DynamicResource AccentSoftBrush}" BorderThickness="1" CornerRadius="{DynamicResource SoftRadius}" Padding="14,10">
      <DockPanel>
        <Button DockPanel.Dock="Right" VerticalAlignment="Center" Margin="12,0,0,0" Classes="accent"
                Content="{DynamicResource triggers.open_accessibility}" Command="{Binding OpenAccessibilityCommand}" />
        <TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{DynamicResource home.accessibility_needed}" />
      </DockPanel>
    </Border>

    <!-- Windows: Filee runs as administrator while Explorer doesn't. Explorer can't drop files here, use the menu or
         have its selection read until Filee runs with normal rights again. -->
    <Border IsVisible="{Binding IsElevated}" Background="{DynamicResource AccentFaintBrush}"
            BorderBrush="{DynamicResource DangerBrush}" BorderThickness="1" CornerRadius="{DynamicResource SoftRadius}" Padding="14,10">
      <DockPanel>
        <Button DockPanel.Dock="Right" VerticalAlignment="Center" Margin="12,0,0,0" Classes="accent"
                Content="{DynamicResource home.elevated_restart}" Command="{Binding RestartWithoutAdministratorRightsCommand}" />
        <StackPanel Spacing="6" VerticalAlignment="Center">
          <TextBlock TextWrapping="Wrap" Text="{DynamicResource home.elevated}" />
          <TextBlock Classes="caption danger" TextWrapping="Wrap" IsVisible="{Binding ElevationRestartFailed}"
                     Text="{DynamicResource home.elevated_restart_failed}" />
        </StackPanel>
      </DockPanel>
    </Border>

    <!-- Drop zone: files dropped here open the donut toolbar at the cursor. Double-click opens file selector. -->
    <Border x:Name="DropZone" DragDrop.AllowDrop="True" MinHeight="220"
            Cursor="Hand" ToolTip.Tip="{DynamicResource home.drop_select}"
            Background="{DynamicResource AccentFaintBrush}" BorderBrush="{DynamicResource AccentSoftBrush}"
            BorderThickness="2" CornerRadius="{DynamicResource SoftRadiusLarge}" Padding="24">
      <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="10">
        <Border Width="64" Height="64" CornerRadius="999" Background="{DynamicResource AccentSoftBrush}" HorizontalAlignment="Center">
          <PathIcon Width="28" Height="28" Data="{StaticResource Icon.Upload}" Foreground="{DynamicResource AccentStrongBrush}" />
        </Border>
        <TextBlock Classes="h2" HorizontalAlignment="Center" Text="{DynamicResource home.drop_title}" />
        <TextBlock Classes="muted" HorizontalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" MaxWidth="460"
                   Text="{Binding DropHint}" />
      </StackPanel>
    </Border>

    <!-- Recent conversions -->
    <StackPanel Spacing="10">
      <DockPanel>
        <Button DockPanel.Dock="Right" Classes="ghost" Content="{DynamicResource home.clear_history}" Command="{Binding ClearHistoryCommand}" />
        <TextBlock Classes="h2" VerticalAlignment="Center" Text="{DynamicResource home.recent}" />
      </DockPanel>
      <TextBox Classes="search clearButton" Text="{Binding Search}" PlaceholderText="{DynamicResource common.search}"
               IsVisible="{Binding !IsEmpty}">
        <TextBox.InnerLeftContent>
          <PathIcon Width="14" Height="14" Margin="10,0,0,0" Data="{StaticResource Icon.Search}" Foreground="{DynamicResource TextSecondaryBrush}" />
        </TextBox.InnerLeftContent>
      </TextBox>
      <TextBlock Classes="muted" Text="{DynamicResource home.recent_empty}" IsVisible="{Binding IsEmpty}" />
      <TextBlock Classes="muted" Text="{DynamicResource home.no_matches}" IsVisible="{Binding NoMatches}" />
      <ItemsControl ItemsSource="{Binding History}">
        <ItemsControl.ItemsPanel>
          <ItemsPanelTemplate>
            <StackPanel Spacing="8" />
          </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
          <DataTemplate x:DataType="vm:HistoryItemViewModel">
            <Border Classes="card history-card" Padding="14,10">
              <StackPanel Spacing="8">
                <DockPanel>
                  <StackPanel DockPanel.Dock="Right" Orientation="Horizontal" Spacing="6" VerticalAlignment="Center"
                              IsVisible="{Binding HasOutputs}">
                    <Button Command="{Binding OpenFileCommand}" IsVisible="{Binding CanOpen}" Padding="10,5">
                      <StackPanel Orientation="Horizontal" Spacing="6">
                        <PathIcon Width="13" Height="13" Data="{StaticResource Icon.File}" />
                        <TextBlock Text="{DynamicResource home.open_file}" />
                      </StackPanel>
                    </Button>
                    <!-- Only where the system has an "Open with" dialog (Windows). -->
                    <Button Command="{Binding OpenWithCommand}" IsVisible="{Binding CanOpenWith}" Padding="8,5"
                            ToolTip.Tip="{DynamicResource home.open_with}" AutomationProperties.Name="{DynamicResource home.open_with}">
                      <PathIcon Width="13" Height="13" Data="{StaticResource Icon.OpenWith}" />
                    </Button>
                    <Button Command="{Binding OpenFolderCommand}" Padding="10,5">
                      <StackPanel Orientation="Horizontal" Spacing="6">
                        <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Folder}" />
                        <TextBlock Text="{DynamicResource home.open_folder}" />
                      </StackPanel>
                    </Button>
                    <!-- Only while every result is as the job left it: they go to the Recycle Bin / Trash. -->
                    <Button Command="{Binding UndoCommand}" IsVisible="{Binding CanUndo}" Padding="10,5" ToolTip.Tip="{DynamicResource home.undo_hint}">
                      <StackPanel Orientation="Horizontal" Spacing="6">
                        <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Undo}" />
                        <TextBlock Text="{DynamicResource home.undo}" />
                      </StackPanel>
                    </Button>
                  </StackPanel>
                  <!-- The result: its picture, else its format; the corner says whether the job went well. -->
                  <Panel DockPanel.Dock="Left" Width="42" Height="42" Margin="0,0,12,0">
                    <Border CornerRadius="{DynamicResource SoftRadiusSmall}" ClipToBounds="True" Background="{DynamicResource AccentSoftBrush}">
                      <Panel>
                        <Image Source="{Binding Thumbnail}" Stretch="UniformToFill" IsVisible="{Binding HasThumbnail}" />
                        <TextBlock Text="{Binding FormatBadge}" FontSize="11" FontWeight="Bold" Foreground="{DynamicResource TextPrimaryBrush}"
                                   HorizontalAlignment="Center" VerticalAlignment="Center">
                          <TextBlock.IsVisible>
                            <MultiBinding Converter="{x:Static BoolConverters.And}">
                              <Binding Path="!HasThumbnail" />
                              <Binding Path="HasFormatBadge" />
                            </MultiBinding>
                          </TextBlock.IsVisible>
                        </TextBlock>
                        <PathIcon Width="15" Height="15" Data="{StaticResource Icon.Check}" Foreground="{DynamicResource AccentStrongBrush}">
                          <PathIcon.IsVisible>
                            <MultiBinding Converter="{x:Static BoolConverters.And}">
                              <Binding Path="!HasThumbnail" />
                              <Binding Path="!HasFormatBadge" />
                            </MultiBinding>
                          </PathIcon.IsVisible>
                        </PathIcon>
                      </Panel>
                    </Border>
                    <Border Width="18" Height="18" CornerRadius="999" Margin="0,0,-4,-4" HorizontalAlignment="Right" VerticalAlignment="Bottom"
                            Background="{DynamicResource SurfaceBrush}" BorderBrush="{DynamicResource SubtleBorderBrush}" BorderThickness="1">
                      <Panel>
                        <PathIcon Width="10" Height="10" Data="{StaticResource Icon.Check}" Foreground="{DynamicResource SuccessBrush}" IsVisible="{Binding !HasErrors}" />
                        <PathIcon Width="10" Height="10" Data="{StaticResource Icon.Alert}" Foreground="{DynamicResource DangerBrush}" IsVisible="{Binding HasErrors}" />
                      </Panel>
                    </Border>
                  </Panel>
                  <StackPanel VerticalAlignment="Center">
                    <TextBlock FontWeight="SemiBold" Text="{Binding Title}" TextTrimming="CharacterEllipsis" />
                    <StackPanel Orientation="Horizontal" Spacing="8">
                      <TextBlock Classes="caption" Text="{Binding Subtitle}" TextTrimming="CharacterEllipsis" MaxWidth="420" />
                      <TextBlock Classes="caption" Text="·" />
                      <TextBlock Classes="caption" Text="{Binding Time}" />
                    </StackPanel>
                  </StackPanel>
                </DockPanel>

                <TextBlock Classes="caption" Margin="54,0,0,0" TextWrapping="Wrap" Text="{Binding UndoneText}" IsVisible="{Binding IsUndone}" />
                <TextBlock Classes="caption danger" Margin="54,0,0,0" TextWrapping="Wrap" Text="{Binding UndoError}" IsVisible="{Binding HasUndoError}" />

                <!-- Failed files: the list on demand, and converting them again -->
                <DockPanel IsVisible="{Binding HasFailures}" Margin="54,0,0,0">
                  <Button DockPanel.Dock="Right" Command="{Binding RetryCommand}" IsVisible="{Binding CanRetry}" Padding="10,5">
                    <StackPanel Orientation="Horizontal" Spacing="6">
                      <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Refresh}" />
                      <TextBlock Text="{DynamicResource common.retry}" />
                    </StackPanel>
                  </Button>
                  <Button Classes="ghost" Command="{Binding ToggleFailuresCommand}" Padding="6,4" HorizontalAlignment="Left">
                    <StackPanel Orientation="Horizontal" Spacing="6">
                      <PathIcon Classes="chevron reading" Classes.open="{Binding ShowFailures}" Width="12" Height="12"
                                Data="{StaticResource Icon.ChevronRight}" />
                      <TextBlock Classes="caption danger" Text="{Binding FailureSummary}" />
                    </StackPanel>
                  </Button>
                </DockPanel>
                <ItemsControl ItemsSource="{Binding Failures}" IsVisible="{Binding ShowFailures}" Margin="60,0,0,2">
                  <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                      <StackPanel Spacing="4" />
                    </ItemsPanelTemplate>
                  </ItemsControl.ItemsPanel>
                  <ItemsControl.ItemTemplate>
                    <DataTemplate x:DataType="app:FailureItem">
                      <StackPanel>
                        <SelectableTextBlock Classes="caption" FontWeight="SemiBold" Text="{Binding Name}" TextWrapping="Wrap" />
                        <SelectableTextBlock Classes="caption danger" Text="{Binding Reason}" TextWrapping="Wrap" />
                      </StackPanel>
                    </DataTemplate>
                  </ItemsControl.ItemTemplate>
                </ItemsControl>
              </StackPanel>
            </Border>
          </DataTemplate>
        </ItemsControl.ItemTemplate>
      </ItemsControl>
    </StackPanel>
  </StackPanel>
</UserControl>