Ejemplo n.º 1
0
        ResourceElementXml EncodeResourceElement(ResourceElement rElement)
        {
            List<AbstractResource> resources = new List<AbstractResource>();
            List<string> resourceIDs = new List<string>();
            try
            {
                foreach (AbstractResource resource in rElement.ResourceBox.Items)
                {
                    AddResource(resource);
                    resourceIDs.Add(resource.Id);
                }
            }
            catch (InvalidCastException)
            {
                MessageBox.Show("Element: " + rElement.Caption + " has no resources.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return null;
            }

            return new ResourceElementXml() { ID = rElement.Caption, ResourceIDs = resourceIDs.ToArray() };
        }
Ejemplo n.º 2
0
        void ExportMuseumGuideItemsHTML(ResourceElement rElement)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(htmlHeader + "\t<title>" + Common.HtmlEncode(rElement.Caption) + "</title>\n"
                + "\t<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>"
                + "</head>");

            sb.AppendLine("<body>");
            foreach (AbstractResource resource in rElement.ResourceBox.Items.OfType<AbstractResource>())
            {
                EncodeResource(resource, sb);
            }
            sb.AppendLine("</body>\n</html>");

            using (StreamWriter sw = File.CreateText(basePath + "\\" + GetHtmlFilename(rElement.Caption)))
            {
                sw.Write(sb.ToString());
            }
        }
Ejemplo n.º 3
0
        public void AddElement(ElementType type, Point position)
        {
            Element newElement;
            switch (type)
            {
                case ElementType.Connector:
                    newElement = new Connector();
                    break;

                case ElementType.MuseumGuideApp:
                    newElement= new MuseumGuideElement { Caption = "Museum Guide"};
                    break;

                case ElementType.HistoryPuzzleApp:
                    newElement = new HistoryPuzzleElement { Caption = "History-Puzzle" };
                    break;

                case ElementType.ExcursionGameApp:
                    newElement = new ExcursionGameElement { Caption = "Excursion-Game" };
                    break;

                case ElementType.Prologue:
                    newElement = new PrologueElement();
                    break;

                case ElementType.Mission:
                    newElement = new MissionElement();
                    break;

                case ElementType.Goal:
                    newElement = new GoalElement();
                    break;

                case ElementType.CSound:
                    newElement = new ContextSoundElement();
                    break;

                case ElementType.OracleHint:
                    newElement = new OracleElement();
                    break;

                case ElementType.MissionList:
                    newElement = new MissionListElement();
                    break;

                case ElementType.QuestionsAnswers:
                    newElement = new QuestionElement { Caption = "Q&A" };
                    break;

                case ElementType.Theme:
                    newElement = new ThemeElement() { Caption = "Theme" };
                    break;

                case ElementType.Item:
                    newElement = new PageElement() { Caption = "Item" };
                    break;

                case ElementType.Map:
                    newElement = new MapElement() { Caption = "Map" };
                    break;

                case ElementType.UG_ContentItem:
                    newElement = new AvengersUtd.Explore.Environment.Controls.Elements.UG_Elements.UG_ContentItem() { Caption = "Monument" };
                    break;
                case ElementType.UG_GoalElement:
                    newElement = new AvengersUtd.Explore.Environment.Controls.Elements.UG_Elements.UG_GoalElement() { Caption = "Goal Monument" };
                    break;
                case ElementType.UG_CityElement:
                    if (elementList.Count(x => x is AvengersUtd.Explore.Environment.Controls.Elements.UG_Elements.UG_CityElement) > 0)
                    {
                        MessageBox.Show("Can not insert more than one item for City element");
                        return;
                    }
                    newElement = new AvengersUtd.Explore.Environment.Controls.Elements.UG_Elements.UG_CityElement() { Caption = "City element", Height=300 };
                    break;
                default:
                case ElementType.UG_ResourceElement:
                    newElement = new AvengersUtd.Explore.Environment.Controls.Elements.ResourceElement() { Caption="Resource element"  };
                    newElement.BuildingBlockLabel = "UG";
                    ((AvengersUtd.Explore.Environment.Controls.Elements.ResourceElement)newElement).ResourceRules = new Dictionary<Data.Resources.ResourceType, ResourceRule>();
                    ((AvengersUtd.Explore.Environment.Controls.Elements.ResourceElement)newElement).ResourceRules.Add(Data.Resources.ResourceType.Image, new ResourceRule(Data.Resources.ResourceType.Image, 0, 10));
                    ((AvengersUtd.Explore.Environment.Controls.Elements.ResourceElement)newElement).ResourceRules.Add(Data.Resources.ResourceType.Audio, new ResourceRule(Data.Resources.ResourceType.Audio, 0, 10));
                    ((AvengersUtd.Explore.Environment.Controls.Elements.ResourceElement)newElement).ResourceRules.Add(Data.Resources.ResourceType.Text, new ResourceRule(Data.Resources.ResourceType.Text, 0, 10));
                    ((AvengersUtd.Explore.Environment.Controls.Elements.ResourceElement)newElement).ResourceRules.Add(Data.Resources.ResourceType.Video, new ResourceRule(Data.Resources.ResourceType.Video, 0, 10));

                    break;
                case ElementType.Puzzle:
                    newElement = new PuzzleElement { Caption = "Puzzle" };
                    break;
            }

            SetLeft(newElement, position.X);
            SetTop(newElement, position.Y);

            AddElement(newElement);
        }