ブランチの作成と切り替えを、画面から操作できるようにする

このコミットが含まれているのは:
routersys committed 2026-11-01 20:54:20 +09:00
1 親 b300cb052f
コミット 111c698608
6ファイル変更
+327 -6

検索条件に一致するファイルはありません

+141
ファイルの表示
@@ -217,6 +217,147 @@ public sealed class UndoTreeViewModelTests
Assert.Equal(string.Format(Texts.ApplyResult, 2, 0), model.ResultText);
}
[Fact]
public void StartingASubHistoryShowsItsBannerNameAndMarkOnTheStartingNode()
{
var (model, manager, document) = Open();
Histories.Edit(manager, () => document.X = 1);
var start = model.Items[^1];
var allowed = model.StartLineCommand.CanExecute(null);
model.StartLineCommand.Execute(null);
Assert.True(allowed);
Assert.True(model.HasActiveLine);
Assert.True(model.HasLines);
Assert.Equal(string.Format(Texts.LineDefaultName, 1), model.ActiveLineName);
Assert.StartsWith($"[{string.Format(Texts.LineMark, model.ActiveLineName)}]", start.DisplayText);
Assert.Equal([Texts.WholeHistory, model.ActiveLineName], model.LineChoices.Select(choice => choice.Name));
Assert.Equal([false, true], model.LineChoices.Select(choice => choice.IsActive));
}
[Fact]
public void RenamingFromTheBannerChangesTheMarkAndAnEmptyNameIsTakenBack()
{
var (model, manager, document) = Open();
Histories.Edit(manager, () => document.X = 1);
var start = model.Items[^1];
model.StartLineCommand.Execute(null);
var raised = new List<string?>();
model.PropertyChanged += (_, e) => raised.Add(e.PropertyName);
model.ActiveLineName = "Colors";
var renamed = raised.ToArray();
raised.Clear();
model.ActiveLineName = " ";
Assert.Equal("Colors", model.ActiveLineName);
Assert.Contains("Colors", start.DisplayText);
Assert.Equal("Colors", model.LineChoices[1].Name);
Assert.Contains(nameof(UndoTreeViewModel.ActiveLineName), renamed);
Assert.Contains(nameof(UndoTreeViewModel.ActiveLineName), raised);
}
[Fact]
public void LeavingTheSubHistoryGoesBackToTheWholeHistoryAndItCanBeEnteredAgain()
{
var (model, manager, document) = Open();
Histories.Edit(manager, () => document.X = 1);
model.StartLineCommand.Execute(null);
Histories.Edit(manager, () => document.X = 2);
var canLeave = model.SwitchLineCommand.CanExecute(null);
model.SwitchLineCommand.Execute(null);
var left = (model.HasActiveLine, document.X, model.SwitchLineCommand.CanExecute(null));
model.SwitchLineCommand.Execute(model.LineChoices[1]);
Assert.True(canLeave);
Assert.Equal((false, 1, false), left);
Assert.True(model.HasActiveLine);
Assert.Equal(2, document.X);
}
[Fact]
public void ChoosingTheChoiceThatIsAlreadyActiveChangesNothing()
{
var (model, manager, document) = Open();
Histories.Edit(manager, () => document.X = 1);
model.StartLineCommand.Execute(null);
Histories.Edit(manager, () => document.X = 2);
var line = model.LineChoices[1];
var allowed = model.SwitchLineCommand.CanExecute(line);
model.SwitchLineCommand.Execute(line);
Assert.True(allowed);
Assert.True(line.IsActive);
Assert.True(model.HasActiveLine);
Assert.Equal(2, document.X);
}
[Fact]
public void WithoutAnyLineTheButtonToLeaveIsUnavailableButTheListStillOffersTheWholeHistory()
{
var (model, manager, document) = Open();
Histories.Edit(manager, () => document.X = 1);
Assert.False(model.SwitchLineCommand.CanExecute(null));
Assert.True(model.SwitchLineCommand.CanExecute(model.LineChoices[0]));
Assert.True(model.LineChoices[0].IsActive);
Assert.False(model.HasLines);
}
[Fact]
public void DeletingTheActiveSubHistoryKeepsTheStateAndRemovesTheBanner()
{
var (model, manager, document) = Open();
Histories.Edit(manager, () => document.X = 1);
var start = model.Items[^1];
model.StartLineCommand.Execute(null);
Histories.Edit(manager, () => document.X = 2);
var allowed = model.DeleteLineCommand.CanExecute(null);
model.DeleteLineCommand.Execute(null);
Assert.True(allowed);
Assert.False(model.HasActiveLine);
Assert.False(model.HasLines);
Assert.Equal(2, document.X);
Assert.Equal([Texts.WholeHistory], model.LineChoices.Select(choice => choice.Name));
Assert.DoesNotContain("[", start.DisplayText);
Assert.False(model.DeleteLineCommand.CanExecute(null));
}
[Fact]
public void StartingFromAnotherNodeMovesThereFirst()
{
var (model, manager, document) = Open();
Histories.Edit(manager, () => document.X = 1);
var older = model.Items[^1];
Histories.Edit(manager, () => document.X = 2);
model.StartLineCommand.Execute(older);
Assert.Equal(1, document.X);
Assert.True(older.IsCurrent);
Assert.StartsWith("[", older.DisplayText);
}
[Fact]
public void NothingStartsASubHistoryWhileThePreviousHistoryIsShown()
{
var (model, manager, document) = Open();
Histories.Edit(manager, () => document.X = 1);
model.SetRecord(PreviousSession());
model.IsShowingRecord = true;
var archived = model.Items[1];
Assert.False(model.StartLineCommand.CanExecute(archived));
Assert.False(model.StartLineCommand.CanExecute(null));
Assert.False(model.SwitchLineCommand.CanExecute(null));
}
[Fact]
public void NodesOnTheCurrentPathCannotBeApplied()
{
+37
ファイルの表示
@@ -0,0 +1,37 @@
using Microsoft.Xaml.Behaviors;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
namespace UndoTree;
internal class CommitOnEnterBehavior : Behavior<TextBox>
{
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.PreviewKeyDown += AssociatedObject_PreviewKeyDown;
}
protected override void OnDetaching()
{
base.OnDetaching();
AssociatedObject.PreviewKeyDown -= AssociatedObject_PreviewKeyDown;
}
private void AssociatedObject_PreviewKeyDown(object sender, KeyEventArgs e)
{
var binding = BindingOperations.GetBindingExpression(AssociatedObject, TextBox.TextProperty);
switch (e.Key)
{
case Key.Enter:
binding?.UpdateSource();
e.Handled = true;
break;
case Key.Escape:
binding?.UpdateTarget();
e.Handled = true;
break;
}
}
}
+10
ファイルの表示
@@ -560,3 +560,13 @@ DiffEmptyLast,,前回の最後の状態との差はありません,There is no d
RecordNotReplayable,,再現できない操作を含むため、適用できません,Cannot apply because it includes an operation that cannot be reproduced.,包含无法重现的操作,因此无法应用。,包含無法重現的操作,因此無法套用。,재현할 수 없는 작업이 포함되어 있어 적용할 수 없습니다.,No se puede aplicar porque incluye una operación que no se puede reproducir.,لا يمكن التطبيق لأنه يتضمن عملية لا يمكن إعادة إنتاجها.,Tidak dapat diterapkan karena mencakup operasi yang tidak dapat direproduksi.
LineMark,,サブ履歴: {0},Sub-history: {0},子历史记录:{0},子歷史記錄:{0},하위 기록: {0},Subhistorial: {0},سجل فرعي: {0},Sub-riwayat: {0}
LineDefaultName,,サブ履歴 {0},Sub-history {0},子历史记录 {0},子歷史記錄 {0},하위 기록 {0},Subhistorial {0},سجل فرعي {0},Sub-riwayat {0}
StartLine,,現在の状態からサブ履歴を始める,Start a sub-history from the current state,从当前状态开始子历史记录,從目前狀態開始子歷史記錄,현재 상태에서 하위 기록 시작,Iniciar un subhistorial desde el estado actual,بدء سجل فرعي من الحالة الحالية,Mulai sub-riwayat dari keadaan saat ini
StartLineAtNode,,この状態からサブ履歴を始める,Start a sub-history from this state,从此状态开始子历史记录,從此狀態開始子歷史記錄,이 상태에서 하위 기록 시작,Iniciar un subhistorial desde este estado,بدء سجل فرعي من هذه الحالة,Mulai sub-riwayat dari keadaan ini
SwitchLine,,サブ履歴を切り替え,Switch sub-history,切换子历史记录,切換子歷史記錄,하위 기록 전환,Cambiar de subhistorial,تبديل السجل الفرعي,Ganti sub-riwayat
WholeHistory,,全体の履歴,Whole history,整体历史记录,整體歷史記錄,전체 기록,Historial completo,السجل الكامل,Seluruh riwayat
LineTitle,,サブ履歴,Sub-history,子历史记录,子歷史記錄,하위 기록,Subhistorial,سجل فرعي,Sub-riwayat
LineTip,,元に戻すとやり直しは、このサブ履歴の始まりまでの範囲で効きます。編集は全体の履歴の木に残ります。,Undo and redo work only within this sub-history. Your edits stay in the tree of the whole history.,撤销和重做只在此子历史记录的范围内有效。编辑内容会保留在整体历史记录的树中。,復原與重做只在此子歷史記錄的範圍內有效。編輯內容會保留在整體歷史記錄的樹中。,실행 취소와 다시 실행은 이 하위 기록의 범위 안에서만 동작합니다. 편집 내용은 전체 기록의 트리에 남습니다.,Deshacer y rehacer solo actúan dentro de este subhistorial. Tus ediciones permanecen en el árbol del historial completo.,يعمل التراجع والإعادة داخل هذا السجل الفرعي فقط. تبقى تعديلاتك في شجرة السجل الكامل.,Urungkan dan Ulangi hanya berlaku di dalam sub-riwayat ini. Hasil edit tetap ada di pohon seluruh riwayat.
LineName,,サブ履歴の名前。Enter で確定します。,Name of the sub-history. Press Enter to confirm.,子历史记录的名称。按 Enter 确认。,子歷史記錄的名稱。按 Enter 確認。,하위 기록의 이름입니다. Enter 키로 확정합니다.,Nombre del subhistorial. Pulsa Intro para confirmar.,اسم السجل الفرعي. اضغط Enter للتأكيد.,Nama sub-riwayat. Tekan Enter untuk mengonfirmasi.
LeaveLine,,全体の履歴へ戻る,Back to the whole history,返回整体历史记录,返回整體歷史記錄,전체 기록으로 돌아가기,Volver al historial completo,العودة إلى السجل الكامل,Kembali ke seluruh riwayat
LeaveLineTip,,全体の履歴で最後にいた状態へ戻ります。このサブ履歴の編集は残るので、切り替えて続けられます。,"Returns to where you were in the whole history. The edits in this sub-history are kept, so you can switch back and continue.",返回到在整体历史记录中最后所处的状态。此子历史记录中的编辑会保留,可以切换回来继续。,返回到在整體歷史記錄中最後所處的狀態。此子歷史記錄中的編輯會保留,可以切換回來繼續。,전체 기록에서 마지막으로 있던 상태로 돌아갑니다. 이 하위 기록의 편집 내용은 남아 있으므로 다시 전환해 이어갈 수 있습니다.,"Vuelve al punto en el que estabas en el historial completo. Las ediciones de este subhistorial se conservan, así que puedes volver a él y continuar.",يعود إلى الحالة التي كنت فيها آخر مرة في السجل الكامل. تبقى تعديلات هذا السجل الفرعي محفوظة، ويمكنك التبديل إليه ومتابعة العمل.,"Kembali ke posisi terakhir Anda di seluruh riwayat. Hasil edit di sub-riwayat ini tetap tersimpan, sehingga Anda dapat beralih kembali dan melanjutkan."
DeleteLine,,このサブ履歴を削除します。名前だけが消え、編集は全体の履歴に残ります。,Deletes this sub-history. Only its name goes away; the edits stay in the whole history.,删除此子历史记录。只会删除名称,编辑内容仍保留在整体历史记录中。,刪除此子歷史記錄。只會刪除名稱,編輯內容仍保留在整體歷史記錄中。,이 하위 기록을 삭제합니다. 이름만 사라지고 편집 내용은 전체 기록에 남습니다.,Elimina este subhistorial. Solo desaparece su nombre; las ediciones permanecen en el historial completo.,يحذف هذا السجل الفرعي. يُحذف اسمه فقط، وتبقى التعديلات في السجل الكامل.,Menghapus sub-riwayat ini. Hanya namanya yang hilang; hasil edit tetap ada di seluruh riwayat.
1 Key Parameter ja-jp en-us zh-cn zh-tw ko-kr es-es ar-sa id-id
560 RecordNotReplayable 再現できない操作を含むため、適用できません Cannot apply because it includes an operation that cannot be reproduced. 包含无法重现的操作,因此无法应用。 包含無法重現的操作,因此無法套用。 재현할 수 없는 작업이 포함되어 있어 적용할 수 없습니다. No se puede aplicar porque incluye una operación que no se puede reproducir. لا يمكن التطبيق لأنه يتضمن عملية لا يمكن إعادة إنتاجها. Tidak dapat diterapkan karena mencakup operasi yang tidak dapat direproduksi.
561 LineMark サブ履歴: {0} Sub-history: {0} 子历史记录:{0} 子歷史記錄:{0} 하위 기록: {0} Subhistorial: {0} سجل فرعي: {0} Sub-riwayat: {0}
562 LineDefaultName サブ履歴 {0} Sub-history {0} 子历史记录 {0} 子歷史記錄 {0} 하위 기록 {0} Subhistorial {0} سجل فرعي {0} Sub-riwayat {0}
563 StartLine 現在の状態からサブ履歴を始める Start a sub-history from the current state 从当前状态开始子历史记录 從目前狀態開始子歷史記錄 현재 상태에서 하위 기록 시작 Iniciar un subhistorial desde el estado actual بدء سجل فرعي من الحالة الحالية Mulai sub-riwayat dari keadaan saat ini
564 StartLineAtNode この状態からサブ履歴を始める Start a sub-history from this state 从此状态开始子历史记录 從此狀態開始子歷史記錄 이 상태에서 하위 기록 시작 Iniciar un subhistorial desde este estado بدء سجل فرعي من هذه الحالة Mulai sub-riwayat dari keadaan ini
565 SwitchLine サブ履歴を切り替え Switch sub-history 切换子历史记录 切換子歷史記錄 하위 기록 전환 Cambiar de subhistorial تبديل السجل الفرعي Ganti sub-riwayat
566 WholeHistory 全体の履歴 Whole history 整体历史记录 整體歷史記錄 전체 기록 Historial completo السجل الكامل Seluruh riwayat
567 LineTitle サブ履歴 Sub-history 子历史记录 子歷史記錄 하위 기록 Subhistorial سجل فرعي Sub-riwayat
568 LineTip 元に戻すとやり直しは、このサブ履歴の始まりまでの範囲で効きます。編集は全体の履歴の木に残ります。 Undo and redo work only within this sub-history. Your edits stay in the tree of the whole history. 撤销和重做只在此子历史记录的范围内有效。编辑内容会保留在整体历史记录的树中。 復原與重做只在此子歷史記錄的範圍內有效。編輯內容會保留在整體歷史記錄的樹中。 실행 취소와 다시 실행은 이 하위 기록의 범위 안에서만 동작합니다. 편집 내용은 전체 기록의 트리에 남습니다. Deshacer y rehacer solo actúan dentro de este subhistorial. Tus ediciones permanecen en el árbol del historial completo. يعمل التراجع والإعادة داخل هذا السجل الفرعي فقط. تبقى تعديلاتك في شجرة السجل الكامل. Urungkan dan Ulangi hanya berlaku di dalam sub-riwayat ini. Hasil edit tetap ada di pohon seluruh riwayat.
569 LineName サブ履歴の名前。Enter で確定します。 Name of the sub-history. Press Enter to confirm. 子历史记录的名称。按 Enter 确认。 子歷史記錄的名稱。按 Enter 確認。 하위 기록의 이름입니다. Enter 키로 확정합니다. Nombre del subhistorial. Pulsa Intro para confirmar. اسم السجل الفرعي. اضغط Enter للتأكيد. Nama sub-riwayat. Tekan Enter untuk mengonfirmasi.
570 LeaveLine 全体の履歴へ戻る Back to the whole history 返回整体历史记录 返回整體歷史記錄 전체 기록으로 돌아가기 Volver al historial completo العودة إلى السجل الكامل Kembali ke seluruh riwayat
571 LeaveLineTip 全体の履歴で最後にいた状態へ戻ります。このサブ履歴の編集は残るので、切り替えて続けられます。 Returns to where you were in the whole history. The edits in this sub-history are kept, so you can switch back and continue. 返回到在整体历史记录中最后所处的状态。此子历史记录中的编辑会保留,可以切换回来继续。 返回到在整體歷史記錄中最後所處的狀態。此子歷史記錄中的編輯會保留,可以切換回來繼續。 전체 기록에서 마지막으로 있던 상태로 돌아갑니다. 이 하위 기록의 편집 내용은 남아 있으므로 다시 전환해 이어갈 수 있습니다. Vuelve al punto en el que estabas en el historial completo. Las ediciones de este subhistorial se conservan, así que puedes volver a él y continuar. يعود إلى الحالة التي كنت فيها آخر مرة في السجل الكامل. تبقى تعديلات هذا السجل الفرعي محفوظة، ويمكنك التبديل إليه ومتابعة العمل. Kembali ke posisi terakhir Anda di seluruh riwayat. Hasil edit di sub-riwayat ini tetap tersimpan, sehingga Anda dapat beralih kembali dan melanjutkan.
572 DeleteLine このサブ履歴を削除します。名前だけが消え、編集は全体の履歴に残ります。 Deletes this sub-history. Only its name goes away; the edits stay in the whole history. 删除此子历史记录。只会删除名称,编辑内容仍保留在整体历史记录中。 刪除此子歷史記錄。只會刪除名稱,編輯內容仍保留在整體歷史記錄中。 이 하위 기록을 삭제합니다. 이름만 사라지고 편집 내용은 전체 기록에 남습니다. Elimina este subhistorial. Solo desaparece su nombre; las ediciones permanecen en el historial completo. يحذف هذا السجل الفرعي. يُحذف اسمه فقط، وتبقى التعديلات في السجل الكامل. Menghapus sub-riwayat ini. Hanya namanya yang hilang; hasil edit tetap ada di seluruh riwayat.
+18
ファイルの表示
@@ -0,0 +1,18 @@
using YukkuriMovieMaker.Commons;
namespace UndoTree;
internal class UndoTreeLineViewModel(UndoTreeLine? line) : Bindable
{
public UndoTreeLine? Line { get; } = line;
public string Name { get; private set => Set(ref field, value); } = line?.Name ?? Texts.WholeHistory;
public bool IsActive { get; private set => Set(ref field, value); }
internal void Refresh(UndoTreeLine? active)
{
Name = Line?.Name ?? Texts.WholeHistory;
IsActive = ReferenceEquals(Line, active);
}
}
+46 -6
ファイルの表示
@@ -18,6 +18,7 @@
<local:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter"/>
<ContextMenu x:Key="NodeContextMenu" d:DataContext="{d:DesignInstance Type={x:Type local:UndoTreeNodeViewModel}}">
<MenuItem Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBox}, Path=DataContext.JumpCommand}" CommandParameter="{Binding}" Header="{x:Static local:Texts.Jump}" Icon="{DynamicResource {x:Static icons:IconKeys.Restore}}"/>
<MenuItem Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBox}, Path=DataContext.StartLineCommand}" CommandParameter="{Binding}" Header="{x:Static local:Texts.StartLineAtNode}"/>
<Separator/>
<MenuItem Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBox}, Path=DataContext.CherryPickCommand}" CommandParameter="{Binding}" Header="{x:Static local:Texts.CherryPick}" Icon="{DynamicResource {x:Static icons:IconKeys.SourceMerge}}"/>
<MenuItem Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBox}, Path=DataContext.CherryPickRangeCommand}" CommandParameter="{Binding}" Header="{x:Static local:Texts.CherryPickRange}" Icon="{DynamicResource {x:Static icons:IconKeys.SourceFork}}"/>
@@ -38,6 +39,7 @@
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition MinHeight="{x:Static local:UndoTreeLayout.MinTreeHeight}"/>
@@ -107,6 +109,18 @@
<MenuItem Header="{x:Static local:Texts.GoToSaved}" ToolTip="{x:Static local:Texts.GoToSavedTip}" Command="{Binding DataContext.GoToSavedCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
<MenuItem Header="{x:Static local:Texts.ShowPrevious}" ToolTip="{x:Static local:Texts.ShowPreviousTip}" IsCheckable="True" IsEnabled="{Binding HasRecord}" IsChecked="{Binding IsShowingRecord,Mode=TwoWay}"/>
<Separator/>
<MenuItem Header="{x:Static local:Texts.StartLine}" Command="{Binding DataContext.StartLineCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
<MenuItem Header="{x:Static local:Texts.SwitchLine}" ItemsSource="{Binding LineChoices}" IsEnabled="{Binding HasLines}">
<MenuItem.ItemContainerStyle>
<Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Header" Value="{Binding Name}"/>
<Setter Property="IsChecked" Value="{Binding IsActive, Mode=OneWay}"/>
<Setter Property="Command" Value="{Binding DataContext.SwitchLineCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
<Setter Property="CommandParameter" Value="{Binding}"/>
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
<Separator/>
<MenuItem Header="{x:Static local:Texts.CopyHistory}" Command="{Binding DataContext.CopyHistoryCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
<MenuItem Header="{x:Static local:Texts.ExportHistory}" Command="{Binding DataContext.ExportHistoryCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
<Separator/>
@@ -121,7 +135,33 @@
</c:DropDownButton.ContextMenu>
</c:DropDownButton>
</Grid>
<Grid Grid.Row="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
<Grid Grid.Row="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" ToolTip="{x:Static local:Texts.LineTip}">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding HasActiveLine}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{x:Static local:Texts.LineTitle}" Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" Padding="4,0,4,0" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" Height="26" Padding="3,0,3,0" VerticalContentAlignment="Center" Text="{Binding ActiveLineName, Mode=TwoWay}" ToolTip="{x:Static local:Texts.LineName}">
<i:Interaction.Behaviors>
<local:CommitOnEnterBehavior/>
</i:Interaction.Behaviors>
</TextBox>
<Button Grid.Column="2" Height="26" MinWidth="80" VerticalAlignment="Center" Content="{x:Static local:Texts.LeaveLine}" ToolTip="{x:Static local:Texts.LeaveLineTip}" Command="{Binding SwitchLineCommand}"/>
<Button Grid.Column="3" Width="26" Height="26" Padding="3" VerticalAlignment="Center" Content="{DynamicResource {x:Static icons:IconKeys.Delete}}" ToolTip="{x:Static local:Texts.DeleteLine}" Command="{Binding DeleteLineCommand}"/>
</Grid>
<Grid Grid.Row="2" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Collapsed"/>
@@ -141,7 +181,7 @@
<Button Grid.Column="1" Height="26" MinWidth="80" VerticalAlignment="Center" Content="{x:Static local:Texts.RecoveryRestore}" Command="{Binding RecoverCommand}"/>
<Button Grid.Column="2" Width="26" Height="26" Padding="3" VerticalAlignment="Center" Content="{DynamicResource {x:Static icons:IconKeys.Close}}" ToolTip="{x:Static local:Texts.RecoveryDismiss}" Command="{Binding DismissRecoveryCommand}"/>
</Grid>
<TextBlock Grid.Row="1" Text="{x:Static local:Texts.Unsupported}" TextWrapping="Wrap" Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}">
<TextBlock Grid.Row="2" Text="{x:Static local:Texts.Unsupported}" TextWrapping="Wrap" Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}">
<TextBlock.Style>
<Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
<Setter Property="Visibility" Value="Collapsed"/>
@@ -153,7 +193,7 @@
</Style>
</TextBlock.Style>
</TextBlock>
<ListBox Grid.Row="2" ItemsSource="{Binding Items}" BorderThickness="0" Background="Transparent" SelectionMode="Single"
<ListBox Grid.Row="3" ItemsSource="{Binding Items}" BorderThickness="0" Background="Transparent" SelectionMode="Single"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.ScrollUnit="Pixel" ScrollViewer.CanContentScroll="True">
<i:Interaction.Behaviors>
@@ -304,9 +344,9 @@
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<GridSplitter Grid.Row="3" Height="6" HorizontalAlignment="Stretch" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Cursor="SizeNS" ResizeDirection="Rows"
<GridSplitter Grid.Row="4" Height="6" HorizontalAlignment="Stretch" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Cursor="SizeNS" ResizeDirection="Rows"
Visibility="{Binding IsDetailsVisible, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<Grid Grid.Row="4" Visibility="{Binding IsDetailsVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid Grid.Row="5" Visibility="{Binding IsDetailsVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
<ListBox ItemsSource="{Binding Details}" BorderThickness="0" Background="Transparent" Focusable="False" SelectionMode="Single"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemContainerStyle>
@@ -345,7 +385,7 @@
</TextBlock.Style>
</TextBlock>
</Grid>
<StackPanel Grid.Row="5">
<StackPanel Grid.Row="6">
<TextBlock Text="{Binding ResultText}" TextWrapping="Wrap" Foreground="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}">
<TextBlock.Style>
<Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
+75
ファイルの表示
@@ -1,6 +1,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows;
using YukkuriMovieMaker.Commons;
@@ -27,6 +28,8 @@ internal class UndoTreeViewModel : Bindable, IToolViewModel, ITimelineToolViewMo
(string Path, DateTime Stamp, long Length)? recoveryChecked;
bool isBulkChanging;
bool isLinkSuppressed;
readonly ConditionalWeakTable<UndoTreeLine, UndoTreeLineViewModel> lineChoices = [];
readonly UndoTreeLineViewModel wholeChoice = new(null);
public event EventHandler<CreateNewToolViewRequestedEventArgs>? CreateNewToolViewRequested
{
@@ -68,6 +71,22 @@ internal class UndoTreeViewModel : Bindable, IToolViewModel, ITimelineToolViewMo
public bool HasRecovery { get; private set => Set(ref field, value); }
public ObservableCollection<UndoTreeLineViewModel> LineChoices { get; } = [];
public bool HasLines { get; private set => Set(ref field, value); }
public bool HasActiveLine { get; private set => Set(ref field, value); }
public string ActiveLineName
{
get => history?.ActiveLine?.Name ?? string.Empty;
set
{
if (history?.ActiveLine is { } line && !history.RenameLine(line, value))
OnPropertyChanged(nameof(ActiveLineName));
}
}
public bool IsShowingRecord
{
get;
@@ -145,6 +164,12 @@ internal class UndoTreeViewModel : Bindable, IToolViewModel, ITimelineToolViewMo
public ActionCommand DropBranchesCommand { get; }
public ActionCommand StartLineCommand { get; }
public ActionCommand SwitchLineCommand { get; }
public ActionCommand DeleteLineCommand { get; }
public ActionCommand SwitchConflictPolicyCommand { get; }
public IEnumerable<ActionCommand> Commands => [
@@ -167,6 +192,9 @@ internal class UndoTreeViewModel : Bindable, IToolViewModel, ITimelineToolViewMo
RecoverCommand,
DismissRecoveryCommand,
DropBranchesCommand,
StartLineCommand,
SwitchLineCommand,
DeleteLineCommand,
SwitchConflictPolicyCommand,
];
@@ -298,6 +326,15 @@ internal class UndoTreeViewModel : Bindable, IToolViewModel, ITimelineToolViewMo
if (count > 0 && UndoTreeDispatch.Confirm(string.Format(Texts.ConfirmDropBranches, count)))
history.DropSideBranches();
});
StartLineCommand = new ActionCommand(
_ => CanUseLines,
parameter => _ = RunAsync(() => StartLineAsync(parameter as UndoTreeNodeViewModel ?? history!.Cursor)));
SwitchLineCommand = new ActionCommand(
parameter => CanUseLines && (parameter is UndoTreeLineViewModel || history!.ActiveLine is not null),
parameter => _ = RunAsync(() => SwitchLineAsync((parameter as UndoTreeLineViewModel)?.Line)));
DeleteLineCommand = new ActionCommand(
_ => !isRunning && history?.ActiveLine is not null,
_ => history!.DeleteLine(history.ActiveLine!));
SwitchConflictPolicyCommand = new ActionCommand(
_ => true,
parameter =>
@@ -511,6 +548,43 @@ internal class UndoTreeViewModel : Bindable, IToolViewModel, ITimelineToolViewMo
LinkSelection(node);
}
bool CanUseLines => !isRunning && history is { CanSetFloor: true } && !IsShowingRecord;
async Task StartLineAsync(UndoTreeNodeViewModel from)
{
await history!.StartLineAsync(from);
ExpandAncestorsOfCurrent();
SelectCurrent();
}
async Task SwitchLineAsync(UndoTreeLine? line)
{
await history!.SwitchToAsync(line);
ExpandAncestorsOfCurrent();
SelectCurrent();
}
void UpdateLines()
{
var lines = history?.Lines ?? [];
var active = history?.ActiveLine;
var choices = new List<UndoTreeLineViewModel> { wholeChoice };
choices.AddRange(lines.Select(line => lineChoices.GetValue(line, key => new UndoTreeLineViewModel(key))));
foreach (var choice in choices)
choice.Refresh(active);
if (!LineChoices.SequenceEqual(choices))
{
LineChoices.Clear();
foreach (var choice in choices)
LineChoices.Add(choice);
}
HasLines = lines.Count > 0;
HasActiveLine = active is not null;
OnPropertyChanged(nameof(ActiveLineName));
}
async Task GoToSavedAsync()
{
var saved = history!.FindSavedState();
@@ -725,6 +799,7 @@ internal class UndoTreeViewModel : Bindable, IToolViewModel, ITimelineToolViewMo
RebuildRows();
UpdateStatus();
UpdateLines();
UpdateRecovery();
OnPropertyChanged(nameof(IsSupported));
if (UndoTreeSettings.Default.FollowCurrent && !Filter.IsActive && !IsShowingRecord)