Exemplo n.º 1
0
            public bool Play()
            {
                error = null;

                try {
                    if (!File.Exists(path))
                    {
                        error = string.Format("File '{0}' does not exist.", path);
                        return(false);
                    }

                    var           fileIOHandler = FileIOHelper.GetByExtension(path);
                    EventSequence sequence      = fileIOHandler.OpenSequence(path);
                    numberOfChannels = sequence.FullChannelCount;

                    object executionIfaceObj;
                    if (!Interfaces.Available.TryGetValue("IExecution", out executionIfaceObj))
                    {
                        error = "IExecution interface not available.";
                        return(false);
                    }

                    executionInterface = (IExecution)executionIfaceObj;
                    contextHandle      = executionInterface.RequestContext(true, false, null);
                    executionInterface.SetSynchronousContext(contextHandle, sequence);

                    executionInterface.ExecutePlay(contextHandle, 0, 0);

                    return(true);
                }
                catch (Exception e) {
                    error = e.Message;
                    return(false);
                }
            }
Exemplo n.º 2
0
 public ChannelCopyDialog(AffectGridDelegate affectGridDelegate, EventSequence sequence, Channel selected, bool constrainToGroup)
 {
     InitializeComponent();
     _channels = new Channel[constrainToGroup ? sequence.ChannelCount : sequence.FullChannelCount];
     for (var channel = 0; channel < _channels.Length; channel++) {
         _channels[channel] = constrainToGroup ? sequence.Channels[channel] : sequence.FullChannels[channel];
     }
     // ReSharper disable CoVariantArrayConversion
     comboBoxSourceChannel.Items.AddRange(_channels);
     comboBoxDestinationChannel.Items.AddRange(_channels);
     // ReSharper restore CoVariantArrayConversion
     if (comboBoxSourceChannel.Items.Count > 0) {
         if (comboBoxSourceChannel.Items.Contains(selected)) {
             comboBoxSourceChannel.SelectedItem = selected;
         }
         else {
             comboBoxSourceChannel.SelectedIndex = 0;
         }
     }
     if (comboBoxDestinationChannel.Items.Count > 0) {
         comboBoxDestinationChannel.SelectedIndex = 0;
     }
     _eventSequence = sequence;
     _sequenceData = new byte[1,sequence.TotalEventPeriods];
     _affectGridDelegate = affectGridDelegate;
 }
Exemplo n.º 3
0
 private void LogAudio(EventSequence sequence)
 {
     if (_isLoggingEnabled && (sequence.Audio != null))
     {
         Host.LogAudio("Sequence", sequence.Name, sequence.Audio.FileName, sequence.Audio.Duration);
     }
 }
Exemplo n.º 4
0
        private static byte[,] ReconfigureSourceData(EventSequence sequence)
        {
            var buffer = new byte[sequence.FullChannelCount, sequence.TotalEventPeriods];
            var list   = sequence.FullChannels.Select(channel => channel.OutputChannel).ToList();

            for (var i = 0; i < sequence.FullChannelCount; i++)
            {
                var row               = list[i];
                int delayMs           = sequence.Channels[i].DelayMillis;
                int delayEventPeriods = 0;
                if (delayMs != 0)
                {
                    delayEventPeriods = (int)Math.Round((double)delayMs / (double)sequence.EventPeriod);
                }
                for (var column = 0; column < sequence.TotalEventPeriods; column++)
                {
                    int srcColumn = column + delayEventPeriods;
                    if (srcColumn < 0 || srcColumn >= sequence.TotalEventPeriods)
                    {
                        buffer[row, column] = 0;
                    }
                    else
                    {
                        buffer[row, column] = sequence.EventValues[i, srcColumn];
                    }
                }
            }
            return(buffer);
        }
Exemplo n.º 5
0
 public void Dispose()
 {
     if (Sequence != null)
     {
         Sequence.Dispose();
         Sequence = null;
     }
     GC.SuppressFinalize(this);
 }
Exemplo n.º 6
0
 public void InheritChannelsFrom(EventSequence sequence)
 {
     _channelObjects = sequence.FullChannels;
     _channelOutputs.Clear();
     foreach (var channel in sequence.FullChannels)
     {
         _channelOutputs.Add(channel.OutputChannel);
     }
     IsDirty = true;
 }
Exemplo n.º 7
0
        public void SaveSequence(EventSequence eventSequence)
        {
            const byte colorEncoding = 2, gamma = 1, versionMajor = 1, versionMinor = 0;
            const string fileType = "PSEQ";
            const ushort fixedHeaderLength = 28, mediaHeaderSize = 5, padding = 0, universeCount = 0, universeSize = 0;

            var mediaFileName = eventSequence.Audio != null ? eventSequence.Audio.FileName ?? "" : "";
            var mediaHeaderTotalLength = mediaFileName.Length == 0 ? 0 : mediaFileName.Length + mediaHeaderSize;

            var offsetToSequenceData = RoundUshortTo4((ushort) (fixedHeaderLength + mediaHeaderTotalLength));
            var numberOfChannels = RoundUIntTo4((uint) eventSequence.FullChannelCount);
            var numberOfEvents = (uint)eventSequence.TotalEventPeriods;
            var frameSizeMs = (ushort)eventSequence.EventPeriod;

            using (var fileStream = new FileStream(eventSequence.FileName, FileMode.Create)) {
                using (var binaryWriter = new BinaryWriter(fileStream)) {
                    binaryWriter.Write(fileType.ToCharArray()); // 0:3
                    binaryWriter.Write(offsetToSequenceData); //  4:5
                    binaryWriter.Write(versionMinor); // 6
                    binaryWriter.Write(versionMajor); //  7
                    binaryWriter.Write(fixedHeaderLength); //  8:9
                    binaryWriter.Write(numberOfChannels); // (step size) 10:13
                    binaryWriter.Write(numberOfEvents); // (steps/frames) 14:17
                    binaryWriter.Write(frameSizeMs); // 18:19
                    binaryWriter.Write(universeCount); // 20:21
                    binaryWriter.Write(universeSize); //  22:23
                    binaryWriter.Write(gamma); // 24
                    binaryWriter.Write(colorEncoding); // 25
                    binaryWriter.Write(padding); // 26:27
                    if (mediaHeaderTotalLength > 0) {
                        binaryWriter.Write((ushort) (mediaHeaderTotalLength)); // 28:29
                        binaryWriter.Write("mf".ToCharArray()); // 30:31
                        binaryWriter.Write(mediaFileName.ToCharArray()); // 32:32+mediaFileName.Length
                    }

                    // (pad to nearest 4)
                    var padSize = offsetToSequenceData - (fixedHeaderLength + mediaHeaderTotalLength);

                    for (var pad = 0; pad < padSize; pad++) {
                        binaryWriter.Write((byte) 0);
                    }

                    // Write the event data
                    for (var period = 0; period < numberOfEvents; period++) {
                        for (var channel = 0; channel < numberOfChannels; channel++) {
                            binaryWriter.Write(eventSequence.EventValues[channel, period]);
                        }
                    }

                    // Done and Done :)
                    binaryWriter.Close();
                }

            }
        }
Exemplo n.º 8
0
        // ReSharper disable once UnusedParameter.Local
        private void NewMenuItemClick(object sender, EventArgs e)
        {
            var item = (ToolStripItem)sender;

            if (!(item.Tag is IUIPlugIn))
            {
                return;
            }

            var tag      = (IUIPlugIn)item.Tag;
            var instance = (IUIPlugIn)Activator.CreateInstance(tag.GetType());

            instance.Sequence = null;
            if (_preferences.GetBoolean("WizardForNewSequences"))
            {
                EventSequence resultSequence = null;
                switch (instance.RunWizard(ref resultSequence))
                {
                case DialogResult.None:
                    MessageBox.Show(Resources.VixenPlusForm_NoWizardMsg, Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    instance.Sequence = instance.New();
                    break;

                case DialogResult.OK:
                    instance.Sequence = instance.New(resultSequence);
                    if (!SaveAs(instance))
                    {
                        DialogResult = DialogResult.None;
                    }
                    break;

                case DialogResult.Cancel:
                    return;
                }
            }
            else
            {
                instance.Sequence = instance.New();
            }

            if (instance.Sequence == null)
            {
                return;
            }

            var uiBase = instance as UIBase;

            if (uiBase != null)
            {
                uiBase.DirtyChanged += plugin_DirtyChanged;
                uiBase.IsDirty       = DialogResult == DialogResult.None;
            }
            instance.MdiParent = this;
            instance.Show();
        }
Exemplo n.º 9
0
        public NutcrackerControlDialog(EventSequence sequence, Rectangle selectedRange, bool constrainToGroup)
        {
            _sequence = sequence;
            _selectedRange = selectedRange;

            _channels = constrainToGroup ? _sequence.Channels : _sequence.FullChannels;
            InitializeComponent();
            MaximumSize = Size;
            MinimumSize = Size;
            InitializeControls();
        }
Exemplo n.º 10
0
 public void LoadEmbeddedData(string fileName, EventSequence es)
 {
     if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) {
         var document = new XmlDocument();
         document.Load(fileName);
         LoadEmbeddedData(document.SelectSingleNode("//Program"), es);
     }
     else {
         es.PlugInData = new SetupData();
     }
 }
Exemplo n.º 11
0
 public SequenceProgram(EventSequence sequence)
 {
     _profile = null;
     UseSequencePluginData = false;
     TreatAsLocal = false;
     _key = Host.GetUniqueKey();
     _mask = null;
     FileName = sequence.FileName;
     ConstructUsing();
     SetupData = sequence.PlugInData;
     EventSequences.Add(new EventSequenceStub(sequence));
 }
Exemplo n.º 12
0
 public SequenceProgram(EventSequence sequence)
 {
     _profile = null;
     UseSequencePluginData = false;
     TreatAsLocal          = false;
     _key     = Host.GetUniqueKey();
     _mask    = null;
     FileName = sequence.FileName;
     ConstructUsing();
     SetupData = sequence.PlugInData;
     EventSequences.Add(new EventSequenceStub(sequence));
 }
Exemplo n.º 13
0
        private void Initialize(EventSequence sequence)
        {
            switch (Mode)
            {
            case EngineMode.Asynchronous:
                InitializeForAsynchronous(sequence);
                break;

            default:
                Initialize(new SequenceProgram(sequence));
                break;
            }
        }
Exemplo n.º 14
0
        public override void SaveSequence(EventSequence eventSequence)
        {
            var contextNode = Xml.CreateXmlDocument();

            BaseSaveSequence(contextNode, eventSequence, FormatChannel);

            var programNode = Xml.GetNodeAlways(contextNode, "Program");

            if (eventSequence.Profile == null) {
                Group.SaveToXml(programNode, eventSequence.Groups);
            }

            contextNode.Save(eventSequence.FileName);
        }
Exemplo n.º 15
0
        private static byte[,] ReconfigureSourceData(EventSequence sequence)
        {
            var buffer = new byte[sequence.FullChannelCount, sequence.TotalEventPeriods];
            var list   = sequence.FullChannels.Select(channel => channel.OutputChannel).ToList();

            for (var i = 0; i < sequence.FullChannelCount; i++)
            {
                var row = list[i];
                for (var column = 0; column < sequence.TotalEventPeriods; column++)
                {
                    buffer[row, column] = sequence.EventValues[i, column];
                }
            }
            return(buffer);
        }
Exemplo n.º 16
0
 public EventSequenceStub(EventSequence sequence)
 {
     FileName = string.Empty;
     _length = 0;
     LengthString = string.Empty;
     AudioName = string.Empty;
     AudioFileName = string.Empty;
     Sequence = null;
     FileName = sequence.FileName;
     Length = sequence.Time;
     if (sequence.Audio != null) {
         AudioName = sequence.Audio.Name;
         AudioFileName = sequence.Audio.FileName;
     }
     Sequence = sequence;
     Mask = Sequence.Mask;
 }
Exemplo n.º 17
0
 public TestChannelsDialog(EventSequence sequence, IExecution executionInterface, bool constrainToGroup)
 {
     InitializeComponent();
     _executionInterface = executionInterface;
     _channels = constrainToGroup ? sequence.Channels : sequence.FullChannels;
     if (_channels != null) {
         // ReSharper disable CoVariantArrayConversion
         listBoxChannels.Items.AddRange(_channels.ToArray());
         // ReSharper restore CoVariantArrayConversion
     }
     _actualLevels = ((ISystem) Interfaces.Available["ISystem"]).UserPreferences.GetBoolean("ActualLevels");
     trackBar.Maximum = _actualLevels ? Utils.Cell8BitMax : Utils.Cell8BitMax.ToPercentage();
     _channelLevels = new byte[sequence.FullChannelCount];
     _executionContextHandle = _executionInterface.RequestContext(false, true, null);
     _executionInterface.SetAsynchronousContext(_executionContextHandle, sequence);
     BringToFront();
     trackBar.Value = trackBar.Maximum;
 }
Exemplo n.º 18
0
 public EventSequenceStub(EventSequence sequence)
 {
     FileName      = string.Empty;
     _length       = 0;
     LengthString  = string.Empty;
     AudioName     = string.Empty;
     AudioFileName = string.Empty;
     Sequence      = null;
     FileName      = sequence.FileName;
     Length        = sequence.Time;
     if (sequence.Audio != null)
     {
         AudioName     = sequence.Audio.Name;
         AudioFileName = sequence.Audio.FileName;
     }
     Sequence = sequence;
     Mask     = Sequence.Mask;
 }
Exemplo n.º 19
0
        public DrawingIntensityDialog(EventSequence sequence, byte currentLevel, bool actualLevels)
        {
            InitializeComponent();
            _actualLevels = actualLevels;

            if (actualLevels) {
                udLevel.Minimum = sequence.MinimumLevel;
                udLevel.Maximum = sequence.MaximumLevel;
                udLevel.Value = currentLevel;
            }
            else {
                udLevel.Minimum = sequence.MinimumLevel.ToPercentage();
                udLevel.Maximum = sequence.MaximumLevel.ToPercentage();
                udLevel.Value = currentLevel.ToPercentage();
            }

            lblInfo.Text = string.Format("Current Settings:\nIntensity: {0}{3}\nMinimum Allowed: {1}{3}\nMaximum Allowed: {2}{3}",
                udLevel.Value, udLevel.Minimum, udLevel.Maximum, actualLevels ? "" : "%");
        }
Exemplo n.º 20
0
        public TestConsoleDialog(EventSequence sequence, IExecution executionInterface, bool constrainToGroup)
        {
            InitializeComponent();
            _sequence = sequence;
            _executionInterface = executionInterface;
            _executionContextHandle = _executionInterface.RequestContext(false, true, null);
            _executionInterface.SetAsynchronousContext(_executionContextHandle, sequence);
            _channelLevels = new byte[_sequence.FullChannelCount];
            var channels = new Channel[constrainToGroup ? _sequence.ChannelCount + 1 : _sequence.FullChannelCount + 1];
            channels[0] = new Channel(Resources.Unassigned, Color.Gainsboro, 0);

            for (var channel = 1; channel <= channels.Length - 1; channel++) {
                channels[channel] = constrainToGroup ? _sequence.Channels[channel - 1] : _sequence.FullChannels[channel - 1];
            }

            foreach (var trackBar in groupBox2.Controls.Cast<object>().OfType<ConsoleTrackBar>().Where(trackBar => trackBar.Master != null)) {
                trackBar.TextStrings = channels;
                trackBar.ResetIndex = 0;
                _channelControls.Add(trackBar);
            }
        }
Exemplo n.º 21
0
        public ChannelMapper(EventSequence sequence)
        {
            _sourceSequence = sequence;
            _useCheckmark = Preference2.GetInstance().GetBoolean("UseCheckmark");

            InitializeComponent();

            _sourceProfile = new ChannelMapperProfile(_sourceSequence.Profile.FileName);
            //_sourceNatural = new ChannelMapperProfile(sourceSequence.Profile.FileName);
            _sourceChannelCount = _sourceProfile.GetChannelCount();
            InitializeDropDownList();
            InitializeScrollbar();

            GetDestinationProfile();

            BuildDynamicComponents();
            InitializeDynamicComponents();
            IsMapValid = false;
            MouseWheel += MapperMouseWheel;
            _previewButtonToolTip = toolTips.GetToolTip(btnPreviewEdit);
            _previewButtonText = btnPreviewEdit.Text;
            TogglePreviewElements(true);
        }
Exemplo n.º 22
0
        public EventSequence OpenSequence(string fileName)
        {
            var seqDoc = Xml.LoadDocument(fileName);
            var trackNode = seqDoc.SelectSingleNode("sequence/tracks");
            var channelsInfoNode = seqDoc.SelectSingleNode("sequence/channels");

            SetTotalCentiseconds(trackNode);

            var seqChannels = GetChannels(trackNode, channelsInfoNode);

            _eventValues = new byte[seqChannels.Count, TotalCentiseconds];
            SetChannelEvents(seqChannels, channelsInfoNode);

            var es = new EventSequence();
            es.SetFullChannels(seqChannels);
            es.Time = TotalCentiseconds * 10;
            es.EventPeriod = 10;
            es.FileIOHandler = this;
            es.EventValues = _eventValues;
            es.Name = Path.GetFileNameWithoutExtension(fileName);

            return es;
        }
Exemplo n.º 23
0
 public void InheritPlugInDataFrom(EventSequence sequence)
 {
     PlugInData.LoadFromXml(sequence.PlugInData.RootNode.ParentNode);
 }
Exemplo n.º 24
0
 private void Initialize(EventSequence sequence)
 {
     switch (Mode) {
         case EngineMode.Asynchronous:
             InitializeForAsynchronous(sequence);
             break;
         default:
             Initialize(new SequenceProgram(sequence));
             break;
     }
 }
Exemplo n.º 25
0
 public void SaveSequence(EventSequence eventSequence)
 {
     throw new NotSupportedException("Saving LOR Files is not supported");
 }
Exemplo n.º 26
0
        // ReSharper disable once FunctionComplexityOverflow
        protected EventSequence BaseOpenSequence(string fileName, IFileIOHandler ioHandler)
        {
            var contextNode = new XmlDocument();
            contextNode.Load(fileName);
            var requiredNode = Xml.GetRequiredNode(contextNode, "Program");

            var es = new EventSequence {
                FileName = fileName, FullChannels = new List<Channel>(), Channels = new List<Channel>(), PlugInData = new SetupData(),
                LoadableData = new LoadableData(), Extensions = new SequenceExtensions(),
                AudioDeviceVolume = int.Parse(Xml.GetNodeAlways(requiredNode, "AudioVolume", "100").InnerText), FileIOHandler = ioHandler
            };

            var timeNode = requiredNode.SelectSingleNode("Time");
            if (timeNode != null) {
                es.Time = Convert.ToInt32(timeNode.InnerText);
            }

            var eventPeriodNode = requiredNode.SelectSingleNode("EventPeriodInMilliseconds");
            if (eventPeriodNode != null) {
                es.EventPeriod = Convert.ToInt32(eventPeriodNode.InnerText);
            }

            var minLevelNode = requiredNode.SelectSingleNode("MinimumLevel");
            if (minLevelNode != null) {
                es.MinimumLevel = (byte) Convert.ToInt32(minLevelNode.InnerText);
            }

            var mnaxLevelNode = requiredNode.SelectSingleNode("MaximumLevel");
            if (mnaxLevelNode != null) {
                es.MaximumLevel = (byte) Convert.ToInt32(mnaxLevelNode.InnerText);
            }

            var audioDeviceNode = requiredNode.SelectSingleNode("AudioDevice");
            if (audioDeviceNode != null) {
                es.AudioDeviceIndex = int.Parse(audioDeviceNode.InnerText);
            }

            var profileNode = requiredNode.SelectSingleNode("Profile");
            if (profileNode == null) {
                LoadEmbeddedData(requiredNode, es);
            }
            else {
                var path = Path.Combine(Paths.ProfilePath, profileNode.InnerText + Vendor.ProfileExtension);
                if (File.Exists(path)) {
                    es.AttachToProfile(es.FileIOHandler.OpenProfile(path));
                    es.Groups = es.Profile.Groups;
                }
                else {
                    LoadEmbeddedData(es.FileName, es);
                }
            }

            es.UpdateEventValueArray();

            var audioFileNode = requiredNode.SelectSingleNode("Audio");
            if (audioFileNode != null) {
                if (audioFileNode.Attributes != null) {
                    es.Audio = new Audio(audioFileNode.InnerText, audioFileNode.Attributes["filename"].Value,
                        Convert.ToInt32(audioFileNode.Attributes["duration"].Value));
                }
            }

            var eventValueNode = requiredNode.SelectSingleNode("EventValues");
            if (eventValueNode != null) {
                var buffer = Convert.FromBase64String(eventValueNode.InnerText);
                var index = 0;
                var count = es.FullChannels.Count;
                for (var row = 0; (row < count) && (index < buffer.Length); row++) {
                    for (var column = 0; (column < es.TotalEventPeriods) && (index < buffer.Length); column++) {
                        es.EventValues[row, column] = buffer[index++];
                    }
                }
            }

            var windowSizeNode = requiredNode.SelectSingleNode("WindowSize");
            if (windowSizeNode != null) {
                var strArray = windowSizeNode.InnerText.Split(',');
                try {
                    es.WindowWidth = Convert.ToInt32(strArray[0]);
                }
                catch {
                    es.WindowWidth = 0;
                }
                try {
                    es.WindowHeight = Convert.ToInt32(strArray[1]);
                }
                catch {
                    es.WindowHeight = 0;
                }
            }

            windowSizeNode = requiredNode.SelectSingleNode("ChannelWidth");
            if (windowSizeNode != null) {
                try {
                    es.ChannelWidth = Convert.ToInt32(windowSizeNode.InnerText);
                }
                catch {
                    es.ChannelWidth = 0;
                }
            }

            var engineTypeNode = requiredNode.SelectSingleNode("EngineType");
            if (engineTypeNode != null) {
                try {
                    es.EngineType = (EngineType) Enum.Parse(typeof (EngineType), engineTypeNode.InnerText);
                }
                    // ReSharper disable EmptyGeneralCatchClause
                catch
                    // ReSharper restore EmptyGeneralCatchClause
                {}
            }

            es.LoadableData.LoadFromXml(requiredNode);
            es.Extensions.LoadFromXml(requiredNode);

            es.ApplyGroup();

            return es;
        }
Exemplo n.º 27
0
 public void LoadEmbeddedData(string fileName, EventSequence es)
 {
     Debug.Assert(false);
 }
Exemplo n.º 28
0
 public override DialogResult RunWizard(ref EventSequence resultSequence)
 {
     DialogResult result;
     using (var dialog = new NewSequenceWizardDialog(_systemInterface.UserPreferences)) {
         result = dialog.ShowDialog();
         if (result == DialogResult.OK) {
             resultSequence = dialog.Sequence;
         }
     }
     return result;
 }
Exemplo n.º 29
0
 public void LoadEmbeddedData(string fileName, EventSequence es)
 {
     throw new NotSupportedException("Format does not support embedded data.");
 }
Exemplo n.º 30
0
 public void InheritPlugInDataFrom(EventSequence sequence)
 {
     PlugInData.LoadFromXml(sequence.PlugInData.RootNode.ParentNode);
 }
Exemplo n.º 31
0
        //public virtual EventSequence Open(string filePath) {
        //    throw new NotImplementedException();
        //}


        public virtual DialogResult RunWizard(ref EventSequence resultSequence)
        {
            throw new NotImplementedException();
        }
Exemplo n.º 32
0
 public virtual EventSequence New(EventSequence seedSequence)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 33
0
 private static byte[,] ReconfigureSourceData(EventSequence sequence)
 {
     var buffer = new byte[sequence.FullChannelCount,sequence.TotalEventPeriods];
     var list = sequence.FullChannels.Select(channel => channel.OutputChannel).ToList();
     for (var i = 0; i < sequence.FullChannelCount; i++) {
         var row = list[i];
         for (var column = 0; column < sequence.TotalEventPeriods; column++) {
             buffer[row, column] = sequence.EventValues[i, column];
         }
     }
     return buffer;
 }
Exemplo n.º 34
0
        public override void handleGETRequest(HttpProcessor p)
        {
            string[] args = p.http_url.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            p.writeSuccess();

            if (args == null || args.Length == 0)
            {
                showHelp(p);
                return;
            }

            if (args[0] == "files")
            {
                string path = string.Join("\\", args.Skip(1).ToArray());
                p.serveFile(path);
                return;
            }
            else if (args[0] == "sequence")
            {
                string fullPath = Path.Combine(VixenPlusCommon.Paths.SequencePath, Uri.UnescapeDataString(args[1]));
                object obj2;
                if (sequences.Contains(fullPath))
                {
                    //Sequence exists
                    if (Interfaces.Available.TryGetValue("IExecution", out obj2))
                    {
                        var fileIOHandler = FileIOHelper.GetByExtension(fullPath);
                        sequence = fileIOHandler.OpenSequence(fullPath);

                        _executionInterface     = (IExecution)obj2;
                        _executionContextHandle = _executionInterface.RequestContext(false, true, null);
                        _executionInterface.SetAsynchronousContext(_executionContextHandle, sequence);

                        try {
                            if (_channelLevels == null)
                            {
                                _channelLevels = new byte[sequence.FullChannelCount];
                            }


                            if (args.Length == 2)
                            {
                                p.writeLine("Successfully selected sequence!");
                                p.writeLine("<br>");
                                p.writeLine("Commands: <br>");
                                p.writeLine("   /play/ <br>");
                                p.writeLine("   /play/ms/ <br>");
                                p.writeLine("   /pause/ <br>");
                                p.writeLine("   /stop/ <br>");
                                p.writeLine("   /channels/ <br>");
                                return;
                            }

                            if (args[2] == "channels")
                            {
                                int maxChannels = sequence.FullChannelCount;
                                if (args.Length == 3)
                                {
                                    p.writeLine("/set/channelnum/0-255");
                                    p.writeLine("<br>");
                                    p.writeLine("/get/channelnum/");
                                    p.writeLine("<br>");
                                    p.writeLine("Max channels: " + maxChannels);
                                    return;
                                }

                                if (args[3] == "set")
                                {
                                    int  channel = int.Parse(args[4]);
                                    byte value   = byte.Parse(args[5]);
                                    _channelLevels[channel] = value;
                                    updateChannels();
                                    p.writeLine("Executed command: " + args[2]);
                                }

                                if (args[3] == "get")
                                {
                                    int channel = int.Parse(args[4]);
                                    p.writeLine("" + _channelLevels[channel]);
                                }
                            }
                        } finally {
                            _executionInterface.ReleaseContext(_executionContextHandle);
                        }
                    }
                }
                else
                {
                    //Error and say that their sequence they selected doesnt exist.
                    p.writeLine(args[1] + " Does not exist.");
                    p.writeLine("<br>");
                    p.writeLine("Selectable sequences: ");
                    p.writeLine("<br>");
                    printoutVixenSequences(p, "<br>");
                }
            }
            else if (args[0] == "listseq")
            {
                printoutVixenSequences(p, null);
            }
            else
            {
                showHelp(p);
            }
        }
Exemplo n.º 35
0
 public override EventSequence New(EventSequence seedSequence)
 {
     _sequence = seedSequence;
     return _sequence;
 }
Exemplo n.º 36
0
 public override void SaveSequence(EventSequence eventSequence)
 {
     var contextNode = Xml.CreateXmlDocument();
     BaseSaveSequence(contextNode, eventSequence, FormatChannel);
     contextNode.Save(eventSequence.FileName);
 }
Exemplo n.º 37
0
 public virtual EventSequence New(EventSequence seedSequence)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 38
0
        protected static void BaseSaveSequence(XmlDocument contextNode, EventSequence eventSequence, FormatChannelDelegate fc)
        {
            var programNode = Xml.GetEmptyNodeAlways(contextNode, "Program");
            Xml.SetValue(programNode, "Time", eventSequence.Length.ToString(CultureInfo.InvariantCulture));
            Xml.SetValue(programNode, "EventPeriodInMilliseconds", eventSequence.EventPeriod.ToString(CultureInfo.InvariantCulture));
            Xml.SetValue(programNode, "MinimumLevel", eventSequence.MinimumLevel.ToString(CultureInfo.InvariantCulture));
            Xml.SetValue(programNode, "MaximumLevel", eventSequence.MaximumLevel.ToString(CultureInfo.InvariantCulture));
            Xml.SetValue(programNode, "AudioDevice", eventSequence.AudioDeviceIndex.ToString(CultureInfo.InvariantCulture));
            Xml.SetValue(programNode, "AudioVolume", eventSequence.AudioDeviceVolume.ToString(CultureInfo.InvariantCulture));

            if (eventSequence.Audio != null) {
                var node = Xml.SetNewValue(programNode, "Audio", eventSequence.Audio.Name);
                Xml.SetAttribute(node, "filename", eventSequence.Audio.FileName);
                Xml.SetAttribute(node, "duration", eventSequence.Audio.Duration.ToString(CultureInfo.InvariantCulture));
            }

            var doc = contextNode.OwnerDocument ?? contextNode;

            if (eventSequence.Profile == null) {
                //Channels
                var channelNodes = Xml.GetEmptyNodeAlways(programNode, "Channels");
                foreach (var channel in eventSequence.FullChannels) {
                    channelNodes.AppendChild(fc(doc, channel));
                }

                //Plugins
                if (programNode.OwnerDocument != null) {
                    programNode.AppendChild(programNode.OwnerDocument.ImportNode(eventSequence.PlugInData.RootNode, true));
                }
                BaseSaveNativeData(eventSequence.FileName, eventSequence.Groups);
            }
            else {
                Xml.SetValue(programNode, "Profile", eventSequence.Profile.Name);
            }

            var channelCount = eventSequence.FullChannels.Count;
            var totalEventPeriods = eventSequence.TotalEventPeriods;
            var inArray = new byte[channelCount * totalEventPeriods];
            var eventIndex = 0;
            for (var row = 0; row < channelCount; row++) {
                for (var col = 0; col < totalEventPeriods; col++) {
                    inArray[eventIndex++] = eventSequence.EventValues[row, col];
                }
            }
            //todo GZIP inArray before encoding?
            Xml.GetNodeAlways(programNode, "EventValues").InnerText = Convert.ToBase64String(inArray);
            if (programNode.OwnerDocument != null && eventSequence.LoadableData != null) {
                programNode.AppendChild(programNode.OwnerDocument.ImportNode(eventSequence.LoadableData.RootNode, true));
            }

            Xml.SetValue(programNode, "EngineType", eventSequence.EngineType.ToString());

            if (programNode.OwnerDocument != null) {
                programNode.AppendChild(programNode.OwnerDocument.ImportNode(eventSequence.Extensions.RootNode, true));
            }
        }
Exemplo n.º 39
0
 //public virtual EventSequence Open(string filePath) {
 //    throw new NotImplementedException();
 //}
 public virtual DialogResult RunWizard(ref EventSequence resultSequence)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 40
0
        private static void LoadEmbeddedData(XmlNode requiredNode, EventSequence es)
        {
            var fullChannels = new List<Channel>();
            var xmlNodeList = requiredNode.SelectNodes("Channels/Channel");
            if (xmlNodeList != null) {
                fullChannels.AddRange(from XmlNode node in xmlNodeList select new Channel(node));
            }
            es.SetFullChannels(fullChannels);

            es.PlugInData = new SetupData();
            es.PlugInData.LoadFromXml(requiredNode);
            es.Groups = Group.LoadFromXml(requiredNode) ?? new Dictionary<string, GroupData>();
            Group.LoadFromFile(requiredNode, es.Groups);
        }
Exemplo n.º 41
0
 public void InheritChannelsFrom(EventSequence sequence)
 {
     _channelObjects = sequence.FullChannels;
     _channelOutputs.Clear();
     foreach (var channel in sequence.FullChannels) {
         _channelOutputs.Add(channel.OutputChannel);
     }
     IsDirty = true;
 }
Exemplo n.º 42
0
 public abstract void SaveSequence(EventSequence eventSequence);
Exemplo n.º 43
0
 private void LogAudio(EventSequence sequence)
 {
     if (_isLoggingEnabled && (sequence.Audio != null)) {
         Host.LogAudio("Sequence", sequence.Name, sequence.Audio.FileName, sequence.Audio.Duration);
     }
 }