Esempio n. 1
0
 private void loadSoundBoard(Project proj, Dictionary<Guid, IEventProvider> providers)
 {
     foreach (var button in proj.SoundBoard)
     {
         _inst[button.Row, button.Col] = providers[button.ID];
     }
 }
Esempio n. 2
0
 private void loadLibraries(Project proj)
 {
     foreach (var lib in proj.Libraries)
     {
         _inst.Resources.LoadLibrary(lib.Path);
     }
 }
Esempio n. 3
0
        private Dictionary<Guid, IEventProvider> loadEvents(Project proj)
        {
            EventProviderFactory factory = new EventProviderFactory(_inst);
            var providers = proj.Events.Select(evt => factory.GetProvider(evt));
            _inst.Events.AddRange(providers);

            return factory.GetProviders();
        }
Esempio n. 4
0
        public void Serialize(Stream stream)
        {
            Project proj = new Project();

            proj.Libraries = modelLibraries();
            var models = modelEvents();
            proj.Events = models.Values.ToList();
            proj.SoundBoard = modelSoundBoard(models);

            using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.ASCII) { Formatting = Formatting.Indented })
            {
                XmlSerializer serializer = Project.GetSerializer();
                serializer.Serialize(writer, proj);
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Project proj = new Project();

            FolderLibraryElement folder1 = new FolderLibraryElement() { Path = @"E:\Media" };
            FolderLibraryElement folder2 = new FolderLibraryElement() { Path = @"E:\Veggie" };

            PeriodicEventElement period = new PeriodicEventElement() { Name = "Periodic1", BaseColor = Color.Red };
            DelayEventElement delay = new DelayEventElement() { Name = "Delay1", BaseColor = Color.Aqua, Subordinate = period };
            RandomEventElement rand = new RandomEventElement() { Name = "Random1", BaseColor = Color.Blue, Selection = new SubordinateElement[] { period, delay }.ToList() };
            SoundEventElement snd = new SoundEventElement() { Name = "Sound1", Resource = "Media::sttng.wav" };

            proj.Libraries = new ALibraryElement[] { folder1, folder2 }.ToList();
            proj.Events = new AEventElement[] { delay, period, rand, snd }.ToList();
            proj.SoundBoard = new SoundBoardElement[] { delay.ToSoundBoard(5, 7), period.ToSoundBoard(1, 2), snd.ToSoundBoard(4, 9) }.ToList();

            MemoryStream stream = new MemoryStream();
            using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.ASCII) { Formatting = Formatting.Indented })
            {
                XmlSerializer serializer = Project.GetSerializer();
                serializer.Serialize(writer, proj);

                stream = writer.BaseStream as MemoryStream;
            }

            string content = (stream == null) ? "<nope />" : Encoding.ASCII.GetString(stream.ToArray());

            Console.WriteLine(content);
            Console.ReadLine();

            MemoryStream instream = new MemoryStream(Encoding.ASCII.GetBytes(content));
            StreamReader reader = new StreamReader(instream);

            XmlSerializer deser = Project.GetSerializer();
            Project newproj = (Project)deser.Deserialize(reader);
            reader.Close();

            Console.ReadLine();
        }