예제 #1
0
    // Initializes the game
    void InitGame()
    {
        Items.Start();
        Jobs.Start();
        Dialogue.Start();

        // Draw the textbox
        textbox = Instantiate(textbox, new Vector3(4.5f, 0.5f, 0f), Quaternion.identity) as GameObject;
        textManager = textbox.GetComponent<Textbox>();
        textManager.Draw();

        // Create the map
        map = Instantiate(map, new Vector3(5.5f, 5.5f, 0), Quaternion.identity) as GameObject;
        mapManager = map.GetComponent<MapManager>();
        mapManager.textbox = textManager;
        mapManager.SetupScene();

        // Where are we on the map?
        int mapX = Random.Range(0, 10);
        int mapY = Random.Range(0, 10);
        Vector3 tile = mapManager.map[mapX][mapY].EmptyLocation();
        while (tile.x == -1)
            tile = mapManager.map[mapX][mapY].EmptyLocation();

        // Create the player
        player = Instantiate(player, new Vector3(tile.x, tile.y, 10f), Quaternion.identity) as GameObject;
        playerManager = player.GetComponent<Player>();
        playerManager.map = mapManager;
        playerManager.textbox = textManager;
        playerManager.PlaceAt(mapX, mapY, (int)tile.x, (int)tile.y, (int)(10 - tile.y));

        // Draw our area on the map
        mapManager.player = playerManager;
        mapManager.Draw(playerManager.mapX, playerManager.mapY);
    }
예제 #2
0
 public GameObject CreateTutorialBox(string message, Textbox.TutorialBoxPosition position = Textbox.TutorialBoxPosition.MIDDLE, float destroyTimer = -1, bool transparent=false, bool standalone=false)
 {
     if (activeTutorialBox != null && !standalone)
     {
         Destroy(activeTutorialBox);
     }
     GameObject dialog = (GameObject)Instantiate(dialogueContainer, dialogueContainer.transform.position, Quaternion.identity);
     StartCoroutine(dialog.GetComponent<Textbox>().DrawTutorialBox(Textbox.ColorTutorialKeyword(message), destroyTimer, position, transparent));
     if (!standalone)
     {
         activeTutorialBox = dialog;
     }
     return dialog;
 }
예제 #3
0
    public static MvcHtmlString UxTextbox(this HtmlHelper helper,
		string text,
		string placeholder = null,
		bool multiLine = false,
		int? rows = null,
		TextboxSize size = null,
		GridSize gridSize = null,
		string width = null,
		string height = null,
		string helpText = null,
		string clientId = null)
    {
        var textbox = new Textbox(text, placeholder,
            multiLine, rows, size, gridSize,
            width, height, helpText, clientId);
        return helper.RenderUxControl(textbox);
    }
예제 #4
0
        private Rdl.TextboxType CreateTextbox(string fieldName,bool hidden)
        {
            Textbox box = new Textbox();
            var style = new Style
            {
                FontSize = "9pt",
                FontWeight = "Bold",
                FontFamily = "宋体"
            };
            box.Paragraphs = Common.Report.RdlGenerator.CreateParagraphs(fieldName, style.Create());
            if (hidden)
            {
                box.Visibility = new Visibility() { Hidden = "true" }.Create();
            }

            box.Style = new Style
            {
                Border = new Border { Style = "Solid" }.Create()
            }.Create();
            box.CanGrow = true;
            string name = "Header_" + Seed;
            Seed++;
            return box.Create(name);
        }
예제 #5
0
        private Rdl.TextboxType CreateHeaderTableCellTextbox(string fieldName)
        {
            Textbox box = new Textbox();
            var style=new Style
            {
                FontSize = "9pt",
                FontWeight = "Bold",
                FontFamily="����"
            };
            box.Paragraphs = RdlGenerator.CreateParagraphs(fieldName, style.Create());

            box.Style = new Style
            {
                Border = new Border { Style = "Solid" }.Create()
            }.Create();
            box.CanGrow = true;
            return box.Create(m_fields[fieldName] + "_Header");
        }
        public SpecificModConfigMenu(IManifest modManifest)
        {
            mod = modManifest;

            modConfig = Mod.instance.configs[mod];

            table = new Table();
            table.LocalPosition = new Vector2(200 / 2, 82);
            table.Size          = new Vector2(Game1.viewport.Width - 200, Game1.viewport.Height - 64 - 100);
            table.RowHeight     = 50;
            foreach (var opt in modConfig.Options)
            {
                opt.SyncToMod();

                var label = new Label()
                {
                    String = opt.Name
                };
                label.UserData = opt.Description;
                if (opt.Description != null && opt.Description != "")
                {
                    optHovers.Add(label);
                }

                Element other = new Label()
                {
                    String = "TODO", LocalPosition = new Vector2(500, 0)
                };
                Element other2 = null;
                if (opt is ComplexModOption c)
                {
                    var custom = new ComplexModOptionWidget(c);
                    custom.LocalPosition = new Vector2(table.Size.X / 5 * 3, 0);
                    other = custom;
                }
                else if (opt is SimpleModOption <bool> b)
                {
                    var checkbox = new Checkbox();
                    checkbox.LocalPosition = new Vector2(table.Size.X / 3 * 2, 0);
                    checkbox.Checked       = b.Value;
                    checkbox.Callback      = (Element e) => b.Value = (e as Checkbox).Checked;
                    other = checkbox;
                }
                else if (opt is SimpleModOption <SButton> k)
                {
                    var label2 = new Label()
                    {
                        String = k.Value.ToString()
                    };
                    label2.LocalPosition = new Vector2(table.Size.X / 3 * 2, 0);
                    label2.Callback      = (Element e) => doKeybindingFor(k, e as Label);
                    other = label2;
                }
                else if (opt is ClampedModOption <int> ci)
                {
                    var label2 = new Label()
                    {
                        String = ci.Value.ToString()
                    };
                    label2.LocalPosition = new Vector2(table.Size.X / 2 + table.Size.X / 3 + 50, 0);
                    other2 = label2;
                    var slider = new Slider <int>();
                    slider.LocalPosition = new Vector2(table.Size.X / 2, 0);
                    slider.Width         = (int)table.Size.X / 3;
                    slider.Value         = ci.Value;
                    slider.Minimum       = ci.Minimum;
                    slider.Maximum       = ci.Maximum;
                    slider.Interval      = ci.Interval;
                    slider.Callback      = (Element e) =>
                    {
                        ci.Value      = (e as Slider <int>).Value;
                        label2.String = ci.Value.ToString();
                    };
                    other = slider;
                }
                else if (opt is ClampedModOption <float> cf)
                {
                    var label2 = new Label()
                    {
                        String = cf.Value.ToString()
                    };
                    label2.LocalPosition = new Vector2(table.Size.X / 2 + table.Size.X / 3 + 50, 0);
                    other2 = label2;
                    var slider = new Slider <float>();
                    slider.LocalPosition = new Vector2(table.Size.X / 2, 0);
                    slider.Width         = (int)table.Size.X / 3;
                    slider.Value         = cf.Value;
                    slider.Minimum       = cf.Minimum;
                    slider.Maximum       = cf.Maximum;
                    slider.Interval      = cf.Interval;
                    slider.Callback      = (Element e) =>
                    {
                        cf.Value      = (e as Slider <float>).Value;
                        label2.String = cf.Value.ToString();
                    };
                    other = slider;
                }
                else if (opt is ChoiceModOption <string> cs)
                {
                    var dropdown = new Dropdown()
                    {
                        Choices = cs.Choices
                    };
                    dropdown.LocalPosition   = new Vector2(table.Size.X / 7 * 4, 0);
                    dropdown.Value           = cs.Value;
                    dropdown.MaxValuesAtOnce = Math.Min(dropdown.Choices.Length, 5);
                    dropdown.Callback        = (Element e) => cs.Value = (e as Dropdown).Value;
                    other = dropdown;
                }
                // The following need to come after the Clamped/ChoiceModOption's since those subclass these
                else if (opt is SimpleModOption <int> i)
                {
                    var intbox = new Intbox();
                    intbox.LocalPosition = new Vector2(table.Size.X / 5 * 3, 0);
                    intbox.Value         = i.Value;
                    intbox.Callback      = (Element e) => i.Value = (e as Intbox).Value;
                    other = intbox;
                }
                else if (opt is SimpleModOption <float> f)
                {
                    var floatbox = new Floatbox();
                    floatbox.LocalPosition = new Vector2(table.Size.X / 5 * 3, 0);
                    floatbox.Value         = f.Value;
                    floatbox.Callback      = (Element e) => f.Value = (e as Floatbox).Value;
                    other = floatbox;
                }
                else if (opt is SimpleModOption <string> s)
                {
                    var textbox = new Textbox();
                    textbox.LocalPosition = new Vector2(table.Size.X / 5 * 3, 0);
                    textbox.String        = s.Value;
                    textbox.Callback      = (Element e) => s.Value = (e as Textbox).String;
                    other = textbox;
                }
                else if (opt is LabelModOption l)
                {
                    label.LocalPosition = new Vector2(table.Size.X / 2 - label.Font.MeasureString(label.String).X / 2, 0);
                    if (l.Name == "")
                    {
                        label = null;
                    }
                    other = null;
                }

                if (label == null)
                {
                    table.AddRow(new Element[] { });
                }
                else if (other == null)
                {
                    table.AddRow(new Element[] { label });
                }
                else if (other2 == null)
                {
                    table.AddRow(new Element[] { label, other });
                }
                else
                {
                    table.AddRow(new Element[] { label, other, other2 });
                }
            }
            ui.AddChild(table);

            addDefaultLabels(modManifest);

            // We need to update widgets at least once so ComplexModOptionWidget's get initialized
            table.ForceUpdateEvenHidden();

            ActiveConfigMenu = this;
        }
예제 #7
0
    public static void Main()
    {
        HostWindow window = new HostWindow(delegate
        {
            // Create a layer container
            LayerContainer lc = new LayerContainer();

            // Create a form with many buttons
            {
                FlowContainer flow = new FlowContainer(10.0, Axis.Vertical);
                for (int t = 0; t < 40; t++)
                {
                    int i = t + 1;
                    Button b = new Button("Button #" + i.ToString());
                    flow.AddChild(b, 30.0);
                    b.Click += delegate
                    {
                        MessageBox.ShowOKCancel(lc, "Button Clicked!", "You have clicked button #" + i.ToString() + ".", null);
                    };
                }
                Point targetflowsize = new Point(120.0, flow.SuggestLength);
                MarginContainer margin = flow.WithMargin(10.0);
                Point targetmarginsize = margin.GetSize(targetflowsize);
                WindowContainer win = new WindowContainer(margin);
                SunkenContainer sunken = new SunkenContainer(win);
                ScrollContainer scroll = new ScrollContainer(win, sunken.WithBorder(1.0, 1.0, 0.0, 1.0));
                scroll.ClientHeight = targetmarginsize.Y;

                Form form = new Form(scroll, "Lots of buttons");
                form.ClientSize = new Point(targetmarginsize.X + 20.0, 200.0);
                lc.AddControl(form, new Point(30.0, 30.0));
            }

            // Popup test
            {
                Label label = new Label("Right click for popup", Color.RGB(0.0, 0.3, 0.0), new LabelStyle()
                    {
                        HorizontalAlign = TextAlign.Center,
                        VerticalAlign = TextAlign.Center,
                        Wrap = TextWrap.Ellipsis
                    });
                PopupContainer pc = new PopupContainer(label);
                pc.ShowOnRightClick = true;
                pc.Items = new MenuItem[]
                {
                    MenuItem.Create("Do nothing", delegate { }),
                    MenuItem.Create("Remain inert", delegate { }),
                    MenuItem.Create("Make a message box", delegate
                    {
                        MessageBox.ShowOKCancel(lc, "Message Box", "Done", null);
                    }),
                    MenuItem.Seperator,
                    MenuItem.Create("Mouseover me!", new MenuItem[]
                    {
                        MenuItem.Create("Some", delegate { }),
                        MenuItem.Create("Items", delegate { }),
                        MenuItem.Create("Spawn", delegate { }),
                        MenuItem.Create("Another", delegate { }),
                        MenuItem.Create("Popup", delegate { }),
                    }),
                    MenuItem.Seperator,
                    MenuItem.Create("Try", delegate { }),
                    MenuItem.Create("The", delegate { }),
                    MenuItem.Create("Keyboard", delegate { }),
                };

                Form form = new Form(pc.WithAlign(label.SuggestSize, Align.Center, Align.Center).WithBorder(1.0), "Popup Test");
                form.ClientSize = new Point(200.0, 50.0);
                lc.AddControl(form, new Point(230.0, 30.0));
                form.AddCloseButton();
            }

            // Timers and progress bars
            {
                FlowContainer flow = new FlowContainer(10.0, Axis.Vertical);
                Button addbutton = new Button("Add Some");
                Button resetbutton = new Button("Reset");
                Progressbar bar = new Progressbar();
                flow.AddChild(addbutton, 30.0);
                flow.AddChild(resetbutton, 30.0);
                flow.AddChild(bar, 30.0);

                addbutton.Click += delegate
                {
                    bar.Value = bar.Value + 0.05;
                };
                resetbutton.Click += delegate
                {
                    bar.Value = 0.0;
                };

                MarginContainer margin = flow.WithMargin(20.0);

                Form form = new Form(margin.WithBorder(1.0), "Progress bars!");
                form.ClientSize = margin.GetSize(new Point(200.0, flow.SuggestLength)) + new Point(4, 4);
                lc.AddControl(form, new Point(230.0, 150.0));
                form.AddCloseButton();
            }

            // Textbox
            {
                Textbox tb = new Textbox();
                MarginContainer margin = tb.WithMargin(20.0);

                Form form = new Form(margin.WithBorder(1.0), "Change the title of this form!");
                form.ClientSize = margin.GetSize(new Point(400.0, 32.0));
                lc.AddControl(form, new Point(30.0, 360.0));

                tb.TextChanged += delegate(string Text)
                {
                    form.Text = Text;
                };
            }

            return lc;
        }, "Lots of controls");
        window.Run();
    }
예제 #8
0
        /// <summary>
        /// Create report
        /// </summary>
        /// <param name="model">Create report model</param>
        public void CreateReport(CreateReportModel model)
        {
            var ssrs = this.ssrsWrapperProvider.GetReportingServiceWrapper();

            Warning[] warnings;

            Report report = new Report();

            report.Description = model.ReportDescription;

            report.Page.PageWidth  = new ReportSize(280, SizeTypes.Mm);
            report.Page.PageHeight = new ReportSize(210, SizeTypes.Mm);
            report.Width           = new ReportSize(297, SizeTypes.Mm);
            report.Body.Height     = new ReportSize(210, SizeTypes.Mm);

            DataSource dataSource = new DataSource
            {
                Name = "DataSource",
                DataSourceReference = ConfigurationManager.AppSettings["SharedSsrsDataSourceName"]
            };

            report.DataSources.Add(dataSource);

            report.DataSets.Add(new DataSet()
            {
                Name   = "DataSet1",
                Fields = this.ssrsProvider.GetFieldsFromQuery(model.DatabaseName, model.Query),
                Query  = new Query()
                {
                    CommandType    = CommandTypes.Text,
                    CommandText    = string.Format("USE {0}; {1}", model.DatabaseName, model.Query),
                    Timeout        = 30,
                    DataSourceName = report.DataSources[0].Name
                }
            });

            //report.ReportParameters.Add(new ReportParameter()
            //                                {
            //                                    DataType = DataTypes.String,
            //                                    UsedInQuery = UsedInQueryTypes.False,
            //                                    MultiValue = false,
            //                                    Prompt = "?",
            //                                    Name = "TestParameter",
            //                                    AllowBlank = true
            //                                });

            Tablix tablix = new Tablix()
            {
                Name  = "tablix1",
                Width = new ReportSize("250mm"),
                Left  = new ReportSize("3mm")
            };

            tablix.DataSetName = report.DataSets[0].Name;

            var colHeirarcy = new TablixHierarchy();
            var rowHeirarcy = new TablixHierarchy();

            foreach (var field in report.DataSets[0].Fields)
            {
                tablix.TablixBody.TablixColumns.Add(new TablixColumn()
                {
                    Width = new ReportSize(50, SizeTypes.Mm)
                });
            }

            TablixRow header = new TablixRow()
            {
                Height = new ReportSize(8, SizeTypes.Mm)
            };

            foreach (var field in report.DataSets[0].Fields)
            {
                TablixCell cell = new TablixCell();
                Textbox    tbx  = new Textbox();
                tbx.Name = tablix.Name + "_Header_txt" + field.Name.Replace(" ", string.Empty);
                tbx.Paragraphs[0].TextRuns[0].Value = field.Name;
                tbx.Paragraphs[0].TextRuns[0].Style = new Style()
                {
                    FontWeight = new ReportExpression <FontWeights>(FontWeights.Bold),
                    FontSize   = new ReportExpression <ReportSize>("10pt"),
                };

                cell.CellContents = new CellContents()
                {
                    ReportItem = tbx
                };
                header.TablixCells.Add(cell);
                colHeirarcy.TablixMembers.Add(new TablixMember());
            }

            tablix.TablixBody.TablixRows.Add(header);

            TablixRow row = new TablixRow()
            {
                Height = new ReportSize(5, SizeTypes.Mm)
            };

            foreach (var field in report.DataSets[0].Fields)
            {
                TablixCell cell = new TablixCell();

                Textbox tbx = new Textbox();
                tbx.Name = "txt" + field.Name.Replace(" ", string.Empty);
                tbx.Paragraphs[0].TextRuns[0].Value = "=Fields!" + field.Name + ".Value";
                tbx.Paragraphs[0].TextRuns[0].Style = new Style()
                {
                    FontSize = new ReportExpression <ReportSize>("8pt")
                };
                cell.CellContents = new CellContents()
                {
                    ReportItem = tbx
                };
                row.TablixCells.Add(cell);
            }

            tablix.TablixBody.TablixRows.Add(row);
            var mem = new TablixMember()
            {
                KeepTogether = true
            };
            var mem2 = new TablixMember()
            {
                Group = new Group {
                    Name = "Details"
                }
            };

            rowHeirarcy.TablixMembers.Add(mem);
            rowHeirarcy.TablixMembers.Add(mem2);

            tablix.TablixColumnHierarchy = colHeirarcy;
            tablix.TablixRowHierarchy    = rowHeirarcy;

            tablix.Style = new Style()
            {
                Border = new Border()
            };

            report.Body.ReportItems.Add(tablix);

            RdlSerializer serializer = new RdlSerializer();

            using (MemoryStream ms = new MemoryStream())
            {
                serializer.Serialize(ms, report);
                ssrs.CreateCatalogItem("Report", model.ReportName, "/", false, ms.ToArray(), null, out warnings);
            }
        }
예제 #9
0
 public string ProcessTextbox(Textbox textbox)
 {
     return($"Textbox ({textbox.PositionX},{textbox.PositionY}) width={textbox.Width} height={textbox.Height} text=\"{textbox.Text}\"");
 }
예제 #10
0
        /// <summary>
        /// Draws the current form onto the console.
        /// </summary>
        /// <param name="clear">A <see cref="bool">bool</see> indicating whether or
        /// not the screen should be cleared before it is redrawn.</param>
        public void Render(bool clear)
        {
            Console.ResetColor();

            if (clear)
                Console.Clear();

            Console.Title = _name;

            // Resize the window and the buffer to the form's size.
            if (Console.BufferHeight != _height || Console.BufferWidth != _width)
            {
                Console.SetWindowSize(_width, _height);
                Console.SetBufferSize(_width, _height);
            }

            if (Console.WindowHeight != _height || Console.WindowWidth != _width)
            {
                Console.SetBufferSize(_width, _height);
                Console.SetWindowSize(_width, _height);
            }

            // Draw the lines first.
            foreach (Line line in _lines)
            {
                Console.BackgroundColor = line.Colour;

                if (line.Orientation == Line.LineOrientation.Horizontal)
                {
                    // Instructions for drawing a horizontal line.
                    Console.SetCursorPosition(line.Location.X, line.Location.Y);
                    Console.Write(new string(' ', line.Length));
                }
                else
                {
                    // Instructions for drawing a vertical line.
                    int x = line.Location.X;

                    for (int i = line.Location.Y; i < line.Location.Y + line.Length; i++)
                    {
                        Console.SetCursorPosition(x, i);
                        Console.Write(" ");
                    }
                }
            }

            // Draw the labels next.
            foreach (Label label in _labels)
                Refresh(label);

            // Now draw the textboxes.
            foreach (Textbox text in _textboxes)
                Refresh(text);

            // If any textboxes are defined for the form, pick the first one and position
            // the cursor accordingly.
            if (_textboxes.Count > 0)
            {
                _field = _textboxes[0];
                _textboxes.FocusField = _field;
                Console.SetCursorPosition(_field.Location.X + _field.Text.Length, _field.Location.Y);
                Console.CursorVisible = true;
            }
            else
            // Otherwise, hide the cursor.
                Console.CursorVisible = false;

            _labels.Rendered();
            _textboxes.Rendered();

            if (_keyThread.Name == null)
            {
                // Start the thread that listens for keypresses.
                _keyThread.Name = "Keypress loop for " + _name;
                _keyThread.Start();
            }
        }
예제 #11
0
        //创建页眉
        private PageSectionType CreatPageHeader()
        {
            var height = 0.91;
            var lrHeigth = 0.0;
            const double tableHeaderHeigth = 0.0;
            var items = new ArrayList();

            var ctb = new Textbox
            {
                Height = "0.9cm",
                Left = LeftMargin + "mm",
                Width = (A4Width - LeftMargin - RightMargin) + "mm",
                Paragraphs = CreateParagraphs(PageHeaderText, new Style { FontFamily = "宋体", FontSize = "18pt", FontWeight = "Bold", TextAlign = "Center" }.Create()),
                CanGrow = true,
                Style = new Style { FontSize = "18pt", FontWeight = "Bold", TextAlign = "Center" }.Create()
            };

            TextboxType headerTextbox = ctb.Create("Page_HeaderText");
            items.Add(headerTextbox);

            ctb.Width = ((A4Width - LeftMargin - RightMargin) / 2) + "mm";
            ctb.Height = "0.5cm";
            ctb.Paragraphs = CreateParagraphs(PageHeaderLeftText);
            ctb.Style = new Style { FontSize = "9pt", TextAlign = "Left" }.Create();
            ctb.Top = "0.92cm";
            TextboxType headerLeftTextbox = ctb.Create("Page_HeaderLeftText");
            if (!string.IsNullOrEmpty(PageHeaderLeftText))
            {
                items.Add(headerLeftTextbox);
                lrHeigth = 0.5;
            }

            ctb.Style = new Style { FontSize = "9pt", TextAlign = "Right" }.Create();
            ctb.Left = ((A4Width) / 2) + "mm";
            ctb.Paragraphs = CreateParagraphs(PageHeaderRightText);

            TextboxType headerRightTextbox = ctb.Create("Page_HeaderRightText");
            if (!string.IsNullOrEmpty(PageHeaderRightText))
            {
                items.Add(headerRightTextbox);
                lrHeigth = 0.5;
            }

            var reportItems = new ReportItemsType {Items = items.ToArray()};

            var header = new PageSection {ReportItems = reportItems};
            height = height + tableHeaderHeigth + lrHeigth;
            header.Height = height + "cm";
            header.PrintOnFirstPage = true;
            header.PrintOnLastPage = true;
            return header.Create();
        }
예제 #12
0
        //创建页脚
        private PageSectionType CreatPageFooter()
        {
            string height = "0.65cm";
            string top = "0mm";
            var items = new ArrayList();

            var style = new Style {FontSize = "9pt", TextAlign = "Left"};
            var ctb = new Textbox
                          {
                              Width = ((A4Width - LeftMargin - RightMargin)/2) + "mm",
                              Height = "0.63cm",
                              Paragraphs = CreateParagraphs(PageFooterLeftText, style.Create()),
                              Style = style.Create(),
                              CanGrow = true,
                              Left = LeftMargin + "mm"
                          };
            TextboxType headerLeftTextbox = ctb.Create("Page_FooterLeftText");
            if (!string.IsNullOrEmpty(PageFooterLeftText))
            {
                items.Add(headerLeftTextbox);
                height = "1.1cm";
                top = "0.6cm";
            }

            style.TextAlign = "Right";
            ctb.Style = style.Create();
            ctb.Left = ((A4Width) / 2) + "mm";
            ctb.Paragraphs = CreateParagraphs(PageFooterRightText, style.Create());
            TextboxType headerRightTextbox = ctb.Create("Page_FooterRightText");
            if (!string.IsNullOrEmpty(PageFooterRightText))
            {
                items.Add(headerRightTextbox);
                height = "1.1cm";
                top = "0.6cm";
            }

            style.TextAlign = "Center";
            ctb = new Textbox
            {
                Top = top,
                Height = "0.6cm",
                //Left = LeftMargin + "mm",
                Width = (A4Width - LeftMargin - RightMargin) + "mm",
                Paragraphs = CreateParagraphs(string.Format("=" + _pageFooterText, "Globals!PageNumber", "Globals!TotalPages"), style.Create()),
                //Value = string.Format("=" + pageFooterText, "Globals!PageNumber", "Globals!TotalPages"),
                Style = style.Create()
            };
            TextboxType headerTextbox = ctb.Create("Page_FooterText");
            items.Add(headerTextbox);

            var reportItems = new ReportItemsType { Items = items.ToArray() };
            var header = new PageSection
                             {
                                 ReportItems = reportItems,
                                 Height = height,
                                 PrintOnFirstPage = true,
                                 PrintOnLastPage = true
                             };
            return header.Create();
        }
예제 #13
0
        public LoginForm(int width, int height, string name)
            : base(width, height)
        {
            Name = name;

            Label lblTitle = new Label("lblTitle",
                new Point(1, 2),
                10,
                "Login",
                ConsoleColor.Green,
                ConsoleColor.Black);

            Label lblserver = new Label("lblserver",
                new Point(1, 10),
                28,
                "server",
                ConsoleColor.Green,
                ConsoleColor.Black);

            Label lblUsername = new Label("lbluname",
                new Point(1, 12),
                10,
                "Username",
                ConsoleColor.Green,
                ConsoleColor.Black);

            Label lblPass = new Label("lblpass",
                new Point(1, 14),
                10,
                "Password",
                ConsoleColor.Green,
                ConsoleColor.Black);

            Textbox txtServer = new Textbox("txtServer",
                new Point(12, 10),
                30,
                string.Empty,
                ConsoleColor.White,
                ConsoleColor.DarkGray);

            Textbox txtUser = new Textbox("txtUser",
                new Point(12, 12),
                30,
                string.Empty,
                ConsoleColor.White,
                ConsoleColor.DarkGray);

            Textbox txtPassword = new Textbox("txtPass",
                new Point(12, 14),
                30,
                string.Empty,
                ConsoleColor.White,
                ConsoleColor.DarkGray)
            {
                PasswordChar = '*'
            };

            Add(lblTitle);

            Add(lblTitle);
            Add(lblserver);
            Add(lblUsername);
            Add(lblPass);

            Add(txtServer);
            Add(txtUser);
            Add(txtPassword);
        }
예제 #14
0
 /// <summary>
 /// Appends a <see cref="Textbox">Textbox</see> to the list.
 /// </summary>
 /// <param name="t">The <see cref="Textbox">Textbox</see> to add.</param>
 public void Add(Textbox t)
 {
     _textboxes.Add(t);
 }
예제 #15
0
        /// <summary>
        /// Reads Xml when the <see cref="Textboxes">Textboxes</see> is to be deserialized 
        /// from a stream.</summary>
        /// <param name="reader">The stream from which the object will be deserialized.</param>
        void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            if (!reader.IsEmptyElement) {
                while (reader.Read()) {
                    if (reader.NodeType == System.Xml.XmlNodeType.EndElement) {
                        reader.Read();
                        break;
                    }

                    Textbox textbox = new Textbox();

                    ((IXmlSerializable)textbox).ReadXml(reader);
                    _textboxes.Add(textbox);

                    reader.Read();
                }
            } else
                reader.Read();
        }
예제 #16
0
        public MainScreen(IDictionary <Type, object> managers)
            : base(managers)
        {
            _Width      = (int)CluwneLib.Screen.Size.X;
            _Height     = (int)CluwneLib.Screen.Size.Y;
            _background = ResourceManager.GetSprite("mainbg_filler");
            //  _background.Smoothing = Smoothing.Smooth;

            _btnConnect = new ImageButton
            {
                ImageNormal = "connect_norm",
                ImageHover  = "connect_hover"
            };
            _btnConnect.Clicked += _buttConnect_Clicked;

            _btnOptions = new ImageButton
            {
                ImageNormal = "options_norm",
                ImageHover  = "options_hover"
            };
            _btnOptions.Clicked += _buttOptions_Clicked;

            _btnExit = new ImageButton
            {
                ImageNormal = "exit_norm",
                ImageHover  = "exit_hover"
            };
            _btnExit.Clicked += _buttExit_Clicked;

            _txtConnect = new Textbox(100, ResourceManager)
            {
                Text = ConfigurationManager.GetServerAddress()
            };
            _txtConnect.OnSubmit += ConnectTextboxOnSubmit;

            Assembly        assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);

            _lblVersion            = new Label("v. " + fvi.FileVersion, "CALIBRI", ResourceManager);
            _lblVersion.Text.Color = Color.WhiteSmoke;

            _lblVersion.Position = new Point(_Width - _lblVersion.ClientArea.Width - 3,
                                             _Height - _lblVersion.ClientArea.Height - 3);


            _imgTitle = new SimpleImage
            {
                Sprite   = "SpaceStationLogoColor",
                Position = new Point(_Width - 550, 100),
            };

            _lblVersion.Update(0);
            _imgTitle.Update(0);
            _txtConnect.Position = new Point(_imgTitle.ClientArea.Left + 40, _imgTitle.ClientArea.Bottom + 50);
            _txtConnect.Update(0);
            _btnConnect.Position = new Point(_txtConnect.Position.X, _txtConnect.ClientArea.Bottom + 20);
            _btnConnect.Update(0);
            _btnOptions.Position = new Point(_btnConnect.Position.X, _btnConnect.ClientArea.Bottom + 20);
            _btnOptions.Update(0);
            _btnExit.Position = new Point(_btnOptions.Position.X, _btnOptions.ClientArea.Bottom + 20);
            _btnExit.Update(0);
        }
예제 #17
0
        public OptionsOptionControl(ScreenComponent manager, OptionsScreen optionsScreen) : base(manager)
        {
            settings           = manager.Game.Settings;
            this.optionsScreen = optionsScreen;

            ////////////////////////////////////////////Settings Stack////////////////////////////////////////////
            StackPanel settingsStack = new StackPanel(manager)
            {
                Orientation       = Orientation.Vertical,
                VerticalAlignment = VerticalAlignment.Top,
                Padding           = new Border(20, 20, 20, 20),
                Width             = 650
            };

            Controls.Add(settingsStack);

            //////////////////////Viewrange//////////////////////
            string viewrange = settings.Get <string>("Viewrange");

            rangeTitle = new Label(manager)
            {
                Text = Languages.OctoClient.Viewrange + ": " + viewrange
            };
            settingsStack.Controls.Add(rangeTitle);

            Slider viewrangeSlider = new Slider(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Height = 20,
                Range  = 9,
                Value  = int.Parse(viewrange) - 1
            };

            viewrangeSlider.ValueChanged += (value) => SetViewrange(value + 1);
            settingsStack.Controls.Add(viewrangeSlider);


            //////////////////////Persistence//////////////////////
            StackPanel persistenceStack = new StackPanel(manager)
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Border(0, 20, 0, 0)
            };

            settingsStack.Controls.Add(persistenceStack);

            Label persistenceTitle = new Label(manager)
            {
                Text = Languages.OctoClient.DisablePersistence + ":"
            };

            persistenceStack.Controls.Add(persistenceTitle);

            Checkbox disablePersistence = new Checkbox(manager)
            {
                Checked   = settings.Get("DisablePersistence", false),
                HookBrush = new TextureBrush(manager.Game.Assets.LoadTexture(typeof(ScreenComponent), "iconCheck_brown"), TextureBrushMode.Stretch),
            };

            disablePersistence.CheckedChanged += (state) => SetPersistence(state);
            persistenceStack.Controls.Add(disablePersistence);

            //////////////////////Map Path//////////////////////
            StackPanel mapPathStack = new StackPanel(manager)
            {
                Orientation         = Orientation.Vertical,
                Margin              = new Border(0, 20, 0, 0),
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            settingsStack.Controls.Add(mapPathStack);

            mapPath = new Textbox(manager)
            {
                Text                = settings.Get <string>("ChunkRoot"),
                Enabled             = false,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Background          = new BorderBrush(Color.LightGray, LineType.Solid, Color.Gray)
            };
            mapPathStack.Controls.Add(mapPath);

            Button changePath = Button.TextButton(manager, Languages.OctoClient.ChangePath);

            changePath.HorizontalAlignment = HorizontalAlignment.Center;
            changePath.Height          = 40;
            changePath.LeftMouseClick += (s, e) => ChangePath();
            mapPathStack.Controls.Add(changePath);

            //////////////////////Fullscreen//////////////////////
            StackPanel fullscreenStack = new StackPanel(manager)
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Border(0, 20, 0, 0)
            };

            settingsStack.Controls.Add(fullscreenStack);

            Label fullscreenTitle = new Label(manager)
            {
                Text = Languages.OctoClient.EnableFullscreenOnStartup + ":"
            };

            fullscreenStack.Controls.Add(fullscreenTitle);

            Checkbox enableFullscreen = new Checkbox(manager)
            {
                Checked   = settings.Get <bool>("EnableFullscreen"),
                HookBrush = new TextureBrush(manager.Game.Assets.LoadTexture(typeof(ScreenComponent), "iconCheck_brown"), TextureBrushMode.Stretch),
            };

            enableFullscreen.CheckedChanged += (state) => SetFullscreen(state);
            fullscreenStack.Controls.Add(enableFullscreen);

            //////////////////////Auflösung//////////////////////
            StackPanel resolutionStack = new StackPanel(manager)
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Border(0, 20, 0, 0)
            };

            settingsStack.Controls.Add(resolutionStack);

            Label resolutionTitle = new Label(manager)
            {
                Text = Languages.OctoClient.Resolution + ":"
            };

            resolutionStack.Controls.Add(resolutionTitle);

            Textbox resolutionWidthTextbox = new Textbox(manager)
            {
                Text       = settings.Get <string>("Width"),
                Width      = 50,
                Background = new BorderBrush(Color.LightGray, LineType.Solid, Color.Gray)
            };

            resolutionWidthTextbox.TextChanged += ResolutionWidthTextbox_TextChanged;
            resolutionStack.Controls.Add(resolutionWidthTextbox);

            Label xLabel = new Label(manager)
            {
                Text = "x"
            };

            resolutionStack.Controls.Add(xLabel);

            Textbox resolutionHeightTextbox = new Textbox(manager)
            {
                Text       = settings.Get <string>("Height"),
                Width      = 50,
                Background = new BorderBrush(Color.LightGray, LineType.Solid, Color.Gray)
            };

            resolutionHeightTextbox.TextChanged += ResolutionHeightTextbox_TextChanged;
            resolutionStack.Controls.Add(resolutionHeightTextbox);

            Label pxLabel = new Label(manager)
            {
                Text = Languages.OctoClient.Pixels
            };

            resolutionStack.Controls.Add(pxLabel);
        }
예제 #18
0
        public void SetFocus(Textbox field)
        {
            for (int i = 0; i < _textboxes.Count; i++)
                if (_textboxes[i] == field)
                {
                    _field = Textboxes[i];
                    _currentField = i;

                    Console.ForegroundColor = _field.Foreground;
                    Console.BackgroundColor = _field.Background;
                    Console.SetCursorPosition(_field.Location.X + _field.Text.Length, _field.Location.Y);

                    return;
                }

            throw new InvalidOperationException(field.Name + " not found.");
        }
예제 #19
0
        public MainScreen(IDictionary <Type, object> managers) : base(managers)
        {
            _Width      = (int)CluwneLib.Screen.Size.X;
            _Height     = (int)CluwneLib.Screen.Size.Y;
            _background = ResourceCache.GetSprite("coderart");


            _btnConnect = new ImageButton
            {
                ImageNormal = "connect_norm",
                ImageHover  = "connect_hover"
            };
            _btnConnect.Clicked += _buttConnect_Clicked;

            _btnOptions = new ImageButton
            {
                ImageNormal = "options_norm",
                ImageHover  = "options_hover"
            };
            _btnOptions.Clicked += _buttOptions_Clicked;

            _btnExit = new ImageButton
            {
                ImageNormal = "exit_norm",
                ImageHover  = "exit_hover"
            };
            _btnExit.Clicked += _buttExit_Clicked;

            _txtConnect = new Textbox(100, ResourceCache)
            {
                Text = ConfigurationManager.GetCVar <string>("net.server")
            };
            _txtConnect.Position  = new Vector2i(_Width / 3, _Height / 2);
            _txtConnect.OnSubmit += ConnectTextboxOnSubmit;

            Assembly        assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);

            _lblVersion            = new Label("v. " + fvi.FileVersion, "CALIBRI", ResourceCache);
            _lblVersion.Text.Color = new SFML.Graphics.Color(245, 245, 245);

            _lblVersion.Position = new Vector2i(_Width - _lblVersion.ClientArea.Width - 3,
                                                _Height - _lblVersion.ClientArea.Height - 3);


            _imgTitle = new SimpleImage
            {
                Sprite   = "SpaceStationLogoColor",
                Position = new Vector2i(_Width - 550, 100),
            };

            _lblVersion.Update(0);
            _imgTitle.Update(0);
            _txtConnect.Position = new Vector2i(_imgTitle.ClientArea.Left + 40, _imgTitle.ClientArea.Bottom() + 50);
            _txtConnect.Update(0);
            _btnConnect.Position = new Vector2i(_txtConnect.Position.X, _txtConnect.ClientArea.Bottom() + 20);
            _btnConnect.Update(0);
            _btnOptions.Position = new Vector2i(_btnConnect.Position.X, _btnConnect.ClientArea.Bottom() + 20);
            _btnOptions.Update(0);
            _btnExit.Position = new Vector2i(_btnOptions.Position.X, _btnOptions.ClientArea.Bottom() + 20);
            _btnExit.Update(0);
        }
예제 #20
0
        /// <summary>
        /// A method that loops and processes keystrokes until the form is complete, 
        /// either by <see cref="FormComplete">FormComplete</see> or 
        /// <see cref="FormCancelled">FormCancelled</see> events.
        /// </summary>
        private void LoopForKeypress()
        {
            // Loop for keypresses.  Since we're doing all the work of processing, we have
            // to trap special keypresses and respond appropriately
            while (true)
            {
                // Blocks on the next function call.
                ConsoleKeyInfo cki = Console.ReadKey(true);

                ConsoleKey nKey = cki.Key;

                // A key's been pressed.  Figure out what to do.
                // All actions will be against the current field, stored in _field.
                char cChar = cki.KeyChar;

                if (cChar != 0)
                {
                    // Guard against unprintable chars.
                    KeyPressEventArgs kpea = new KeyPressEventArgs(_field, cChar);

                    if (_keyPressEvent != null)
                        _keyPressEvent(this, kpea);

                    if (!kpea.Cancel)
                    {
                        // Process the keystroke.  It wasn't cancelled.
                        switch (nKey)
                        {
                            case ConsoleKey.Backspace: // Backspace pressed
                                // Is there a character to backspace over?
                                if (_field.Text.Length > 0)
                                {
                                    _field.Text = _field.Text.Substring(0, _field.Text.Length - 1);
                                    Refresh(_field);
                                }

                                break;

                            case ConsoleKey.Tab: // Tab -> Move to the next field.
                                if (cki.Modifiers == ConsoleModifiers.Shift)
                                {
                                    // Go backwards.
                                    _currentField--;

                                    // If we're at the first field, move to the last.
                                    if (_currentField == -1)
                                        _currentField = _textboxes.Count - 1;
                                }
                                else
                                {
                                    // Go forwards
                                    _currentField++;

                                    // If we're in the last field already, move back to the first.
                                    if (_currentField == _textboxes.Count)
                                        _currentField = 0;
                                }

                                // Set the current field to the next one in the collection.
                                _field = _textboxes[_currentField];
                                _textboxes.FocusField = _field;

                                // Move the cursor to the location of the next field, accomodating
                                // any text that may already be there..
                                Console.SetCursorPosition(_field.Location.X + _field.Text.Length, _field.Location.Y);
                                break;

                            case ConsoleKey.Enter: // Enter -> Fire the complete event if it's wired.
                                if (_formCompleteEvent != null)
                                {
                                    FormCompleteEventArgs fcea = new FormCompleteEventArgs();

                                    _formCompleteEvent(this, fcea);

                                    // The listener of this event will set the Cancel field if they
                                    // want to re-use the form.  If not cancelled, the form will
                                    // be destroyed.
                                    if (!fcea.Cancel)
                                    {
                                        return;
                                    } // else the current form will be reused.  Go back for more keys.
                                }

                                break;

                            case ConsoleKey.Escape: // Esc -> Fire the cancelled event if it's wired.
                                if (this.FormCancelled != null)
                                {
                                    this.FormCancelled(this, System.EventArgs.Empty);
                                    return;
                                }

                                break;

                            default: // Any other keystroke
                                if (_field != null)
                                {
                                    // May not be an active textbox.
                                    if (_field.Text.Length < _field.Length)
                                    {
                                        // The field is not yet full.  It can be appended to.
                                        _field.NonEventingText += cChar;
                                        Console.ForegroundColor = _field.Foreground;
                                        Console.BackgroundColor = _field.Background;

                                        if (_field.PasswordChar != char.MinValue)
                                            // It's a password field.  Display the password character.
                                            Console.Write(_field.PasswordChar);
                                        else
                                        // Not a password type field.  Show the actual character.
                                            Console.Write(cChar);
                                    } // Field already full => no keystrokes accepted.
                                }
                                break;
                        } // Keystroke was not cancelled
                    } // Character was printable
                } // End of switch statement
            } // End loop for keypresses
        }
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            background = Content.Load<Texture2D>("fond");
            _font = Content.Load<SpriteFont>("DF");
            _font2 = Content.Load<SpriteFont>("DFsmall");
            textbox = new Textbox(
            GraphicsDevice,
            400,
            Content.Load<SpriteFont>("DFsmall"))
            {
                ForegroundColor = Color.Blue,
                BackgroundColor = Color.White,
                Position = new Vector2((game.size_window.X / 2) - 400 / 2, 160),
                HasFocus = true
            };

            BigBangChaosGame.TabScore.HighScoreData data = tab.LoadHighScores(tab.HighScoresFilename);
            score = (int)game.distance;
            int scoreIndex = -1;
            for (int i = data.Count - 1; i > -1; i--)
            {
                if (score >= data.Score[i])
                {
                    scoreIndex = i;
                }
            }
            if (scoreIndex > -1)
            {
                showTextbox = true;
            }
            texthighscore = tab.makeHighScoreString(data);
            soundHightScore = Content.Load<SoundEffect>("Sounds/highscore_v1.0");
        }
예제 #22
0
 /// <summary>
 /// Constructor called to initialize the event args with the key pressed by the user.
 /// </summary>
 /// <param name="c"></param>
 public KeyPressEventArgs(Textbox field, char c)
 {
     _field = field;
     _char = c;
 }
예제 #23
0
 private void Textbox_Click(object sender, EventArgs e)
 {
     Textbox.Focus();
 }
예제 #24
0
        public override void update(GameTime gameTime)
        {
            if (Controller.KeyPressed(Keys.Space))
                SceneManagement.SceneManager.setScene(new Scenes.PreviewScreen(), true);

            line.Update(gameTime);
            if (coracaoDesenhado)
            {
                heart.Update(gameTime);
            }
            // Controle da pausa
            if (fraseAtual != 3 && fraseAtual != 4 && fraseAtual != 5 && fraseAtual != 7 && fraseAtual != 8 && fraseAtual != 9)
            {
                contadorNextTexto--;

                if (contadorNextTexto == 0)
                {
                    contadorNextTexto = 300;

                    if (fraseAtual == 11 || fraseAtual == 10)
                    {
                        fraseAtual = 12;
                        caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[12], 10, 20);
                    }

                    else if (fraseAtual == 12)
                    {
                        SceneManagement.SceneManager.setScene(new Scenes.PreviewScreen(), true);
                    }

                    else
                    {
                        fraseAtual++;
                        caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[fraseAtual], 10, 20);
                    }

                }
            }
            // O que acontece com cada frase que foge da pausa
            else
            {
                if (fraseAtual == 3)
                {
                    if (coracaoDesenhado == false)
                    {
                        heart.lastTimePressed = Game1.currentTime;
                    }

                    coracaoDesenhado = true;

                    heart.decayFactor = 0;

                    if (Controller.KeyPressed(Keys.A))
                    {
                        fraseAtual++;
                        caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[fraseAtual], 10, 20);
                    }
                }

                else if (fraseAtual == 4)
                {
                    if (Controller.KeyPressed(Keys.S) || (Controller.KeyPressed(Keys.L)))
                    {
                        fraseAtual++;
                        caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[fraseAtual], 10, 20);
                    }
                }

                else if (fraseAtual == 5)
                {
                    if (heart.lastPattern == Heart.HeartPattern.Regular)
                    {
                        fraseAtual++;
                        heart.lastPattern = Heart.HeartPattern.None;
                        caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[fraseAtual], 10, 20);
                    }

                }

                else if (fraseAtual == 7)
                {
                    heart.lastTimePressed = Game1.currentTime;

                    if (contadorTentativa == 0)
                    {
                        if (heart.heartSpeed > 100 && heart.heartSpeed < 150)
                        {
                            contadorTentativa = 900;
                            heart.decayFactor = 1;
                            fraseAtual++;
                            caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[fraseAtual], 10, 20);
                        }

                        else if (heart.heartSpeed > 150 || heart.heartSpeed < 20)
                        {
                            CenaManagement.CenaBase.matarHeroi("tutorial");
                        }

                        else
                        {
                            contadorTentativa = 900;
                            caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[fraseAtual], 10, 20);
                        }

                    }

                    else
                    {
                        heart.decayFactor = 0;
                        contadorTentativa--;
                    }

                }

                else if (fraseAtual == 8)
                {
                    heart.lastTimePressed = Game1.currentTime;
                    if (contadorTentativa == 0)
                    {

                        if (heart.heartSpeed > 20 && heart.heartSpeed < 70)
                        {
                            contadorTentativa = 420;
                            heart.decayFactor = 0;
                            fraseAtual++;
                            caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[fraseAtual], 10, 20);

                        }

                        else if (heart.heartSpeed > 150 || heart.heartSpeed < 20)
                        {
                            CenaManagement.CenaBase.matarHeroi("tutorial");
                        }

                        else
                        {
                            contadorTentativa = 900;
                            caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[fraseAtual], 10, 20);
                        }

                    }

                    else
                    {
                        //heart.decayFactor = 1;
                        contadorTentativa--;
                    }

                }

                else if (fraseAtual == 9)
                {
                    heart.lastTimePressed = Game1.currentTime;

                    if ((!heart.autoPilot) && (heart.decayFactor == 0))
                        heart.StartAutoPilot(gameTime);

                    if (Controller.KeyPressed(Keys.Enter) && heart.decayFactor == 0)
                    {
                        heart.decayFactor = 1;
                        heart.EndAutoPilot();
                        textoLido = true;

                    }

                    if (heart.decayFactor == 1)
                    {
                        if (contadorTentativa == 0)
                        {
                            if (heart.heartSpeed > 100 && heart.heartSpeed < 150)
                            {
                                contadorTentativa = 600;
                                heart.decayFactor = 0;
                                fraseAtual = 11;
                                caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[fraseAtual], 10, 20);
                            }

                            if (heart.heartSpeed > 20 && heart.heartSpeed < 100)
                            {
                                contadorTentativa = 600;
                                heart.decayFactor = 0;
                                fraseAtual = 10;
                                caixaTexto = new Textbox(800, new Vector2(100, 100), listaStrings[fraseAtual], 10, 20);
                            }

                            else if (heart.heartSpeed > 150 || heart.heartSpeed < 20)
                            {
                                CenaManagement.CenaBase.matarHeroi("tutorial");
                            }

                        }

                        else
                        {
                            heart.decayFactor = 1;
                            contadorTentativa--;
                        }
                    }

                }
            }

            caixaTexto.Update(gameTime);
        }
        public void CreateTextbox_WriteOutputWithNoSample_FormatCorrect()
        {
            var textbox = new Textbox(5, 5, 200, 100);

            Assert.AreEqual("Textbox (5,5) width=200 height=100", textbox.WriteOutput());
        }
예제 #26
0
        public override void start()
        {
            Self = this;
            listaStrings = new List<string>();
            listaStrings.Add("Hey... are you there?");
            listaStrings.Add("It's time to wake up, can you do that?");
            listaStrings.Add("I see, you can't do anything right now...");
            listaStrings.Add("I will help you then. Press 'A' to control the first beat of your heart.");
            listaStrings.Add("Nice! But that is not good enough to wake you up. Press 'S' or 'L' to control the second beat of your heart.");
            listaStrings.Add("Awesome! Now is the time. Press 'A' Then Press 'S' or 'L' alternately, in a heartbeat rhythm. That should do it.");
            listaStrings.Add("Perfect! I think it's working, soon you will be awake for good. I have one last thing to teach you. It's the most important thing you have to do now before you awake.");
            listaStrings.Add("Something is wrong with your body. If the beat is too fast, you will make tense and stressed choices... Try to stress your heart now.. But not too much ! Otherwise you will have a heart attack and well... die.");
            listaStrings.Add("Awesome! In the other hand, if the beat is too slow, you will make controlled and sensible choices... Now, Try to calm your heart down. But not too much ! Otherwise you will have a cardiac arrest and also die.");
            listaStrings.Add("Perfect! It seems a little tough right now, but you will get used to it. When you see 'Reading' on the screen, you can take your time to read the text. Press 'Enter' when you are done to go to the next step.  When you see 'Follow your heart' on the monitor, a decision has to be made. You will have to control your heartbeat.");
            listaStrings.Add("Great! You remained calm even with all those news. This is a good Sign!");
            listaStrings.Add("Wow! You're already stressed. Calm down my friend! There are a lot of things yet to come. This is just the beginning.");
            listaStrings.Add("You're awaking now. I can't help you anymore because of reasons you will not understand. Good Luck and stay alive!");

            backRender = new RenderTarget2D(Game1.Self.GraphicsDevice, Game1.GameRactangle.Width, Game1.GameRactangle.Height);

            SoundManager.StopMusic();

            avisoReading = new Objeto2D(Game1.Self.Content.Load<Texture2D>("reading"));
            avisoReading.position.X = 500;
            avisoReading.position.Y = 425;

            avisoFollow = new Objeto2D(Game1.Self.Content.Load<Texture2D>("follow_your_heart"));
            avisoFollow.position.X = 500;
            avisoFollow.position.Y = 425;

            fundo = new Objects.Objeto2D(Game1.Self.Content.Load<Texture2D>("fundoGame"));
            fundo.position.X = Game1.Self.Window.ClientBounds.Width / 2;
            fundo.position.Y = Game1.Self.Window.ClientBounds.Height / 2;

            heart = new DumativaHeart.Objects.Heart();
            line = new Line();

            contadorTentativa = 600;
            contadorNextTexto = 240;
            fraseAtual = 0;

            textoLido = false;

            filtro = new Objeto2D(Game1.Self.Content.Load<Texture2D>("filtro vermelho"));
            //filtro.position.X = Game1.Self.Window.ClientBounds.Width / 2;
            //filtro.position.Y = Game1.Self.Window.ClientBounds.Height / 2;

            caixaTexto = new Textbox(800, new Vector2(100, 200), listaStrings[fraseAtual], 10, 20);
            font = Game1.Self.Content.Load<SpriteFont>("OCR");
            fontDecisao = Game1.Self.Content.Load<SpriteFont>("fontDecisao");
        }
예제 #27
0
        public void start(int indexCena)
        {
            this.indexCena = indexCena;
            fundoGame = new Objects.Objeto2D(Game1.Self.Content.Load<Texture2D>("fundoGame"));
            fundoGame.position.X = Game1.Self.Window.ClientBounds.Width / 2;
            fundoGame.position.Y = Game1.Self.Window.ClientBounds.Height / 2;

            heart = new DumativaHeart.Objects.Heart();

            avisoReading = new Objeto2D(Game1.Self.Content.Load<Texture2D>("reading"));
            avisoReading.position.X = 500;
            avisoReading.position.Y = 425;

            avisoFollow = new Objeto2D(Game1.Self.Content.Load<Texture2D>("follow_your_heart"));
            avisoFollow.position.X = 500;
            avisoFollow.position.Y = 425;

            contadorTempo = 600;
            Save.lerXml(indexCena);
            caixaTexto = new Textbox(800, new Vector2(100, 200), Save.textoAtual, 10, 20);
            fontDecisao = Game1.Self.Content.Load<SpriteFont>("fontDecisao");
            heart.autoPilot = true;

            font = Game1.Self.Content.Load<SpriteFont>("OCR");
            line = new Line();

            backRender = new RenderTarget2D(Game1.Self.GraphicsDevice, Game1.GameRactangle.Width, Game1.GameRactangle.Height);
        }
예제 #28
0
 IEnumerator Slide_Coroutine(TutorialManager.Slide slide, bool hideMenu=true, Textbox.TutorialBoxPosition boxPos=Textbox.TutorialBoxPosition.BOTTOM)
 {
     if (hideMenu)
     {
         GameManager.instance.transform.Find("Menu_layout").gameObject.SetActive(false);
     }
     GameObject.Find("Canvas/Slide").gameObject.GetComponent<Image>().sprite = Resources.Load<Sprite>(slide.imageName);
     if (slide.text != null && slide.text != "")
     {
         yield return new WaitForSeconds(1f);
         CreateTutorialBox(slide.text, boxPos, slide.timer - 1f);
         yield return null;
     }
     yield return new WaitForSeconds(slide.timer);
 }
예제 #29
0
 protected override void Initialize()
 {
     base.Initialize();
     help = new InputHelper();
     players = new List<Player>();
     p1 = new KeyboardPlayer(Content.Load<Texture2D>("p1"), new Rectangle(300, 300, 50, 50));
     p2 = new GamepadPlayer(Content.Load<Texture2D>("p2"), new Rectangle(300, 350, 50, 50));
     players.Add(p1);
     players.Add(p2);
     r = new Room("deer", 10, 10, Content.Load<Texture2D>("tileset"));
     levelName = new Textbox(font, "deer", Color.White, Vector2.Zero);
 }
예제 #30
0
        static void Main(string[] args)
        {
            var mainPanel = new Panel();
            mainPanel.Name = "mainPanle";
            mainPanel.Width = Application.STANDARD_ROOT_BOUNDARY.Width - 12;
            mainPanel.Height = Application.STANDARD_ROOT_BOUNDARY.Height - 6;
            mainPanel.Top = 3;
            mainPanel.Left = 6;

            #region Left Side
            var leftBox = new Groupbox();
            leftBox.Name = "leftBox";
            leftBox.Header = "Left Box";
            leftBox.Top = leftBox.Left = 0;
            leftBox.Width = mainPanel.Width / 2;
            leftBox.Height = mainPanel.Height;

            var lblLeftStatus = new Label("Status:");
            lblLeftStatus.Name = "lblLeftStatus";

            lblLeftStatusText = new Label();
            lblLeftStatusText.Name = "lblLeftStatusText";
            lblLeftStatusText.Left = lblLeftStatus.Text.Length;
            lblLeftStatusText.Width = leftBox.Width - lblLeftStatus.Width;
            lblLeftStatusText.Align = ContentAlign.Right;

            var btnLeftIncrement = new Button("Increment");
            btnLeftIncrement.Top = 1;
            btnLeftIncrement.Name = "btnLeftIncrement";
            btnLeftIncrement.Pressed += BtnLeftIncrementOnPressed;

            var btnLeftClear = new Button("Clear");
            btnLeftClear.Top = 2;
            btnLeftClear.Name = "btnLeftClear";
            btnLeftClear.Pressed += (sender, eventArgs) => lblLeftStatusText.Text = "";

            var txtLeftText = new Textbox();
            txtLeftText.Text = "asd123";
            txtLeftText.Top = 3;
            txtLeftText.Left = 21;
            txtLeftText.Width = 10;
            txtLeftText.BackColor = ConsoleColor.Gray;
            txtLeftText.ForeColor = ConsoleColor.Black;
            txtLeftText.Name = "txtLeftText";
            txtLeftText.EnterPressed += (sender, eventArgs) => lblLeftStatusText.Text = txtLeftText.Text;

            var btnLeftSetText = new Button("Set this text =>");
            btnLeftSetText.Top = 3;
            btnLeftSetText.Name = "btnLeftSetText";
            btnLeftSetText.Pressed += (sender, eventArgs) => lblLeftStatusText.Text = txtLeftText.Text;

            var chkLeftMoveDir = new Checkbox("Move button up");
            chkLeftMoveDir.Top = 5;
            chkLeftMoveDir.Left = 12;
            chkLeftMoveDir.Name = "chkLeftMoveDir";
            chkLeftMoveDir.Checked = CheckState.Unchecked;

            var prgLeftMoveButton = new Progressbar();
            prgLeftMoveButton.Top = 6;
            prgLeftMoveButton.Left = 12;
            prgLeftMoveButton.Name = "prgLeftMoveButton";
            prgLeftMoveButton.Width = chkLeftMoveDir.Text.Length + 4;
            prgLeftMoveButton.Value = 10;

            var lblLeftPrgDesc = new Label(@"^ Progressbar ^");
            lblLeftPrgDesc.Top = 7;
            lblLeftPrgDesc.Left = 14;
            lblLeftPrgDesc.Name = "lblLeftPrgDesc";

            var myPlayground = new Playground(7, 14);
            myPlayground.Name = "playground";
            myPlayground.Top = 9;
            myPlayground.Left = 14;
            myPlayground.BackColor = ConsoleColor.Blue;
            myPlayground.ForeColor = ConsoleColor.Red;
            myPlayground[0, 0] = 'x';
            myPlayground[2, 2] = 'x';
            myPlayground[4, 4] = 'x';
            myPlayground[6, 6] = 'o';
            myPlayground[4, 8] = 'x';
            myPlayground[2, 10] = 'x';
            myPlayground[0, 12] = 'x';

            var btnLeftMove = new Button("Move");
            btnLeftMove.Top = 4;
            btnLeftMove.Name = "btnLeftMove";
            btnLeftMove.Pressed += (sender, eventArgs) =>
                {
                    var mv = chkLeftMoveDir.Checked == CheckState.Checked ? -1 : 1;
                    if(btnLeftMove.Top + mv < btnLeftMove.Container.Height - 3 &&
                       btnLeftMove.Top + mv > 3)
                        btnLeftMove.Top += mv;
                    prgLeftMoveButton.Value = (int)(((btnLeftMove.Top - 2) / (float)(btnLeftMove.Container.Height - 6)) * 100);
                };

            leftBox.Add(lblLeftStatus);
            leftBox.Add(lblLeftStatusText);
            leftBox.Add(btnLeftIncrement);
            leftBox.Add(btnLeftClear);
            leftBox.Add(btnLeftSetText);
            leftBox.Add(txtLeftText);
            leftBox.Add(btnLeftMove);
            leftBox.Add(chkLeftMoveDir);
            leftBox.Add(prgLeftMoveButton);
            leftBox.Add(lblLeftPrgDesc);
            leftBox.Add(myPlayground);
            #endregion

            #region Right Side
            var rightBox = new Groupbox();
            rightBox.Name = "rightBox";
            rightBox.Header = "Right Box";
            rightBox.Top = 0;
            rightBox.Left = mainPanel.Width / 2;
            rightBox.Width = mainPanel.Width / 2;
            rightBox.Height = mainPanel.Height;

            var rightRightBox = new Groupbox();
            rightRightBox.Name = "rightRightBox";
            rightRightBox.Header = "Checkbox!";
            rightRightBox.Top = 1;
            rightRightBox.Width = rightBox.Width / 2 - 2;
            rightRightBox.Height = 8;
            for (int i = 0; i < 4; i++)
                rightRightBox.Add(new Checkbox("Foo" + i) { Name = "foo" + i, Top = i });

            var rightLeftBox = new Groupbox();
            rightLeftBox.Name = "rightLeftBox";
            rightLeftBox.Header = "Radiobutton!";
            rightLeftBox.Top = 1;
            rightLeftBox.Left = rightBox.Width / 2 - 2;
            rightLeftBox.Width = rightBox.Width / 2 + 2;
            rightLeftBox.Height = 8;
            for (int i = 0; i < 4; i++)
                rightLeftBox.Add(new RadioButton("Bar" + i) { Name = "bar" + i, Top = i });

            var lblRightRadioDesc = new Label("Radiobuttons can have groups:");
            lblRightRadioDesc.Top = rightLeftBox.Height + 2;
            lblRightRadioDesc.Name = "lblDesc";
            for (int i = 0; i < 6; i++)
                rightBox.Add(new RadioButton("asd" + i) { Text = "Group" + (i / 3),
                                                          Name = "chk" + i.ToString(),
                                                          Top = (i % 3) + rightRightBox.Height + 3,
                                                          Left = (i / 3) * 15 + 2,
                                                          ComboboxGroup = "grp" + (i / 3) });

            rightBox.Add(rightRightBox);
            rightBox.Add(rightLeftBox);
            rightBox.Add(lblRightRadioDesc);
            #endregion

            mainPanel.Add(leftBox);
            mainPanel.Add(rightBox);

            var app = new Application(mainPanel);
            app.FocusManager = new FocusManager(mainPanel, btnLeftIncrement);
            app.Name = "FoggyConsole";
            app.Run();
        }
예제 #31
0
        public SplitScreen(BaseScreenComponent manager) : base(manager)
        {
            Background = new BorderBrush(Color.Gray);                               //Hintergrundfarbe festlegen

            Button backButton = Button.TextButton(manager, "Back");                 //Neuen TextButton erzeugen

            backButton.HorizontalAlignment = HorizontalAlignment.Left;              //Links
            backButton.VerticalAlignment   = VerticalAlignment.Top;                 //Oben
            backButton.LeftMouseClick     += (s, e) => { manager.NavigateBack(); }; //KlickEvent festlegen
            Controls.Add(backButton);                                               //Button zum Screen hinzufügen



            //ScrollContainer
            ScrollContainer scrollContainer = new ScrollContainer(manager)  //Neuen ScrollContainer erzeugen
            {
                VerticalAlignment   = VerticalAlignment.Stretch,            // 100% Höhe
                HorizontalAlignment = HorizontalAlignment.Stretch           //100% Breite
            };

            Controls.Add(scrollContainer);                                  //ScrollContainer zum Root(Screen) hinzufügen



            //Stackpanel - SubControls werden Horizontal oder Vertikal gestackt
            StackPanel panel = new StackPanel(manager);                 //Neues Stackpanel erzeugen

            panel.VerticalAlignment = VerticalAlignment.Stretch;        //100% Höhe
            scrollContainer.Content = panel;                            //Ein Scroll Container kann nur ein Control beherbergen
            panel.ControlSpacing    = 20;

            //Label
            Label label = new Label(manager)
            {
                Text = "Control Showcase"
            };                                                              //Neues Label erzeugen

            panel.Controls.Add(label);                                      //Label zu Panel hinzufügen

            Button tB = Button.TextButton(manager, "TEST");

            tB.Background = new TextureBrush(LoadTexture2DFromFile("./test_texture_round.png", manager.GraphicsDevice), TextureBrushMode.Stretch);
            panel.Controls.Add(tB);

            //Button
            Button button = Button.TextButton(manager, "Dummy Button"); //Neuen TextButton erzeugen

            panel.Controls.Add(button);                                 //Button zu Panel hinzufügen

            //Progressbar
            ProgressBar pr = new ProgressBar(manager)                   //Neue ProgressBar erzeugen
            {
                Value  = 99,                                            //Aktueller Wert
                Height = 20,                                            //Höhe
                Width  = 200                                            //Breite
            };

            panel.Controls.Add(pr);                                     //ProgressBar zu Panel hinzufügen

            //ListBox
            Listbox <string> list = new Listbox <string>(manager);      //Neue ListBox erstellen

            list.TemplateGenerator = (item) =>                          //Template Generator festlegen
            {
                return(new Label(manager)
                {
                    Text = item
                });                                                     //Control (Label) erstellen
            };
            panel.Controls.Add(list);                                   //Liste zu Panel hinzufügen

            list.Items.Add("Hallo");                                    //Items zur Liste hinzufügen
            list.Items.Add("Welt");                                     //...

            //Combobox
            Combobox <string> combobox = new Combobox <string>(manager) //Neue Combobox erstellen
            {
                Height = 20,                                            //Höhe 20
                Width  = 100                                            //Breite 100
            };

            combobox.TemplateGenerator = (item) =>                      //Template Generator festlegen
            {
                return(new Label(manager)
                {
                    Text = item
                });                                                     //Control (Label) erstellen
            };
            panel.Controls.Add(combobox);                               //Combobox zu Panel  hinzufügen

            combobox.Items.Add("Combobox");                             //Items zu Combobox hinzufügen
            combobox.Items.Add("Item");
            combobox.Items.Add("Hallo");


            Button clearCombobox = Button.TextButton(manager, "Clear Combobox");

            clearCombobox.LeftMouseClick += (s, e) => {
                combobox.Items.Clear();
                list.Items.Clear();
            };
            panel.Controls.Add(clearCombobox);

            //Slider Value Label
            Label labelSliderHorizontal = new Label(manager);

            //Horizontaler Slider
            Slider sliderHorizontal = new Slider(manager)
            {
                Width  = 150,
                Height = 20,
            };

            sliderHorizontal.ValueChanged += (value) => { labelSliderHorizontal.Text = "Value: " + value; }; //Event on Value Changed
            panel.Controls.Add(sliderHorizontal);
            labelSliderHorizontal.Text = "Value: " + sliderHorizontal.Value;                                 //Set Text initially
            panel.Controls.Add(labelSliderHorizontal);

            //Slider Value Label
            Label labelSliderVertical = new Label(manager);

            //Vertikaler Slider
            Slider sliderVertical = new Slider(manager)
            {
                Range       = 100,
                Height      = 200,
                Width       = 20,
                Orientation = Orientation.Vertical
            };

            sliderVertical.ValueChanged += (value) => { labelSliderVertical.Text = "Value: " + value; };
            panel.Controls.Add(sliderVertical);
            labelSliderVertical.Text = "Value: " + sliderVertical.Value;
            panel.Controls.Add(labelSliderVertical);

            Checkbox checkbox = new Checkbox(manager);

            panel.Controls.Add(checkbox);


            //Textbox
            textbox = new Textbox(manager)                              //Neue TextBox erzeugen
            {
                Background          = new BorderBrush(Color.LightGray), //Festlegen eines Backgrounds für ein Control
                HorizontalAlignment = HorizontalAlignment.Stretch,      //100% Breite
                Text     = "TEXTBOX!",                                  //Voreingestellter text
                MinWidth = 100                                          //Eine Textbox kann ihre Größe automatisch anpassen
            };

            Button clearTextbox = new Button(manager);

            clearTextbox.LeftMouseClick += (s, e) =>
            {
                textbox.SelectionStart = 0;
                textbox.Text           = "";
            };
            panel.Controls.Add(clearTextbox);
            panel.Controls.Add(textbox);                                //Textbox zu Panel hinzufügen
        }
예제 #32
0
                public override string Output()
                {
                    string s = "<div";
                    if (CssClass != null) {
                        s += " class=\"" + CssClass + "\"";
                    }
                    if (Attributes != null) {
                        foreach (var a in Attributes) {
                            s += " " + a.Key + "=\"" + a.Value + "\"";
                        }
                    }
                    s += ">";
                    s += new Textbox(this.Key + Constants.Parameter.Suffix.CreditCard.Number, "Credit Card Number", true, null, new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("onkeydown", "return f.cc(this,event)"), new KeyValuePair<string, string>("onpaste", "return f.cc_paste(this, event)") }).Output();
                    s += $"<div class=\"f\"><div class=\"w50\">{new Textbox(this.Key + Constants.Parameter.Suffix.CreditCard.Expiration, "Expiration (MM/YY)", true, null, new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("placeholder", "MM/YY") }).Output()}</div>";
                    s += $"<div>&emsp;</div><div class=\"f1\">{new Textbox(this.Key + Constants.Parameter.Suffix.CreditCard.Code, "CCV", true).Output()}</div></div>";
                    s += new Textbox(this.Key + Constants.Parameter.Suffix.CreditCard.AddressCity, "City", true).Output();
                    s += new Dropdown(this.Key + Constants.Parameter.Suffix.CreditCard.AddressState, "State", Util.Address.AllStates, true) { Value = "NH" }.Output();
                    s += $"<div class=\"w50\">{new Textbox(this.Key + Constants.Parameter.Suffix.CreditCard.AddressPostalCode, "Zip Code", true).Output()}</div>";

                    return s + "</div>";
                }
예제 #33
0
 public GameObject CreateTutorialBox(string message, float destroyTimer = -1, Textbox.TutorialBoxPosition position = Textbox.TutorialBoxPosition.MIDDLE)
 {
     GameObject dialog = (GameObject)Instantiate(dialogueContainer, dialogueContainer.transform.position, Quaternion.identity);
     StartCoroutine(dialog.GetComponent<Textbox>().DrawTutorialBox(message, destroyTimer, position));
     return dialog;
 }
        public static IList <IShape> TextFileToShapes(StreamReader fileStreamReader)
        {
            var    peekableStreamReader = new PeekableStreamReaderAdapter(fileStreamReader);
            string nextLine;
            var    result = new List <IShape>();

            while ((nextLine = peekableStreamReader.ReadLine()) != null)
            {
                if (!nextLine.StartsWith("•	"))
                {
                    throw new Exception($"Input file not correctly formatted, new shapes must be marked with a black bullet point \" { nextLine }\"");
                }

                // Get the quantity and string word representing the name of the shape (after removing the bullet point and white space)
                var splitInput = nextLine.Substring(2, nextLine.Length - 2).Split(" x ");

                if (splitInput.Length != 2)
                {
                    throw new Exception("Item properties must be submitted in the form of \"{number} x {name of shape}\"");
                }

                int quantity;
                var shapeText = splitInput[1];
                try
                {
                    quantity = Convert.ToInt32(splitInput[0]);
                }
                catch
                {
                    throw new Exception($"\"{splitInput[0]}\" is not a valid quantity for shape \"{ shapeText }\"");
                }

                IShape nextShape;
                IDictionary <string, object> properties;

                switch (shapeText)
                {
                case "Rectangle":
                    var rectangle = new Rectangle();
                    properties = ParseProperties(peekableStreamReader);
                    if (properties.ContainsKey("Position X"))
                    {
                        rectangle.PositionX = Convert.ToInt32(properties["Position X"]);
                    }
                    if (properties.ContainsKey("Position Y"))
                    {
                        rectangle.PositionY = Convert.ToInt32(properties["Position Y"]);
                    }
                    if (properties.ContainsKey("Width"))
                    {
                        rectangle.Width = Convert.ToInt32(properties["Width"]);
                    }
                    if (properties.ContainsKey("Height"))
                    {
                        rectangle.Height = Convert.ToInt32(properties["Height"]);
                    }
                    nextShape = rectangle;
                    break;

                case "Square":
                    var square = new Square();
                    properties = ParseProperties(peekableStreamReader);
                    if (properties.ContainsKey("Position X"))
                    {
                        square.PositionX = Convert.ToInt32(properties["Position X"]);
                    }
                    if (properties.ContainsKey("Position Y"))
                    {
                        square.PositionY = Convert.ToInt32(properties["Position Y"]);
                    }
                    if (properties.ContainsKey("Width"))
                    {
                        square.Width = Convert.ToInt32(properties["Width"]);
                    }
                    nextShape = square;
                    break;

                case "Ellipse":
                    var ellipse = new Ellipse();
                    properties = ParseProperties(peekableStreamReader);
                    if (properties.ContainsKey("Position X"))
                    {
                        ellipse.PositionX = Convert.ToInt32(properties["Position X"]);
                    }
                    if (properties.ContainsKey("Position Y"))
                    {
                        ellipse.PositionY = Convert.ToInt32(properties["Position Y"]);
                    }
                    if (properties.ContainsKey("Horizontal Diameter"))
                    {
                        ellipse.HorizontalDiameter = Convert.ToInt32(properties["Horizontal Diameter"]);
                    }
                    if (properties.ContainsKey("Vertical Diameter"))
                    {
                        ellipse.VerticalDiameter = Convert.ToInt32(properties["Vertical Diameter"]);
                    }
                    nextShape = ellipse;
                    break;

                case "Circle":
                    var circle = new Circle();
                    properties = ParseProperties(peekableStreamReader);
                    if (properties.ContainsKey("Position X"))
                    {
                        circle.PositionX = Convert.ToInt32(properties["Position X"]);
                    }
                    if (properties.ContainsKey("Position Y"))
                    {
                        circle.PositionY = Convert.ToInt32(properties["Position Y"]);
                    }
                    if (properties.ContainsKey("Diameter"))
                    {
                        circle.Diameter = Convert.ToInt32(properties["Diameter"]);
                    }
                    nextShape = circle;
                    break;

                case "Textbox":
                    var textBox = new Textbox();
                    properties = ParseProperties(peekableStreamReader);
                    if (properties.ContainsKey("Position X"))
                    {
                        textBox.PositionX = Convert.ToInt32(properties["Position X"]);
                    }
                    if (properties.ContainsKey("Position Y"))
                    {
                        textBox.PositionY = Convert.ToInt32(properties["Position Y"]);
                    }
                    if (properties.ContainsKey("Width"))
                    {
                        textBox.Width = Convert.ToInt32(properties["Width"]);
                    }
                    if (properties.ContainsKey("Height"))
                    {
                        textBox.Height = Convert.ToInt32(properties["Height"]);
                    }
                    if (properties.ContainsKey("Text"))
                    {
                        textBox.Text = (string)properties["Text"];
                    }
                    nextShape = textBox;
                    break;

                default:
                    throw new Exception($"The string \"{ shapeText }\" cannot be parsed into a new shape object");
                }

                for (var i = 0; i < quantity; i++)
                {
                    result.Add(nextShape);
                }
            }

            return(result);
        }
예제 #35
0
        public void TestGetDataBackAgain()
        {
            HSSFSheet      s;
            HSSFShapeGroup s1;
            HSSFShapeGroup s2;

            patriarch.SetCoordinates(10, 20, 30, 40);

            MemoryStream baos = new MemoryStream();

            workbook.Write(baos);
            workbook = new HSSFWorkbook(new MemoryStream(baos.ToArray()));
            s        = (HSSFSheet)workbook.GetSheetAt(0);

            patriarch = (HSSFPatriarch)s.DrawingPatriarch;

            Assert.IsNotNull(patriarch);
            Assert.AreEqual(10, patriarch.X1);
            Assert.AreEqual(20, patriarch.Y1);
            Assert.AreEqual(30, patriarch.X2);
            Assert.AreEqual(40, patriarch.Y2);

            // Check the two groups too
            Assert.AreEqual(2, patriarch.CountOfAllChildren);
            Assert.IsTrue(patriarch.Children[0] is HSSFShapeGroup);
            Assert.IsTrue(patriarch.Children[1] is HSSFShapeGroup);

            s1 = (HSSFShapeGroup)patriarch.Children[0];
            s2 = (HSSFShapeGroup)patriarch.Children[1];

            Assert.AreEqual(0, s1.X1);
            Assert.AreEqual(0, s1.Y1);
            Assert.AreEqual(1023, s1.X2);
            Assert.AreEqual(255, s1.Y2);
            Assert.AreEqual(0, s2.X1);
            Assert.AreEqual(0, s2.Y1);
            Assert.AreEqual(1023, s2.X2);
            Assert.AreEqual(255, s2.Y2);

            Assert.AreEqual(0, s1.Anchor.Dx1);
            Assert.AreEqual(0, s1.Anchor.Dy1);
            Assert.AreEqual(1022, s1.Anchor.Dx2);
            Assert.AreEqual(255, s1.Anchor.Dy2);
            Assert.AreEqual(20, s2.Anchor.Dx1);
            Assert.AreEqual(30, s2.Anchor.Dy1);
            Assert.AreEqual(500, s2.Anchor.Dx2);
            Assert.AreEqual(200, s2.Anchor.Dy2);


            // Write and re-load once more, to Check that's ok
            baos = new MemoryStream();
            workbook.Write(baos);
            workbook  = new HSSFWorkbook(new MemoryStream(baos.ToArray()));
            s         = (HSSFSheet)workbook.GetSheetAt(0);
            patriarch = (HSSFPatriarch)s.DrawingPatriarch;

            Assert.IsNotNull(patriarch);
            Assert.AreEqual(10, patriarch.X1);
            Assert.AreEqual(20, patriarch.Y1);
            Assert.AreEqual(30, patriarch.X2);
            Assert.AreEqual(40, patriarch.Y2);

            // Check the two groups too
            Assert.AreEqual(2, patriarch.CountOfAllChildren);
            Assert.IsTrue(patriarch.Children[0] is HSSFShapeGroup);
            Assert.IsTrue(patriarch.Children[1] is HSSFShapeGroup);

            s1 = (HSSFShapeGroup)patriarch.Children[0];
            s2 = (HSSFShapeGroup)patriarch.Children[1];

            Assert.AreEqual(0, s1.X1);
            Assert.AreEqual(0, s1.Y1);
            Assert.AreEqual(1023, s1.X2);
            Assert.AreEqual(255, s1.Y2);
            Assert.AreEqual(0, s2.X1);
            Assert.AreEqual(0, s2.Y1);
            Assert.AreEqual(1023, s2.X2);
            Assert.AreEqual(255, s2.Y2);

            Assert.AreEqual(0, s1.Anchor.Dx1);
            Assert.AreEqual(0, s1.Anchor.Dy1);
            Assert.AreEqual(1022, s1.Anchor.Dx2);
            Assert.AreEqual(255, s1.Anchor.Dy2);
            Assert.AreEqual(20, s2.Anchor.Dx1);
            Assert.AreEqual(30, s2.Anchor.Dy1);
            Assert.AreEqual(500, s2.Anchor.Dx2);
            Assert.AreEqual(200, s2.Anchor.Dy2);

            // Change the positions of the first groups,
            //  but not of their anchors
            s1.SetCoordinates(2, 3, 1021, 242);

            baos = new MemoryStream();
            workbook.Write(baos);
            workbook  = new HSSFWorkbook(new MemoryStream(baos.ToArray()));
            s         = (HSSFSheet)workbook.GetSheetAt(0);
            patriarch = (HSSFPatriarch)s.DrawingPatriarch;

            Assert.IsNotNull(patriarch);
            Assert.AreEqual(10, patriarch.X1);
            Assert.AreEqual(20, patriarch.Y1);
            Assert.AreEqual(30, patriarch.X2);
            Assert.AreEqual(40, patriarch.Y2);

            // Check the two groups too
            Assert.AreEqual(2, patriarch.CountOfAllChildren);
            Assert.AreEqual(2, patriarch.Children.Count);
            Assert.IsTrue(patriarch.Children[0] is HSSFShapeGroup);
            Assert.IsTrue(patriarch.Children[1] is HSSFShapeGroup);

            s1 = (HSSFShapeGroup)patriarch.Children[0];
            s2 = (HSSFShapeGroup)patriarch.Children[1];

            Assert.AreEqual(2, s1.X1);
            Assert.AreEqual(3, s1.Y1);
            Assert.AreEqual(1021, s1.X2);
            Assert.AreEqual(242, s1.Y2);
            Assert.AreEqual(0, s2.X1);
            Assert.AreEqual(0, s2.Y1);
            Assert.AreEqual(1023, s2.X2);
            Assert.AreEqual(255, s2.Y2);

            Assert.AreEqual(0, s1.Anchor.Dx1);
            Assert.AreEqual(0, s1.Anchor.Dy1);
            Assert.AreEqual(1022, s1.Anchor.Dx2);
            Assert.AreEqual(255, s1.Anchor.Dy2);
            Assert.AreEqual(20, s2.Anchor.Dx1);
            Assert.AreEqual(30, s2.Anchor.Dy1);
            Assert.AreEqual(500, s2.Anchor.Dx2);
            Assert.AreEqual(200, s2.Anchor.Dy2);


            // Now Add some text to one group, and some more
            //  to the base, and Check we can get it back again
            Textbox tbox1 =
                patriarch.CreateTextbox(new HSSFClientAnchor(1, 2, 3, 4, (short)0, 0, (short)0, 0));

            tbox1.String = (new HSSFRichTextString("I am text box 1"));
            Textbox tbox2 =
                s2.CreateTextbox(new HSSFChildAnchor(41, 42, 43, 44));

            tbox2.String = (new HSSFRichTextString("This is text box 2"));

            Assert.AreEqual(3, patriarch.Children.Count);


            baos = new MemoryStream();
            workbook.Write(baos);
            workbook = new HSSFWorkbook(new MemoryStream(baos.ToArray()));
            s        = (HSSFSheet)workbook.GetSheetAt(0);

            patriarch = (HSSFPatriarch)s.DrawingPatriarch;

            Assert.IsNotNull(patriarch);
            Assert.AreEqual(10, patriarch.X1);
            Assert.AreEqual(20, patriarch.Y1);
            Assert.AreEqual(30, patriarch.X2);
            Assert.AreEqual(40, patriarch.Y2);

            // Check the two groups and the text
            Assert.AreEqual(3, patriarch.CountOfAllChildren);
            Assert.AreEqual(2, patriarch.Children.Count);

            // Should be two groups and a text
            Assert.IsTrue(patriarch.Children[0] is HSSFShapeGroup);
            Assert.IsTrue(patriarch.Children[1] is HSSFTextbox);
            //      Assert.IsTrue(patriarch.Children.Get(2) is HSSFShapeGroup);

            s1    = (HSSFShapeGroup)patriarch.Children[0];
            tbox1 = (HSSFTextbox)patriarch.Children[1];

            //      s2 = (HSSFShapeGroup)patriarch.Children[1];

            Assert.AreEqual(2, s1.X1);
            Assert.AreEqual(3, s1.Y1);
            Assert.AreEqual(1021, s1.X2);
            Assert.AreEqual(242, s1.Y2);
            Assert.AreEqual(0, s2.X1);
            Assert.AreEqual(0, s2.Y1);
            Assert.AreEqual(1023, s2.X2);
            Assert.AreEqual(255, s2.Y2);

            Assert.AreEqual(0, s1.Anchor.Dx1);
            Assert.AreEqual(0, s1.Anchor.Dy1);
            Assert.AreEqual(1022, s1.Anchor.Dx2);
            Assert.AreEqual(255, s1.Anchor.Dy2);
            Assert.AreEqual(20, s2.Anchor.Dx1);
            Assert.AreEqual(30, s2.Anchor.Dy1);
            Assert.AreEqual(500, s2.Anchor.Dx2);
            Assert.AreEqual(200, s2.Anchor.Dy2);

            // Not working just yet
            //Assert.AreEqual("I am text box 1", tbox1.String.String);
        }
        /// <summary>
        /// Model Binder used to construct Form object from the query params
        /// </summary>
        Task IModelBinder.BindModelAsync(ModelBindingContext bindingContext)
        {
            if (bindingContext == null)
            {
                throw new ArgumentNullException(nameof(bindingContext));
            }

            var formIdValueProvider = bindingContext.ValueProvider.GetValue("fId");
            var inputIdProvider     = bindingContext.ValueProvider.GetValue("inpId");
            var inputValueProvider  = bindingContext.ValueProvider.GetValue("val");
            var inputTypeProvider   = bindingContext.ValueProvider.GetValue("inpType");
            var btnIdProvider       = bindingContext.ValueProvider.GetValue("btnId");

            if (formIdValueProvider == ValueProviderResult.None ||
                inputIdProvider == ValueProviderResult.None ||
                inputValueProvider == ValueProviderResult.None ||
                btnIdProvider == ValueProviderResult.None)
            {
                return(Task.CompletedTask);
            }
            if (!IsInt(formIdValueProvider.FirstValue))
            {
                bindingContext.ModelState.TryAddModelError("fId", "Form Id must be an integer.");
                return(Task.CompletedTask);
            }
            if (!IsInt(btnIdProvider.FirstValue))
            {
                bindingContext.ModelState.TryAddModelError("btnId", "Button Id must be an integer.");
                return(Task.CompletedTask);
            }
            var result = new Form(Convert.ToInt32(formIdValueProvider.FirstValue));

            result.AddFormInput(new Button(Convert.ToInt32(btnIdProvider.FirstValue), ""));
            if (inputIdProvider.Length != inputValueProvider.Length)
            {
                bindingContext.ModelState.TryAddModelError(
                    "InputId",
                    "Number of input ids must be same as number of input values.");
                return(Task.CompletedTask);
            }
            var inputIds    = inputIdProvider.Values.ToArray();
            var inputValues = inputValueProvider.Values.ToArray();
            var inputTypes  = inputTypeProvider.Values.ToArray();

            for (int i = 0; i < inputIds.Length; i++)
            {
                if (!IsInt(inputIds[i]))
                {
                    bindingContext.ModelState.TryAddModelError("inpId", "Input Id must be an integer.");
                    return(Task.CompletedTask);
                }
                if (inputValues[i].Length > 150)
                {
                    bindingContext.ModelState.TryAddModelError("val", "Length of val cannot exceed 50 characters.");
                    return(Task.CompletedTask);
                }

                if (inputTypes.Length > 0 && i < inputTypes.Length)
                {
                    if (int.TryParse(inputTypes[i], out int intInputType))
                    {
                        FormInputTypes inputType = (FormInputTypes)intInputType;

                        if (inputType == FormInputTypes.TextBox)
                        {
                            var text = new Textbox(Convert.ToInt32(inputIds[i]), "");
                            text.Value = inputValues[i];
                            result.AddFormInput(text);
                        }
                        else if (inputType == FormInputTypes.RadioButton)
                        {
                            var radioButtonList = new RadioButtonList(Convert.ToInt32(inputIds[i]), "", null);
                            radioButtonList.SelectedValue = inputValues[i];
                            result.AddFormInput(radioButtonList);
                        }
                    }
                }
                else
                {
                    // This is for backward compatibility. This should be removed once the UI is updated.
                    var text = new Textbox(Convert.ToInt32(inputIds[i]), "");
                    text.Value = inputValues[i];
                    result.AddFormInput(text);
                }
            }
            bindingContext.Result = ModelBindingResult.Success(result);
            return(Task.CompletedTask);
        }
예제 #37
0
 private void ConnectTextboxOnSubmit(string text, Textbox sender)
 {
     StartConnect(text);
 }
예제 #38
0
        /// <summary>
        /// Initialization
        /// </summary>
        protected override void OnInitialize()
        {
            var device = AlmiranteEngine.Device;

            this.overlay = new Texture2D(device, 1, 1);
            this.overlay.SetData(new Color[] { Color.FromNonPremultiplied(0, 0, 0, 255) });

            ///
            /// Name panel
            ///

            this.panel_login = new Control()
            {
                Size     = new Vector2(250, 250),
                Position = new Vector2((1280 - 250) / 2, (720 - 250) / 2)
            };

            var labellogin = new Label()
            {
                Text     = "Name:",
                Visible  = true,
                Size     = new Vector2(250, 15),
                Position = new Vector2(0, 0)
            };

            this.panel_login.Controls.Add(labellogin);

            this.textname = new Textbox()
            {
                Visible  = true,
                Size     = new Vector2(250, 30),
                Position = labellogin.Position + new Vector2(0, 30)
            };
            this.panel_login.Controls.Add(this.textname);

            this.enter = new Button()
            {
                Text     = "Enter",
                Visible  = true,
                Size     = new Vector2(120, 30),
                Position = textname.Position + new Vector2(0, 40)
            };
            this.enter.MouseClick += OnEnter;
            this.panel_login.Controls.Add(this.enter);

            this.back = new Button()
            {
                Text     = "Back",
                Visible  = true,
                Size     = new Vector2(120, 30),
                Position = textname.Position + new Vector2(130, 40)
            };
            this.back.MouseClick += OnBack;
            this.panel_login.Controls.Add(this.back);

            this.Interface.Controls.Add(this.panel_login);

            ///
            /// Message
            ///

            this.message_label = new Label()
            {
                Size      = new Vector2(600, 15),
                Position  = new Vector2(300, 0),
                Alignment = FontAlignment.Center,
                Text      = "?"
            };

            this.message_button = new Button()
            {
                Size     = new Vector2(100, 30),
                Position = new Vector2(250, 30),
                Text     = "OK"
            };

            this.message_panel = new Control()
            {
                Size     = new Vector2(600, 50),
                Position = new Vector2((1280 - 600) / 2, (720 - 50) / 2),
                Visible  = false
            };

            this.message_panel.Controls.Add(this.message_label);
            this.message_panel.Controls.Add(this.message_button);

            this.Interface.Controls.Add(this.message_panel);

            ///
            /// Messages
            ///

            Player.Instance.Protocol.Subscribe <JoinResponse>(this.OnJoinResponse);
        }
예제 #39
0
        private void LoadTextboxFromXML(XElement textboxElement, Dictionary <string, SpriteFont> fonts,
                                        ContentManager content, GUIManager parent)
        {
            string textboxName = textboxElement.Attribute("name")?.Value.ToString();

            string text        = textboxElement.Element("text")?.Value.ToString() ?? "";
            string texturePath = textboxElement.Element("texture")?.Value.ToString();
            string fontName    = textboxElement.Element("font")?.Value.ToString();

            uint.TryParse(textboxElement.Element("fontsize")?.Value.ToString(), out uint charSize);

            int.TryParse(textboxElement.Element("padding")?.Element("x")?.Value.ToString(), out int offX);
            int.TryParse(textboxElement.Element("padding")?.Element("y")?.Value.ToString(), out int offY);
            Vector2 textOffset = new Vector2(offX, offY);

            float.TryParse(textboxElement.Element("scale")?.Element("x")?.Value.ToString(), out float scaleX);
            float.TryParse(textboxElement.Element("scale")?.Element("y")?.Value.ToString(), out float scaleY);

            if (scaleX <= 0)
            {
                scaleX = 1;
            }
            if (scaleY <= 0)
            {
                scaleY = 1;
            }

            Vector2 scale = new Vector2(scaleX, scaleY);

            var color = this.ParseColor(textboxElement.Element("color"));

            float.TryParse(textboxElement.Element("origin")?.Element("x")?.Value.ToString(), out float originX);
            float.TryParse(textboxElement.Element("origin")?.Element("y")?.Value.ToString(), out float originY);
            Vector2 origin = new Vector2(originX, originY);

            string mask = textboxElement.Element("mask")?.Value.ToString() ?? null;

            var texture = content.LoadTexture2D(Constants.FILEPATH_DATA + texturePath);

            var position = parent.ParsePosition(textboxElement.Element("position")?.Element("x")?.Value.ToString(),
                                                textboxElement.Element("position")?.Element("y")?.Value.ToString());

            int.TryParse(textboxElement.Element("zorder")?.Value.ToString(), out int zOrder);

            if (!bool.TryParse(textboxElement.Element("visible")?.Value, out bool visible))
            {
                visible = true;
            }

            SpriteFont font    = fonts[fontName];
            var        textBox = new Textbox(texture, font, textOffset, charSize)
            {
                Text      = text,
                Position  = position,
                ForeColor = color,
                Origin    = origin,
                Mask      = mask,
                ZOrder    = zOrder,
                Visible   = visible,
                Scale     = scale,
            };

            parent.AddWidget(textBox, textboxName);
        }
예제 #40
0
 public void Clear()
 {
     Textbox.Clear();
 }
예제 #41
0
 public MyClass(Textbox TB)
 {
     m_TextBox = TB;
 }
예제 #42
0
 public override string PerformAction(string actionString, Textbox originTextbox)
 {
     Debug.Log("End Called");
     originTextbox.MasterSequence.closeSequence();
     return("");
 }
예제 #43
0
        public OptionsScreen(ScreenComponent manager) : base(manager)
        {
            game    = (OctoGame)manager.Game;
            Padding = new Border(0, 0, 0, 0);

            Title = Languages.OctoClient.Options;

            SetDefaultBackground();

            ////////////////////////////////////////////Settings Stack////////////////////////////////////////////
            StackPanel settingsStack = new StackPanel(manager);

            settingsStack.Orientation = Orientation.Vertical;
            Texture2D panelBackground = manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/panel.png", manager.GraphicsDevice);

            settingsStack.Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30);
            settingsStack.Padding    = new Border(20, 20, 20, 20);
            settingsStack.Width      = 500;
            Controls.Add(settingsStack);


            //////////////////////Viewrange//////////////////////
            string viewrange = SettingsManager.Get("Viewrange");

            rangeTitle      = new Label(manager);
            rangeTitle.Text = Languages.OctoClient.Viewrange + ": " + viewrange;
            settingsStack.Controls.Add(rangeTitle);

            Slider viewrangeSlider = new Slider(manager);

            viewrangeSlider.HorizontalAlignment = HorizontalAlignment.Stretch;
            viewrangeSlider.Height        = 20;
            viewrangeSlider.Range         = 9;
            viewrangeSlider.Value         = int.Parse(viewrange) - 1;
            viewrangeSlider.ValueChanged += (value) => SetViewrange(value + 1);
            settingsStack.Controls.Add(viewrangeSlider);


            //////////////////////Persistence//////////////////////
            StackPanel persistenceStack = new StackPanel(manager);

            persistenceStack.Orientation = Orientation.Horizontal;
            persistenceStack.Margin      = new Border(0, 10, 0, 0);
            settingsStack.Controls.Add(persistenceStack);

            persistenceTitle      = new Label(manager);
            persistenceTitle.Text = Languages.OctoClient.DisablePersistence + ":";
            persistenceStack.Controls.Add(persistenceTitle);

            Checkbox disablePersistence = new Checkbox(manager);

            disablePersistence.Checked         = bool.Parse(SettingsManager.Get("DisablePersistence"));
            disablePersistence.CheckedChanged += (state) => SetPersistence(state);
            persistenceStack.Controls.Add(disablePersistence);

            //////////////////////Map Path//////////////////////
            StackPanel mapPathStack = new StackPanel(manager);

            mapPathStack.Orientation         = Orientation.Horizontal;
            mapPathStack.Margin              = new Border(0, 10, 0, 0);
            mapPathStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            settingsStack.Controls.Add(mapPathStack);

            mapPath = new Textbox(manager);
            // mapPath.HorizontalAlignment = HorizontalAlignment.Stretch;
            mapPath.Text       = SettingsManager.Get("ChunkRoot");
            mapPath.Enabled    = false;
            mapPath.Background = new BorderBrush(Color.LightGray, LineType.Solid, Color.Gray);
            mapPathStack.Controls.Add(mapPath);

            Button changePath = Button.TextButton(manager, Languages.OctoClient.ChangePath);

            changePath.Height          = 31;
            changePath.LeftMouseClick += (s, e) => ChangePath();
            mapPathStack.Controls.Add(changePath);

            ////////////////////////////////////////////Restart Button////////////////////////////////////////////
            exitButton = Button.TextButton(manager, Languages.OctoClient.RestartGameToApplyChanges);
            exitButton.VerticalAlignment   = VerticalAlignment.Top;
            exitButton.HorizontalAlignment = HorizontalAlignment.Right;
            exitButton.Enabled             = false;
            exitButton.Visible             = false;
            exitButton.LeftMouseClick     += (s, e) => Program.Restart();
            exitButton.Margin = new Border(10, 10, 10, 10);
            Controls.Add(exitButton);
        }
예제 #44
0
        public override void LoadContent()
        {
            base.LoadContent();
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _background  = Content.Load <Texture2D>("Images/MenuBackground");

            //Load font range for scaling.
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-20"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-22"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-24"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-26"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-28"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-30"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-32"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-34"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-36"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-38"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-40"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-42"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-44"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-46"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-48"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-50"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-52"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-54"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-56"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-58"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-60"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-62"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-64"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-66"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-68"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-70"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-72"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-74"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-76"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-78"));

            fontPackage = FontHelper.GetFont(_fontList, proposedTextHeight, GraphicsDevice.Viewport.Bounds);

            newGame = FontHelper.SetTextBoxPosition(newGame, fontPackage, GraphicsDevice.Viewport.Bounds, VerticalPosition.Centered, 0f, HorizontalPosition.Centered, 0f);

            RectangleF newGameRectangle     = fontPackage.Font.GetStringRectangle(newGame.Value);
            float      centerPointNewGame   = GraphicsDevice.Viewport.Bounds.Width / 2f - (newGameRectangle.Width / 2f);
            float      verticalPointNewGame = GraphicsDevice.Viewport.Bounds.Height * 0.25f;

            newGame.Location          = new Vector2(centerPointNewGame, verticalPointNewGame);
            newGameRectangle.Position = new Point2(newGame.Location.X, newGame.Location.Y);
            newGame.BoundingBox       = newGameRectangle;

            RectangleF loadGameRectangle     = fontPackage.Font.GetStringRectangle(loadGame.Value);
            float      centerPointLoadGame   = GraphicsDevice.Viewport.Bounds.Width / 2f - (loadGameRectangle.Width / 2f);
            float      verticalPointLoadGame = verticalPointNewGame + (newGame.BoundingBox.Height * 1.5f);

            loadGame.Location = new Vector2(centerPointLoadGame, verticalPointLoadGame);

            RectangleF optionsRectangle     = fontPackage.Font.GetStringRectangle(options.Value);
            float      centerPointOptions   = GraphicsDevice.Viewport.Bounds.Width / 2f - (optionsRectangle.Width / 2f);
            float      verticalPointOptions = verticalPointLoadGame + (newGame.BoundingBox.Height * 1.5f);

            options.Location = new Vector2(centerPointOptions, verticalPointOptions);

            RectangleF exitRectangle     = fontPackage.Font.GetStringRectangle(exit.Value);
            float      centerPointExit   = GraphicsDevice.Viewport.Bounds.Width / 2f - (exitRectangle.Width / 2f);
            float      verticalPointExit = verticalPointOptions + (newGame.BoundingBox.Height * 1.5f);

            exit.Location          = new Vector2(centerPointExit, verticalPointExit);
            exitRectangle.Position = new Point2(exit.Location.X, exit.Location.Y);
            exit.BoundingBox       = exitRectangle;
        }
예제 #45
0
        public LoginForm(int width, int height, string name) : base(width, height)
        {
            Name = name;

            Label lblTitle = new Label("lblTitle",
                                       new Point(1, 2),
                                       10,
                                       "Login",
                                       ConsoleColor.Green,
                                       ConsoleColor.Black);

            Label lblserver = new Label("lblserver",
                                        new Point(1, 10),
                                        28,
                                        "server",
                                        ConsoleColor.Green,
                                        ConsoleColor.Black);

            Label lblUsername = new Label("lbluname",
                                          new Point(1, 12),
                                          10,
                                          "Username",
                                          ConsoleColor.Green,
                                          ConsoleColor.Black);

            Label lblPass = new Label("lblpass",
                                      new Point(1, 14),
                                      10,
                                      "Password",
                                      ConsoleColor.Green,
                                      ConsoleColor.Black);


            Textbox txtServer = new Textbox("txtServer",
                                            new Point(12, 10),
                                            30,
                                            string.Empty,
                                            ConsoleColor.White,
                                            ConsoleColor.DarkGray);

            Textbox txtUser = new Textbox("txtUser",
                                          new Point(12, 12),
                                          30,
                                          string.Empty,
                                          ConsoleColor.White,
                                          ConsoleColor.DarkGray);

            Textbox txtPassword = new Textbox("txtPass",
                                              new Point(12, 14),
                                              30,
                                              string.Empty,
                                              ConsoleColor.White,
                                              ConsoleColor.DarkGray)
            {
                PasswordChar = '*'
            };

            Add(lblTitle);

            Add(lblTitle);
            Add(lblserver);
            Add(lblUsername);
            Add(lblPass);

            Add(txtServer);
            Add(txtUser);
            Add(txtPassword);
        }
예제 #46
0
        internal static VisualTreeElement Serialize(XmlNode node, Control root)
        {
            ElementPair parse = null;

            switch (node.Name)
            {
            case "Control":
                parse = Control.ParseNested(node, root);
                break;

            case "VerticalPanel":
                parse = VerticalPanel.Parse(node, root);
                break;

            case "HorizontalPanel":
                parse = HorizontalPanel.Parse(node, root);
                break;

            case "Button":
                parse = Button.Parse(node, root);
                break;

            case "Label":
                parse = Label.Parse(node, root);
                break;

            case "Text":
                parse = Textbox.Parse(node, root);
                break;

            case "ListBox":
                parse = ListBox.Parse(node, root);
                break;

            case "Grid":
                parse = Grid.Parse(node, root);
                break;

            case "Calendar":
                parse = Calendar.Parse(node, root);
                break;

            case "Panel":
                parse = Panel.Parse(node, root);
                break;

            case "VerticalSlider":
                parse = VerticalSlider.Parse(node, root);
                break;

            case "HorizontalSlider":
                parse = HorizontalSlider.Parse(node, root);
                break;

            default:
                break;
            }
            if (parse != null)
            {
                parse.Element.BindWidgetProperties(node, root);
                foreach (XmlNode child in node.ChildNodes)
                {
                    if (child.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }
                    var nextElement = Serialize(child, root);
                    if (parse.Element is IAttachable)
                    {
                        ((IAttachable)parse.Element).AttachProperties(nextElement, child);
                    }
                    if (nextElement != null)
                    {
                        parse.AddToElement(nextElement);
                    }
                }
                return(parse.Element);
            }
            return(null);
        }
예제 #47
0
        /// <summary>
        /// Model Binder used to construct Form object from the query params
        /// </summary>
        Task IModelBinder.BindModelAsync(ModelBindingContext bindingContext)
        {
            if (bindingContext == null)
            {
                throw new ArgumentNullException(nameof(bindingContext));
            }

            var formIdValueProvider = bindingContext.ValueProvider.GetValue("fId");
            var inputIdProvider     = bindingContext.ValueProvider.GetValue("inpId");
            var inputValueProvider  = bindingContext.ValueProvider.GetValue("val");
            var btnIdProvider       = bindingContext.ValueProvider.GetValue("btnId");

            if (formIdValueProvider == ValueProviderResult.None ||
                inputIdProvider == ValueProviderResult.None ||
                inputValueProvider == ValueProviderResult.None ||
                btnIdProvider == ValueProviderResult.None)
            {
                return(Task.CompletedTask);
            }
            if (!IsInt(formIdValueProvider.FirstValue))
            {
                bindingContext.ModelState.TryAddModelError("fId", "Form Id must be an integer.");
                return(Task.CompletedTask);
            }
            if (!IsInt(btnIdProvider.FirstValue))
            {
                bindingContext.ModelState.TryAddModelError("btnId", "Button Id must be an integer.");
                return(Task.CompletedTask);
            }
            var result = new Form(Convert.ToInt32(formIdValueProvider.FirstValue));

            result.AddFormInput(new Button(Convert.ToInt32(btnIdProvider.FirstValue), ""));
            if (inputIdProvider.Length != inputValueProvider.Length)
            {
                bindingContext.ModelState.TryAddModelError(
                    "InputId",
                    "Number of input ids must be same as number of input values.");
                return(Task.CompletedTask);
            }
            var inputIds    = inputIdProvider.Values.ToArray();
            var inputValues = inputValueProvider.Values.ToArray();

            for (int i = 0; i < inputIds.Length; i++)
            {
                if (!IsInt(inputIds[i]))
                {
                    bindingContext.ModelState.TryAddModelError("inpId", "Input Id must be an integer.");
                    return(Task.CompletedTask);
                }
                if (inputValues[i].Length > 150)
                {
                    bindingContext.ModelState.TryAddModelError("val", "Length of val cannot exceed 50 characters.");
                    return(Task.CompletedTask);
                }
                var text = new Textbox(Convert.ToInt32(inputIds[i]), "");
                text.Value = inputValues[i];
                result.AddFormInput(text);
            }
            bindingContext.Result = ModelBindingResult.Success(result);
            return(Task.CompletedTask);
        }
예제 #48
0
        public CreateUniverseScreen(ScreenComponent manager) : base(manager)
        {
            Manager  = manager;
            settings = manager.Game.Settings;

            Padding = new Border(0, 0, 0, 0);

            Title = Languages.OctoClient.CreateUniverse;

            SetDefaultBackground();

            Panel panel = new Panel(manager);

            panel.VerticalAlignment   = VerticalAlignment.Stretch;
            panel.HorizontalAlignment = HorizontalAlignment.Stretch;
            panel.Margin     = Border.All(50);
            panel.Background = new BorderBrush(Color.White * 0.5f);
            panel.Padding    = Border.All(10);
            Controls.Add(panel);

            Grid grid = new Grid(manager);

            grid.VerticalAlignment   = VerticalAlignment.Stretch;
            grid.HorizontalAlignment = HorizontalAlignment.Stretch;
            panel.Controls.Add(grid);

            grid.Columns.Add(new ColumnDefinition()
            {
                ResizeMode = ResizeMode.Auto
            });
            grid.Columns.Add(new ColumnDefinition()
            {
                Width = 1, ResizeMode = ResizeMode.Parts
            });

            nameInput              = GetTextbox();
            nameInput.TextChanged += (s, e) => {
                createButton.Visible = !string.IsNullOrEmpty(e.NewValue);
            };
            AddLabeledControl(grid, string.Format("{0}: ", Languages.OctoClient.Name), nameInput);

            seedInput = GetTextbox();
            AddLabeledControl(grid, string.Format("{0}: ", Languages.OctoClient.Seed), seedInput);

            createButton = Button.TextButton(manager, Languages.OctoClient.Create);
            createButton.HorizontalAlignment = HorizontalAlignment.Right;
            createButton.VerticalAlignment   = VerticalAlignment.Bottom;
            createButton.Visible             = false;
            createButton.LeftMouseClick     += (s, e) =>
            {
                if (string.IsNullOrEmpty(nameInput.Text))
                {
                    return;
                }

                int?seed = null;
                int textseed;
                if (int.TryParse(seedInput.Text, out textseed))
                {
                    seed = textseed;
                }

                manager.Player.RemovePlayer();
                Guid guid = Manager.Game.Simulation.NewGame(nameInput.Text, seed);
                settings.Set("LastUniverse", guid.ToString());
                manager.Game.Player.InsertPlayer();
                manager.NavigateToScreen(new GameScreen(manager));
            };
            panel.Controls.Add(createButton);
        }
        public void CreateTextbox_WriteOutput_FormatCorrect()
        {
            var textbox = new Textbox(5, 5, 200, 100, "sample text");

            Assert.AreEqual("Textbox (5,5) width=200 height=100 text=\"sample text\"", textbox.WriteOutput());
        }
예제 #50
0
        public void InitializeMenu()
        {
            int width = GameConstants.PLAYER_WIDTH;

            animations.Add("walkDown", new Rectangle[4] {
                new Rectangle(0, 0, width, width), new Rectangle(32, 0, width, width), new Rectangle(64, 0, width, width), new Rectangle(96, 0, width, width)
            });

            menuMotto = ContentChest.Instance.menuMottos[random.Next(0, ContentChest.Instance.menuMottos.Count)];

            menuBackground     = new MenuBackground();
            MediaPlayer.Volume = GameOptions.Instance.MUSIC_VOLUME;

            resolutions = new List <string>();
            resolutions.Add("1920x1080");
            resolutions.Add("1280x720");

            try
            {
                MediaPlayer.Play(ContentChest.Instance.menuMusic);
                MediaPlayer.IsRepeating = true;
            }
            catch (Exception e)
            {
                Debug.Write(e);
                Debug.WriteLine("No music found to play.");
            }

            string playGameString = "Login";
            string optionsString  = "Options";
            string quitString     = "Quit";
            string backString     = "Back";
            string refreshString  = "Refresh";


            string musicUp   = "+";
            string musicDown = "-";

            int padding = 20;

            menuButtons          = new List <Button>();
            optionsButtons       = new List <Button>();
            serverBrowserButtons = new List <Button>();
            loginMenu            = new List <Button>();

            currentResolution = Resolution.GameWidth + "x" + Resolution.GameHeight;
            float strWidth = ContentChest.Instance.menuFont.MeasureString(currentResolution).X;

            menuButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(playGameString).X / 2,
                                                   Resolution.GameHeight / 2), playGameString, ButtonTag.LOGIN, ContentChest.Instance.menuFont, new Color(231, 231, 231), true));

            menuButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(optionsString).X / 2,
                                                   Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(playGameString).Y + padding), optionsString, ButtonTag.OPTIONS, ContentChest.Instance.menuFont, new Color(210, 210, 210), true));

            menuButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(quitString).X / 2,
                                                   Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(playGameString).Y * 2 + padding * 2), quitString, ButtonTag.QUIT, ContentChest.Instance.menuFont, new Color(210, 210, 210), true));

            optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(backString).X / 2,
                                                      Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(playGameString).Y * 5), backString, ButtonTag.BACK, ContentChest.Instance.menuFont, new Color(210, 210, 210), true));

            optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(musicDown).X / 2 - 50,
                                                      Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(musicDown).Y - 200), musicDown, ButtonTag.MUSICDOWN, ContentChest.Instance.menuFont, new Color(210, 210, 210), false));

            optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(musicDown).X / 2 + 50,
                                                      Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(musicUp).Y - 200), musicUp, ButtonTag.MUSICUP, ContentChest.Instance.menuFont, new Color(210, 210, 210), false));

            optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(musicDown).X / 2 - 50,
                                                      Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(musicDown).Y - 100), musicDown, ButtonTag.EFFECTDOWN, ContentChest.Instance.menuFont, new Color(210, 210, 210), false));

            optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(musicDown).X / 2 + 50,
                                                      Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(musicUp).Y - 100), musicUp, ButtonTag.EFFECTUP, ContentChest.Instance.menuFont, new Color(210, 210, 210), false));

            optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString("<").X / 2 - 50 - strWidth,
                                                      Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(musicDown).Y + 0), "<", ButtonTag.RESOLUTIONDOWN, ContentChest.Instance.menuFont, new Color(210, 210, 210), false));

            optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(">").X / 2 + 50 + strWidth,
                                                      Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(Resolution.GameWidth + "x" + Resolution.GameHeight).Y + 0), ">", ButtonTag.RESOLUTIONUP, ContentChest.Instance.menuFont, new Color(210, 210, 210), false));


            userNameBox = new Textbox((int)(Resolution.GameWidth / 2),
                                      (int)(Resolution.GameHeight / 2), 10, "Username", false);
            passWordBox = new Textbox((int)(Resolution.GameWidth / 2),
                                      (int)(Resolution.GameHeight / 2 + padding * 5), 10, "Password", true);

            loginMenu.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString("Connect").X / 2,
                                                 (int)(Resolution.GameHeight / 2 + padding * 9)), "Connect", ButtonTag.LOGIN, ContentChest.Instance.menuFont, new Color(231, 231, 231), true));
            loginMenu.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(backString).X / 2,
                                                 (int)(Resolution.GameHeight / 2 + padding * 11)), backString, ButtonTag.BACK, ContentChest.Instance.menuFont, new Color(231, 231, 231), true));

            serverBrowserButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(refreshString).X / 2,
                                                            (int)(Resolution.GameHeight / 2 + padding * 9)), refreshString, ButtonTag.REFRESH, ContentChest.Instance.menuFont, new Color(231, 231, 231), true));
            serverBrowserButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(backString).X / 2,
                                                            (int)(Resolution.GameHeight / 2 + padding * 11)), backString, ButtonTag.BACK, ContentChest.Instance.menuFont, new Color(231, 231, 231), true));


            serverBrowser = new ServerBrowser();
        }
예제 #51
0
        public TargetScreen(ScreenComponent manager, Action <int, int> tp, int x, int y) : base(manager)
        {
            assets = manager.Game.Assets;

            IsOverlay  = true;
            Background = new BorderBrush(Color.Black * 0.5f);
            Title      = "Select target";

            Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel");
            Panel     panel           = new Panel(manager)
            {
                Background          = NineTileBrush.FromSingleTexture(panelBackground, 30, 30),
                Padding             = Border.All(20),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };

            Controls.Add(panel);

            StackPanel spanel = new StackPanel(manager);

            panel.Controls.Add(spanel);

            Label headLine = new Label(manager)
            {
                Text = Title,
                Font = Skin.Current.HeadlineFont,
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            spanel.Controls.Add(headLine);

            StackPanel vstack = new StackPanel(manager);

            vstack.Orientation = Orientation.Vertical;
            spanel.Controls.Add(vstack);

            StackPanel xStack = new StackPanel(manager);

            xStack.Orientation = Orientation.Horizontal;
            vstack.Controls.Add(xStack);

            Label xLabel = new Label(manager);

            xLabel.Text = "X:";
            xStack.Controls.Add(xLabel);

            Textbox xText = new Textbox(manager)
            {
                Background = new BorderBrush(Color.Gray),
                Width      = 150,
                Margin     = new Border(2, 10, 2, 10),
                Text       = x.ToString()
            };

            xStack.Controls.Add(xText);

            StackPanel yStack = new StackPanel(manager);

            yStack.Orientation = Orientation.Horizontal;
            vstack.Controls.Add(yStack);

            Label yLabel = new Label(manager);

            yLabel.Text = "Y:";
            yStack.Controls.Add(yLabel);

            Textbox yText = new Textbox(manager)
            {
                Background = new BorderBrush(Color.Gray),
                Width      = 150,
                Margin     = new Border(2, 10, 2, 10),
                Text       = y.ToString()
            };

            yStack.Controls.Add(yText);

            Button closeButton = Button.TextButton(manager, "Teleport");

            closeButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            closeButton.LeftMouseClick     += (s, e) =>
            {
                if (tp != null)
                {
                    tp(int.Parse(xText.Text), int.Parse(yText.Text));
                }
                else
                {
                    manager.NavigateBack();
                }
            };
            spanel.Controls.Add(closeButton);
        }
예제 #52
0
        private Widget buildFieldEditor(EffectConfig.ConfigField field)
        {
            if (field.AllowedValues != null)
            {
                var widget = new Selectbox(Manager)
                {
                    Value      = field.Value,
                    Options    = field.AllowedValues,
                    AnchorFrom = BoxAlignment.Right,
                    AnchorTo   = BoxAlignment.Right,
                    CanGrow    = false,
                };
                widget.OnValueChanged += (sender, e) => setFieldValue(field, widget.Value);
                return(widget);
            }
            else if (field.Type == typeof(bool))
            {
                var widget = new Selectbox(Manager)
                {
                    Value   = field.Value,
                    Options = new NamedValue[]
                    {
                        new NamedValue()
                        {
                            Name = true.ToString(), Value = true,
                        },
                        new NamedValue()
                        {
                            Name = false.ToString(), Value = false,
                        },
                    },
                    AnchorFrom = BoxAlignment.Right,
                    AnchorTo   = BoxAlignment.Right,
                    CanGrow    = false,
                };
                widget.OnValueChanged += (sender, e) => setFieldValue(field, widget.Value);
                return(widget);
            }
            else if (field.Type == typeof(string))
            {
                var widget = new Textbox(Manager)
                {
                    Value           = field.Value?.ToString(),
                    AnchorFrom      = BoxAlignment.Right,
                    AnchorTo        = BoxAlignment.Right,
                    AcceptMultiline = true,
                    CanGrow         = false,
                };
                widget.OnValueCommited += (sender, e) =>
                {
                    setFieldValue(field, widget.Value);
                    widget.Value = effect.Config.GetValue(field.Name).ToString();
                };
                return(widget);
            }
            else if (field.Type == typeof(Vector2))
            {
                var widget = new Vector2Picker(Manager)
                {
                    Value      = (Vector2)field.Value,
                    AnchorFrom = BoxAlignment.Right,
                    AnchorTo   = BoxAlignment.Right,
                    CanGrow    = false,
                };
                widget.OnValueCommited += (sender, e) =>
                {
                    setFieldValue(field, widget.Value);
                    widget.Value = (Vector2)effect.Config.GetValue(field.Name);
                };
                return(widget);
            }
            else if (field.Type == typeof(Color4))
            {
                var widget = new HsbColorPicker(Manager)
                {
                    Value      = (Color4)field.Value,
                    AnchorFrom = BoxAlignment.Right,
                    AnchorTo   = BoxAlignment.Right,
                    CanGrow    = false,
                };
                widget.OnValueCommited += (sender, e) =>
                {
                    setFieldValue(field, widget.Value);
                    widget.Value = (Color4)effect.Config.GetValue(field.Name);
                };
                return(widget);
            }
            else if (field.Type.GetInterface(nameof(IConvertible)) != null)
            {
                var widget = new Textbox(Manager)
                {
                    Value      = Convert.ToString(field.Value, CultureInfo.InvariantCulture),
                    AnchorFrom = BoxAlignment.Right,
                    AnchorTo   = BoxAlignment.Right,
                    CanGrow    = false,
                };
                widget.OnValueCommited += (sender, e) =>
                {
                    try
                    {
                        var value = Convert.ChangeType(widget.Value, field.Type, CultureInfo.InvariantCulture);
                        setFieldValue(field, value);
                    }
                    catch { }
                    widget.Value = Convert.ToString(effect.Config.GetValue(field.Name), CultureInfo.InvariantCulture);
                };
                return(widget);
            }

            return(new Label(Manager)
            {
                StyleName = "listItem",
                Text = field.Value.ToString(),
                Tooltip = $"Values of type {field.Type.Name} cannot be edited",
                AnchorFrom = BoxAlignment.Right,
                AnchorTo = BoxAlignment.Right,
                CanGrow = false,
            });
        }
예제 #53
0
        private Rdl.TextboxType CreateTableCellTextbox(int i,string fieldName)
        {
            var cellStyle = CreateStyle();
            var fontStyle = CreateStyle();

            Border bd = new Border();
            bd.Style = "Solid";
            cellStyle.Border = bd.Create();

            string value = "=Fields!" + fieldName + ".Value";
            if (Parent.TableCellRenderer != null)
            {
                Parent.TableCellRenderer(fieldName, cellStyle, fontStyle,value);
            }

            Textbox box = new Textbox();
            box.Paragraphs = RdlGenerator.CreateParagraphs(value, fontStyle.Create());
            box.Style = cellStyle.Create();
            box.CanGrow = true;
            return box.Create(fieldName);
        }
예제 #54
0
 public void addTextbox(Textbox tb)
 {
     tb.setConversation(this);
     textboxes.Add(tb);
 }
예제 #55
0
        private void trocarTela(int indexCena)
        {
            if (indexCena != 47 && indexCena != 48)
            {
                contadorTempo = 600;
                Save.lerXml(indexCena);

                caixaTexto = new Textbox(800, new Vector2(100, 200), Save.textoAtual, 10, 20);
                heart.autoPilot = true;
            }

            else
            {
                contadorTempo = 600;
                caixaTexto = new Textbox(800, new Vector2(100, 200), Save.textoAtual, 10, 20);
                //SceneManagement.SceneManager.setScene(new Scenes.Menu(), true);

            }
        }
예제 #56
0
        public TextBubble(IGuiManager guiManager, Texture2D texture, Transform worldPointToFollow, Camera camera)
        {
            mTweakablesHandler = new TweakablesHandler(mTweakablesPath, this);
            IgnoreUnusedVariableWarning(mTweakablesHandler);

            if (guiManager == null)
            {
                throw new ArgumentNullException("guiManager");
            }
            mGuiManager = guiManager;
            XmlGuiFactory loadTextBubble = new XmlGuiFactory(mResourcePath, guiManager);
            IGuiStyle     bubbleStyle    = null;
            IGuiStyle     textStyle      = null;

            foreach (IGuiStyle style in loadTextBubble.ConstructAllStyles())
            {
                if (style == null)
                {
                    continue;
                }
                if (style.Name == "TextBubbleStyleWindow")
                {
                    bubbleStyle = style;
                }
                else if (style.Name == "TextBubbleStyleBase")
                {
                    textStyle = style;
                }
            }

            if (bubbleStyle == null)
            {
                throw new Exception("Unable to load TextBubbleStyleWindow from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            if (textStyle == null)
            {
                throw new Exception("Unable to load TextBubbleStyleBase from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            foreach (IGuiElement element in loadTextBubble.ConstructAllElements())
            {
                if (element is Window && element.Name == "TextBubbleWindow")
                {
                    mBubbleWindow = (Window)element;
                }
            }

            if (mBubbleWindow == null)
            {
                throw new Exception("Unable to load TextBubbleWindow from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            mFollowWorldSpaceObject = new FollowWorldSpaceObject
                                      (
                camera,
                worldPointToFollow,
                GuiAnchor.BottomLeft,
                new Vector2(0.0f, 0.0f),                        // SDN: TODO:  make these offsets configurable
                new Vector3(0.0f, 1.8f, 0.0f)
                                      );

            guiManager.SetTopLevelPosition
            (
                mBubbleWindow,
                mFollowWorldSpaceObject
            );


            mBubbleWindow.Style = bubbleStyle;

            Image bubbleImage = mBubbleWindow.SelectSingleElement <Image>("**/TextBubbleImage");

            bubbleImage.Texture = texture;

            GuiFrame mainFrame  = mBubbleWindow.SelectSingleElement <GuiFrame>("**/TextBubbleFrame");
            Textbox  bubbleText = mBubbleWindow.SelectSingleElement <Textbox>("**/TextBubbleTextbox");

            mainFrame.RemoveChildWidget(bubbleText);

            Vector2 size = new Vector2(texture.width, texture.height);

            size.x += mBubbleWindow.Style.InternalMargins.Left + mBubbleWindow.Style.InternalMargins.Right;
            size.y += mBubbleWindow.Style.InternalMargins.Top + mBubbleWindow.Style.InternalMargins.Bottom;

            mBubbleWindow.GuiSize = new FixedSize(size);
        }
예제 #57
0
        public TextBubble(IGuiManager guiManager, string text, Transform worldPointToFollow, Camera camera)
        {
            mTweakablesHandler = new TweakablesHandler(mTweakablesPath, this);
            IgnoreUnusedVariableWarning(mTweakablesHandler);

            if (guiManager == null)
            {
                throw new ArgumentNullException("guiManager");
            }
            mGuiManager = guiManager;
            XmlGuiFactory loadTextBubble = new XmlGuiFactory(mResourcePath, guiManager);
            IGuiStyle     bubbleStyle    = null;
            IGuiStyle     textStyle      = null;

            foreach (IGuiStyle style in loadTextBubble.ConstructAllStyles())
            {
                if (style == null)
                {
                    continue;
                }
                if (style.Name == "TextBubbleStyleWindow")
                {
                    bubbleStyle = style;
                }
                else if (style.Name == "TextBubbleStyleBase")
                {
                    textStyle = style;
                }
            }

            if (bubbleStyle == null)
            {
                throw new Exception("Unable to load TextBubbleStyleWindow from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            if (textStyle == null)
            {
                throw new Exception("Unable to load TextBubbleStyleBase from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            foreach (IGuiElement element in loadTextBubble.ConstructAllElements())
            {
                if (element is Window && element.Name == "TextBubbleWindow")
                {
                    mBubbleWindow = (Window)element;
                }
            }

            if (mBubbleWindow == null)
            {
                throw new Exception("Unable to load TextBubbleWindow from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            mFollowWorldSpaceObject = new FollowWorldSpaceObject
                                      (
                camera,
                worldPointToFollow,
                GuiAnchor.BottomLeft,
                new Vector2(0.0f, 0),                                // SDN: TODO:  make these offsets configurable
                new Vector3(0.0f, 1.8f, 0.0f)
                                      );

            guiManager.SetTopLevelPosition
            (
                mBubbleWindow,
                mFollowWorldSpaceObject
            );

            Textbox bubbleText = mBubbleWindow.SelectSingleElement <Textbox>("**/TextBubbleTextbox");

            mBubbleWindow.Style = bubbleStyle;
            bubbleText.Text     = text;

            Image    bubbleImage = mBubbleWindow.SelectSingleElement <Image>("**/TextBubbleImage");
            GuiFrame mainFrame   = mBubbleWindow.SelectSingleElement <GuiFrame>("**/TextBubbleFrame");

            mainFrame.RemoveChildWidget(bubbleImage);

            // Set the size of the window to be the smallest that draws the entire chat message
            UnityEngine.GUIStyle unityStyle = bubbleText.Style.GenerateUnityGuiStyle();
            unityStyle.wordWrap = false;
            GUIContent textContent = new GUIContent(text);

            Vector2 size = unityStyle.CalcSize(textContent);

            if (size.x > mMaxWidth)
            {
                size.x = mMaxWidth;
                unityStyle.wordWrap = true;
                size.y = unityStyle.CalcHeight(textContent, mMaxWidth);
            }
            if (size.x < mMinWidth)
            {
                size.x = mMinWidth;
            }
            size.x += mBubbleWindow.Style.InternalMargins.Left + mBubbleWindow.Style.InternalMargins.Right;
            size.y += mBubbleWindow.Style.InternalMargins.Top + mBubbleWindow.Style.InternalMargins.Bottom;

            mBubbleWindow.GuiSize = new FixedSize(size);
        }
예제 #58
0
 internal static HandleRef getCPtr(Textbox obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
 private Textbox CreateTextBox()
 {
     Textbox tb = new Textbox();
     tb.ID = this.ControlID + "_textbox";
     tb.CssClass = "autocompletetextbox";
     tb.Visible = this.IsVisible;
     tb.Enabled = this.IsEnabled;
     tb.ReadOnly = this.IsReadOnly;
     tb.Value = this._value; 
     return tb;
 }
예제 #60
0
        //����ҳü
        private PageSectionType CreatPageHeader()
        {
            double height = 0.91;
            double LRHeigth = 0.0;
            double tableHeaderHeigth = 0.0;
            ArrayList Items = new ArrayList();

            Textbox ctb = new Textbox
            {
                Height = "0.9cm",
                Left = LeftMargin.ToString() + "mm",
                Width = (A4Width - LeftMargin - RightMargin).ToString() + "mm",
                Paragraphs = CreateParagraphs(PageHeaderText, new Style { FontFamily="����", FontSize = "18pt", FontWeight = "Bold", TextAlign = "Center" }.Create()),
                CanGrow = true ,
                Style = new Style { FontSize = "18pt", FontWeight = "Bold", TextAlign = "Center" }.Create()
            };

            TextboxType headerTextbox = ctb.Create("Page_HeaderText");
            Items.Add(headerTextbox);

            ctb.Width = ((A4Width - LeftMargin - RightMargin) / 2).ToString() + "mm";
            ctb.Height = "0.5cm";
            ctb.Paragraphs = CreateParagraphs(PageHeaderLeftText);
            ctb.Style = new Style { FontSize = "9pt", TextAlign = "Left" }.Create();
            ctb.Top = "0.92cm";
            TextboxType headerLeftTextbox = ctb.Create("Page_HeaderLeftText");
            if (!string.IsNullOrEmpty(this.PageHeaderLeftText))
            {
                Items.Add(headerLeftTextbox);
                LRHeigth = 0.5;
            }

            ctb.Style = new Style { FontSize = "9pt", TextAlign = "Right" }.Create();
            ctb.Left = ((A4Width) / 2).ToString() + "mm";
            ctb.Paragraphs = CreateParagraphs(PageHeaderRightText);

            TextboxType headerRightTextbox = ctb.Create("Page_HeaderRightText");
            if (!string.IsNullOrEmpty(this.PageHeaderRightText))
            {
                Items.Add(headerRightTextbox);
                LRHeigth = 0.5;
            }

            ReportItemsType reportItems = new ReportItemsType();
            reportItems.Items = Items.ToArray();

            PageSection header = new PageSection();
            header.ReportItems = reportItems;
            height = height+tableHeaderHeigth + LRHeigth;
            header.Height = height.ToString()+"cm";
            header.PrintOnFirstPage = true;
            header.PrintOnLastPage = true;
            return header.Create();
        }