Skip to content

Commit

Permalink
Fixed duplicated LineBoxes are sharing same viewmodel
Browse files Browse the repository at this point in the history
  • Loading branch information
EX3exp committed Oct 7, 2024
1 parent 68f48af commit 1c81492
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 59 deletions.
21 changes: 17 additions & 4 deletions Mirivoice/Commands/DuplicateLineBoxReceiver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Mirivoice.Views;
using Mirivoice.Engines;
using Mirivoice.Mirivoice.Core;
using Mirivoice.Mirivoice.Core.Format;
using Mirivoice.Views;
using System;

namespace Mirivoice.Commands
Expand All @@ -14,11 +17,21 @@ public DuplicateLineBoxReceiver(LineBoxView l)

public override void DoAction()
{

var lineBox = new LineBoxView(l);
MLinePrototype mLinePrototype = new MLinePrototype(l);
int LineNoToBeAdded = Int32.Parse(l.viewModel.LineNo);

lineBox.viewModel.SetLineNo(LineNoToBeAdded + 1);
int spkid = l.viewModel.voicerSelector.CurrentVoicer.CurrentVoicerMeta.SpeakerId;
int metaIndex = 0;
foreach (VoicerMeta v in l.viewModel.voicerSelector.CurrentVoicer.VoicerMetaCollection)
{
if (v.SpeakerId == spkid)
{
break;
}
metaIndex++;
}
var lineBox = new LineBoxView(mLinePrototype, l.v, LineNoToBeAdded + 1, l.viewModel.voicerSelector.CurrentDefaultVoicerIndex, metaIndex);


l.v.LineBoxCollection.Insert(LineNoToBeAdded, lineBox);
LineBoxIndexLastAdded = LineNoToBeAdded;
Expand Down
55 changes: 0 additions & 55 deletions Mirivoice/Views/LineBoxView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,61 +206,6 @@ public LineBoxView(MainViewModel v, string line="")



public LineBoxView(LineBoxView l)
{
this.v = l.v;
int voicerIndex = l.viewModel.voicerSelector.CurrentDefaultVoicerIndex;

int spkid = l.viewModel.voicerSelector.CurrentVoicer.CurrentVoicerMeta.SpeakerId;
int metaIndex = 0;
foreach (VoicerMeta v in v.voicerSelector.Voicers[voicerIndex].VoicerMetaCollection)
{
if (v.SpeakerId == spkid)
{
break;
}
metaIndex++;
}



InitializeComponent(voicerIndex, metaIndex);
viewModel.LineText = l.viewModel.LineText;
IPAText = l.IPAText;
_currentCacheName = AudioManager.GetUniqueCachePath();


//lockButton = this.FindControl<ToggleButton>("lockButton");
SetCommands(v);

this.MResultsCollection = l.MResultsCollection;

mouseEntered = false;
isDragging = false;

this.AddHandler(PointerReleasedEvent, OnDragEnd, RoutingStrategies.Tunnel);

targetIndex = -1;

string line = viewModel.LineText;

ShouldPhonemize = false;
DeActivatePhonemizer = true;

if (line != string.Empty)
{
ShouldPhonemizeWhenSelected = true;
}
else
{
ShouldPhonemizeWhenSelected = false;
}



singleLineEditorView = l.singleLineEditorView;

}


public LineBoxView(MLinePrototype mLinePrototype, MainViewModel v, int index, int voicerIndex, int metaIndex)
Expand Down

0 comments on commit 1c81492

Please sign in to comment.