2023-03-03 21:23:48 +01:00
|
|
|
|
using System.Collections.Generic;
|
2017-09-12 14:32:34 +02:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
|
using ChatController.HauptKlassen;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ChatController
|
|
|
|
|
|
{
|
2020-06-17 19:36:52 +02:00
|
|
|
|
public partial class ChatEmojiiControl
|
2017-09-12 14:32:34 +02:00
|
|
|
|
{
|
2020-06-17 19:36:52 +02:00
|
|
|
|
private ChatMainControl _ChatMainControl;
|
|
|
|
|
|
private readonly ChatEmoji _ChatEmoji;
|
2017-09-12 14:32:34 +02:00
|
|
|
|
|
2020-06-17 19:36:52 +02:00
|
|
|
|
private readonly List<ListBox> _EmojiListBoxes = new List<ListBox>();
|
2017-09-12 14:32:34 +02:00
|
|
|
|
|
|
|
|
|
|
public ChatEmojiiControl()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
2020-06-17 19:36:52 +02:00
|
|
|
|
_ChatEmoji = new ChatEmoji();
|
2017-09-12 14:32:34 +02:00
|
|
|
|
|
|
|
|
|
|
SetEmojis();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-17 19:36:52 +02:00
|
|
|
|
public void InitChatView(ChatMainControl chatMainControl)
|
2017-09-12 14:32:34 +02:00
|
|
|
|
{
|
2020-06-17 19:36:52 +02:00
|
|
|
|
_ChatMainControl = chatMainControl;
|
2017-09-12 14:32:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetEmojis()
|
|
|
|
|
|
{
|
2020-06-17 19:36:52 +02:00
|
|
|
|
EmojisListBox1.ItemsSource = _ChatEmoji.EmojisListBox1;
|
|
|
|
|
|
EmojisListBox2.ItemsSource = _ChatEmoji.EmojisListBox2;
|
|
|
|
|
|
EmojisListBox3.ItemsSource = _ChatEmoji.EmojisListBox3;
|
|
|
|
|
|
EmojisListBox4.ItemsSource = _ChatEmoji.EmojisListBox4;
|
|
|
|
|
|
EmojisListBox5.ItemsSource = _ChatEmoji.EmojisListBox5;
|
|
|
|
|
|
EmojisListBox6.ItemsSource = _ChatEmoji.EmojisListBox6;
|
|
|
|
|
|
EmojisListBox7.ItemsSource = _ChatEmoji.EmojisListBox7;
|
|
|
|
|
|
|
|
|
|
|
|
_EmojiListBoxes.AddRange(
|
|
|
|
|
|
new List<ListBox>
|
|
|
|
|
|
{
|
|
|
|
|
|
EmojisListBox1,
|
|
|
|
|
|
EmojisListBox2,
|
|
|
|
|
|
EmojisListBox3,
|
|
|
|
|
|
EmojisListBox4,
|
|
|
|
|
|
EmojisListBox5,
|
|
|
|
|
|
EmojisListBox6,
|
|
|
|
|
|
EmojisListBox7
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
TabItem1.Header = _ChatEmoji.TabItem1;
|
|
|
|
|
|
TabItem2.Header = _ChatEmoji.TabItem2;
|
|
|
|
|
|
TabItem3.Header = _ChatEmoji.TabItem3;
|
|
|
|
|
|
TabItem4.Header = _ChatEmoji.TabItem4;
|
|
|
|
|
|
TabItem5.Header = _ChatEmoji.TabItem5;
|
|
|
|
|
|
TabItem6.Header = _ChatEmoji.TabItem6;
|
|
|
|
|
|
TabItem7.Header = _ChatEmoji.TabItem7;
|
2017-09-12 14:32:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnEmojiClick(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2020-06-17 19:36:52 +02:00
|
|
|
|
foreach(var emojiListBox in _EmojiListBoxes)
|
2017-09-12 14:32:34 +02:00
|
|
|
|
{
|
2020-06-17 19:36:52 +02:00
|
|
|
|
foreach(var selectedItem in emojiListBox.SelectedItems)
|
2017-09-12 14:32:34 +02:00
|
|
|
|
{
|
2020-06-17 19:36:52 +02:00
|
|
|
|
var directoryListing = selectedItem as DirectoryListing;
|
2017-09-12 14:32:34 +02:00
|
|
|
|
|
2020-06-17 19:36:52 +02:00
|
|
|
|
if(!string.IsNullOrWhiteSpace(directoryListing?.EmojiCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
PassEmojiToChatMainControl(directoryListing.EmojiCode);
|
|
|
|
|
|
}
|
2017-09-12 14:32:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-17 19:36:52 +02:00
|
|
|
|
emojiListBox.SelectedIndex = -1;
|
2017-09-12 14:32:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-17 19:36:52 +02:00
|
|
|
|
public void PassEmojiToChatMainControl(string emojiCode)
|
2017-09-12 14:32:34 +02:00
|
|
|
|
{
|
2023-03-03 21:23:48 +01:00
|
|
|
|
Dispatcher.Invoke(
|
|
|
|
|
|
DispatcherPriority.Normal,
|
|
|
|
|
|
(ThreadStart) delegate
|
|
|
|
|
|
{
|
|
|
|
|
|
_ChatMainControl.Chatbox.Focus();
|
2022-11-22 13:22:28 +01:00
|
|
|
|
|
2023-03-03 21:23:48 +01:00
|
|
|
|
var selectionStart = _ChatMainControl.Chatbox.SelectionStart;
|
|
|
|
|
|
_ChatMainControl.Chatbox.Text = _ChatMainControl.Chatbox.Text.Insert(selectionStart, emojiCode);
|
|
|
|
|
|
_ChatMainControl.Chatbox.SelectionStart = selectionStart + emojiCode.Length;
|
|
|
|
|
|
});
|
2017-09-12 14:32:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|