From cc316d3871fae48eb45abe865b7695fbd484e2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=92=E7=8C=AB=E5=A4=A7=E7=A6=8F?= <93469977+rokujyushi@users.noreply.github.com> Date: Tue, 12 Nov 2024 02:04:48 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=88=E3=83=9C?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=82=B9=E3=81=AE=E8=A4=87=E6=95=B0=E9=81=B8?= =?UTF-8?q?=E6=8A=9E=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenUtau/ViewModels/ExpressionsViewModel.cs | 16 +++++++++++++++- OpenUtau/Views/ExpressionsDialog.axaml | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/OpenUtau/ViewModels/ExpressionsViewModel.cs b/OpenUtau/ViewModels/ExpressionsViewModel.cs index 6f8070ec8..08bade2ec 100644 --- a/OpenUtau/ViewModels/ExpressionsViewModel.cs +++ b/OpenUtau/ViewModels/ExpressionsViewModel.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Reactive.Linq; @@ -117,8 +118,14 @@ public ExpressionBuilder? Expression { set => this.RaiseAndSetIfChanged(ref expression, value); } + public List? SelectExpressions { + get => selectexpressions; + set => this.RaiseAndSetIfChanged(ref selectexpressions, value); + } + private ReadOnlyObservableCollection expressions; private ExpressionBuilder? expression; + private List? selectexpressions; private ObservableCollectionExtended expressionsSource; @@ -130,6 +137,7 @@ public ExpressionsViewModel() { expressionsSource.AddRange(DocManager.Inst.Project.expressions.Select(pair => new ExpressionBuilder(pair.Value))); if (expressionsSource.Count > 0) { expression = expressionsSource[0]; + selectexpressions = expressionsSource.ToList(); } } @@ -160,7 +168,13 @@ public void Add() { } public void Remove() { - if (Expression != null) { + if (SelectExpressions != null) { + foreach (var expression in SelectExpressions) { + if (expression.IsCustom) { + expressionsSource.Remove(expression); + } + } + } else if (Expression != null) { expressionsSource.Remove(Expression); } } diff --git a/OpenUtau/Views/ExpressionsDialog.axaml b/OpenUtau/Views/ExpressionsDialog.axaml index 83b4326c1..b5f43cb54 100644 --- a/OpenUtau/Views/ExpressionsDialog.axaml +++ b/OpenUtau/Views/ExpressionsDialog.axaml @@ -19,7 +19,7 @@ - + From af17e581fe7b19c3203beb6cbd0f767f85d0e435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=92=E7=8C=AB=E5=A4=A7=E7=A6=8F?= <93469977+rokujyushi@users.noreply.github.com> Date: Thu, 21 Nov 2024 01:59:39 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=80=E6=8B=AC=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenUtau/ViewModels/ExpressionsViewModel.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/OpenUtau/ViewModels/ExpressionsViewModel.cs b/OpenUtau/ViewModels/ExpressionsViewModel.cs index 08bade2ec..294b95b29 100644 --- a/OpenUtau/ViewModels/ExpressionsViewModel.cs +++ b/OpenUtau/ViewModels/ExpressionsViewModel.cs @@ -118,18 +118,16 @@ public ExpressionBuilder? Expression { set => this.RaiseAndSetIfChanged(ref expression, value); } - public List? SelectExpressions { - get => selectexpressions; - set => this.RaiseAndSetIfChanged(ref selectexpressions, value); - } + public ObservableCollection? SelectExpressions => selectexpressions; private ReadOnlyObservableCollection expressions; private ExpressionBuilder? expression; - private List? selectexpressions; + private ObservableCollection? selectexpressions; private ObservableCollectionExtended expressionsSource; public ExpressionsViewModel() { + selectexpressions = new ObservableCollection(); expressionsSource = new ObservableCollectionExtended(); expressionsSource.ToObservableChangeSet() .Bind(out expressions) @@ -137,7 +135,6 @@ public ExpressionsViewModel() { expressionsSource.AddRange(DocManager.Inst.Project.expressions.Select(pair => new ExpressionBuilder(pair.Value))); if (expressionsSource.Count > 0) { expression = expressionsSource[0]; - selectexpressions = expressionsSource.ToList(); } } @@ -169,7 +166,8 @@ public void Add() { public void Remove() { if (SelectExpressions != null) { - foreach (var expression in SelectExpressions) { + var selectedItems = SelectExpressions.ToList(); + foreach (var expression in selectedItems) { if (expression.IsCustom) { expressionsSource.Remove(expression); }