Exemplo n.º 1
0
        private void OnGUI()
        {
            if (DisplayText != "")
            {
                var x = DrawPosition.x;
                var y = Screen.height - DrawPosition.y;

                var UiString = DisplayText.Substring(0, Mathf.Min(140, DisplayText.Length));

                var labelSize = GuiStyleFore.CalcSize(new GUIContent(UiString));

                GUI.Box(new Rect(x - labelSize.x / 2 - 5, y + 15, labelSize.x + 10, labelSize.y + 10),
                        "", GuiStyleBack);
                GUI.Box(new Rect(x - labelSize.x / 2, y + 20, labelSize.x, labelSize.y),
                        UiString, GuiStyleFore);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Logically represents the user deleting a character in the UI calculator
        /// </summary>
        /// <param name="sender">The backspace button in the calculator</param>
        /// <param name="e"></param>
        public void BackSpace(object sender, RoutedEventArgs e)
        {
            string backspaceChar = "";

            if (DisplayText == "0" || DisplayText == "")
            {
                return;
            }
            else
            {
                backspaceChar = DisplayText[DisplayText.Length - 1].ToString();
                string backspaceString = DisplayText.Substring(0, (DisplayText.Length - 1));
                DisplayText = backspaceString;
            }

            if (backspaceChar == ".")
            {
                HasDecimal = false;
            }
        }