Inheritance: INotifyPropertyChanged
        public IElement ToGlueIElement(ArrowElementSave arrowElement)
        {
            List<string> referencedFiles = new List<string>();


            IElement glueElement;

            if (arrowElement.ElementType == ElementType.Screen)
            {
                glueElement = new ScreenSave();
                glueElement.Name = "Screens/" + arrowElement.Name;
            }
            else
            {
                glueElement = new EntitySave();
                glueElement.Name = "Entities/" + arrowElement.Name;
            }


            AddSpritesToElement(arrowElement, glueElement, referencedFiles);

            AddCirclesToElement(arrowElement, glueElement);
            AddRectanglesToElement(arrowElement, glueElement);

            AddElementInstancesToElement(arrowElement, glueElement);

            AddReferencedFileSaves(referencedFiles, glueElement);

            AddCustomVariables(glueElement);

            return glueElement;
        }
        public void TestConversion()
        {
            ArrowProjectSave project = new ArrowProjectSave();

            SpriteSave spriteSave = new SpriteSave();
            spriteSave.X = 3;
            spriteSave.Y = 4;
            spriteSave.Name = "SpriteInstance";
            spriteSave.Texture = "Entities/FirstElement/redball.BMP";
            

            ArrowElementSave element = new ArrowElementSave();
            element.Name = "FirstElement";
            element.Sprites.Add(spriteSave);
            project.Elements.Add(element);


            element = new ArrowElementSave();
            element.Name = "ContainerOfFirstElement";
            element.Sprites.Add(spriteSave);
            project.Elements.Add(element);

            ArrowElementInstance instance = new ArrowElementInstance();
            instance.Name = "FirstElementInstance";
            instance.Type = "FirstElement";
            instance.SetVariable("X", 4);
            instance.SetVariable("Y", 5);
            element.ElementInstances.Add(instance);



            ArrowProjectToGlueProjectConverter converter = new ArrowProjectToGlueProjectConverter();

            GlueProjectSave gps = converter.ToGlueProjectSave(project);

            EntitySave firstElementEntity = gps.Entities.FirstOrDefault(item => item.Name == "Entities/FirstElement");
            EntitySave containerOfFirstElement = gps.Entities.FirstOrDefault(item => item.Name == "Entities/ContainerOfFirstElement");
            if (firstElementEntity.Name.StartsWith("Entities/") == false)
            {
                throw new Exception("Entity names must start with \"Entities/\"");
            }

            if (firstElementEntity.ReferencedFiles.Count == 0)
            {
                throw new Exception("The Entity should automatically contain a ReferencedFile for the redball file");
            }

            if (containerOfFirstElement.NamedObjects.FirstOrDefault(item => item.InstanceName == "FirstElementInstance") == null)
            {
                throw new Exception("The entity should contain a NOS for another element, but it doesn't");
            }

            string gluxString;

            FileManager.XmlSerialize(gps, out gluxString);

            string aroxString;
            FileManager.XmlSerialize(project, out aroxString);

        }
        private void AddElementInstancesToElement(ArrowElementSave arrowElement, IElement glueElement)
        {
            foreach (var instance in arrowElement.ElementInstances)
            {
                NamedObjectSave nosToAdd = mArrowElementInstanceConverter.ArrowElementInstanceToNos(instance);

                glueElement.NamedObjects.Add(nosToAdd);
            }
        }
Esempio n. 4
0
        public ArrowElementSave Element()
        {
            TextInputWindow tiw = new TextInputWindow();

            tiw.Text = "Enter new element name:";

            List<string> intentNames = new List<string>();

            const string noIntent = "<NO INTENT>";

            intentNames.Add(noIntent);
            foreach (var item in ArrowState.Self.CurrentArrowProject.Intents)
            {
                intentNames.Add(item.Name);
            }



            var treeView = tiw.AddTreeView(intentNames);


            var result = tiw.ShowDialog();

            if (result.HasValue && result.Value)
            {

                ArrowElementSave toReturn = new ArrowElementSave();
                toReturn.Name = tiw.Result;
                ArrowProjectSave projectToAddTo = ArrowState.Self.CurrentArrowProject;

                if (treeView.SelectedItem as string != noIntent)
                {
                    toReturn.Intent = treeView.SelectedItem as string;

                    ArrowIntentSave intent = new ArrowIntentSave();
                    IntentManager.Self.AddRequirementsForIntent(toReturn, intent);
                }

                projectToAddTo.Elements.Add(toReturn);

                ArrowCommands.Self.File.SaveProject();
                ArrowCommands.Self.File.GenerateGlux();
                ArrowState.Self.CurrentArrowProjectVm.Refresh();

                return toReturn;
            }
            else
            {
                return null;
            }
        }
Esempio n. 5
0
        public ArrowElementInstance ElementInstance(string name, ArrowElementSave typeToAdd)
        {
            ArrowElementInstance instance = new ArrowElementInstance();
            instance.Name = name;
            instance.Type = typeToAdd.Name;

            ArrowState.Self.CurrentArrowElementSave.ElementInstances.Add(instance);

            ArrowCommands.Self.File.SaveProject();
            ArrowCommands.Self.File.GenerateGlux();

            ArrowCommands.Self.UpdateToSelectedElement();

            ArrowState.Self.CurrentInstance = instance;

            return instance;
        }
Esempio n. 6
0
        private void AfterAddLogic(ArrowElementSave arrowElement, object newObject)
        {
            MakeNewObjectUnique(arrowElement, newObject);
            ArrowCommands.Self.File.SaveProject();
            ArrowCommands.Self.File.GenerateGlux();

            ArrowState.Self.CurrentArrowElementVm.Refresh();

            ArrowCommands.Self.UpdateToSelectedElement();
            //ArrowCommands.Self.GuiCommands.RefreshSingleElementTreeView();
        }
        private void AddRectanglesToElement(ArrowElementSave arrowElement, IElement glueElemement)
        {
            foreach (var rectangle in arrowElement.Rectangles)
            {
                NamedObjectSave nos = mRectangleSaveConverter.RectangleSaveToNamedObjectSave(rectangle);

                glueElemement.NamedObjects.Add(nos);
            }

        }
        private void AddCirclesToElement(ArrowElementSave arrowElement, IElement glueElemement)
        {
            foreach (var circle in arrowElement.Circles)
            {
                NamedObjectSave nos = mCircleSaveConverter.CircleSaveToNamedObjectSave(circle);

                glueElemement.NamedObjects.Add(nos);
            }
        }
        private void AddSpritesToElement(ArrowElementSave arrowElement, IElement glueElemement, List<string> referencedFiles)
        {
            foreach (var sprite in arrowElement.Sprites)
            {
                NamedObjectSave nos = mSpriteSaveConverter.SpriteSaveToNamedObjectSave(sprite);

                glueElemement.NamedObjects.Add(nos);

                sprite.GetReferencedFiles(referencedFiles);
            }
        }