Esempio n. 1
0
        public static bool Update()
        {
            List <TouchData> touchDataList = Touch.GetData(0);

            if (button.TouchDown(touchDataList))
            {
                if (dialog == null)
                {
                    dialog      = new TextInputDialog();
                    dialog.Text = button.Label;
                    dialog.Open();
                }
                return(true);
            }

            if (dialog != null)
            {
                if (dialog.State == CommonDialogState.Finished)
                {
                    if (dialog.Result == CommonDialogResult.OK)
                    {
                        button.Label = dialog.Text;
                    }
                    dialog.Dispose();
                    dialog = null;
                }
            }

            return(true);
        }
Esempio n. 2
0
        public static bool Update()
        {
            List <TouchData> touchDataList = Touch.GetData(0);

            if (pasteButton.TouchDown(touchDataList))
            {
                copyTextButton.Label = Clipboard.GetText();
            }

            if (copyButton.TouchDown(touchDataList))
            {
                Clipboard.SetText(inputTextButton.Label);
            }


            if (inputTextButton.TouchDown(touchDataList))
            {
                if (dialog == null)
                {
                    dialog      = new TextInputDialog();
                    dialog.Text = inputTextButton.Label;
                    dialog.Open();
                }
                return(true);
            }

            if (dialog != null)
            {
                if (dialog.State == CommonDialogState.Finished)
                {
                    if (dialog.Result == CommonDialogResult.OK)
                    {
                        inputTextButton.Label = dialog.Text;
                    }
                    dialog.Dispose();
                    dialog = null;
                }
            }

            return(true);
        }
Esempio n. 3
0
        public void Update(MouseState ms_Mouse)
        {
            sSprite.Alpha = 0.5f;
            cText = new Color(Color.White, 0.5f);
            if (new Rectangle((int)sSprite.Position.X, (int)sSprite.Position.Y, sSprite.FrameWidth, sSprite.FrameHeight).Intersects(new Rectangle((int)ms_Mouse.X, (int)ms_Mouse.Y, 1, 1)))
            {
                Hovered();
                if (ms_Mouse.LeftButton == ButtonState.Pressed && !bClicked)
                {
                    if (sText == sStandardText) { sText = ""; }
                    cText = new Color(Color.White, 1.0f);
                    bClicked = true;
                    bSelected = true;
                    kLastKey = Keys.None;
                }
            }
            else if (ms_Mouse.LeftButton == ButtonState.Pressed && bSelected)
            {
                if (sText == "")
                {
                    sText = sStandardText;
                    cText = new Color(Color.White, 0.5f);
                }
                bClicked = false;
                bSelected = false;
            }
            if (bSelected)
            {
            #if DESKTOP
                iFlashTimer -= (int)Control.DeltaTime.dDeltaTime;
                if (iFlashTimer <= 0) { iFlashTimer = 400; }
                iTime -= (int)Control.DeltaTime.dDeltaTime;
                Keys[] key = Keyboard.GetState().GetPressedKeys();
                bool bShift, bNum;
                bShift = Control.KeyChecker.GetShift(key);
                bNum = Control.KeyChecker.GetNumLock(key);
                if (key.Length == 0) { bKeyPressed = false; kLastKey = Keys.None; }
                if (key.Length > 0)
                {
                    if (kLastKey != key[0]) { bKeyPressed = false; }
                    Char c = Control.KeyChecker.TranslateChar(key, bShift, bNum);
                    if (c != (char)0)
                    {
                        if (sText == sStandardText) { sText = ""; }
                        if (!bKeyPressed && key[0] != Keys.None)
                        {
                            bKeyPressed = true;
                            kLastKey = key[0];
                            sText += c;
                        }
                    }
                    else if (key[0] == Keys.Back && iTime <= 0)
                    {
                        iTime = 50;
                        if (sText.Length > 0) { sText = sText.Substring(0, sText.Length - 1); }
                        return;
                    }
                }
            #elif PSM
            // input dialog.
                if (dialog == null) {
                    dialog = new TextInputDialog();
                    if (sText == "Filename") { sText = ""; }
                    dialog.Text = sText;
                    dialog.Open();
                    bSelected = false;
                }
            #endif
            }
            #if PSM
            if (dialog != null) {
                if (dialog.State == CommonDialogState.Finished) {
                    if (dialog.Result == CommonDialogResult.OK) {
                        int len = dialog.Text.Length;
                        sText = dialog.Text.Substring(0,len);
                    }
                    dialog.Dispose();
                    dialog = null;

                    bClicked = false;
                    bSelected = false;
                }
            }
            #endif
        }
Esempio n. 4
0
        // check objects change state,
        private static bool CheckChangeState()
        {
            bool             changeState   = false;
            List <TouchData> touchDataList = Touch.GetData(0);

            // button.
            if (button0.TouchDown(touchDataList))
            {
                if (true == System.IO.File.Exists(@SAVE_FILE))
                {
                    using (System.IO.FileStream hStream = System.IO.File.Open(@SAVE_FILE, FileMode.Open)) {
                        if (hStream != null)
                        {
                            long size = hStream.Length;
                            inputData = new byte[size];
                            hStream.Read(inputData, 0, (int)size);
                            inputDataSize = (int)size;
                            string label = System.Text.Encoding.Unicode.GetString(inputData);
                            inputTextButton.SetText(label);
                            hStream.Close();
                            eventAction = EVENT_LOAD;
                        }
                    }
                }
            }

            else if (button1.TouchDown(touchDataList))
            {
                if (inputDataSize > 0)
                {
                    using (System.IO.FileStream hStream = System.IO.File.Open(@SAVE_FILE, FileMode.Create)) {
                        hStream.SetLength((int)inputDataSize);
                        hStream.Write(inputData, 0, (int)inputDataSize);
                        hStream.Close();
                        isFileExist = true;
                        eventAction = EVENT_WRITE;
                    }
                }
            }

            else if (button2.TouchDown(touchDataList))
            {
                if (true == System.IO.File.Exists(@SAVE_FILE))
                {
                    System.IO.File.Delete(@SAVE_FILE);
                    inputTextButton.SetText(" ");
                    inputDataSize = 0;
                    inputData     = null;
                    isFileExist   = false;
                    eventAction   = EVENT_DELETE;
                }
            }


            // input dialog.
            if (inputTextButton.TouchDown(touchDataList))
            {
                if (dialog == null)
                {
                    dialog      = new TextInputDialog();
                    dialog.Text = inputTextButton.Label;
                    dialog.Open();
                }
                return(true);
            }

            if (dialog != null)
            {
                if (dialog.State == CommonDialogState.Finished)
                {
                    if (dialog.Result == CommonDialogResult.OK)
                    {
                        string setLabelStr;
                        int    i;

                        int len = dialog.Text.Length;

                        if (len > MAX_INPUT_CHARACTOR)
                        {
                            len = MAX_INPUT_CHARACTOR;
                        }

                        setLabelStr = dialog.Text.Substring(0, len);

                        inputTextButton.Label = setLabelStr;

                        byte[] byteArray0 = System.Text.Encoding.Unicode.GetBytes(setLabelStr);
                        inputData = new byte[byteArray0.Length];
                        for (i = 0; i < byteArray0.Length; i++)
                        {
                            inputData[i] = byteArray0[i];
                        }

                        inputDataSize = byteArray0.Length;

                        changeState = true;
                    }
                    dialog.Dispose();
                    dialog = null;
                }
            }

            return(changeState);
        }
        // check objects change state,
        private static bool CheckChangeState()
        {
            bool             changeState   = false;
            List <TouchData> touchDataList = Touch.GetData(0);

            // button.
            if (button0.ButtonColor == DISABLE_COLOR &&
                button0.TouchDown(touchDataList))
            {
                button0.SetText(BUTTON_PRESS);
                button0.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON0] = 1;
                changeState = true;
            }
            else if (button0.ButtonColor == ENABLE_COLOR &&
                     button0.TouchDown(touchDataList))
            {
                button0.SetText(BUTTON_RELEASE);
                button0.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON0] = 0;
                changeState = true;
            }

            if (button1.ButtonColor == DISABLE_COLOR &&
                button1.TouchDown(touchDataList))
            {
                button1.SetText(BUTTON_PRESS);
                button1.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON1] = 1;
                changeState = true;
            }
            else if (button1.ButtonColor == ENABLE_COLOR &&
                     button1.TouchDown(touchDataList))
            {
                button1.SetText(BUTTON_RELEASE);
                button1.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON1] = 0;
                changeState = true;
            }

            if (button2.ButtonColor == DISABLE_COLOR &&
                button2.TouchDown(touchDataList))
            {
                button2.SetText(BUTTON_PRESS);
                button2.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON2] = 1;
                changeState = true;
            }
            else if (button2.ButtonColor == ENABLE_COLOR &&
                     button2.TouchDown(touchDataList))
            {
                button2.SetText(BUTTON_RELEASE);
                button2.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON2] = 0;
                changeState = true;
            }

            if (button3.ButtonColor == DISABLE_COLOR &&
                button3.TouchDown(touchDataList))
            {
                button3.SetText(BUTTON_PRESS);
                button3.ButtonColor = ENABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON3] = 1;
                changeState = true;
            }
            else if (button3.ButtonColor == ENABLE_COLOR &&
                     button3.TouchDown(touchDataList))
            {
                button3.SetText(BUTTON_RELEASE);
                button3.ButtonColor = DISABLE_COLOR;
                persistentMemoryData[STATE_ADDR_BUTTON3] = 0;
                changeState = true;
            }

            // slider.
            slider.Update(touchDataList);
            float curRate = slider.Rate;

            if (curRate != oldRate)
            {
                byte[] byteArray;
                byteArray = BitConverter.GetBytes(curRate);
                for (int i = 0; i < byteArray.Length; i++)
                {
                    persistentMemoryData[STATE_ADDR_SLIDER + i] = byteArray[i];
                }
                oldRate     = curRate;
                changeState = true;
            }

            // input dialog.
            if (inputTextButton.TouchDown(touchDataList))
            {
                if (dialog == null)
                {
                    dialog      = new TextInputDialog();
                    dialog.Text = inputTextButton.Label;
                    dialog.Open();
                }
                return(true);
            }

            if (dialog != null)
            {
                if (dialog.State == CommonDialogState.Finished)
                {
                    if (dialog.Result == CommonDialogResult.OK)
                    {
                        string setLabelStr;
                        int    i;

                        int len = dialog.Text.Length;

                        if (len > MAX_INPUT_CHARACTOR)
                        {
                            len = MAX_INPUT_CHARACTOR;
                        }

                        setLabelStr = dialog.Text.Substring(0, len);

                        inputTextButton.Label = setLabelStr;

                        byte[] byteArray0 = System.Text.Encoding.Unicode.GetBytes(setLabelStr);
                        for (i = 0; i < byteArray0.Length; i++)
                        {
                            persistentMemoryData[STATE_ADDR_STRING + i] = byteArray0[i];
                        }

                        byte[] byteArray1 = BitConverter.GetBytes(len);
                        for (i = 0; i < byteArray1.Length; i++)
                        {
                            persistentMemoryData[STATE_ADDR_STRING_NO + i] = byteArray1[i];
                        }

                        changeState = true;
                    }
                    dialog.Dispose();
                    dialog = null;
                }
            }

            return(changeState);
        }