VixenModules.SequenceType.Vixen2x.Vixen2xSequenceImporterForm.ProcessFile C# (CSharp) Method

ProcessFile() public method

public ProcessFile ( string Vixen2File ) : bool
Vixen2File string
return bool
        public bool ProcessFile(string Vixen2File)
        {
            var result = false;
            this.Show();
            this.Text = "Importing " + Path.GetFileName(Vixen2File);

            parsedV2Sequence = new Vixen2SequenceData(Vixen2File);

            // make a channel mapping, and present that to the user. Not editable at the moment.
            mappings = new List<ChannelMapping>();

            foreach (ElementNode element in VixenSystem.Nodes.GetLeafNodes()) {
                if (mappings.Count >= parsedV2Sequence.ElementCount)
                    break;

                string newName = "Channel " + (mappings.Count + 1).ToString();
                mappings.Add(new ChannelMapping(newName, element));
            }

            // pad out the mappings with null elements; we want to be able to not map some stuff (later on)
            while (mappings.Count < parsedV2Sequence.ElementCount) {
                string newName = "Channel " + (mappings.Count + 1).ToString();
                mappings.Add(new ChannelMapping(newName, null));
            }

            initializeProgressBar();

            // show the user the mapping form
            Vixen2xSequenceImporterChannelMapper mappingForm = new Vixen2xSequenceImporterChannelMapper(mappings);
            mappingForm.ShowDialog();

            createTimedSequence();
            importSequenceData(mappings);

            result = true;

            Close();

            return result;
        }

Usage Example

 public override ISequence LoadSequenceFromFile(string Vixen2File)
 {
     Vixen2xSequenceImporterForm v2ImporterForm = new Vixen2xSequenceImporterForm();
     if (!v2ImporterForm.ProcessFile(Vixen2File)) {
         throw new System.FormatException("Not enough channel nodes to import file");
     }
     return v2ImporterForm.Sequence;
 }