implement Clone() for stuff in Lighting plugin

This commit is contained in:
Michael Becker 2021-11-15 23:52:17 -05:00
parent dd2b88c16f
commit 6a2f3b5d0a
5 changed files with 57 additions and 6 deletions

View File

@ -1,6 +1,8 @@
using System;
namespace UniversalEditor.ObjectModels.Lighting.Script
{
public class Fixture
public class Fixture : ICloneable
{
public class FixtureCollection
: System.Collections.ObjectModel.Collection<Fixture>
@ -9,5 +11,12 @@ namespace UniversalEditor.ObjectModels.Lighting.Script
private int mvarInitialAddress = 0;
public int InitialAddress { get { return mvarInitialAddress; } set { mvarInitialAddress = value; } }
public object Clone()
{
Fixture clone = new Fixture();
clone.InitialAddress = InitialAddress;
return clone;
}
}
}

View File

@ -22,7 +22,15 @@ namespace UniversalEditor.ObjectModels.Lighting.Script
}
public override void CopyTo(ObjectModel where)
{
throw new NotImplementedException();
ScriptObjectModel clone = (where as ScriptObjectModel);
foreach (Fixture item in Fixtures)
{
clone.Fixtures.Add(item.Clone() as Fixture);
}
foreach (Track item in Tracks)
{
clone.Tracks.Add(item.Clone() as Track);
}
}
private string mvarAudioFileName = String.Empty;

View File

@ -5,7 +5,7 @@ using System.Text;
namespace UniversalEditor.ObjectModels.Lighting.Script
{
public class Track
public class Track : ICloneable
{
public class TrackCollection
: System.Collections.ObjectModel.Collection<Track>
@ -17,5 +17,16 @@ namespace UniversalEditor.ObjectModels.Lighting.Script
private TrackEntry.TrackEntryCollection mvarEntries = new TrackEntry.TrackEntryCollection();
public TrackEntry.TrackEntryCollection Entries { get { return mvarEntries; } }
public object Clone()
{
Track clone = new Track();
clone.Name = (Name?.Clone() as string);
foreach (TrackEntry entry in Entries)
{
clone.Entries.Add(entry.Clone() as TrackEntry);
}
return clone;
}
}
}

View File

@ -5,7 +5,7 @@ using System.Text;
namespace UniversalEditor.ObjectModels.Lighting.Script
{
public class TrackEntry
public class TrackEntry : ICloneable
{
public class TrackEntryCollection
: System.Collections.ObjectModel.Collection<TrackEntry>
@ -26,5 +26,18 @@ namespace UniversalEditor.ObjectModels.Lighting.Script
/// The duration, in frames, of the entry.
/// </summary>
public int Duration { get { return mvarDuration; } set { mvarDuration = value; } }
public object Clone()
{
TrackEntry clone = new TrackEntry();
clone.Name = (Name?.Clone() as string);
clone.StartFrame = StartFrame;
clone.Duration = Duration;
foreach (TrackEntryCommand command in Commands)
{
clone.Commands.Add(command.Clone() as TrackEntryCommand);
}
return clone;
}
}
}

View File

@ -6,18 +6,19 @@ using UniversalEditor.ObjectModels.Lighting.Fixture;
namespace UniversalEditor.ObjectModels.Lighting.Script
{
public abstract class TrackEntryCommand
public abstract class TrackEntryCommand : ICloneable
{
public class TrackEntryCommandCollection
: System.Collections.ObjectModel.Collection<TrackEntryCommand>
{
}
public abstract object Clone();
}
public class TrackEntryChannelCommand : TrackEntryCommand
{
private Channel mvarChannel = null;
public Channel Channel { get { return mvarChannel; } }
public Channel Channel { get { return mvarChannel; } set { mvarChannel = value; } }
private byte mvarStartValue = 0;
public byte StartValue { get { return mvarStartValue; } set { mvarStartValue = value; } }
@ -26,5 +27,14 @@ namespace UniversalEditor.ObjectModels.Lighting.Script
public byte EndValue { get { return mvarEndValue; } set { mvarEndValue = value; } }
// Interpolation mode?
public override object Clone()
{
TrackEntryChannelCommand clone = new TrackEntryChannelCommand();
clone.Channel = (Channel?.Clone() as Channel);
clone.StartValue = StartValue;
clone.EndValue = EndValue;
return clone;
}
}
}