public void GetBackUp()
 {
     AutoCompleteCollection.Clear();
     foreach (AutoCompleteEntry item in _beckUpAutoCompleteCollection)
     {
         AutoCompleteCollection.Add(item);
     }
 }
Ejemplo n.º 2
0
 private bool HandleAutoComplete(KeyEventArgs e)
 {
     // /
     if (e.Key == Key.Oem2 && ChatInput.CaretIndex == 0)
     {
         AutoCompleteCollection.Clear();
         autoCompleteTriggerKey = e.Key;
         foreach (var c in ChatRoom.SlashCommands)
         {
             AutoCompleteCollection.Add(new DescriptionItem <string>(c.Key, c.Value));
         }
         autoCompleteStart = ChatInput.CaretIndex + 1;
         return(true);
     }
     // @ key
     if ((Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) && e.Key == Key.D2)
     {
         AutoCompleteCollection.Clear();
         autoCompleteTriggerKey = e.Key;
         foreach (var u in this.UserListItems)
         {
             AutoCompleteCollection.Add(new DescriptionItem <string>(u.User.UserName));
         }
         autoCompleteStart = ChatInput.CaretIndex + 1;
         return(true);
     }
     if (e.Key == Key.Escape)
     {
         if (AutoCompleteVisible)
         {
             this.AutoCompleteCollection.Clear();
             return(true);
         }
         return(false);
     }
     if (e.Key == Key.Space)
     {
         this.AutoCompleteCollection.Clear();
         if (this.AutoCompleteVisible)
         {
             if (this.autoCompleteTriggerKey == Key.D2)
             {
                 this.ChatInput.Select(this.autoCompleteStart - 1, 1);
                 this.ChatInput.SelectedText = "";
                 this.ChatInput.Select(this.ChatInput.Text.Length, 0);
                 return(true);
             }
         }
         return(false);
     }
     if (e.Key == Key.Enter)
     {
         if (this.AutoCompleteVisible)
         {
             if (this.AutoCompleteListBox.Items.Count == 0)
             {
                 return(true);
             }
             if (this.AutoCompleteListBox.SelectedIndex == -1)
             {
                 return(true);
             }
             var item = (DescriptionItem <string>) this.AutoCompleteListBox.SelectedItem;
             this.ChatInput.Select(this.autoCompleteStart, this.ChatInput.Text.Length - this.autoCompleteStart);
             this.ChatInput.SelectedText = item.Item;
             this.ChatInput.Select(this.ChatInput.Text.Length, 0);
             e.Handled = true;
             this.AutoCompleteCollection.Clear();
             if (this.autoCompleteTriggerKey == Key.D2)
             {
                 this.ChatInput.Select(this.autoCompleteStart - 1, 1);
                 this.ChatInput.SelectedText = "";
                 this.ChatInput.Select(this.ChatInput.Text.Length, 0);
             }
             return(true);
         }
         return(false);
     }
     if (e.Key == Key.Up)
     {
         if (this.AutoCompleteVisible)
         {
             if (this.AutoCompleteListBox.Items.Count > 0)
             {
                 if (this.AutoCompleteListBox.SelectedIndex - 1 < 0)
                 {
                     this.AutoCompleteListBox.SelectedIndex = this.AutoCompleteListBox.Items.Count - 1;
                 }
                 else
                 {
                     this.AutoCompleteListBox.SelectedIndex--;
                 }
                 e.Handled = true;
                 this.AutoCompleteListBox.ScrollIntoView(this.AutoCompleteListBox.SelectedItem);
                 return(true);
             }
         }
         return(false);
     }
     if (e.Key == Key.Down)
     {
         if (this.AutoCompleteVisible)
         {
             if (this.AutoCompleteListBox.Items.Count > 0)
             {
                 if (this.AutoCompleteListBox.SelectedIndex + 1 >= this.AutoCompleteListBox.Items.Count)
                 {
                     this.AutoCompleteListBox.SelectedIndex = 0;
                 }
                 else
                 {
                     this.AutoCompleteListBox.SelectedIndex++;
                 }
                 e.Handled = true;
                 this.AutoCompleteListBox.ScrollIntoView(this.AutoCompleteListBox.SelectedItem);
                 return(true);
             }
         }
         return(false);
     }
     return(false);
 }