예제 #1
0
파일: Manager.cs 프로젝트: alcexhim/Auralux
        public static void LoadFile(string filename)
        {
            LightingXMLDataFormat xdf = new LightingXMLDataFormat();
            LightingObjectModel lighting = new LightingObjectModel();

            Document.Load(lighting, xdf, new FileAccessor(filename));

            lighting.CopyTo(mvarObjectModel);
        }
예제 #2
0
        private void LoadFixtures(MarkupTagElement tag, LightingObjectModel lighting)
        {
            foreach (MarkupElement el1 in tag.Elements)
            {
                MarkupTagElement tag1 = (el1 as MarkupTagElement);
                if (tag1 == null) continue;
                if (tag1.FullName != "Fixture") continue;

                MarkupAttribute attID = tag1.Attributes["ID"];
                if (attID == null) continue;

                Fixture item = new Fixture();
                item.ID = new Guid(attID.Value);

                MarkupAttribute attManufacturerID = tag1.Attributes["ManufacturerID"];
                if (attManufacturerID != null) item.ManufacturerID = new Guid(attManufacturerID.Value);

                MarkupTagElement tagInformation = (tag1.Elements["Information"] as MarkupTagElement);
                if (tagInformation != null)
                {
                    MarkupTagElement tagTitle = (tagInformation.Elements["Title"] as MarkupTagElement);
                    if (tagTitle != null) item.Title = tagTitle.Value;
                }

                #region Channels
                {
                    MarkupTagElement tagChannels = (tag1.Elements["Channels"] as MarkupTagElement);
                    if (tagChannels != null)
                    {
                        foreach (MarkupElement elChannel in tagChannels.Elements)
                        {
                            MarkupTagElement tagChannel = (elChannel as MarkupTagElement);
                            if (tagChannel == null) continue;
                            if (tagChannel.FullName != "Channel") continue;

                            MarkupAttribute attChannelID = tagChannel.Attributes["ID"];
                            if (attChannelID == null) continue;

                            FixtureChannel channel = new FixtureChannel();
                            channel.ID = new Guid(attChannelID.Value);

                            MarkupTagElement tagChannelInformation = (tagChannel.Elements["Information"] as MarkupTagElement);
                            if (tagChannelInformation != null)
                            {
                                MarkupTagElement tagChannelTitle = (tagChannelInformation.Elements["Title"] as MarkupTagElement);
                                if (tagChannelTitle != null) channel.Title = tagChannelTitle.Value;
                            }

                            MarkupTagElement tagChannelValues = (tagChannel.Elements["Values"] as MarkupTagElement);
                            if (tagChannelValues != null)
                            {
                                foreach (MarkupElement elChannelValue in tagChannelValues.Elements)
                                {
                                    MarkupTagElement tagChannelValue = (elChannelValue as MarkupTagElement);
                                    if (tagChannelValue == null) continue;

                                    MarkupAttribute attTitle = (tagChannelValue.Attributes["Title"] as MarkupAttribute);
                                    string title = null;
                                    if (attTitle != null) title = attTitle.Value;

                                    switch (tagChannelValue.FullName.ToLower())
                                    {
                                        case "range":
                                        {
                                            FixtureChannelValueRange value = new FixtureChannelValueRange();

                                            MarkupAttribute attStartingValue = tagChannelValue.Attributes["From"];
                                            MarkupAttribute attEndingValue = tagChannelValue.Attributes["Until"];

                                            value.Title = title;
                                            value.StartingValue = Byte.Parse(attStartingValue.Value);
                                            value.EndingValue = Byte.Parse(attEndingValue.Value);

                                            channel.Values.Add(value);
                                            break;
                                        }
                                        case "static":
                                        {
                                            FixtureChannelValueStatic value = new FixtureChannelValueStatic();

                                            MarkupAttribute attStartingValue = tagChannelValue.Attributes["From"];
                                            MarkupAttribute attEndingValue = tagChannelValue.Attributes["Until"];

                                            value.Title = title;
                                            value.StartingValue = Byte.Parse(attStartingValue.Value);
                                            value.EndingValue = Byte.Parse(attEndingValue.Value);

                                            channel.Values.Add(value);
                                            break;
                                        }
                                        default:
                                        {
                                            Console.WriteLine("alxml: unknown channel value type '" + tagChannelValue.FullName + "'");
                                            break;
                                        }
                                    }
                                }
                            }

                            item.Channels.Add(channel);
                        }
                    }
                }
                #endregion

                #region Modes
                {
                    MarkupTagElement tagModes = (tag1.Elements["Modes"] as MarkupTagElement);
                    if (tagModes != null)
                    {
                        foreach (MarkupElement elMode in tagModes.Elements)
                        {
                            MarkupTagElement tagMode = (elMode as MarkupTagElement);
                            LoadMode(tagMode, item);
                        }
                    }
                }
                #endregion

                lighting.Fixtures.Add(item);
            }
        }
예제 #3
0
        private void LoadManufacturers(MarkupTagElement tag, LightingObjectModel lighting)
        {
            foreach (MarkupElement el1 in tag.Elements)
            {
                MarkupTagElement tag1 = (el1 as MarkupTagElement);
                if (tag1 == null) continue;
                if (tag1.FullName != "Manufacturer") continue;

                MarkupAttribute attID = tag1.Attributes["ID"];
                if (attID == null) continue;

                Manufacturer item = new Manufacturer();
                item.ID = new Guid(attID.Value);

                MarkupTagElement tagInformation = (tag1.Elements["Information"] as MarkupTagElement);
                if (tagInformation != null)
                {
                    MarkupTagElement tagTitle = (tagInformation.Elements["Title"] as MarkupTagElement);
                    if (tagTitle != null) item.Title = tagTitle.Value;
                }

                lighting.Manufacturers.Add(item);
            }
        }