Пример #1
0
 void TextInput_OnCaretMoved(TextInput arg1, int arg2)
 {
     Vector3 cPosH = Font.GetCaretOffsetAndHeight(arg1.Text, Math.Max(0, arg2));
     Vector2 cPos = new Vector2(cPosH.X, cPosH.Y) * drawText.TextScale;
     Caret.Offset = new Point((int)cPos.X, (int)cPos.Y);
     Caret.Height = (int)(cPosH.Z * drawText.TextScale);
 }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //StreamReader reader = new StreamReader("c:\\tmp\\en.yml");
            StreamReader reader = new StreamReader("c:\\tmp\\de.yml");

            TextInput input = new TextInput(reader.ReadToEnd());

            bool success;
            YamlParser parser = new YamlParser();
            YamlStream yamlStream = parser.ParseYamlStream(input, out success);
            if (success)
            {
                foreach (YamlDocument doc in yamlStream.Documents)
                {
                    TreeNode rootNode = YamlEmittor.CreateNode(doc.Root);
                    treeView1.Nodes.Add(rootNode);

                    foreach (TreeNode node in rootNode.Nodes)
                    {
                        richTextBox1.AppendText(node.Text);
                    }
                }
            }
            else
            {
                richTextBox1.Text = parser.GetErrorMessages();
            }
        }
Пример #3
0
 static DevConsole()
 {
     IsActivated = false;
     tInput = new TextInput();
     tInput.Text = "";
     lc = 0;
 }
Пример #4
0
 public TextInputWidget(WidgetRenderer wr, SpriteFont f = null, Texture2D t = null)
     : base(wr, f)
 {
     Caret = new RectWidget(wr, t);
     Caret.Parent = this;
     Caret.Width = 1;
     Caret.Height = Height;
     TextInput = new TextInput();
     TextInput.OnTextChanged += tInput_OnTextChanged;
     TextInput.OnCaretMoved += TextInput_OnCaretMoved;
 }
Пример #5
0
        private void addTextYou(string text)
        {
            messages.Add(new Message()
            {
                Side     = MessageSide.You,
                Text     = TextInput.Text,
                PrevSide = curside
            });

            curside = MessageSide.You;

            ScrollConversationToEnd();

            TextInput.Text = "";
            TextInput.Focus();
        }
Пример #6
0
        public async Task <QueryResult> CheckIntent(string userInput, string LanguageCode = "en")
        {
            await CreateSession();

            QueryInput queryInput = new QueryInput();
            var        queryText  = new TextInput();

            queryText.Text         = userInput;
            queryText.LanguageCode = LanguageCode;
            queryInput.Text        = queryText;

            // Make the request
            DetectIntentResponse response = await _sessionsClient.DetectIntentAsync(_sessionName, queryInput);

            return(response.QueryResult);
        }
Пример #7
0
 /// <summary>
 /// 鼠标按下事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void mapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 1 && !isControl && !isMouseDown)
     {
         textCtrl          = new TextInput();
         textCtrl.Location = new Point(e.x, e.y);
         mapControl.CreateControl();//强制创建控件
         mapControl.Controls.Add(textCtrl);
         textCtrl.InputFinished += InputFinish;
         downPoint = new MapLngLat()
         {
             Lng = e.mapX, Lat = e.mapY
         };
         isMouseDown = true;
     }
 }
Пример #8
0
        public void CreateStartMenu()
        {
            startScreenPanel = new Panel();
            UserInterface.Active.AddEntity(startScreenPanel);

            hostButton = new GBBtutton("Host", skin: ButtonSkin.Alternative, anchor: Anchor.Auto, size: new Vector2(300, 50));
            startScreenPanel.AddChild(hostButton);
            hostButton.OnClick += StartHost;

            input = new TextInput(false, anchor: Anchor.Auto, size: new Vector2(300, 50));
            input.PlaceholderText = "Insert Host IP";
            startScreenPanel.AddChild(input);
            clientButton = new GBBtutton("Connect to host", skin: ButtonSkin.Alternative, anchor: Anchor.Auto, size: new Vector2(300, 50));
            startScreenPanel.AddChild(clientButton);
            clientButton.OnClick += ConnectToHost;
        }
Пример #9
0
        public void Update()
        {
            this.updateDeltaTime(this.getUnscaledDeltaTime());

            Timer.update();

            bool hasFocus = this.hasFocus();

            using (this.getScope()) {
                WidgetsBinding.instance.focusManager.focusNone(!hasFocus);
                this._updateScrollInput();
                TextInput.Update();
                this._timerProvider.update(this.flushMicrotasks);
                this.flushMicrotasks();
            }
        }
Пример #10
0
    static void AddInput(DisplayObjectContainer container, double defval, Action <double> action)
    {
        var input = new TextInput();

        input.text     = defval.ToString();
        input.width    = 50;
        input.keyDown += e =>
        {
            if (e.keyCode == Keyboard.ENTER)
            {
                var v = double.Parse(input.text);
                action(v);
            }
        };
        container.addChild(input);
    }
Пример #11
0
 protected override void Update()
 {
     MainCanvas = this;
     UserAction.Update();
     Keyboard.InfoCollection();
     DispatchUserAction();
     AnimationManage.Manage.Update();
     if (UIPage.CurrentPage != null)
     {
         UIPage.CurrentPage.Update(UserAction.TimeSlice);
     }
     TextInput.Dispatch();
     InputCaret.UpdateCaret();
     CheckSize();
     ThreadMission.ExtcuteMain();
 }
Пример #12
0
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            //Setting up employees
            Dietitian       theDietitian       = new Dietitian("Mrs Lind", Employee.Positions.Dietitian);
            PersonalTrainer thePersonalTrainer = new PersonalTrainer("Arnold Schwarzenegger", Employee.Positions.PersonalTrainer);
            //Setting up clinic
            NutritionClinic theClinic = new NutritionClinic("Mayonaise Foundation", theDietitian, thePersonalTrainer);

            var input = new TextInput();
            var gui   = new ConsoleGUI()
            {
                Input = input
            };
            var sim = new MySimulation(input, theClinic);
            await gui.Start(sim);
        }
        public override void Load()
        {
            sndButtonOver  = new FMODSound(FMODSystem, "Content/Triple Thunder/Menus/SFX/Button Over.wav");
            sndButtonClick = new FMODSound(FMODSystem, "Content/Triple Thunder/Menus/SFX/Button Click.wav");

            sprBackground = Content.Load <Texture2D>("Triple Thunder/Menus/Create Room/Background Mission");

            CancelButton = new InteractiveButton(Content, "Triple Thunder/Menus/Common/Cancel Button", new Vector2(490, 380), OnButtonOver, Cancel);
            OKButton     = new InteractiveButton(Content, "Triple Thunder/Menus/Common/OK Button", new Vector2(565, 380), OnButtonOver, CreateMissionSelect);

            fntArial12    = Content.Load <SpriteFont>("Fonts/Arial12");
            RoomNameInput = new TextInput(fntArial12, sprPixel, sprPixel, new Vector2(270, 255), new Vector2(314, 20));
            PasswordInput = new TextInput(fntArial12, sprPixel, sprPixel, new Vector2(470, 287), new Vector2(84, 20), null, true);

            RoomNameInput.SetText("Let's have fun!");
        }
Пример #14
0
        private void inputTypeSwitchClicked(Button btn)
        {
            TextInput input = btn.Tag as TextInput;

            NumberStyles oldStyle;
            string       format = "";

            if (btn.Text == "H")
            {
                btn.TextColor = Main.DecColor;
                oldStyle      = NumberStyles.HexNumber;
            }
            else
            {
                btn.TextColor = Main.HexColor;
                oldStyle      = NumberStyles.Integer;
                format        = "X2";
            }

            if (input.Text != "")
            {
                if (input == searchInput) // special treatment for search input because it can have several values (space-separated)
                {
                    byte[] query = getSearchQuery();
                    if (query != null)
                    {
                        List <string> bytes = new List <string>();
                        foreach (byte b in query)
                        {
                            bytes.Add(b.ToString(format));
                        }
                        input.Text = string.Join(" ", bytes);
                    }
                }
                else
                {
                    int i = -1;
                    if (int.TryParse(input.Text, oldStyle, null, out i))
                    {
                        input.Text = i.ToString(format);
                    }
                }
            }

            input.TextColor = btn.TextColor;
            btn.Text        = btn.Text == "H" ? "D" : "H"; // do this here and not above because getSearchQuery relies on the text
        }
Пример #15
0
        public static void Create(string dir, Action onNameGet, Action <string, string> onFinish)
        {
            // Asks for the name of the test.
            TextInput.GetInput("Enter a name for your test.", "Test", name =>
            {
                onNameGet();

                // Cancels if they didn't input anything.
                if (name == "")
                {
                    onFinish("", dir);
                    return;
                }

                var editor = new TestEditor(name);

                /*
                 * If the test is discarded or it fails to save,
                 * it calls the onFinish delegate but without
                 * a returned name.
                 */

                editor.onFinish = () =>
                {
                    if (editor.DialogResult == DialogResult.OK)
                    {
                        if (editor.Save(dir + "/" + name))
                        {
                            onFinish(name, dir);
                        }
                        else
                        {
                            onFinish("", dir);
                        }
                    }
                    else
                    {
                        onFinish("", dir);
                    }
                };

                editor.Show();
            }, "", s =>
            {
                return(TextInput.dirNameValid(s) && !Helper.Exists(dir + s));
            });
        }
Пример #16
0
        public override void OnEntry(GameTime gameTime)
        {
            KeyboardEventDispatcher.OnKeyPressed += KeyboardEventDispatcher_OnKeyPressed;

            font = game.Content.Load <SpriteFont>(@"Fonts\CourierNew32");
            wr   = new WidgetRenderer(G, font);

            wUsername        = new TextWidget(wr);
            wUsername.Anchor = new Point(G.Viewport.Width / 2, G.Viewport.Height / 2);
            wUsername.AlignY = Alignment.BOTTOM;
            wUsername.AlignX = Alignment.MID;
            wUsername.Color  = Color.White;
            wUsername.Height = 32;

            ButtonHighlightOptions h1 = new ButtonHighlightOptions(100, 30, Color.Red);
            ButtonHighlightOptions h2 = new ButtonHighlightOptions(100, 30, Color.Green);

            bFinish = new RectButton(wr, h1, h2);
            bFinish.OffsetAlignY   = Alignment.BOTTOM;
            bFinish.OffsetAlignX   = Alignment.MID;
            bFinish.AlignX         = Alignment.MID;
            bFinish.Offset         = new Point(0, 0);
            bFinish.Parent         = wUsername;
            bFinish.OnButtonPress += bFinish_OnButtonPress;
            bFinish.Hook();

            txtLogin              = new TextWidget(wr);
            txtLogin.Height       = bFinish.Height;
            txtLogin.Text         = "Login";
            txtLogin.Color        = Color.Black;
            txtLogin.AlignX       = Alignment.MID;
            txtLogin.AlignY       = Alignment.MID;
            txtLogin.OffsetAlignX = Alignment.MID;
            txtLogin.OffsetAlignY = Alignment.MID;
            txtLogin.Parent       = bFinish;

            tInput = new TextInput();
            tInput.OnTextChanged += tInput_OnTextChanged;
            tInput.Activate();
            tInput.Text = UserConfig.UserName;

            if (UserConfig.UserName.Equals(UserConfig.DEFAULT_USER_NAME))
            {
                // Must Create A Default User Name
                wUsername.Text = "Please Enter A New Username";
            }
        }
        //public OneSignalBusiness(GO_TECHEntities context = null) : base()
        //{
        //}
        public string StartPushNoti(object obj, List <string> deviceID, string contents, string headerStr, int?sound = null)
        {
            OneSignalInput input  = new OneSignalInput();
            TextInput      header = new TextInput();

            header.en = "Thông báo !";
            TextInput content = new TextInput();

            content.en               = headerStr;
            input.app_id             = SystemParam.APP_ID;
            input.data               = obj;
            input.headings           = header;
            input.contents           = content;
            input.android_channel_id = SystemParam.ANDROID_CHANNEL_ID;
            input.include_player_ids = deviceID;
            return(JsonConvert.SerializeObject(input));
        }
Пример #18
0
        /// <summary>
        /// 释放工具命令
        /// </summary>
        public void ReleaseCommond()
        {
            if (textCtrl != null)
            {
                gmapControl.Controls.Remove(textCtrl);
                textCtrl.Dispose();
                textCtrl = null;
            }
            if (gmapControl != null)
            {
                gmapControl.SetCursor(Cursors.Default);
                gmapControl.MouseDown -= gmapControl_MouseDown;
                gmapControl.KeyDown   -= gmapControl_KeyDown;
            }

            Utils.bPublishEvent = true;
        }
        public async Task <QueryResult> VerificarIntent(string chatID, string message)
        {
            _sessionsClient = await SessionsClient.CreateAsync();

            _sessionName = new SessionName(chatbottelegramdio.project_id, chatID);

            QueryInput queryInput = new QueryInput();
            var        queryText  = new TextInput();

            queryText.Text         = message;
            queryText.LanguageCode = "pt-BR";
            queryInput.Text        = queryText;

            DetectIntentResponse response = await _sessionsClient.DetectIntentAsync(_sessionName, queryInput);

            return(response.QueryResult);
        }
Пример #20
0
 public static YamlStream Load(string file)
 {
     string text = File.ReadAllText(file);
     TextInput input = new TextInput(text);
     YamlParser parser = new YamlParser();
     bool success;
     YamlStream stream = parser.ParseYamlStream(input, out success);
     if (success)
     {
         return stream;
     }
     else
     {
         string message = parser.GetEorrorMessages();
         throw new Exception(message);
     }
 }
Пример #21
0
    private void Awake()
    {
        DialogBox playerDialogBoxScript = GameObject.Find("Player").GetComponent <DialogBox>();

        textInput     = GameObject.Find("Player").GetComponent <TextInput>();
        title_text    = playerDialogBoxScript.title_text;
        body_text     = playerDialogBoxScript.body_text;
        input_canvas  = playerDialogBoxScript.input_canvas;
        dialog_canvas = playerDialogBoxScript.dialog_canvas;
        bang          = gameObject.transform.Find("Bang").gameObject;
        if (!bang)
        {
            Debug.Log(gameObject + " Failed bang init");
        }

        window = GameObject.Find("GameMaster").GetComponent <ProgressTracker>().windows[flag].GetComponent <windowControl>().window;
    }
Пример #22
0
        public void AddInputTextTest()
        {
            string text = text = "Gratis af te halen in Assen: een monumentaal kunstwerk. Er is ייn maar: het kunstwerk is 15 meter hoog.\n" +
                                 "Het gaat om een kunstwerk dat vanaf 1989 voor het station in Assen stond en door de Haarlemse kunstenaar Jan Jacobs Mulder is gemaakt. Het werk heet Aarde, Water, Huis en bestaat uit drie delen: een stalen sokkel met daarboven twee stalen frames.\n" +
                                 "Het kunstwerk is van de gemeente. Die verwijderde het in 2013 omdat het stationsgebied wordt heringericht, schrijft RTV Drenthe. De werkgroep Monumentale Kunst van erfgoedvereniging Heemschut kwam erachter dat het sindsdien - zo omschrijft Norman Vervat van de werkgroep - \"op een werf lag weg te roesten.\"\n" +
                                 "Plein, rotonde of verzamelaar\n" +
                                 "Assen gaat het niet terugplaatsen en vroeg de werkgroep te helpen bij het zoeken naar een ander \"tehuis\". Vervat: \"We denken aan een plein, park of rotonde. Of aan een verzamelaar met een grote tuin.\"\n" +
                                 "Hij heeft al enkele mailtjes van belangstellenden binnen. De nieuwe eigenaar moet wel over geld beschikken: het werk moet worden opgeknapt en moet bij herplaatsing een fundering krijgen (kosten: 15.000 euro). Het tienjaarlijkse onderhoud kost ook enkele duizenden euro's.";
            TextInput textInput = new TextInput(text);

            var response = instance.AddInputText(jobid, textInput);

            Assert.IsInstanceOf <Job>(response, "response is Job");
            Assert.NotNull(response);
            Assert.AreEqual(Job.StateEnum.INPUTSUPLOADED, response.State);
            Assert.AreEqual(1, response.Inputs.Count);
        }
        public void WhenTextInputInvoked_ThenViewModelIsUpdated(string key, string value)
        {
            var values = new Dictionary <string, string>()
            {
                { key, value }
            };

            var component = new TextInput();

            component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext();

            ViewViewComponentResult result      = component.Invoke(values) as ViewViewComponentResult;
            TextInputModel          resultModel = (TextInputModel)result.ViewData.Model;

            //Assert
            value.Should().Be(ViewComponentTestHelper.GetPropertyValue(resultModel, key));
        }
Пример #24
0
        /// <summary>
        /// Creates a new view for telling that the player has completed the level
        /// </summary>
        /// <param name="game">The Game instance that will show this view</param>
        public WinView(Game1 game) : base(game)
        {
            recordHandler = new RecordHandler(game.currentLevelName);
            recordHandler.LoadRecords();
            closeButton = new Button("ok", new Vector2(0, 0), game.Content);
            closeButton.ButtonPressed += new Action <Button>(closeButton_ButtonPressed);

            closeButton.Position = new Vector2(game.getWidth() * 0.5f -
                                               closeButton.Width * 0.5f,
                                               game.getHeight() * 0.75f);
            textInput = new TextInput("Enter your name here",
                                      new Vector2(game.getWidth() * 0.3f, game.relativeY(200)),
                                      game.Content, (int)(game.getWidth() * 0.4f),
                                      (int)(game.getHeight() * 0.1f));
            font      = game.Content.Load <SpriteFont>("SpriteFont2");
            placement = recordHandler.GetPlacement((int)(game.finishTime.TotalMilliseconds));
        }
Пример #25
0
        private void FriendRoomBtn_Click(object sender, EventArgs e)
        {
            if (NetRoomPeer.CurrentRoom != null)
            {
                return;
            }

            SetNativeEnabled(false);

            // Asks for the name of the theme.
            TextInput.GetInput("Enter a username:"******"Friend Room",
                               username =>
            {
                if (username == "")
                {
                    SetNativeEnabled(true);
                    return;
                }

                Settings.Default.username = username;
                Settings.Default.Save();

                var onlineChoose = new OnlineChoose();

                onlineChoose.FormClosing += (s, ev) =>
                {
                    SetNativeEnabled(true);

                    if (onlineChoose.DialogResult == DialogResult.OK)
                    {
                        if (onlineChoose.Host)
                        {
                            NetRoomServer.Begin(username, onlineChoose.Port);
                        }
                        else
                        {
                            NetRoomClient.Begin(username, onlineChoose.IP, onlineChoose.Port);
                        }
                    }
                };

                onlineChoose.Show();
            }, Settings.Default.username);
        }
Пример #26
0
        public Vortex()
        {
            panelMaster    = new Panel(masterSize, PanelSkin.None, anchor: Anchor.AutoInline, offset: new Vector2(0, 0));
            panelInside    = new Panel(new Vector2(GlobalFields.PANEL_EDITOR_INSIDE_SIZE.X, 380), PanelSkin.Simple, anchor: Anchor.AutoInline, offset: new Vector2(0, 0));
            checkboxActive = new CheckBox("Active", isChecked: false)
            {
                OnClick = (Entity btn) => { OnClickCheckboxActive(); }
            };
            panelInside.Visible = false;
            panelMaster.Size    = masterSizeMinimized;

            panelMaster.AddChild(new RichParagraph("{{GOLD}} Vortex"));
            panelMaster.AddChild(checkboxActive);
            panelMaster.AddChild(panelInside);

            panelInside.AddChild(new Paragraph("Position", Anchor.AutoInline, new Vector2(.9f, -1)));

            panelInside.AddChild(new Paragraph("X", Anchor.AutoInline, new Vector2(0.2f, -1)));
            positionX = new TextInput(false, new Vector2(0.3f, -1f), anchor: Anchor.AutoInline);
            positionX.Validators.Add(new TextValidatorNumbersOnly(true));
            positionX.Value          = "50";
            positionX.ValueWhenEmpty = "0.1";
            panelInside.AddChild(positionX);

            panelInside.AddChild(new Paragraph("Y", Anchor.AutoInline, new Vector2(0.2f, -1)));
            positionY = new TextInput(false, new Vector2(0.3f, -1f), anchor: Anchor.AutoInline);
            positionY.Validators.Add(new TextValidatorNumbersOnly(true));
            positionY.Value          = "50";
            positionY.ValueWhenEmpty = "0.1";
            panelInside.AddChild(positionY);

            panelInside.AddChild(new Paragraph("Mass", Anchor.AutoInline, new Vector2(.9f, -1)));
            mass = new TextInput(false, new Vector2(0.9f, -1f), anchor: Anchor.AutoInline);
            mass.Validators.Add(new TextValidatorNumbersOnly(true));
            mass.Value          = "10";
            mass.ValueWhenEmpty = "0.1";
            panelInside.AddChild(mass);

            panelInside.AddChild(new Paragraph("Max Speed", Anchor.AutoInline, new Vector2(.9f, -1)));
            maxSpeed = new TextInput(false, new Vector2(0.9f, -1f), anchor: Anchor.AutoInline);
            maxSpeed.Validators.Add(new TextValidatorNumbersOnly(true));
            maxSpeed.Value          = "10";
            maxSpeed.ValueWhenEmpty = "0.1";
            panelInside.AddChild(maxSpeed);
        }
Пример #27
0
        public static void Duplicate(string from, string dir, Action onNameGet, Action <string, string> onFinish)
        {
            TextInput.GetInput("Enter a name for your document.", "Document", docName =>
            {
                onNameGet();

                if (docName == "")
                {
                    onFinish("", dir);
                    return;
                }

                var document = new Document(from, dir);
                if (!document.TryLoadText())
                {
                    return;
                }

                var editor = new DocumentForm(docName, document.text);

                editor.onFinish = () =>
                {
                    if (editor.DialogResult == DialogResult.OK)
                    {
                        if (editor.Save(dir + "/" + docName))
                        {
                            onFinish(docName, dir);
                        }
                        else
                        {
                            onFinish("", dir);
                        }
                    }
                    else
                    {
                        onFinish("", dir);
                    }
                };

                editor.Show();
            }, "", s =>
            {
                return(TextInput.dirNameValid(s) && !Helper.Exists(dir + s));
            });
        }
Пример #28
0
        private List <IDialog> BookSteps()
        {
            var steps = new List <IDialog>();

            var userName = new TextInput
            {
                Property = "user.userProfile.Name",
                Prompt   = new ActivityTemplate("[AskForName]")
            };

            var cityInput = new TextInput
            {
                Property = "user.userProfile.destination",
                Prompt   = new ActivityTemplate("[DestinationPrompt]")
            };

            steps.Add(userName);
            steps.Add(new SendActivity("[AckName]"));
            steps.Add(cityInput);
            steps.Add(new SendActivity("[ConfirmInfo]"));

            var confirm = new ConfirmInput
            {
                Prompt   = new ActivityTemplate("[ConfirmPrompt]"),
                Property = "turn.finalConfirmation"
            };

            steps.Add(confirm);

            var condition = new IfCondition
            {
                Condition = "turn.finalConfirmation == true",
                Steps     = new List <IDialog>()
                {
                    new SendActivity("[ConfirmInfo]")
                },
                ElseSteps = new List <IDialog> {
                    new SendActivity("[NotConfirm]")
                }
            };

            steps.Add(condition);
            steps.Add(new EndDialog());
            return(steps);
        }
Пример #29
0
        /// <summary>
        ///     CLIENT SIDE: Destroy the <see cref="PortalSelectionGUI" /> when active
        /// </summary>
        private static void ResetPortalSelector(On.TextInput.orig_Hide orig, TextInput self)
        {
            orig(self);

            if (ZNet.instance.IsServerInstance())
            {
                return;
            }

            PortalSelectionGUI.Hide();

            // reset position of textinput panel
            self.m_panel.transform.localPosition = new Vector3(0, 0f, 0);

            // restore mouse capture
            GameCamera.instance.m_mouseCapture = true;
            GameCamera.instance.UpdateMouseCapture();
        }
Пример #30
0
        public NewDialog(CellED parent)
            : base(parent, 400, 100, new Vector2(parent.ScreenWidth / 2, parent.ScreenHeight / 2), "New Project")
        {
            textInput              = new TextInput(this, Width - 30, Pos + new Vector2(15, 20));
            textInput.TextChanged += OnTextChanged;

            cancelButton = new Button(this, 60, 30, Pos + new Vector2(Width - 75, Height - 45));
            cancelButton.DisconnectInput();
            cancelButton.ButtonText     = "Cancel";
            cancelButton.ButtonClicked += Hide;

            createButton = new Button(this, 60, 30, cancelButton.Pos + new Vector2(-70, 0));
            createButton.DisconnectInput();
            createButton.ButtonText     = "Create";
            createButton.ButtonClicked += OnCreateClicked;

            warningOffset = Pos + new Vector2(20, 62);
        }
Пример #31
0
        public SettingsScene(ISceneManager sceneManager) : base(sceneManager)
        {
            UsernameInput = new TextInput
            {
                Text     = Settings.Default.Username,
                Position = (-4, -1),
            };
            UsernameInput.OnChange += UsernameInput_OnChange;
            Children.Add(UsernameInput);

            ExitToMenuButton = new Button
            {
                Text     = "Exit to Menu",
                Position = (-4, 3),
            };
            ExitToMenuButton.OnClick += ExitToMenuButton_OnClick;
            Children.Add(ExitToMenuButton);
        }
Пример #32
0
 public TextField(Control parent) : base(parent)
 {
     textInput = new TextInput();
     textInput.EnterPressed += (txt) =>
     {
         EnterPressed?.Invoke(this, txt);
     };
     textInput.TextChanged += (txt) =>
     {
         TextChanged?.Invoke(this, txt);
     };
     textInput.TextTyped += (txt) =>
     {
         TextTyped?.Invoke(this, txt);
     };
     TextColor = Color.Black;
     Font      = Font.Arial11;
 }
Пример #33
0
 void InputValueChanged(TextInput input)
 {
     TextElement.AsyncGetSizeY("", new Vector2(800, 120), 28, new EmojiString(input.InputString), FontStyle.Normal,
                               (o) => {
         var mod = input.TextCom.model;
         var h   = o.y - mod.data.sizeDelta.y;
         if (o.y > y)
         {
             if (h > 0)
             {
                 mod.data.sizeDelta        = o;
                 mod.data.localPosition.y += (o.y - y) / 2;
                 mod.IsChanged             = true;
             }
             y = o.y;
         }
     });
 }
Пример #34
0
        public static void Create(string dir, Action onNameGet, Action <string, string> onFinish)
        {
            // Take name input for flashcards.
            TextInput.GetInput("Enter a name for your flashcards.", "Flashcards", name =>
            {
                onNameGet();

                if (name == "")
                {
                    onFinish("", dir);
                    return;
                }

                // Initialize and show flashcards editor.
                var editor = new FlashcardsEditor(name);

                editor.onFinish = () =>
                {
                    if (editor.DialogResult == DialogResult.OK)
                    {
                        if (editor.Save(dir + "/" + name))
                        {
                            if (editor.DialogResult == DialogResult.OK)
                            {
                                onFinish(name, dir);
                            }
                            else
                            {
                                onFinish("", dir);
                            }
                        }
                    }
                    else
                    {
                        onFinish("", dir);
                    }
                };

                editor.Show();
            }, "", s =>
            {
                return(TextInput.dirNameValid(s) && !Helper.Exists(dir + s));
            });
        }
Пример #35
0
        public ScaleInterpolator2()
        {
            panelMaster    = new Panel(masterSize, PanelSkin.None, anchor: Anchor.AutoInline, offset: new Vector2(0, 0));
            panelInside    = new Panel(new Vector2(GlobalFields.PANEL_EDITOR_INSIDE_SIZE.X, 250), PanelSkin.Simple, anchor: Anchor.AutoInline, offset: new Vector2(0, 0));
            checkboxActive = new CheckBox("Active", isChecked: false)
            {
                OnClick = (Entity btn) => { OnClickCheckboxActive(); }
            };
            panelMaster.AddChild(new RichParagraph("{{GOLD}} Scale Interpolator 2"));
            panelMaster.AddChild(checkboxActive);
            panelMaster.AddChild(panelInside);
            panelInside.Visible = false;
            panelMaster.Size    = masterSizeMinimized;

            panelInside.AddChild(new Paragraph("Initial", Anchor.AutoInline, new Vector2(0, -1)));
            panelInside.AddChild(new Paragraph("X", Anchor.AutoInline, new Vector2(0.2f, -1)));
            _inputInitialX = new TextInput(false, new Vector2(0.3f, -1f), anchor: Anchor.AutoInline);
            _inputInitialX.Validators.Add(new TextValidatorNumbersOnly(true, 0));
            _inputInitialX.Value          = "1";
            _inputInitialX.ValueWhenEmpty = "1";
            panelInside.AddChild(_inputInitialX);

            panelInside.AddChild(new Paragraph("Y", Anchor.AutoInline, new Vector2(0.2f, -1)));
            _inputInitialY = new TextInput(false, new Vector2(0.3f, -1f), anchor: Anchor.AutoInline);
            _inputInitialY.Validators.Add(new TextValidatorNumbersOnly(true, 0));
            _inputInitialY.Value          = "1";
            _inputInitialY.ValueWhenEmpty = "1";
            panelInside.AddChild(_inputInitialY);

            panelInside.AddChild(new Paragraph("Final", Anchor.AutoInline, new Vector2(0, -1)));
            panelInside.AddChild(new Paragraph("X", Anchor.AutoInline, new Vector2(0.2f, -1)));
            _inputFinalX = new TextInput(false, new Vector2(0.3f, -1f), anchor: Anchor.AutoInline);
            _inputFinalX.Validators.Add(new TextValidatorNumbersOnly(true, 0));
            _inputFinalX.Value          = "1.5";
            _inputFinalX.ValueWhenEmpty = "1";
            panelInside.AddChild(_inputFinalX);

            panelInside.AddChild(new Paragraph("Y", Anchor.AutoInline, new Vector2(0.2f, -1)));
            _inputFinalY = new TextInput(false, new Vector2(0.3f, -1f), anchor: Anchor.AutoInline);
            _inputFinalY.Validators.Add(new TextValidatorNumbersOnly(true, 0));
            _inputFinalY.Value          = "1.5";
            _inputFinalY.ValueWhenEmpty = "1";
            panelInside.AddChild(_inputFinalY);
        }
Пример #36
0
        /// <summary>
        /// Gets the sample yaml.
        /// </summary>
        /// <returns></returns>
        public List<MappingEntry> GetSampleYaml()
        {
            YamlParser parser = new YamlParser();
            TextInput input = new TextInput(File.ReadAllText("sample.txt"));
            bool success;
            YamlStream yamlStream = parser.ParseYamlStream(input, out success);
            if (success)
            {

                    Mapping mapping = yamlStream.Documents[0].Root as Mapping;

                    return mapping.Enties;
            }
            else
            {
                Console.WriteLine(parser.GetEorrorMessages());
            }

            return null;
        }
        private void toolStripButtonParse_Click(object sender, EventArgs e)
        {
            TextInput input = new TextInput(richTextBoxSource.Text);

            bool success;
            YamlParser parser = new YamlParser();
            YamlStream yamlStream = parser.ParseYamlStream(input, out success);
            if (success)
            {
                treeViewData.Nodes.Clear();
                foreach (YamlDocument doc in yamlStream.Documents)
                {
                    treeViewData.Nodes.Add(YamlEmittor.CreateNode(doc.Root));
                }
                treeViewData.ExpandAll();
                tabControl1.SelectedTab = tabPageDataTree;
            }
            else
            {
                MessageBox.Show(parser.GetEorrorMessages());
            }
        }
Пример #38
0
 private static void OnTextChanged(TextInput ti, string s)
 {
     if(s.Length > MAX_COMMAND_LENGTH)
         ti.Text = s.Substring(0, MAX_COMMAND_LENGTH);
 }
Пример #39
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            m_env = new Env();
            m_sunImg = Content.Load<Texture2D>("sun");
            string sunSpriteSer = @"
            {Sprites:[
            {Offset:{X:0,Y:0},Rectangle:{Height:122,Width:158,X:0,Y:0}},
            {Offset:{X:4,Y:0},Rectangle:{Height:122,Width:135,X:158,Y:0}}
            ]}
            ";
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);
            sw.Write(sunSpriteSer);
            sw.Flush();
            ms.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(SpriteSheet));
            m_sunSS = (SpriteSheet)serializer.ReadObject(ms);
            m_sun = new Item(m_sunImg, m_sunSS);
            string script = "a != b";
            /*
            string script = @"
            item.SetSprite((env.GetTimeMs() / 200) % 2);
            item.SetSprite = 0;
            ";
            */
            Parser parser = new Parser();
            TextInput ti = new TextInput(script);
            bool succ;
            m_script = parser.ParseChunk(ti, out succ);
            if (!succ)
                Debug.WriteLine(parser.GetEorrorMessages());
            m_globals = new LuaTable();
            LuaTable methods = new LuaTable();
            methods.SetNameValue("__index", methods);
            methods.SetNameValue("__newindex", methods);
            methods.Register("SetSprite", m_sun.SetSprite_FromScript);
            m_globals.SetNameValue("item", new Language.Lua.LuaUserdata(m_sun, methods));

            methods = new LuaTable();
            methods.SetNameValue("__index", methods);
            methods.Register("GetTimeMs", m_env.GetTimeMs);
            m_globals.SetNameValue("env", new LuaUserdata(m_env, methods));

            m_env.TimeMs = 0;
        }
Пример #40
0
        private IEnumerable<IMediaSequence> putFaceLabelledFeatures()
        {
            List<IMediaSequence> mediaSequence = new List<IMediaSequence>();

            for ( int subject = 1; subject <= 100; subject++ )
            {
                string region1BaseDirectory = directory() + "/regions/R" + subject.ToString( "000" );
                string region2BaseDirectory = directory() + "/regions2/R" + subject.ToString( "000" );
                string landmarkBaseDirectory = directory() + "/landmarks/L" + subject.ToString( "000" );
                string landmark2BaseDirectory = directory() + "/landmarks2/L" + subject.ToString( "000" );
                string contourBaseDirectory = directory() + "/contours/C" + subject.ToString( "000" );

                string imageBaseDirectory = directory() + "/images/0" + subject.ToString( "000" );

                DirectoryInfo region1Dir = new DirectoryInfo( region1BaseDirectory );
                DirectoryInfo region2Dir = new DirectoryInfo( region2BaseDirectory );
                DirectoryInfo landmarkDir = new DirectoryInfo( landmarkBaseDirectory );
                DirectoryInfo landmark2Dir = new DirectoryInfo( landmark2BaseDirectory );
                DirectoryInfo contourDir = new DirectoryInfo( contourBaseDirectory );

                FileInfo[] region1Files = region1Dir.GetFiles( "*.yml" );
                foreach ( FileInfo region1FileInfo in region1Files )
                {
                    string imageFilename = imageBaseDirectory + "/" + region1FileInfo.Name.Replace( ".yml", ".JPG" );
                    bool imageFileFound = File.Exists( imageFilename );

                    string region2Filename = region2BaseDirectory + "/" + region1FileInfo.Name;
                    bool region2FileFound = File.Exists( region2Filename );

                    string landmarkFilename = landmarkBaseDirectory + "/" + region1FileInfo.Name;
                    bool landmarkFileFound = File.Exists( landmarkFilename );

                    string landmark2Filename = landmark2BaseDirectory + "/" + region1FileInfo.Name;
                    bool landmark2FileFound = File.Exists( landmark2Filename );

                    string contourFilename = contourBaseDirectory + "/" + region1FileInfo.Name;
                    bool contourFileFound = File.Exists( contourFilename );

                    if ( contourFileFound )
                    {
                        contourFiles++;
                    }

                    if ( !imageFileFound )
                    {
                        missingFiles++;
                        break;
                    }

                    if ( !region2FileFound )
                    {
                        // Have Region 1 file, have image file, but missing Region 2 file
                        missingFiles++;
                        break;
                    }

                    if ( !landmarkFileFound )
                    {
                        // Have Region 1 file, Region 2 file, have image file, but missing Landmark file
                        missingFiles++;
                        break;
                    }

                    if ( !landmark2FileFound )
                    {
                        // Have Region 1 file, Region 2 file, have image file, but missing Landmark file
                        missingFiles++;
                        break;
                    }

                    // We have the corresponding image file, now we actually need to load and process all 3 YAML files (which also exist)
                    bool successRegion1 = false;
                    bool successRegion2 = false;
                    bool successLandmark = false;
                    bool successLandmark2 = false;
                    bool successContour = false;
                    YamlParser parser = new YamlParser();

                    TextInput inputRegion1 = new TextInput( yamlPreprocessor( File.ReadAllText( region1FileInfo.FullName ) ) );
                    YamlStream yamlStreamRegion1 = parser.ParseYamlStream( inputRegion1, out successRegion1 );
                    if ( !successRegion1 )
                    {
                        yamlErrors++;
                    }

                    TextInput inputRegion2 = new TextInput( yamlPreprocessor( File.ReadAllText( region2Filename ) ) );
                    YamlStream yamlStreamRegion2 = parser.ParseYamlStream( inputRegion2, out successRegion2 );
                    if ( !successRegion2 )
                    {
                        yamlErrors++;
                    }

                    TextInput inputLandmark = new TextInput( yamlPreprocessor( File.ReadAllText( landmarkFilename ) ) );
                    YamlStream yamlStreamLandmark = parser.ParseYamlStream( inputLandmark, out successLandmark );
                    if ( !successLandmark )
                    {
                        yamlErrors++;
                    }

                    TextInput inputLandmark2 = new TextInput( yamlPreprocessor( File.ReadAllText( landmark2Filename ) ) );
                    YamlStream yamlStreamLandmark2 = parser.ParseYamlStream( inputLandmark2, out successLandmark2 );
                    if ( !successLandmark2 )
                    {
                        yamlErrors++;
                    }

                    TextInput inputContour;
                    YamlStream yamlStreamContour = null;
                    if ( contourFileFound )
                    {
                        inputContour = new TextInput( yamlPreprocessor( File.ReadAllText( contourFilename ) ) );
                        yamlStreamContour = parser.ParseYamlStream( inputContour, out successContour );
                    }

                    if ( successRegion1 || successRegion2 || successLandmark || successLandmark2 || successContour )
                    {
                        // Create a container for the particular features which are labelled in the YAML
                        List<ILabelledFeature> features = new List<ILabelledFeature>();

                        if ( successRegion1 )
                        {
                            // features.AddRange( extractRegionsFromYaml( yamlStreamRegion1 ) );
                        }
                        if ( successRegion2 )
                        {
                            features.AddRange( extractRegionsFromYaml( yamlStreamRegion2 ) );
                        }
                        if ( successLandmark )
                        {
                            // features.AddRange( extractPointsFromYaml( yamlStreamLandmark ) );
                        }
                        if ( successLandmark2 )
                        {
                            features.AddRange( extractPointsFromYaml( yamlStreamLandmark2 ) );
                        }
                        if ( successContour )
                        {
                            features.AddRange( extractContoursFromYaml( yamlStreamContour ) );
                        }

                        // This frame has the two eye features from above, plus the regions as well
                        IMediaFrame mediaFrame = new LazyLoadImageMediaFrame( imageFilename, features );

                        // This mediaFrame sequence only has the one frame in it
                        mediaSequence.Add( new SingleFrameMediaSequence( getName() + "_subject" + subject.ToString( "000" ), mediaFrame ) );
                    }

                }
            }
            Assert.LessOrEqual( missingFiles, 1, "More than expected number of image files were not found (expected 1)" );
            Assert.LessOrEqual( yamlErrors, 0, "More than expected number of YAML errors occurred (expected 0)" );
            Assert.AreEqual( 2182, contourFiles, "Wrong number of contour files found (expected 2182, although doco says 2193)" );
            Assert.LessOrEqual( regionAllZero, 24457, "More than expected number of regionAllZero occurred (expected 24468)" );
            Assert.LessOrEqual( notFoundRegionCorners, 0, "More than expected number of notFoundRegionCorners occurred (expected 0)" );
            Assert.LessOrEqual( unrecognisedFeatureName, 0, "More than expected number of unrecognisedFeatureName occurred (expected 0)" );
            return mediaSequence;
        }
Пример #41
0
        void tInput_OnTextChanged(TextInput arg1, string arg2)
        {
            drawText.Text = arg2;
            Recompute();
            if(Font == null) return;

            Vector3 cPosH = Font.GetCaretOffsetAndHeight(arg2, Math.Max(0, arg1.Caret));
            Vector2 cPos = new Vector2(cPosH.X, cPosH.Y) * drawText.TextScale;
            Caret.Offset = new Point((int)cPos.X, (int)cPos.Y);
            Caret.Height = (int)(cPosH.Z * drawText.TextScale);
        }
Пример #42
0
 private static void OnTextEntered(TextInput ti, string s)
 {
     ti.Text = "";
     lc = 0;
     AddCommand(s);
 }
Пример #43
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            richTextBox1.Visible = false;
            treeView1.Visible = true;

            StreamReader reader = new StreamReader(fileName);

            TextInput input = new TextInput(reader.ReadToEnd());

            bool success;
            YamlParser parser = new YamlParser();
            YamlStream yamlStream = parser.ParseYamlStream(input, out success);
            if (success)
            {

                foreach (YamlDocument doc in yamlStream.Documents)
                {
                    TreeNode rootNode = YamlEmittor.CreateNode(doc.Root);
                    treeView1.Nodes.Add(rootNode);

                    ProcessTreeNode(rootNode);
                }

                tabControl1.SelectedIndex = 0;
            }
            else
            {
                treeView1.Visible = false;
                richTextBox1.Visible = true;
                richTextBox1.Text = parser.GetErrorMessages();
                tabControl1.SelectedIndex = 1;
                richTextBox1.Focus();
            }
            reader.Close();
        }
Пример #44
0
        public static IEnumerable<GroupConfig> Read(string file)
        {
            YamlStream yaml = null;
            var replacedTabs = false;
            while (yaml == null)
            {
                try
                {
                    if (file.Contains("://"))
                    {
                        var split = file.Split(new[] { "://" }, StringSplitOptions.None);
                        var assemblyName = split.ElementAt(0);
                        var assembly = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(x => x.GetName().Name == assemblyName);
                        var resourceName = split.ElementAt(1);
                        using (var stream = assembly.GetManifestResourceStream(resourceName))
                        {
                            if (stream == null) throw new InvalidOperationException(String.Format("Embedded resource not found: {0}", file));

                            string contents;
                            using (var sr = new StreamReader(stream))
                            {
                                contents = sr.ReadToEnd();
                            }
                            TextInput input = new TextInput(contents);
                            YamlParser parser = new YamlParser();
                            bool success;
                            yaml = parser.ParseYamlStream(input, out success);
                            if (!success)
                                throw new Exception(String.Format("Could not parse embedded YAML file \"{0}\"", file));
                        }
                    }
                    else
                    {
                        yaml = YamlParser.Load(file);
                    }
                }
                catch (Exception e)
                {
                    if (replacedTabs)
                        throw new Exception(String.Format("Could not parse YAML file \"{0}\"", file), e);
                    File.WriteAllLines(file, File.ReadAllLines(file).Select(x => x.Replace('\t'.ToString(), "    ").Replace('\u0009'.ToString(), "    ")));
                    replacedTabs = true;
                }
            }

            var listConfigGroup = new List<GroupConfig>();

            foreach (var entry in (yaml.Documents.First().Root as Mapping).Enties)
            {
                var files = (entry.Value as Mapping).Enties.Where(x =>
                        x.Key.ToString().ToLower() == "files"
                    ).First().Value as Sequence;

                var type = ((entry.Value as Mapping).Enties.Where(x =>
                        x.Key.ToString().ToLower() == "type"
                    ).First().Value as Scalar).Text.ToLower();

                var minifyScalar = ((entry.Value as Mapping).Enties.Where(x =>
                        x.Key.ToString().ToLower() == "minify"
                    ).FirstOrDefault());
                bool minify = false;
                if (minifyScalar != null)
                    minify = (minifyScalar.Value as Scalar).Text.ToLower() == "false" ? false : true;

                var modeScalar = ((entry.Value as Mapping).Enties.Where(x =>
                        x.Key.ToString().ToLower() == "mode"
                    ).FirstOrDefault());
                string mode = null;
                if (modeScalar != null)
                    mode = (modeScalar.Value as Scalar).Text.ToLower();

                var cacheScalar = ((entry.Value as Mapping).Enties.Where(x =>
                        x.Key.ToString().ToLower() == "cache"
                    ).FirstOrDefault());
                string cache = null;
                if (cacheScalar != null)
                    cache = (cacheScalar.Value as Scalar).Text.ToLower();

                var assemblyScalar = ((entry.Value as Mapping).Enties.Where(x =>
                        x.Key.ToString().ToLower() == "assembly"
                    ).FirstOrDefault());
                string assembly = null;
                if (assemblyScalar != null)
                    assembly = (assemblyScalar.Value as Scalar).Text;

                var key = entry.Key.ToString();

                var c = SquishItCache.Unset;
                if (cache != null && (cache == "memory" || cache == "file" || cache == "dynamic" || cache == "static"))
                {
                    if (cache == "dynamic")
                        c = SquishItCache.NamedDynamic;
                    else if (cache == "static")
                        c = SquishItCache.NamedStatic;
                    else if (cache == "file")
                        c = SquishItCache.Named;
                    else if (cache == "memory")
                        c = SquishItCache.Cached;
                }

                var squishitMode = SquishItForce.None;
                if (mode == "release")
                    squishitMode = SquishItForce.Release;
                else if (mode == "debug")
                    squishitMode = SquishItForce.Debug;

                var configType = SquishItType.None;
                if (type == "css")
                    configType = SquishItType.Css;
                if (type == "js")
                    configType = SquishItType.JavaScript;
                if (type == "embedded-css")
                    configType = SquishItType.EmbeddedCss;
                if (type == "embedded-js")
                    configType = SquishItType.EmbeddedJavaScript;


                listConfigGroup.Add(new GroupConfig()
                    {
                        Files = files.Enties.Where(x => x is Scalar).Cast<Scalar>().Select(x => x.Text),
                        Cache = c,
                        Minify = minify,
                        Mode = squishitMode,
                        Type = configType,
                        Key = key,
                        Assembly = assembly,
                        DisableCache = cache == "disable",
                    });
            }

            return listConfigGroup;
        }
 private void LoadYaml()
 {
     TextInput input = new TextInput(txtConfig.Text);
          bool success;
          YamlParser parser = new YamlParser();
          YamlStream yamlStream = parser.ParseYamlStream(input, out success);
          if (success)
          {
                 tviYaml.Nodes.Clear();
                 foreach (YamlDocument doc in yamlStream.Documents)
                 {
                      tviYaml.Nodes.Add(YamlEmittor.CreateNode(doc.Root));
                 }
                 tviYaml.ExpandAll();
                 ESClustername = YamlEmittor.ClusterName;
          }
          else
          {
                 MessageBox.Show(parser.GetEorrorMessages());
          }
 }