Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
InuInu2022 committed Jun 10, 2024
1 parent f9c5e26 commit 7c48ec0
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 218 deletions.
5 changes: 5 additions & 0 deletions SasaraUtil.UI/ViewModels/General/AudioConvertViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public sealed class AudioConvertViewModel

public INotificationMessageManager? Notify { get; set; }
public double StartTime { get; set; }

public Well DockPanelWell { get; }
= Well.Factory.Create<DockPanel>();
public Pile<DockPanel>? DockPanelPile {get;set;}
public ObservableCollection<AudioConvertFileListViewModel>? DroppedFiles { get; set; }
public bool IsDropAreaVisibile { get; set; } = true;
Expand All @@ -53,6 +56,8 @@ public AudioConvertViewModel()

StartTime = 0.0f;

DockPanelWell.Add(DragDrop.DropEvent, DropFileEventAsync);

ConvertAndSend = Command.Factory
.Create(SendToCeVIO());

Expand Down
16 changes: 9 additions & 7 deletions SasaraUtil.UI/ViewModels/Song/BreathSuppressorViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Notification;
using Avalonia.Platform.Storage;
Expand All @@ -22,6 +19,9 @@ public class BreathSuppressorViewModel
private readonly INotificationMessageManager? _notify;
private readonly IStorageProvider? _storage;

public Well DockPanelWell { get; }
= Well.Factory.Create<DockPanel>();

public bool IsConvertable { get; set; }
public ObservableCollection<string> DroppedFiles { get; set; }
public string? TargetFileName { get; set; }
Expand All @@ -39,8 +39,10 @@ public class BreathSuppressorViewModel

public BreathSuppressorViewModel()
{
DroppedFiles = new();
CcsTrackData = new();
DroppedFiles = [];
CcsTrackData = [];

DockPanelWell.Add(DragDrop.DropEvent, DropFileEventAsync);

ResetFiles = Command.Factory
.CreateSync(ResetFile());
Expand Down Expand Up @@ -200,7 +202,7 @@ public async ValueTask DropFileEventAsync(DragEventArgs e)
private Action ResetFile()
=> () =>
{
DroppedFiles = new();
DroppedFiles = [];
IsConvertable = false;
};
}
Expand Down
6 changes: 6 additions & 0 deletions SasaraUtil.UI/ViewModels/Talk/CastSplitterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Notification;
using Avalonia.Platform.Storage;
Expand All @@ -24,6 +25,9 @@ public class CastSplitterViewModel
private readonly IStorageProvider? _storage;

public bool IsConvertable { get; set; }

public Well DockPanelWell { get; }
= Well.Factory.Create<DockPanel>();
public ObservableCollection<string> DroppedFiles { get; set; }
public string? TargetFileName { get; set; }
public ObservableCollection<CcsTrackViewModel> CcsTrackData { get; set; }
Expand All @@ -37,6 +41,8 @@ public CastSplitterViewModel()
DroppedFiles = new();
CcsTrackData = new();

DockPanelWell.Add(DragDrop.DropEvent, DropFileEventAsync);

ResetFiles = Command.Factory
.CreateSync(ResetFile());

Expand Down
16 changes: 11 additions & 5 deletions SasaraUtil.UI/ViewModels/Talk/VocalPercussionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Avalonia.Platform.Storage;
using SasaraUtil.UI.ViewModels.Utility;
using CodingSeb.Localization;
using Avalonia.Controls;

namespace SasaraUtil.ViewModels.VocalPercussion;

Expand All @@ -38,6 +39,9 @@ public class VocalPercussionViewModel
public Command? SaveFile { get; set; }
public Command? SelectFile { get; set; }
public Command? Ready { get; set; }

public Well DockPanelWell { get; }
= Well.Factory.Create<DockPanel>();
public bool IsOpenWithCeVIO { get; set; }
public int SelectedTalkApp { get; set; } = -1;

Expand All @@ -46,17 +50,19 @@ public class VocalPercussionViewModel
public int SelectedTalkCast { get; set; }

public ObservableCollection<string> TalkCasts { get; set; }
= new();
= [];

private static readonly string[] patterns = ["*.ccs"];

public VocalPercussionViewModel()
{
DroppedFiles = new();
CcsTrackData = new();
DroppedFiles = [];
CcsTrackData = [];
TalkApps = new(Enum.GetValues(typeof(TalkApps)).Cast<TalkApps>());
SelectedTalkApp = 0;

DockPanelWell.Add(DragDrop.DropEvent, DropFileEventAsync);

ResetFiles = Command.Factory
.CreateSync(ResetFile());

Expand Down Expand Up @@ -274,8 +280,8 @@ ReadOnlyCollection<string> pathes
private Action ResetFile()
=> () =>
{
DroppedFiles = new();
CcsTrackData = new();
DroppedFiles = [];
CcsTrackData = [];
IsConvertable = false;
};

Expand Down
1 change: 1 addition & 0 deletions SasaraUtil.UI/Views/General/AudioConvert.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<DockPanel
Margin="5"
DragDrop.AllowDrop="True"
epoxy:Fountain.Well="{Binding DockPanelWell}"
epoxy:Anchor.Pile="{Binding DockPanelPile}"
Opacity="1"
Background="{DynamicResource ApplicationPageBackgroundThemeBrush}">
Expand Down
1 change: 1 addition & 0 deletions SasaraUtil.UI/Views/Song/BreathSuppressor.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Margin="5"
Opacity="1"
DragDrop.AllowDrop="True"
epoxy:Fountain.Well="{Binding DockPanelWell}"
Background="{DynamicResource ApplicationPageBackgroundThemeBrush}">

<WrapPanel
Expand Down
2 changes: 1 addition & 1 deletion SasaraUtil.UI/Views/Song/BreathSuppressor.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public BreathSuppressor()
{
this.InitializeComponent();

AddHandler(DragDrop.DropEvent, DropAsync);
//AddHandler(DragDrop.DropEvent, DropAsync);
}

async void DropAsync(object? sender, DragEventArgs e)
Expand Down
1 change: 1 addition & 0 deletions SasaraUtil.UI/Views/Talk/CastSplitter.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<DockPanel
Margin="5"
DragDrop.AllowDrop="True"
epoxy:Fountain.Well="{Binding DockPanelWell}"
Opacity="1"
Background="{DynamicResource ApplicationPageBackgroundThemeBrush}">
<WrapPanel
Expand Down
2 changes: 1 addition & 1 deletion SasaraUtil.UI/Views/Talk/CastSplitter.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public CastSplitter()
{
this.InitializeComponent();

AddHandler(DragDrop.DropEvent, DropAsync);
//AddHandler(DragDrop.DropEvent, DropAsync);
}

async void DropAsync(object? sender, DragEventArgs e)
Expand Down
Loading

0 comments on commit 7c48ec0

Please sign in to comment.