Compare commits

..

No commits in common. "master" and "v1.1.0" have entirely different histories.

5 changed files with 41 additions and 68 deletions

8
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,8 @@
image: ilyasemenov/gitlab-ci-git-push
stages:
- deploy
deploy to production:
stage: deploy
script: git-push git@github.com:adroslice/bfr.git

View File

@ -114,7 +114,6 @@
<Setter Property="Margin" Value="4,4,4,-5"/> <Setter Property="Margin" Value="4,4,4,-5"/>
<Setter Property="TextAlignment" Value="Center"/> <Setter Property="TextAlignment" Value="Center"/>
<Setter Property="FontWeight" Value="Bold"/> <Setter Property="FontWeight" Value="Bold"/>
<Setter Property="IsEnabled" Value="False"/>
</Style> </Style>
<Style Selector="Grid.StyleBorders > Border"> <Style Selector="Grid.StyleBorders > Border">
<Setter Property="Margin" Value="4"/> <Setter Property="Margin" Value="4"/>
@ -125,18 +124,6 @@
<Style Selector="Border.ConnectUp"> <Style Selector="Border.ConnectUp">
<Setter Property="Margin" Value="4,-5,4,4"/> <Setter Property="Margin" Value="4,-5,4,4"/>
</Style> </Style>
<!-- Drag + Drop -->
<Style Selector="ListBoxItem.BlackBottom">
<Setter Property="BorderThickness" Value="0,0,0,2"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="Margin" Value="0,0,0,-2"/>
</Style>
<Style Selector="ListBoxItem.BlackTop">
<Setter Property="BorderThickness" Value="0,2,0,0"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="Margin" Value="0,-2,0,0"/>
</Style>
<!-- Expander Fix --> <!-- Expander Fix -->
<Style Selector="Expander /template/ ToggleButton#PART_toggle /template/ Border"> <Style Selector="Expander /template/ ToggleButton#PART_toggle /template/ Border">
@ -172,7 +159,7 @@
</Grid> </Grid>
</Button.Content> </Button.Content>
</Button> </Button>
<Grid Grid.Column="3" Background="Transparent" Cursor="SizeAll" IsVisible="{Binding $parent.IsPointerOver}" ToolTip.Tip="Click and drag to move this operation." PointerPressed="StartMoveOperation" PointerReleased="EndMoveOperation" PointerMoved="MoveOperation"> <Grid Grid.Column="3" Background="Transparent" Cursor="SizeAll" IsVisible="{Binding $parent.IsPointerOver}" ToolTip.Tip="Click and drag to move this operation." PointerPressed="StartMoveOperation" PointerReleased="EndMoveOperation">
<Path Data="M0,0 L12,0 M0,4 L12,4 M0,8 L12,8" Height="8" VerticalAlignment="Center" Margin="4" Stroke="Black" StrokeThickness="2"/> <Path Data="M0,0 L12,0 M0,4 L12,4 M0,8 L12,8" Height="8" VerticalAlignment="Center" Margin="4" Stroke="Black" StrokeThickness="2"/>
</Grid> </Grid>
<ContentPresenter Grid.ColumnSpan="4" Grid.Row="1" Content="{TemplateBinding Content}" IsVisible="{Binding #OperationExpander.IsExpanded}"/> <ContentPresenter Grid.ColumnSpan="4" Grid.Row="1" Content="{TemplateBinding Content}" IsVisible="{Binding #OperationExpander.IsExpanded}"/>

View File

@ -6,16 +6,15 @@ using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Avalonia; using Avalonia;
using Avalonia.Input;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.VisualTree;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.LogicalTree;
using BFR.Helpers; using BFR.Helpers;
using BFR.DataModels; using BFR.DataModels;
using BFR.Operations; using Avalonia.Interactivity;
using Avalonia.Markup.Xaml.Styling; using Avalonia.Input;
using Avalonia.LogicalTree;
using Avalonia.VisualTree;
namespace BFR namespace BFR
{ {
@ -27,9 +26,8 @@ namespace BFR
public async Task OpenDirectoryButtonClick() => OpenDirectory(await new OpenFolderDialog() { Directory = WorkingDirectory }.ShowAsync(this)); public async Task OpenDirectoryButtonClick() => OpenDirectory(await new OpenFolderDialog() { Directory = WorkingDirectory }.ShowAsync(this));
public void OpenDirectory(string directory) public void OpenDirectory(string directory)
{ {
WorkingDirectory = directory.Replace('\\', '/'); WorkingDirectory = directory;
AllFiles.ReplaceAll(Directory.GetFiles(WorkingDirectory).Select(x => new FileModel(x.Replace('\\', '/')))); AllFiles.ReplaceAll(Directory.GetFiles(WorkingDirectory).Select(x => new FileModel(x)));
new Sort() { Mode = SortMode.Natural }.ApplyTo(AllFiles);
Filter(); Filter();
} }
@ -96,39 +94,21 @@ namespace BFR
Preview(); Preview();
} }
private void ClearDropStyling() public void StartMoveOperation(object sender, PointerPressedEventArgs e) =>
{
foreach (ListBoxItem item in OperationsListBox.GetLogicalChildren())
item.Classes.RemoveAll(new[] { "BlackTop", "BlackBottom" });
}
public void StartMoveOperation(object sender, PointerPressedEventArgs e) =>
DragItem = OperationsListBox.GetLogicalChildren().Cast<ListBoxItem>().Single(x => x.IsPointerOver); DragItem = OperationsListBox.GetLogicalChildren().Cast<ListBoxItem>().Single(x => x.IsPointerOver);
public void MoveOperation(object sender, PointerEventArgs e)
{
if (DragItem == null) return;
var hoveredItem = (ListBoxItem)OperationsListBox.GetLogicalChildren().FirstOrDefault(x => this.GetVisualsAt(e.GetPosition(this)).Contains(((IVisual)x).GetVisualChildren().First()));
var dragItemIndex = OperationsListBox.GetLogicalChildren().ToList().IndexOf(DragItem);
var hoveredItemIndex = OperationsListBox.GetLogicalChildren().ToList().IndexOf(hoveredItem);
ClearDropStyling();
if (hoveredItem != DragItem) hoveredItem?.Classes.Add(dragItemIndex > hoveredItemIndex ? "BlackTop" : "BlackBottom");
}
public void EndMoveOperation(object sender, PointerReleasedEventArgs e) public void EndMoveOperation(object sender, PointerReleasedEventArgs e)
{ {
var hoveredItem = (ListBoxItem)OperationsListBox.GetLogicalChildren().FirstOrDefault(x => this.GetVisualsAt(e.GetPosition(this)).Contains(((IVisual)x).GetVisualChildren().First())); var hoveredItem = (ListBoxItem)OperationsListBox.GetLogicalChildren().FirstOrDefault(x => this.GetVisualsAt(e.GetPosition(this)).Contains(((IVisual)x).GetVisualChildren().First()));
if (DragItem != null && hoveredItem != null && DragItem != hoveredItem) if (DragItem == null ||
{ hoveredItem == null ||
Operations.Move( DragItem == hoveredItem)
OperationsListBox.GetLogicalChildren().ToList().IndexOf(DragItem), return;
OperationsListBox.GetLogicalChildren().ToList().IndexOf(hoveredItem)); Operations.Move(
Preview(); OperationsListBox.GetLogicalChildren().ToList().IndexOf(DragItem),
} OperationsListBox.GetLogicalChildren().ToList().IndexOf(hoveredItem));
ClearDropStyling();
DragItem = null; DragItem = null;
Preview();
} }
public void Commit() public void Commit()
@ -157,15 +137,9 @@ namespace BFR
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
DataContext = this; DataContext = this;
OpenDirectory(Environment.OSVersion.Platform == PlatformID.Win32NT ? @"C:/Users/" : @"/home/"); OpenDirectory(Environment.OSVersion.Platform == PlatformID.Win32NT ? @"C:\Users" : @"\home");
HandleEvents = true; HandleEvents = true;
OperationsListBox = this.Find<ListBox>("OperationsListBox"); OperationsListBox = this.Find<ListBox>("OperationsListBox");
/*var dark = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog"))
{
Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseDark.xaml?assembly=Avalonia.Themes.Default")
};
Styles[0] = dark;/**/
} }
} }
} }

View File

@ -27,8 +27,8 @@
get => $"{Directory}{FullName}"; get => $"{Directory}{FullName}";
set set
{ {
FullName = value.Substring(value.LastIndexOf('/') + 1); FullName = value.Substring(value.LastIndexOf('\\') + 1);
Directory = value.Substring(0, value.LastIndexOf('/') + 1); Directory = value.Substring(0, value.LastIndexOf('\\') + 1);
} }
} }

View File

@ -1,24 +1,28 @@
# BFR - A Modular Bulk File Renaming Utility # BFR - A Modular Bulk File Renaming Utility
Inspired by [this project](https://git.lastassault.de/speatzle/BulkFileRenamer) by speatzle_. Inspired by [this project](https://git.lastassault.de/speatzle/BulkFileRenamer) by speatzle_.
Everyone is welcome to contribute!
## Features ## Features
- Mordern scalable UI (Avalonia) - Mordern scalable UI (Avalonia)
- Extremely flexible - Extremely flexible
- Indefinite undo - Stack-based undo
- Fast automatic preview - Fast and automatic preview
- Crossplatform and portable - Cross-Platform and portable
- Supports RegEx - Supports RegEx
### Operations ### Operations
- Add, Remove, Replace, Overwrite, Number, Sort - Add, Remove, Replace, Overwrite, Number, Sort
### Planned Features ### Upcoming Features
- Case Conversion #1 - [Case Conversion](../issues/1)
- Save-/Loadable Profiles #3 - [Save-/Loadable Profiles](../issues/3)
- Operations based on file Metadata #4 - [Operations based on file Metadata](../issues//4)
- Optional Subdirectory Scanning #5 - [Optional Subdirectory Scanning](../issues/5)
- Anything good that gets [requested](https://git.ulra.eu/adrian/bfr/issues)! - [Option to disable automatic previewing](../issues/7)
- [Improved Add-/Remove-Buttons](../issues/6)
- Anything good that gets [requested](../issues)!
## [Releases](https://git.ulra.eu/adrian/bfr/releases) ## [Releases](../-/releases)
## Screenshot ## Screenshot
![](https://i.imgur.com/qHRTmJH.png) ![](https://i.imgur.com/qHRTmJH.png)