Skip to content

Commit

Permalink
Merge pull request #1334 from rokujyushi/Exp-dialog_fun-added
Browse files Browse the repository at this point in the history
Multi-selection support for ExpressionsDialog.
  • Loading branch information
stakira authored Dec 20, 2024
2 parents fecd585 + 84b45e8 commit c540700
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion OpenUtau/ViewModels/ExpressionsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive.Linq;
Expand Down Expand Up @@ -117,12 +118,16 @@ public ExpressionBuilder? Expression {
set => this.RaiseAndSetIfChanged(ref expression, value);
}

public ObservableCollection<ExpressionBuilder>? SelectExpressions => selectexpressions;

private ReadOnlyObservableCollection<ExpressionBuilder> expressions;
private ExpressionBuilder? expression;
private ObservableCollection<ExpressionBuilder>? selectexpressions;

private ObservableCollectionExtended<ExpressionBuilder> expressionsSource;

public ExpressionsViewModel() {
selectexpressions = new ObservableCollection<ExpressionBuilder>();
expressionsSource = new ObservableCollectionExtended<ExpressionBuilder>();
expressionsSource.ToObservableChangeSet()
.Bind(out expressions)
Expand Down Expand Up @@ -160,7 +165,14 @@ public void Add() {
}

public void Remove() {
if (Expression != null) {
if (SelectExpressions != null) {
var selectedItems = SelectExpressions.ToList();
foreach (var expression in selectedItems) {
if (expression.IsCustom) {
expressionsSource.Remove(expression);
}
}
} else if (Expression != null) {
expressionsSource.Remove(Expression);
}
}
Expand Down
2 changes: 1 addition & 1 deletion OpenUtau/Views/ExpressionsDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<Grid Margin="{Binding $parent.WindowDecorationMargin}">
<Border Margin="10,10,10,40" Width="150" HorizontalAlignment="Left">
<ListBox ItemsSource="{Binding Expressions}" SelectedItem="{Binding Expression}">
<ListBox ItemsSource="{Binding Expressions}" SelectedItem="{Binding Expression}" SelectedItems="{Binding SelectExpressions}" SelectionMode="Multiple">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
Expand Down

0 comments on commit c540700

Please sign in to comment.