示例#1
0
        public UITextEdit(AddTextEditNode Node, ParserState State, UIScreen Screen)
            : base(Screen)
        {
            Name = Node.Name;
            m_ID = Node.ID;
            m_KeyboardInput = true; //UITextEdit needs to receive input from keyboard!

            if (!State.InSharedPropertiesGroup)
            {
                if (Node.TextEditPosition.Numbers.Count > 0)
                {
                    Position = new Vector2(Node.TextEditPosition.Numbers[0], Node.TextEditPosition.Numbers[1]) + Screen.Position;
                    m_TextPosition = Position;
                }

                if (State.InSharedPropertiesGroup)
                    m_Size = State.Size;
                else
                {
                    m_Size = new Vector2();
                    m_Size.X = Node.Size.Numbers[0];
                    m_Size.Y = Node.Size.Numbers[1];
                }

                if (Node.Tooltip != "")
                    Tooltip = m_Screen.GetString(Node.Tooltip);

                Transparent = (Node.Transparent == 1) ? true : false;

                if (Node.Lines != null)
                    m_NumLines = (int)Node.Lines;

                if (Node.Capacity != null)
                    m_MaxChars = (int)Node.Capacity;

                if (Node.Alignment != null)
                    m_Alignment = (TextEditAlignment)Node.Alignment;

                if (Node.FlashOnEmpty != null)
                    m_FlashOnEmpty = (Node.FlashOnEmpty == 1) ? true : false;

                if (Node.FrameOnFocus != null)
                    m_FrameOnFocus = (Node.FrameOnFocus == 1) ? true : false;

                if (State.InSharedPropertiesGroup)
                    TextColor = State.Color;
                else
                    TextColor = new Color(Node.Color.Numbers[0], Node.Color.Numbers[1], Node.Color.Numbers[2]);

                if (Node.BackColor != null)
                {
                    m_BackColor = new Color(Node.Color.Numbers[0], Node.Color.Numbers[1], Node.Color.Numbers[2]);
                    /*Image = new UIImage(FileManager.GetTexture((ulong)FileIDs.UIFileIDs.dialog_textboxbackground), m_Screen);
                    if(Position != null)
                        Image.Position = Position;
                    Image.Slicer = new NineSlicer(new Vector2(0, 0), (int)Image.Texture.Width, (int)Image.Texture.Width, 15, 15, 15, 15);
                    Image.SetSize((int)Size.X, (int)Size.Y);*/
                }
                else
                {
                    m_BackColor = new Color(57, 81, 110, 255);
                    /*Image = new UIImage(FileManager.GetTexture((ulong)FileIDs.UIFileIDs.dialog_textboxbackground), m_Screen);
                    if(Position != null)
                        Image.Position = Position;
                    Image.Slicer = new NineSlicer(new Vector2(0, 0), (int)Image.Texture.Width, Image.Texture.Height, 15, 15, 15, 15);
                    Image.SetSize((int)Size.X, (int)Size.Y);*/
                }

                if (Node.Mode != null)
                    m_Mode = (Node.Mode == "kReadOnly") ? TextEditMode.ReadOnly : TextEditMode.Insert;

                if (Node.ScrollbarImage != string.Empty)
                    m_ScrollbarImage = m_Screen.GetImage(Node.ScrollbarImage).Image.Texture;

                if (Node.ScrollbarGutter != null)
                    m_ScrollbarWidth = (int)Node.ScrollbarGutter;

                if (Node.ScrollbarType != null)
                    m_ScrollbarType = (ScrollbarType)Node.ScrollbarType;

                if (Node.ResizeForExactLineHeight != null)
                    m_ResizeForExactLineHeight = (Node.ResizeForExactLineHeight == 1) ? true : false;

                if (Node.EnableIME != null)
                    m_EnableInputModeEditing = (Node.EnableIME == 1) ? true : false;

                if (Node.CursorColor != null)
                    m_CursorColor = new Color(Node.CursorColor.Numbers[0], Node.CursorColor.Numbers[1], Node.CursorColor.Numbers[2]);

                if (Node.FrameColor != null)
                    m_FrameColor = new Color(Node.FrameColor.Numbers[0], Node.FrameColor.Numbers[1], Node.FrameColor.Numbers[2]);
            }
            else
            {
                if (State.BackColor != null)
                    m_BackColor = State.BackColor;
                if (State.Color != null)
                    TextColor = State.Color;
                if (State.CursorColor != null)
                    m_CursorColor = State.CursorColor;
                if (State.Position != null)
                {
                    Position = new Vector2(State.Position[0], State.Position[1]) + Screen.Position;
                    m_TextPosition = Position;
                    //Image.Position = Position;
                }
                if (State.Tooltip != "")
                    Tooltip = State.Tooltip;
            }

            m_Lines.Add(new RenderableText()
            {
                SBuilder = new StringBuilder(),
                Position = m_TextPosition,
                Visible = true
            });

            int Font = 0;
            if (Node.Font != 0)
                Font = Node.Font;
            else
                Font = State.Font;

            switch(Font)
            {
                case 9:
                    m_Font = Screen.Font9px;
                    break;
                case 10:
                    m_Font = Screen.Font10px;
                    break;
                case 12:
                    m_Font = Screen.Font12px;
                    break;
                case 14:
                    m_Font = Screen.Font14px;
                    break;
                case 16:
                    m_Font = Screen.Font16px;
                    break;
            }

            m_Cursor.Position = Position;
            m_CursorVisibilityTimer = new Timer(100);
            m_CursorVisibilityTimer.Enabled = true;
            m_CursorVisibilityTimer.Elapsed += M_CursorVisibilityTimer_Elapsed;
            m_CursorVisibilityTimer.Start();

            m_Screen.Manager.OnTextInput += Manager_OnTextInput;
        }
示例#2
0
        /// <summary>
        /// Constructs a new UITextEdit control from a parsed UIScript.
        /// </summary>
        /// <param name="Node">The AddTextEditNode that defines this UITextEdit control.</param>
        /// <param name="State">The ParserState returned when parsing the UIScript.</param>
        /// <param name="Screen">A UIScreen instance.</param>
        public UITextEdit2(AddTextEditNode Node, ParserState State, UIScreen Screen) :
            base(Screen)
        {
            Name            = Node.Name;
            m_ID            = Node.ID;
            m_KeyboardInput = true; //UITextEdit needs to receive input from keyboard!

            if (!State.InSharedPropertiesGroup)
            {
                if (Node.TextEditPosition.Numbers.Count > 0)
                {
                    Position       = new Vector2(Node.TextEditPosition.Numbers[0], Node.TextEditPosition.Numbers[1]) + Screen.Position;
                    m_TextPosition = Position;
                }

                if (State.InSharedPropertiesGroup)
                {
                    m_Size = State.Size;
                }
                else
                {
                    m_Size   = new Vector2();
                    m_Size.X = Node.Size.Numbers[0];
                    m_Size.Y = Node.Size.Numbers[1];
                }

                if (Node.Tooltip != "")
                {
                    Tooltip = m_Screen.GetString(Node.Tooltip);
                }

                Transparent = (Node.Transparent == 1) ? true : false;

                if (Node.Lines != null)
                {
                    m_NumLines = (int)Node.Lines;
                }

                if (Node.Capacity != null)
                {
                    m_MaxChars = (int)Node.Capacity;
                }

                if (Node.Alignment != null)
                {
                    m_Alignment = (TextEditAlignment)Node.Alignment;
                }

                if (Node.FlashOnEmpty != null)
                {
                    m_FlashOnEmpty = (Node.FlashOnEmpty == 1) ? true : false;
                }

                if (Node.FrameOnFocus != null)
                {
                    m_FrameOnFocus = (Node.FrameOnFocus == 1) ? true : false;
                }

                if (State.InSharedPropertiesGroup)
                {
                    TextColor = State.Color;
                }
                else
                {
                    TextColor = new Color(Node.Color.Numbers[0], Node.Color.Numbers[1], Node.Color.Numbers[2]);
                }

                if (Node.BackColor != null)
                {
                    m_BackColor = new Color(Node.Color.Numbers[0], Node.Color.Numbers[1], Node.Color.Numbers[2]);
                }
                else
                {
                    m_BackColor = new Color(57, 81, 110, 255);
                }

                if (Node.Mode != null)
                {
                    m_Mode = (Node.Mode == "kReadOnly") ? TextEditMode.ReadOnly : TextEditMode.Insert;
                }

                if (Node.ScrollbarImage != string.Empty)
                {
                    m_ScrollbarImage = m_Screen.GetImage(Node.ScrollbarImage).Image.Texture;
                }

                if (Node.ScrollbarGutter != null)
                {
                    m_ScrollbarWidth = (int)Node.ScrollbarGutter;
                }

                if (Node.ScrollbarType != null)
                {
                    m_ScrollbarType = (ScrollbarType)Node.ScrollbarType;
                }

                if (Node.ResizeForExactLineHeight != null)
                {
                    m_ResizeForExactLineHeight = (Node.ResizeForExactLineHeight == 1) ? true : false;
                }

                if (Node.EnableIME != null)
                {
                    m_EnableInputModeEditing = (Node.EnableIME == 1) ? true : false;
                }

                if (Node.CursorColor != null)
                {
                    m_CursorColor = new Color(Node.CursorColor.Numbers[0], Node.CursorColor.Numbers[1], Node.CursorColor.Numbers[2]);
                }

                if (Node.FrameColor != null)
                {
                    m_FrameColor = new Color(Node.FrameColor.Numbers[0], Node.FrameColor.Numbers[1], Node.FrameColor.Numbers[2]);
                }
            }
            else
            {
                if (State.BackColor != null)
                {
                    m_BackColor = State.BackColor;
                }
                if (State.Color != null)
                {
                    TextColor = State.Color;
                }
                if (State.CursorColor != null)
                {
                    m_CursorColor = State.CursorColor;
                }
                if (State.Position != null)
                {
                    Position       = new Vector2(State.Position[0], State.Position[1]) + Screen.Position;
                    m_TextPosition = Position;
                }
                if (State.Tooltip != "")
                {
                    Tooltip = State.Tooltip;
                }
            }

            int Font = 0;

            if (Node.Font != 0)
            {
                Font = Node.Font;
            }
            else
            {
                Font = State.Font;
            }

            switch (Font)
            {
            case 9:
                m_Font = Screen.Font9px;
                break;

            case 10:
                m_Font = Screen.Font10px;
                break;

            case 12:
                m_Font = Screen.Font12px;
                break;

            case 14:
                m_Font = Screen.Font14px;
                break;

            case 16:
                m_Font = Screen.Font16px;
                break;
            }

            m_Renderer = new TextRenderer((m_NumLines > 1) ? true : false,
                                          Position, Size, m_ScrollFactor, Lineheight, m_Font, TextColor, m_NumLines);

            m_Cursor.Position                = Position;
            m_CursorVisibilityTimer          = new Timer(100);
            m_CursorVisibilityTimer.Enabled  = true;
            m_CursorVisibilityTimer.Elapsed += M_CursorVisibilityTimer_Elapsed;
            m_CursorVisibilityTimer.Start();

            m_Screen.Manager.OnTextInput += Manager_OnTextInput;
        }