public void PromptForCreation(string createType, EventHandler submit)
        {
            this.PromptName = new TextBox();

            var label = new Label();

            label.Text = "Enter the name of the new " + createType + ":";

            var form = new Form();

            form.AddControl("Name: ", this.PromptName);

            var submitButton = new Button();

            submitButton.Text   = "Create";
            submitButton.Click += (sender, e) =>
            {
                submit(sender, e);
                this.m_CanvasEntity.Windows.Remove(this.PromptWindow);
                this.PromptWindow = null;
                this.PromptName   = null;
            };

            var cancelButton = new Button();

            cancelButton.Text   = "Cancel";
            cancelButton.Click += (sender, e) =>
            {
                this.m_CanvasEntity.Windows.Remove(this.PromptWindow);
                this.PromptWindow = null;
                this.PromptName   = null;
            };

            var horizontalContainer = new HorizontalContainer();

            horizontalContainer.AddChild(submitButton, "50%");
            horizontalContainer.AddChild(cancelButton, "50%");

            var verticalContainer = new VerticalContainer();

            verticalContainer.AddChild(label, "24");
            verticalContainer.AddChild(form, "*");
            verticalContainer.AddChild(horizontalContainer, "24");

            this.PromptWindow        = new Window();
            this.PromptWindow.Modal  = true;
            this.PromptWindow.Bounds = new Microsoft.Xna.Framework.Rectangle(
                (int)this.m_CanvasEntity.Width / 2 - 150,
                (int)this.m_CanvasEntity.Height / 2 - 75,
                300,
                150);
            this.PromptWindow.SetChild(verticalContainer);
            this.m_CanvasEntity.Windows.Add(this.PromptWindow);

            this.MainMenu.Active = false;
            foreach (var item in this.MainMenu.Children.Cast <MenuItem>())
            {
                item.Active = false;
            }
        }
Beispiel #2
0
        /*public override void OnFocus()
         * {
         *  // Switch focus to the scrollable container.
         *  _verticalContainer.Focus();
         * }*/

        public override void Update(ISkinLayout skinLayout, Rectangle layout, GameTime gameTime, ref bool stealFocus)
        {
            foreach (var ext in _extensionManager.Extensions)
            {
                if (_verticalContainer.Children.Any(x => x.Userdata == ext))
                {
                    continue;
                }

                var label = new Label
                {
                    Text = ext.Name
                };
                var debugButton = new Button
                {
                    Text = "Debug"
                };
                var restartButton = new Button
                {
                    Text = "Restart"
                };

                debugButton.Click += (sender, e) =>
                {
                    _extensionManager.DebugExtension(ext);
                };
                restartButton.Click += (sender, e) =>
                {
                    _extensionManager.RestartExtension(ext);
                };


                var buttonContainer = new VerticalContainer();
                buttonContainer.AddChild(debugButton, "24");
                buttonContainer.AddChild(restartButton, "24");

                var horizontalContainer = new HorizontalContainer();
                horizontalContainer.Userdata = ext;
                horizontalContainer.AddChild(label, "*");
                horizontalContainer.AddChild(buttonContainer, "120");

                _verticalContainer.AddChild(horizontalContainer, "48");
            }

            foreach (var vert in _verticalContainer.Children.ToArray())
            {
                if (!_extensionManager.Extensions.Any(x => x == vert.Userdata))
                {
                    _verticalContainer.RemoveChild(vert);
                }
            }

            base.Update(skinLayout, layout, gameTime, ref stealFocus);
        }
Beispiel #3
0
        protected override void Initialize()
        {
            random_indices = new ArrayListIndicesRandom((int)Figures.Last);
            random_indices.Initialize();
            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            for (int i = 0; i < (int)Figures.Last; i++)
            {
                if (random_indices[i] == (int)Figures.Third)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }

            HorizontalContainer container = new HorizontalContainer(DrawAreaX, DrawAreaY + figure_size + 0.16, 0.8, 0.3);

            DrawableArea drawable_area;

            AddWidget(container);

            for (int i = 0; i < (int)Figures.Last; i++)
            {
                drawable_area = new DrawableArea(space_figures, 0.2);
                drawable_area.SelectedArea = new Rectangle(0, 0, figure_size, figure_size);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    switch ((Figures)random_indices[n])
                    {
                    case Figures.First:
                        DrawDiamon(e.Context, 0, 0, CerclePosition.Right | CerclePosition.Left);
                        break;

                    case Figures.Second:
                        DrawDiamon(e.Context, 0, 0, CerclePosition.Top | CerclePosition.Right);
                        break;

                    case Figures.Third:
                        DrawDiamon(e.Context, 0, 0, CerclePosition.Bottom | CerclePosition.Top);
                        break;

                    default:
                        throw new InvalidOperationException();
                    }

                    e.Context.MoveTo(0.02, 0.25);
                    e.Context.ShowPangoText(Answer.GetFigureName(n));
                    e.Context.Stroke();
                };
            }
        }
Beispiel #4
0
        protected override void Initialize()
        {
            sum_offset     = random.Next(3);
            random_indices = new ArrayListIndicesRandom(slices.Length / items_per_slice);
            random_indices.Initialize();
            ans_pos = random.Next(possible_answers);

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            Answer.SetMultiOptionAnswer(ans_pos, Answer.GetFigureName(ans_pos));

            bad_answers = new int [possible_answers * items_per_slice];
            for (int i = 0; i < bad_answers.Length; i++)
            {
                bad_answers[i] = 1 + random.Next(9);
            }

            HorizontalContainer container = new HorizontalContainer(DrawAreaX, 0.62, 0.8, 0.3);
            DrawableArea        drawable_area;

            AddWidget(container);

            for (int i = 0; i < possible_answers; i++)
            {
                drawable_area = new DrawableArea(0.8 / 3, 0.3);
                drawable_area.SelectedArea = new Rectangle(0, 0, radius, 0.2);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    DrawSlice(e.Context, 0, 0);
                    if (n == ans_pos)
                    {
                        int pos = random_indices [0];
                        DrawSliceText(e.Context, 0, 0, 0, (sum_offset +
                                                           slices [pos * items_per_slice]).ToString(),
                                      (sum_offset + slices [1 + (pos * items_per_slice)]).ToString(),
                                      (sum_offset + slices [2 + (pos * items_per_slice)]).ToString());
                    }
                    else
                    {
                        DrawSliceText(e.Context, 0, 0, 0,
                                      bad_answers [n * items_per_slice].ToString(),
                                      bad_answers [1 + (n * items_per_slice)].ToString(),
                                      bad_answers [2 + (n * items_per_slice)].ToString());
                    }

                    e.Context.MoveTo(0.0, 0.25);
                    e.Context.DrawTextCentered(radius / 2, 0.25, Answer.GetFigureName(n));
                    e.Context.Stroke();
                };
            }
        }
Beispiel #5
0
        private void SetDrawAnswer()
        {
            double h = 0.25, sel_marginw = 0.05, sel_marginh = 0.025;
            double x = DrawAreaX + 0.1, y = DrawAreaY + 0.62;
            int    fig_count = (int)Figures.Last;

            HorizontalContainer container = new HorizontalContainer(x, y, fig_count * (figure_size + space_x), h);
            DrawableArea        drawable_area;

            AddWidget(container);

            for (int i = 0; i < fig_count; i++)
            {
                drawable_area = new DrawableArea(figure_size + space_x, h);
                drawable_area.SelectedArea = new Rectangle(-sel_marginw, -sel_marginh, figure_size + sel_marginw * 2, h);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int fig = (int)e.Data;

                    switch ((Figures)random_indices[fig])
                    {
                    case Figures.TwoLines:
                        DrawTwoLines(e.Context, 0, 0, figure_size);
                        break;

                    case Figures.Cross:
                        DrawCross(e.Context, 0, 0, figure_size);
                        break;

                    case Figures.RotatedCross:
                        DrawRotatedCross(e.Context, 0, 0, figure_size);
                        break;
                    }

                    e.Context.MoveTo(0, 0.17);
                    e.Context.ShowPangoText(Answer.GetFigureName(fig));
                };
            }
        }
Beispiel #6
0
        protected override void Initialize()
        {
            question_indices = new ArrayListIndicesRandom(question_columns);
            question_indices.Initialize();

            answer_indices = new ArrayListIndicesRandom(possible_answers);
            answer_indices.Initialize();

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            BuildPossibleAnswers();

            const double        total_width = 0.8, total_height = 0.42;
            HorizontalContainer container = new HorizontalContainer(DrawAreaX, 0.52, total_width, total_height);

            AddWidget(container);

            // Possible answers columns
            for (int ans = 0; ans < possible_answers; ans++)
            {
                DrawableArea drawable_area = new DrawableArea(total_width / possible_answers, total_height);
                drawable_area.Data   = ans;
                drawable_area.DataEx = Answer.GetMultiOption(ans);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    double width = total_width / possible_answers;
                    double x = (width - figure_size) / 2, y = 0;
                    int    column = (int)e.Data;

                    for (int figure = 0; figure < figures_column; figure++)
                    {
                        DrawFigure(e.Context, x, y, figure_answers [(column * figures_column) + figure]);
                        y += figure_size + space_height;
                    }

                    e.Context.DrawTextCentered(width / 2, total_height - 0.02, Answer.GetFigureName(column));
                    e.Context.Stroke();
                };
            }
            Answer.SetMultiOptionAnswer(answer_indices[good_answer], Answer.GetFigureName(answer_indices[good_answer]));
        }
Beispiel #7
0
        protected override void Initialize()
        {
            Answer.CheckAttributes  |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            random_indices_questions = new ArrayListIndicesRandom(4);
            random_indices_questions.Initialize();

            random_indices_answers = new ArrayListIndicesRandom(3);
            random_indices_answers.Initialize();

            for (int i = 0; i < random_indices_answers.Count; i++)
            {
                if (random_indices_answers [i] == 0)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }

            HorizontalContainer container = new HorizontalContainer(0.1, 0.5, 0.8, 0.4);
            DrawableArea        drawable_area;

            AddWidget(container);

            for (int i = 0; i < 3; i++)
            {
                drawable_area        = new DrawableArea(0.8 / 3, 0.4);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    DrawAnswerFigures(e.Context, 0.05, 0.2, random_indices_answers [n]);
                    e.Context.MoveTo(0.05, 0.33);
                    e.Context.ShowPangoText(Answer.GetFigureName(n));
                };
            }
        }
        protected override void Initialize()
        {
            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            possible_answers        = new ArrayListIndicesRandom(3);
            possible_answers.Initialize();

            puzzle_index = random.Next(puzzles.Length);
            puzzle       = puzzles [puzzle_index];

            DrawableArea        drawable_area;
            HorizontalContainer container = new HorizontalContainer(0.05, 0.5, 0.9, figure_size + 0.1);

            AddWidget(container);

            for (int i = 0; i < possible_answers.Count; i++)
            {
                drawable_area              = new DrawableArea(figure_size + space_figures, figure_size + 0.1);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);
                drawable_area.SelectedArea = new Rectangle(space_figures / 2, space_figures / 2, figure_size, figure_size);

                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    DrawPossibleAnswer(e.Context, space_figures / 2, space_figures / 2, possible_answers [(int)e.Data]);
                    e.Context.DrawTextCentered(space_figures / 2 + figure_size / 2, space_figures + figure_size + 0.02,
                                               Answer.GetFigureName((int)e.Data));
                };
            }

            for (int i = 0; i < possible_answers.Count; i++)
            {
                if (possible_answers[i] == 0)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }
        }
Beispiel #9
0
        protected override void Initialize()
        {
            int position;

            // In all these cases the clock logic clearly do not work since the small hand is in the next hour
            switch (random.Next(3))
            {
            case 0:
                position = 48;
                addition = 5;
                break;

            case 1:
                position = 38;
                addition = 15;
                break;

            case 2:
            default:
                position = 24;
                addition = 5;
                break;
            }

            handles = new int [clocks * handle_num];

            for (int i = 0; i < handles.Length; i++, i++)
            {
                handles [i]     = position / 10;
                handles [i + 1] = position - ((position / 10) * 10);
                position       += addition;
            }

            Answer.Correct = handles[7].ToString();

            // First row
            HorizontalContainer container = new HorizontalContainer(DrawAreaX, 0.05, 0.8, 0.45);
            DrawableArea        drawable_area;

            AddWidget(container);

            drawable_area           = new DrawableArea(0.8 / 2, 0.4);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawClock(0.05, 0, figure_size, handles[0], handles[1]);
                e.Context.DrawTextCentered(drawable_area.Width / 2, 0.36, Answer.GetFigureName(0));
                e.Context.Stroke();
            };

            drawable_area           = new DrawableArea(0.8 / 2, 0.4);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawClock(0.05, 0, figure_size, handles[2], handles[3]);
                e.Context.MoveTo(0.03, 0.29);
                e.Context.DrawTextCentered(drawable_area.Width / 2, 0.36, Answer.GetFigureName(1));
                e.Context.Stroke();
            };

            // Second row
            container = new HorizontalContainer(DrawAreaX, 0.05 + 0.45, 0.8, 0.45);
            AddWidget(container);

            drawable_area           = new DrawableArea(0.8 / 2, 0.4);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawClock(0.05, 0, figure_size, handles[4], handles[5]);
                e.Context.DrawTextCentered(drawable_area.Width / 2, 0.36, Answer.GetFigureName(2));
                e.Context.Stroke();
            };

            drawable_area           = new DrawableArea(0.8 / 2, 0.4);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawClock(0.05, 0, figure_size, handles[6], Answer.Draw == true ? handles[7] : 0);
                e.Context.MoveTo(0.03, 0.29);
                e.Context.DrawTextCentered(drawable_area.Width / 2, 0.36, Answer.GetFigureName(3));
                e.Context.Stroke();
            };

            /*DateTime dt1 = new DateTime (2008, 2, 20, handles[0], handles[1] * 5, 0);
             * DateTime dt2 = new DateTime (2008, 2, 20, handles[2], handles[3] * 5, 0);
             * Console.WriteLine ("t1 {0}", dt1);
             * Console.WriteLine ("t2 {0}", dt2);
             * Console.WriteLine ("Time diff {0} from 1st to 2nd", dt2-dt1);
             *
             * dt1 = new DateTime (2008, 2, 20, handles[2], handles[3] * 5, 0);
             * dt2 = new DateTime (2008, 2, 20, handles[4], handles[5] * 5, 0);
             * Console.WriteLine ("t1 {0}", dt1);
             * Console.WriteLine ("t2 {0}", dt2);
             * Console.WriteLine ("Time diff {0} from 1st to 2nd", dt2-dt1);
             *
             * dt1 = new DateTime (2008, 2, 20, handles[4], handles[5] * 5, 0);
             * dt2 = new DateTime (2008, 2, 20, handles[6], handles[7] * 5, 0);
             * Console.WriteLine ("t1 {0}", dt1);
             * Console.WriteLine ("t2 {0}", dt2);
             * Console.WriteLine ("Time diff {0} from 1st to 2nd", dt2-dt1);*/
        }
        protected override void Initialize()
        {
            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            palette = new ColorPalette();

            switch (random.Next(2))
            {
            case 0:
                quest1  = g1question_A;
                quest2  = g1question_B;
                answer  = g1answer;
                ranswer = g1rightanswer;
                break;

            case 1:
                quest1  = g2question_A;
                quest2  = g2question_B;
                answer  = g2answer;
                ranswer = g2rightanswer;
                break;
            }

            random_indices = new ArrayListIndicesRandom(answers);
            random_indices.Initialize();

            for (int i = 0; i < answers; i++)
            {
                if (random_indices[i] == ranswer)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }

            double x = DrawAreaX, y = DrawAreaY;

            // Question
            DrawableArea        drawable_area;
            HorizontalContainer container = new HorizontalContainer(x, y, 0.8, 0.3);

            AddWidget(container);

            drawable_area           = new DrawableArea(container.Width / 2, 0.25);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                DrawSquare(e.Context, 0.15, 0);
            };

            drawable_area           = new DrawableArea(container.Width / 2, 0.25);
            drawable_area.Sensitive = false;
            container.AddChild(drawable_area);

            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                DrawLShape(e.Context, 0.15, 0);
            };

            // Answers
            y        += 0.28;
            container = new HorizontalContainer(x, y, 0.8, 0.3);
            AddWidget(container);

            for (int i = 0; i < 2; i++)
            {
                drawable_area        = new DrawableArea(container.Width / 2, 0.25);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;
                    DrawPossibleAnswer(e.Context, 0.12, 0.03, answer, random_indices [n], n);

                    e.Context.DrawTextCentered(drawable_area.Width / 2, 0.22, Answer.GetFigureName(n));
                    e.Context.Stroke();
                };
            }

            container = new HorizontalContainer(x, y + 0.3, 0.8, 0.3);
            AddWidget(container);

            for (int i = 2; i < 4; i++)
            {
                drawable_area        = new DrawableArea(container.Width / 2, 0.25);
                drawable_area.Data   = i;
                drawable_area.DataEx = Answer.GetMultiOption(i);
                container.AddChild(drawable_area);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;
                    DrawPossibleAnswer(e.Context, 0.12, 0.03, answer, random_indices [n], n);

                    e.Context.DrawTextCentered(drawable_area.Width / 2, 0.22, Answer.GetFigureName(n));
                    e.Context.Stroke();
                };
            }
        }
Beispiel #11
0
        private void SetupCanvas()
        {
            _canvas = new Canvas();

            var dockableLayoutContainer = new DockableLayoutContainer();

            dockableLayoutContainer.RightWidth   = 250;
            dockableLayoutContainer.BottomHeight = 250;

            var profilerDockableLayoutContainer = new DockableLayoutContainer();

            profilerDockableLayoutContainer.AddInnerRegion(_editorWindowFactory.CreateProfilerEditorWindow());

            var rightDockableLayoutContainer = new DockableLayoutContainer();

            rightDockableLayoutContainer.SetTopRegion(profilerDockableLayoutContainer);
            rightDockableLayoutContainer.AddInnerRegion(_editorWindowFactory.CreateInspectorEditorWindow());
            dockableLayoutContainer.SetRightRegion(rightDockableLayoutContainer);

            var bottomDockableLayoutContainer = new DockableLayoutContainer();

            bottomDockableLayoutContainer.AddInnerRegion(_editorWindowFactory.CreateProjectEditorWindow());
            bottomDockableLayoutContainer.AddInnerRegion(_editorWindowFactory.CreateConsoleEditorWindow());
            dockableLayoutContainer.SetBottomRegion(bottomDockableLayoutContainer);

            var workspaceDockableLayoutContainer = new DockableLayoutContainer();

            _workspaceContainer = new DockableLayoutContainer();
            workspaceDockableLayoutContainer.AddInnerRegion(_workspaceContainer);
            dockableLayoutContainer.AddInnerRegion(workspaceDockableLayoutContainer);

            var leftDockableLayoutContainer = new DockableLayoutContainer();

            leftDockableLayoutContainer.AddInnerRegion(_editorWindowFactory.CreateHierarchyEditorWindow());
            _workspaceContainer.SetLeftRegion(leftDockableLayoutContainer);

            _workspaceContainer.AddInnerRegion(_editorWindowFactory.CreateStartEditorWindow());
            _workspaceContainer.AddInnerRegion(_worldEditorWindow = _editorWindowFactory.CreateWorldEditorWindow());
            _workspaceContainer.AddInnerRegion(_gameEditorWindow  = _editorWindowFactory.CreateGameEditorWindow());

            var toolContainer = new RelativeContainer();

            /*var panButton = CreateToolButton("texture.IconToolPan", "pan");
             * panButton.Toggled = true;
             *
             * toolContainer.AddChild(panButton, new Rectangle(16, 8, 28, 28));
             * toolContainer.AddChild(CreateToolButton("texture.IconToolMove", "move"), new Rectangle(16 + 30 * 1, 8, 28, 28));
             * toolContainer.AddChild(CreateToolButton("texture.IconToolRotate", "rotate"), new Rectangle(16 + 30 * 2, 8, 28, 28));
             * toolContainer.AddChild(CreateToolButton("texture.IconToolResize", "resize"), new Rectangle(16 + 30 * 3, 8, 28, 28));
             * toolContainer.AddChild(CreateToolButton("texture.IconToolSelect", "select"), new Rectangle(16 + 30 * 4, 8, 28, 28));*/

            _gameControlContainer = new RelativeContainer();

            var unusedContainer = new RelativeContainer();

            _horizontalContainer = new HorizontalContainer();
            _horizontalContainer.AddChild(toolContainer, "*");
            _horizontalContainer.AddChild(_gameControlContainer, "0");
            _horizontalContainer.AddChild(unusedContainer, "*");

            var verticalContainer = new VerticalContainer();

            verticalContainer.AddChild(_horizontalContainer, "40");
            verticalContainer.AddChild(dockableLayoutContainer, "*");

            _canvas.SetChild(verticalContainer);

            _windowManagement.SetMainDocumentContainer(_workspaceContainer);
        }
        public StartEditorWindow(
            IAssetManager assetManager,
            IProjectManager projectManager,
            IProjectManagerUi projectManagerUi,
            ICoroutine coroutine,
            IRecentProjects recentProjects,
            I2DRenderUtilities renderUtilities)
        {
            _assetManager    = assetManager;
            _projectManager  = projectManager;
            _coroutine       = coroutine;
            _recentProjects  = recentProjects;
            _renderUtilities = renderUtilities;

            Title = "Welcome!";
            Icon  = _assetManager.Get <TextureAsset>("texture.IconWelcome");

            var newProject = new Button
            {
                Text = "New Project"
            };
            var openProject = new Button
            {
                Text = "Open Project"
            };

            openProject.Click += (sender, e) =>
            {
                _coroutine.Run(() => projectManagerUi.LoadProject());
            };

            var buttonContainer = new HorizontalContainer();

            buttonContainer.AddChild(newProject, "*");
            buttonContainer.AddChild(new EmptyContainer(), "20");
            buttonContainer.AddChild(openProject, "*");

            _recentProjectsContainer = new VerticalContainer();
            //var scrollableContainer = new ScrollableContainer();
            //scrollableContainer.SetChild(_recentProjectsContainer);

            var verticalContainer = new VerticalContainer();

            verticalContainer.AddChild(new Label {
                Font = _assetManager.Get <FontAsset>("font.Welcome"),
                Text = "Welcome to Protogame!",
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top
            }, "80");
            verticalContainer.AddChild(buttonContainer, "60");
            verticalContainer.AddChild(new EmptyContainer(), "24");
            verticalContainer.AddChild(_recentProjectsContainer, "*");

            var outerVertContainer = new VerticalContainer();

            outerVertContainer.AddChild(new EmptyContainer(), "15%");
            outerVertContainer.AddChild(verticalContainer, "*");
            outerVertContainer.AddChild(new EmptyContainer(), "15%");

            var outerHorContainer = new HorizontalContainer();

            outerHorContainer.AddChild(new EmptyContainer(), "15%");
            outerHorContainer.AddChild(outerVertContainer, "*");
            outerHorContainer.AddChild(new EmptyContainer(), "15%");

            SetChild(outerHorContainer);
        }
Beispiel #13
0
        protected override void Initialize()
        {
            ArrayListIndicesRandom random_indices = new ArrayListIndicesRandom(total_slices);
            Color clr;

            cp = new ColorPalette(Translations);

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            cercle_colors    = new Color [total_slices];
            badcercle_colors = new Color [total_slices];
            for (int i = 0; i < total_slices; i++)
            {
                cercle_colors [i]    = cp.Cairo(i);
                badcercle_colors [i] = cp.Cairo(i);
            }

            // Correct answer
            random_indices.Initialize();
            clr = badcercle_colors [random_indices[0]];
            badcercle_colors [random_indices[0]] = badcercle_colors [random_indices[1]];
            badcercle_colors [random_indices[1]] = clr;

            // Create random color order for the session
            start_indices = new int [circles];
            for (int i = 0; i < circles; i++)
            {
                start_indices[i] = (random_indices[i]);
            }

            ans_pos = random.Next(circles);
            Answer.SetMultiOptionAnswer(ans_pos, Answer.GetFigureName(ans_pos));

            const double        text_offset = 0.04;
            const double        witdh_used  = 0.9;     // Total width used for drawing all the figures
            const double        margin      = 0.1 / circles / 2;
            const double        box_size    = witdh_used / circles;
            double              y;
            HorizontalContainer container;
            DrawableArea        drawable_area;

            Color [] colors;

            y = DrawAreaY + 0.1 + (radius / 2);

            container = new HorizontalContainer(0.05, y, witdh_used, box_size);
            AddWidget(container);

            circle_parameters = new CircleParameters [circles];
            for (int i = 0; i < circles; i++)
            {
                if (ans_pos == i)
                {
                    colors = badcercle_colors;
                }
                else
                {
                    colors = cercle_colors;
                }

                circle_parameters [i]      = new CircleParameters(colors);
                drawable_area              = new DrawableArea(box_size, box_size);
                drawable_area.SelectedArea = new Rectangle((box_size - box_size) / 2, 0, box_size, box_size);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int idx = (int)e.Data;
                    CircleParameters circle = circle_parameters [idx];
                    double           x1, y1;

                    x1 = y1 = radius + margin;

                    DrawCircle(e.Context, x1, y1, circle.Colors, start_indices [idx]);
                    e.Context.DrawTextCentered(e.Width / 2, box_size + text_offset,
                                               Answer.GetFigureName(idx));
                    e.Context.Stroke();
                };
                container.AddChild(drawable_area);
            }
        }
Beispiel #14
0
        public MenuWorld(ISkin skin, IWorldFactory worldFactory, IAssetManagerProvider assetManagerProvider, I2DRenderUtilities twodRenderUtilities)
        {
            this.m_2DRenderUtilities = twodRenderUtilities;

            this.m_LogoTexture = assetManagerProvider.GetAssetManager().Get <TextureAsset>("texture.Logo");

            this.m_WorldFactory = worldFactory;

            this.Entities = new List <IEntity>();

            var startServer = new Button();

            startServer.Text   = "Start Server";
            startServer.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld <IWorldFactory>(
                    x => x.CreateLobbyWorld(false, IPAddress.Any));
            };

            var ipAddressTextBox = new TextBox();

            var joinGame = new Button();

            joinGame.Text   = "Join Game";
            joinGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld <IWorldFactory>(
                    x => x.CreateLobbyWorld(true, IPAddress.Parse(ipAddressTextBox.Text)));
            };

            var exitGame = new Button();

            exitGame.Text   = "Exit Game";
            exitGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.Game.Exit();
            };

            var vertical = new VerticalContainer();

            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label {
                Text = "Perspective"
            }, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(startServer, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label {
                Text = "Server IP address:"
            }, "20");
            vertical.AddChild(ipAddressTextBox, "20");
            vertical.AddChild(joinGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(exitGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");

            var horizontal = new HorizontalContainer();

            horizontal.AddChild(new EmptyContainer(), "*");
            horizontal.AddChild(vertical, "250");
            horizontal.AddChild(new EmptyContainer(), "*");

            var canvas = new Canvas();

            canvas.SetChild(horizontal);

            this.Entities.Add(new CanvasEntity(skin, canvas));
        }
Beispiel #15
0
        protected override void Initialize()
        {
            indications = new Indication [CurrentDifficulty == GameDifficulty.Easy ? 5 : 7];
            Indication.TurnDirection second_turn = (Indication.TurnDirection) 2 + random.Next(2);

            indications[0] = new Indication(Translations, Indication.Type.Start, 0);
            indications[1] = new Indication(Translations, Indication.Type.Turn, random.Next(2));           // right or left
            indications[2] = new Indication(Translations, Indication.Type.Turn, second_turn);              // up or down
            indications[3] = new Indication(Translations, Indication.Type.Turn, random.Next(2));           // right or left

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            if (CurrentDifficulty == GameDifficulty.Easy)
            {
                indications[4] = new Indication(Translations, Indication.Type.End, 1);
            }
            else
            {
                if (second_turn == Indication.TurnDirection.Up)
                {
                    indications[4] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Up);
                }
                else
                {
                    indications[4] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Down);
                }

                indications[5] = new Indication(Translations, Indication.Type.Turn, random.Next(2));                   // right or left
                indications[6] = new Indication(Translations, Indication.Type.End, 1);
            }

            indications_wrongA = CopyAnswer();
            indications_wrongB = CopyAnswer();
            indications_wrongC = CopyAnswer();

            if ((Indication.TurnDirection)indications[3].obj == Indication.TurnDirection.Right)
            {
                indications_wrongA[3] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Left);
            }
            else
            {
                indications_wrongA[3] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Right);
            }

            if (CurrentDifficulty == GameDifficulty.Easy)
            {
                if ((Indication.TurnDirection)indications[2].obj == Indication.TurnDirection.Up)
                {
                    indications_wrongB[2] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Down);
                }
                else
                {
                    indications_wrongB[2] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Up);
                }
            }
            else
            {
                if ((Indication.TurnDirection)indications[5].obj == Indication.TurnDirection.Right)
                {
                    indications_wrongB[5] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Left);
                }
                else
                {
                    indications_wrongB[5] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Right);
                }
            }

            if ((Indication.TurnDirection)indications[1].obj == Indication.TurnDirection.Right)
            {
                indications_wrongC[1] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Left);
            }
            else
            {
                indications_wrongC[1] = new Indication(Translations, Indication.Type.Turn, Indication.TurnDirection.Right);
            }

            base.Initialize();

            answers = new ArrayListIndicesRandom(4);
            answers.Initialize();

            for (int i = 0; i < answers.Count; i++)
            {
                if (answers [i] == 0)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    ans = i;
                    break;
                }
            }

            // Draw row 1
            HorizontalContainer container = new HorizontalContainer(0.05, 0.1, 0.9, 0.4);

            AddWidget(container);

            for (int i = 0; i < 2; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.45, 0.4);
                container.AddChild(drawable_area);
                drawable_area.SelectedArea      = new Rectangle(0, 0, 0.45, 0.3);
                drawable_area.Data              = i;
                drawable_area.DataEx            = Answer.GetMultiOption(i);
                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    DrawPossibleAnswers(e.Context, 0.2, 0.1, WhichAnswer(answers[n]));
                    e.Context.MoveTo(0.2, 0.12 + 0.2);
                    e.Context.ShowPangoText(Answer.GetFigureName(n));
                };
            }

            // Draw row 2
            container = new HorizontalContainer(0.05, 0.5, 0.9, 0.4);
            AddWidget(container);

            for (int i = 2; i < 4; i++)
            {
                DrawableArea drawable_area = new DrawableArea(0.45, 0.4);
                container.AddChild(drawable_area);
                drawable_area.SelectedArea      = new Rectangle(0, 0, 0.45, 0.3);
                drawable_area.Data              = i;
                drawable_area.DataEx            = Answer.GetMultiOption(i);
                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    DrawPossibleAnswers(e.Context, 0.2, 0.1, WhichAnswer(answers[n]));
                    e.Context.MoveTo(0.2, 0.12 + 0.2);
                    e.Context.ShowPangoText(Answer.GetFigureName(n));
                };
            }
        }
Beispiel #16
0
        protected override void Initialize()
        {
            // Question
            ArrayList array_good = new ArrayList();

            array_good.AddRange(new Element [] { Element.SmallCircle, Element.SmallCircle, Element.SmallCircle,
                                                 Element.MediumCircle, Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild });

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            // Four random samples with equal elements
            questions = new ArrayList();
            for (int i = 0; i < 4; i++)
            {
                questions.Add(BuildFigure(array_good, questions));
            }

            ArrayList array = new ArrayList();

            answers = new ArrayList();
            random_indices_answers = new ArrayListIndicesRandom(4);
            random_indices_answers.Initialize();

            for (int i = 0; i < random_indices_answers.Count; i++)
            {
                if ((int)random_indices_answers [i] == 0)
                {
                    Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                    break;
                }
            }

            if (CurrentDifficulty == GameDifficulty.Easy)
            {
                // Answer 1 (good)
                array.AddRange(new Element [] { Element.SmallCircle, Element.SmallCircle, Element.SmallCircle,
                                                Element.MediumCircle, Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild });
                answers.Add(BuildFigure(array, answers));

                // Answer 2
                array.Clear();
                array.AddRange(new Element [] { Element.SmallCircle, Element.SmallCircle, Element.MediumCircle,
                                                Element.MediumCircle, Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild });
                answers.Add(BuildFigure(array, answers));

                // Answer 3
                array.Clear();
                array.AddRange(new Element [] { Element.SmallCircle, Element.SmallCircle, Element.MediumCircle,
                                                Element.MediumCircle, Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild });
                answers.Add(BuildFigure(array, answers));

                // Answer 4
                array.Clear();
                array.AddRange(new Element [] { Element.SmallCircle, Element.SmallCircle, Element.MediumCircle,
                                                Element.MediumCircle, Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild });
                answers.Add(BuildFigure(array, answers));
            }
            else              // Medium or Master
            {
                // Answer 1 (good)
                array.AddRange(new Element [] { Element.SmallCircle, Element.SmallCircle, Element.MediumCircleWithChild,
                                                Element.MediumCircle, Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild });
                answers.Add(BuildFigure(array, answers));

                // Answer 2
                array.Clear();
                array.AddRange(new Element [] { Element.SmallCircle, Element.MediumCircle, Element.MediumCircle,
                                                Element.MediumCircle, Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild });
                answers.Add(BuildFigure(array, answers));

                // Answer 3
                array.Clear();
                array.AddRange(new Element [] { Element.SmallCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild,
                                                Element.MediumCircle, Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild });
                answers.Add(BuildFigure(array, answers));

                // Answer 4
                array.Clear();
                array.AddRange(new Element [] { Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild,
                                                Element.MediumCircle, Element.MediumCircle, Element.MediumCircleWithChild, Element.MediumCircleWithChild });
                answers.Add(BuildFigure(array, answers));
            }

            double figure_size = 0.22;
            double x = DrawAreaX - 0.05, y = DrawAreaY + 0.45;

            HorizontalContainer container = new HorizontalContainer(x, y, random_indices_answers.Count * figure_size, 0.3);
            DrawableArea        drawable_area;

            AddWidget(container);

            for (int i = 0; i < random_indices_answers.Count; i++)
            {
                drawable_area = new DrawableArea(figure_size, figure_size + 0.05);
                drawable_area.SelectedArea = new Rectangle(0.05, 0.05, cercle_size, cercle_size);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int n = (int)e.Data;

                    DrawFigure(e.Context, 0.05, 0.05, (FigureElement [])answers[random_indices_answers[n]]);
                    e.Context.DrawTextCentered(x + (cercle_size / 2), 0.25, Answer.GetFigureName(n));
                };

                container.AddChild(drawable_area);
            }
        }
        public AssetManagerLayout(
            IAssetManagerProvider assetManagerProvider,
            I2DRenderUtilities renderUtilities,
            IAssetLoader[] loaders,
            CanvasEntity canvasEntity)
        {
            this.m_CanvasEntity = canvasEntity;

            var toolbarContainer = new HorizontalContainer();

            toolbarContainer.AddChild(new SingleContainer(), "*");
            toolbarContainer.AddChild(this.Bake = new Button {
                Text = "Bake"
            }, "50");
            toolbarContainer.AddChild(this.MarkDirty = new Button {
                Text = "Mark Dirty"
            }, "80");

            var assetContainer = new VerticalContainer();

            assetContainer.AddChild(toolbarContainer, "20");
            assetContainer.AddChild(this.EditorContainer = new SingleContainer(), "*");

            var contentContainer = new HorizontalContainer();

            contentContainer.AddChild(this.AssetTree = new TreeView(), "210");
            contentContainer.AddChild(assetContainer, "*");

            var menuContainer = new VerticalContainer();

            menuContainer.AddChild(this.MainMenu = new MainMenu(assetManagerProvider, renderUtilities), "24");
            menuContainer.AddChild(contentContainer, "*");
            menuContainer.AddChild(this.Status = new Label {
                Text = "..."
            }, "24");
            this.SetChild(menuContainer);

            var exitItem = new MenuItem(assetManagerProvider, renderUtilities)
            {
                Text = "Exit"
            };
            var bakeAllItem = new MenuItem(assetManagerProvider, renderUtilities)
            {
                Text = "Bake All"
            };
            var assetManagerMenuItem = new MenuItem(assetManagerProvider, renderUtilities)
            {
                Text = "Asset Manager"
            };

            exitItem.Click += (sender, e) =>
            {
                if (this.ExitClick != null)
                {
                    this.ExitClick(sender, e);
                }
            };
            bakeAllItem.Click += (sender, e) =>
            {
                if (this.BakeAllClick != null)
                {
                    this.BakeAllClick(sender, e);
                }
                (bakeAllItem.Parent as MenuItem).Active = false;
            };
            assetManagerMenuItem.AddChild(bakeAllItem);
            assetManagerMenuItem.AddChild(exitItem);
            this.MainMenu.AddChild(assetManagerMenuItem);

            var newAssetMenuItem = new MenuItem(assetManagerProvider, renderUtilities)
            {
                Text = "Create New..."
            };

            foreach (var loader in loaders.Where(x => x.CanNew()))
            {
                var createNewMenuItem = new MenuItem(assetManagerProvider, renderUtilities)
                {
                    Text = loader.GetType().Name
                };
                createNewMenuItem.Click += (sender, e) =>
                {
                    if (this.PromptWindow == null)
                    {
                        this.PromptForCreation(loader.GetType().Name, (_, _2) =>
                        {
                            if (this.CreateNameEntered != null)
                            {
                                this.CreateNameEntered(this, new CreateEventArgs(loader));
                            }
                        });
                    }
                };
                newAssetMenuItem.AddChild(createNewMenuItem);
            }
            this.MainMenu.AddChild(newAssetMenuItem);
        }
Beispiel #18
0
        public AugmentedBoardGameWorld(
            I2DRenderUtilities twoDRenderUtilities,
            IAssetManagerProvider assetManagerProvider,
            IEntityFactory entityFactory)
        {
            this.Entities = new List <IEntity>();

            _renderUtilities = twoDRenderUtilities;
            _assetManager    = assetManagerProvider.GetAssetManager();
            _defaultFont     = this._assetManager.Get <FontAsset>("font.Default");

            var canvasEntity = entityFactory.CreateCanvasEntity();

            var pointThresholdTextBox = new TextBox();
            var minPoints             = new TextBox();
            var maxPoints             = new TextBox();
            var alpha        = new TextBox();
            var deviceWidth  = new TextBox();
            var deviceHeight = new TextBox();
            var nextColor    = new Button()
            {
                Text = "Show Next Color "
            };
            var showDiagnostics = new Button()
            {
                Text = "Show Diagnostics"
            };
            var showBoard = new Button()
            {
                Text = "Show Board"
            };
            var nextDevice = new Button()
            {
                Text = "Next Device"
            };
            var deviceName = new TextBox();

            _fullscreen = new Button()
            {
                Text = "Fullscreen 1080"
            };

            var camera640x480 = new Button()
            {
                Text = "Camera 640x480"
            };

            camera640x480.Click += (sender, args) =>
            {
                deviceWidth.Text  = "640";
                deviceHeight.Text = "480";
            };
            var camera720p = new Button()
            {
                Text = "Camera 720p"
            };

            camera720p.Click += (sender, args) =>
            {
                deviceWidth.Text  = "1080";
                deviceHeight.Text = "720";
            };
            var camera1080p = new Button()
            {
                Text = "Camera 1080p"
            };

            camera1080p.Click += (sender, args) =>
            {
                deviceWidth.Text  = "1920";
                deviceHeight.Text = "1080";
            };

            var pointThresholdEntry = new HorizontalContainer();

            pointThresholdEntry.AddChild(new Label()
            {
                Text = "Point Threshold: "
            }, "100");
            pointThresholdEntry.AddChild(pointThresholdTextBox, "*");

            var minPointsEntry = new HorizontalContainer();

            minPointsEntry.AddChild(new Label()
            {
                Text = "Min. Points: "
            }, "100");
            minPointsEntry.AddChild(minPoints, "*");

            var maxPointsEntry = new HorizontalContainer();

            maxPointsEntry.AddChild(new Label()
            {
                Text = "Max. Points: "
            }, "100");
            maxPointsEntry.AddChild(maxPoints, "*");

            var renderAlphaEntry = new HorizontalContainer();

            renderAlphaEntry.AddChild(new Label()
            {
                Text = "Render Alpha: "
            }, "100");
            renderAlphaEntry.AddChild(alpha, "*");

            var deviceWidthEntry = new HorizontalContainer();

            deviceWidthEntry.AddChild(new Label()
            {
                Text = "Device Width: "
            }, "100");
            deviceWidthEntry.AddChild(deviceWidth, "*");

            var deviceHeightEntry = new HorizontalContainer();

            deviceHeightEntry.AddChild(new Label()
            {
                Text = "Device Height: "
            }, "100");
            deviceHeightEntry.AddChild(deviceHeight, "*");

            var vert = new VerticalContainer();

            vert.AddChild(pointThresholdEntry, "24");
            vert.AddChild(minPointsEntry, "24");
            vert.AddChild(maxPointsEntry, "24");
            vert.AddChild(renderAlphaEntry, "24");
            vert.AddChild(nextColor, "24");
            vert.AddChild(showDiagnostics, "48");
            vert.AddChild(showBoard, "48");
            vert.AddChild(nextDevice, "48");
            vert.AddChild(deviceName, "24");
            vert.AddChild(deviceWidthEntry, "24");
            vert.AddChild(deviceHeightEntry, "24");
            vert.AddChild(_fullscreen, "48");
            vert.AddChild(camera640x480, "48");
            vert.AddChild(camera720p, "48");
            vert.AddChild(camera1080p, "48");

            var hor = new HorizontalContainer();

            hor.AddChild(new EmptyContainer(), "*");
            hor.AddChild(vert, "200");

            var canvas = new Canvas();

            canvas.SetChild(hor);

            canvasEntity.Canvas = canvas;

            var webcamEntity   = entityFactory.CreateWebcamEntity(deviceName, deviceWidth, deviceHeight);
            var detectorEntity = entityFactory.CreateDetectorEntity(webcamEntity);

            detectorEntity.X = 0;
            detectorEntity.Y = 0;
            var boardAnalyzerEntity = entityFactory.CreateBoardAnalyzerEntity(detectorEntity, pointThresholdTextBox, minPoints, maxPoints);
            var boardRendererEntity = entityFactory.CreateBoardRendererEntity(boardAnalyzerEntity, webcamEntity, alpha);

            nextColor.Click += (sender, args) =>
            {
                detectorEntity.NextColor();
            };
            showDiagnostics.Click += (sender, args) =>
            {
                alpha.Text = "0";
            };
            showBoard.Click += (sender, args) =>
            {
                alpha.Text = "1";
            };
            nextDevice.Click += (sender, args) =>
            {
                webcamEntity.NextDevice();
            };

            _hasSetupFullscreenButton = false;

            this.Entities.Add(webcamEntity);
            this.Entities.Add(detectorEntity);
            this.Entities.Add(boardAnalyzerEntity);
            this.Entities.Add(canvasEntity);
            this.Entities.Add(boardRendererEntity);
        }
Beispiel #19
0
        protected override void Initialize()
        {
            random_indices = new ArrayListIndicesRandom(figures);
            random_indices.Initialize();

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            for (int i = 0; i < random_indices.Count; i++)
            {
                if (random_indices[i] != answer_index)
                {
                    continue;
                }

                Answer.SetMultiOptionAnswer(i, Answer.GetFigureName(i));
                break;
            }

            const double        text_offset = 0.04;
            double              x = DrawAreaX, y = DrawAreaY + 0.1, box_size = (1 - (DrawAreaX * 2)) / 3;
            HorizontalContainer container1, container2, container = null;
            DrawableArea        drawable_area;

            for (int figure = 0; figure < figures; figure++)
            {
                switch (figure)
                {
                case 0:
                    x          = DrawAreaX;
                    container1 = new HorizontalContainer(x, y, 0.8, figure_size);
                    container  = container1;
                    AddWidget(container);
                    break;

                case 3:
                    x          = DrawAreaX;
                    y         += 0.4;
                    container2 = new HorizontalContainer(x, y, 0.8, figure_size);
                    container  = container2;
                    AddWidget(container);
                    break;

                default:
                    break;
                }

                drawable_area = new DrawableArea(box_size, figure_size);
                drawable_area.SelectedArea = new Rectangle((box_size - figure_size) / 2, 0, figure_size, figure_size);
                drawable_area.Data         = figure;
                drawable_area.DataEx       = Answer.GetMultiOption(figure);

                switch (random_indices[figure])
                {
                case 0:
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawTriangle(e.Context, (e.Width - figure_size) / 2, 0);
                        e.Context.DrawTextCentered(e.Width / 2, figure_size + text_offset,
                                                   Answer.GetFigureName((int)e.Data));
                    };
                    break;

                case 1:
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawDiamon(e.Context, (e.Width - figure_size) / 2, 0);
                        e.Context.DrawTextCentered(e.Width / 2, figure_size + text_offset,
                                                   Answer.GetFigureName((int)e.Data));
                    };
                    break;

                case 2:
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawRectangleWithTriangles(e.Context, (e.Width - figure_size) / 2, 0);
                        e.Context.DrawTextCentered(e.Width / 2, figure_size + text_offset,
                                                   Answer.GetFigureName((int)e.Data));
                    };
                    break;

                case 3:
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawThreeTriangles(e.Context, (e.Width - figure_size) / 2, 0);
                        e.Context.DrawTextCentered(e.Width / 2, figure_size + text_offset,
                                                   Answer.GetFigureName((int)e.Data));
                    };
                    break;

                case answer_index:
                    drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                    {
                        DrawRectangleWithCross(e.Context, (e.Width - figure_size) / 2, 0);
                        e.Context.DrawTextCentered(e.Width / 2, figure_size + text_offset,
                                                   Answer.GetFigureName((int)e.Data));
                    };
                    break;
                }

                container.AddChild(drawable_area);
                x += box_size;
            }
        }
Beispiel #20
0
        public WelcomeView(ITranslations translations)
        {
            Container    container;
            DrawableArea drawable_area;
            double       y = 0.22;

            Translations = translations;
            containers   = new List <Toolkit.Container> ();

            /* Logic */
            container = new HorizontalContainer(0.05, y, 0.95, space);
            containers.Add(container);

            drawable_area = new DrawableArea(0.17, image_size);
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawImageFromAssembly("logic-games.svg", 0, 0, image_size, image_size);
            };

            drawable_area = new DrawableArea(0.75, space);
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawStringWithWrapping(0, 0,
                                                 Translations.GetString("Logic puzzles. Challenge your reasoning and thinking skills."),
                                                 e.Width);
            };

            /* Math */
            y        += space;
            container = new HorizontalContainer(0.05, y, 0.95, space);
            containers.Add(container);

            drawable_area = new DrawableArea(0.17, image_size);
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawImageFromAssembly("math-games.svg", 0, 0, image_size, image_size);
            };

            drawable_area = new DrawableArea(0.75, space);
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawStringWithWrapping(0, 0,
                                                 Translations.GetString("Mental calculation. Arithmetical operations that test your mental calculation abilities."),
                                                 e.Width);
            };

            /* Memory */
            y        += space;
            container = new HorizontalContainer(0.05, y, 0.95, space);
            containers.Add(container);

            drawable_area = new DrawableArea(0.17, image_size);
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawImageFromAssembly("memory-games.svg", 0, 0, image_size, image_size);
            };

            drawable_area = new DrawableArea(0.75, space);
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawStringWithWrapping(0, 0,
                                                 Translations.GetString("Memory trainers. To prove your short term memory."),
                                                 e.Width);
            };

            /* Verbal */
            y        += space;
            container = new HorizontalContainer(0.05, y, 0.95, space);
            containers.Add(container);

            drawable_area = new DrawableArea(0.17, image_size);
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawImageFromAssembly("verbal-games.svg", 0, 0, image_size, image_size);
            };

            drawable_area = new DrawableArea(0.75, space);
            container.AddChild(drawable_area);
            drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
            {
                e.Context.DrawStringWithWrapping(0, 0,
                                                 Translations.GetString("Verbal analogies. Challenge your verbal aptitude."),
                                                 e.Width);
            };
        }