Exemple #1
0
 /// <summary>Clears sent message history.</summary>
 internal void ClearHistory()
 {
     this.sentMessageHistory.Clear();
     this.bCheatHistoryPosition.SetValue(-1);
     if (this.currentTypedMessage == null)
     {
         this.currentTypedMessage = this.commandChatTextBox.Save();
     }
     this.commandChatTextBox.Load(this.currentTypedMessage, true);
 }
Exemple #2
0
        /// <summary>Handles key press events.</summary>
        public override void receiveKeyPress(Keys key)
        {
            if (!this.isActive())
            {
                return;
            }

            if (key == Keys.Up)
            {
                if (this.bCheatHistoryPosition.GetValue() >= this.sentMessageHistory.Count - 1)
                {
                    return;
                }

                if (this.bCheatHistoryPosition.GetValue() == -1)
                {
                    this.currentTypedMessage = this.commandChatTextBox.Save();
                }

                this.bCheatHistoryPosition.SetValue(this.bCheatHistoryPosition.GetValue() + 1);
                this.commandChatTextBox.Load(this.sentMessageHistory[this.bCheatHistoryPosition.GetValue()]);
            }
            else if (key == Keys.Down)
            {
                if (this.bCheatHistoryPosition.GetValue() <= 0)
                {
                    if (this.bCheatHistoryPosition.GetValue() == -1)
                    {
                        return;
                    }
                    this.bCheatHistoryPosition.SetValue(-1);
                    //This makes the user able to type in the box again.
                    int currIndex = this.displayLineIndex;
                    this.clickAway();
                    this.activate();
                    this.displayLineIndex = currIndex;
                    this.commandChatTextBox.Load(this.currentTypedMessage, true);

                    return;
                }

                this.bCheatHistoryPosition.SetValue(this.bCheatHistoryPosition.GetValue() - 1);
                this.commandChatTextBox.Load(this.sentMessageHistory[this.bCheatHistoryPosition.GetValue()]);
            }
            else if (key == Keys.Left)
            {
                this.commandChatTextBox.OnLeftArrowPress();
            }
            else if (key == Keys.Right)
            {
                this.commandChatTextBox.OnRightArrowPress();
            }
        }
        /// <summary>Restored a previously saved state.</summary>
        public void Load(CommandChatTextBoxState state, bool useSavedPosition = false)
        {
            this.finalText.Clear();
            foreach (ChatSnippet snippet in state.FinalText)
            {
                this.finalText.Add(Utils.CopyChatSnippet(snippet));
            }
            if (useSavedPosition)
            {
                this.currentInsertPosition = state.CurrentInsertPosition;
                this.currentSnippetIndex   = state.CurrentSnippetIndex;
            }
            else
            {
                this.MoveCursorAllTheWayRight();
            }

            this.UpdateForNewRecepient(state.CurrentRecipientId, state.CurrentRecipientName);
            this.updateWidth();
        }