示例#1
0
        public void TestTwoPagesAdded()
        {
            Builder builder = new Builder();
            var     mock    = new Mock <IMainViewAdapter>();

            mock.Setup(library => library.AddPage());
            IMainViewAdapter adapter = mock.Object;

            builder.Build(adapter);

            mock.Verify(library => library.AddPage(), Times.Exactly(2));
        }
示例#2
0
        public void TestToDoAfterBuildIsSet()
        {
            Builder builder = new Builder();
            var     mock    = new Mock <IMainViewAdapter>();

            mock.Setup(library => library.ToDoAfterBuild(builder.AfterBuildShowFirstPage));
            IMainViewAdapter adapter = mock.Object;

            builder.Build(adapter);

            mock.Verify(library => library.ToDoAfterBuild(builder.AfterBuildShowFirstPage), Times.Once());
        }
示例#3
0
        /// <summary>
        /// metodo que crea el mundo en Unity.
        /// </summary>
        /// <param name="providedAdapter"> recibe un IMainViewAdapter para crear el mundo. </param>
        public void Build(IMainViewAdapter providedAdapter)
        {
            this.adapter = providedAdapter ?? throw new ArgumentNullException(nameof(providedAdapter));

            OneAdapter.Adapter = this.adapter;

            this.adapter.AfterBuild += this.AfterBuildShowFirstPage;

            Creator creator = new Creator();

            try
            {
                creator.Create();
            }
            catch (NotFoundOnXMLException e)
            {
                this.adapter.Debug(e.Message);
            }

            World world = Singleton <World> .Instance;

            foreach (Level level in world.ListLevel)
            {
                Creator.UnityPages.Add(level.Name, new List <string>());
                foreach (Screen screen in level.ScreenList)
                {
                    this.nextPageName = this.adapter.AddPage();
                    Creator.UnityPages[level.Name].Add(this.nextPageName);
                    this.adapter.ChangeLayout(Layout.ContentSizeFitter);

                    foreach (Element element in screen.ElementList)
                    {
                        IRenderer renderer = new Renderer();
                        element.Render(renderer);
                    }
                }
            }
        }
示例#4
0
 /// <summary>
 /// constructor de la clase.
 /// </summary>
 public Renderer()
 {
     this.adapter = OneAdapter.Adapter;
 }
示例#5
0
        /// <summary>
        /// Construye una interfaz de usuario interactiva utilizando un <see cref="IMainViewAdapter"/>.
        /// </summary>
        /// <param name="providedAdapter">Un <see cref="IMainViewAdapter"/> que permite construir una interfaz de usuario
        /// interactiva.</param>
        public void Build(IMainViewAdapter providedAdapter)
        {
            string itemId;

            if (providedAdapter != null)
            {
                this.adapter = providedAdapter;
            }
            else
            {
                throw new ArgumentNullException(nameof(providedAdapter));
            }

            this.adapter.AfterBuild += this.AfterBuildShowFirstPage;

            this.firstPageName = this.adapter.AddPage();
            this.adapter.ChangeLayout(Layout.ContentSizeFitter);

            float       worldWidth  = this.adapter.WorldWidth;
            float       worldHeight = this.adapter.WorldHeight;
            const float itemWidth   = 100f;
            const float itemHeight  = 50f;

            // Etiqueta. Posicionada verticalmente en el medio y horizontalmente contra la izquierda.
            this.labelId = this.adapter.CreateLabel((worldWidth / 2 - itemWidth / 2), 0, itemWidth, itemHeight);
            this.adapter.SetFont(labelId, true, true, 24);

            string fileContent = adapter.GetFileContents("test.txt");

            this.adapter.SetText(labelId, $"<color=white>{fileContent}</color>", true);

            // Image. Posicionada en la esquina inferior derecha.
            //**string destinationCellImageId = this.adapter.CreateDragAndDropDestination(250, 180, 200, 100);
            this.dropImage = this.adapter.CreateImage((worldWidth / 2 - 200 / 2), -(worldHeight / 2 - 100 / 2), 200, 100);
            this.adapter.SetImage(this.dropImage, "Cell.png");

            // Image. Posicionada en la esquina inferior izquierda.
            //**string sourceCellImageId = this.adapter.CreateDragAndDropSource(50, 180, 100, 200);
            this.sourceImage = this.adapter.CreateImage(-(worldWidth / 2 - 100 / 2), -(worldHeight / 2 - 200 / 2), 100, 200);
            this.adapter.SetImage(sourceImage, "Cell.png");

            //**string itemId = this.adapter.CreateDragAndDropItem(0, 0, 100, 100);
            this.dragImage = this.adapter.CreateImage(0, 0, 100, 100);
            this.adapter.SetImage(this.dragImage, "Hammer.png");
            //**this.adapter.AddItemToDragAndDropSource(sourceCellImageId, itemId);
            this.adapter.MakeDraggable(this.dragImage, true);
            this.adapter.OnDrop += this.OnDrop;
            this.adapter.Center(this.dragImage, sourceImage);


            // imageId = this.adapter.CreateImage(40, 100, 100, 100);
            // this.adapter.SetImage(imageId, "pexels-photo-1545505.jpeg");

            string buttonId = this.adapter.CreateButton(150, 100, 100, 100, "#09FF0064", this.GoToNextPage);

            this.adapter.SetImage(buttonId, "BlueButton.png");

            this.adapter.SetDrawingRect(-320, 180, 640, 360);
            this.adapter.OnDrawing += this.Drawing;

            this.hideButtonName = this.adapter.CreateButton(250, 200, 100, 100, "#09FF0064", this.Hide);
            this.adapter.SetText(this.hideButtonName, "Hide");

            this.nextPageName = this.adapter.AddPage(); //this.adapter.AddPage();
            //this.adapter.ChangeLayout(Layout.Grid);

            string gridId = this.adapter.CreateImage(-250, 250, 500, 200);

            this.adapter.ChangeLayout(gridId, Layout.Grid);

            buttonId = this.adapter.CreateButton(0, 0, 100, 100, "#BC2FA864", this.GoToFirstPage);
            this.adapter.SetImage(buttonId, "BlueButton.png");
            this.adapter.SetParent(buttonId, gridId);

            itemId = this.adapter.CreateImage(40, 100, 100, 100);
            this.adapter.SetImage(itemId, "BlueButton.png");
            this.adapter.SetParent(itemId, gridId);

            string inputText = this.adapter.CreateInputField(300, 300, 100, 100, null, this.OnEndEdit);

            this.adapter.SetParent(inputText, gridId);
        }