public void AddNewChatWindow(ChatWindowViewModelSettings settings)
        {
            if (ChatWindows.Count >= 10)
            {
                return;
            }

            ChatWindowViewModel cwm = null;

            var trEng = TranslationEngines;

            UiWindow.Window.UIThread(() =>
            {
                cwm = new ChatWindowViewModel(settings, trEng.ToList(), _AllChatCodes.ToList(), _TataruModel.HotKeyManager);


                try
                {
                    ChatWindows.Add(cwm);
                }
                catch (Exception e)
                {
                    Logger.WriteLog(e);
                }

                SelectedTabIndex = ChatWindows.Count - 1;
            });
        }
Esempio n. 2
0
        public void AddChatMessage(ChatMessage chatMessage)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                if (Filtered(chatMessage))
                {
                    return;
                }

                if (chatMessage is LfgMessage lm && !SettingsHolder.DisableLfgChatMessages)
                {
                    lm.LinkLfg();
                }

                chatMessage.SplitSimplePieces();

                if (ChatWindows.All(x => !x.IsPaused))
                {
                    ChatMessages.Insert(0, chatMessage);
                }
                else
                {
                    _pauseQueue.Enqueue(chatMessage);
                }

                NewMessage?.Invoke(chatMessage);
                if (ChatMessages.Count > SettingsHolder.MaxMessages)
                {
                    var toRemove = ChatMessages[ChatMessages.Count - 1];
                    toRemove.Dispose();
                    ChatMessages.RemoveAt(ChatMessages.Count - 1);
                }
                N(nameof(MessageCount));
            }), DispatcherPriority.DataBind);
        }
        public void AddNewChatWindow()
        {
            UiWindow.Window.UIThread(() =>
            {
                if (ChatWindows.Count >= 10)
                {
                    return;
                }

                long winId = 0;
                if (ChatWindows.Count > 0)
                {
                    winId = ChatWindows[ChatWindows.Count - 1].WinId + 1;
                }

                ChatWindowViewModelSettings cws = null;
                ChatWindowViewModel cwm         = null;


                var trEng = TranslationEngines;
                cws       = new ChatWindowViewModelSettings((winId + 1).ToString(), winId);
                cwm       = new ChatWindowViewModel(cws, trEng.ToList(), _AllChatCodes.ToList(), _TataruModel.HotKeyManager);


                ChatWindows.Add(cwm);


                SelectedTabIndex = ChatWindows.Count - 1;
            });
        }
Esempio n. 4
0
 public void SetPaused(bool v)
 {
     ChatWindows.ToList().ForEach(w =>
     {
         if (w.VM != null)
         {
             w.VM.Paused = v;
         }
     });
 }
Esempio n. 5
0
        public void ScrollToMessage(Tab tab, ChatMessage msg)
        {
            var win = ChatWindows.FirstOrDefault(x => x.VM.Tabs.Contains(tab));

            if (win == null)
            {
                return;
            }

            win.ScrollToMessage(tab, msg);
        }
        private void ShowChatWindow(object name)
        {
            string _name = (string)name;

            var cw = ChatWindows.FirstOrDefault(x => x.Name == _name);

            if (cw != null)
            {
                cw.IsHiddenByUser  = !cw.IsHiddenByUser;
                cw.IsWindowVisible = !cw.IsWindowVisible;
            }
        }
Esempio n. 7
0
 public void SetPaused(bool v, ChatMessage dc)
 {
     ChatWindows.ToList().ForEach(w =>
     {
         if (w.VM?.CurrentTab?.Messages == null)
         {
             return;
         }
         if (w.VM.CurrentTab.Messages.Contains(dc))
         {
             w.VM.Paused = v;
         }
     });
 }
Esempio n. 8
0
        public void AddChatMessage(ChatMessage chatMessage)
        {
            if (!App.Settings.ChatEnabled)
            {
                return;
            }

            Dispatcher.InvokeAsync(() =>
            {
                if (Filtered(chatMessage))
                {
                    return;
                }

                if (chatMessage is LfgMessage lm && !App.Settings.DisableLfgChatMessages)
                {
                    lm.LinkListing();
                }

                chatMessage.SplitSimplePieces();

                if (ChatWindows.All(x => !x.IsPaused))
                {
#if BATCH
                    _mainQueue.Enqueue(chatMessage);
#else
                    ChatMessages.Insert(0, chatMessage);
#endif
                }
                else
                {
                    _pauseQueue.Enqueue(chatMessage);
                    N(nameof(QueuedMessagesCount));
                }

                NewMessage?.Invoke(chatMessage);
#if BATCH
#else
                if (ChatMessages.Count > App.Settings.MaxMessages)
                {
                    var toRemove = ChatMessages[ChatMessages.Count - 1];
                    toRemove.Dispose();
                    ChatMessages.RemoveAt(ChatMessages.Count - 1);
                }

                N(nameof(MessageCount));
#endif
            }, DispatcherPriority.DataBind);
        }
        public void DeleteChatWindow(int index)
        {
            UiWindow.Window.UIThread(() =>
            {
                int ind = index;
                if (ind < ChatWindows.Count && ind >= 0)
                {
                    var wnd = ChatWindows[ind];

                    ChatWindows.RemoveAt(ind);

                    wnd.Dispose();
                }
            });
        }
        private void DeleteChatWindow()
        {
            UiWindow.Window.UIThread(() =>
            {
                int ind = SelectedTabIndex;
                if (ind < ChatWindows.Count && ind >= 0)
                {
                    var wnd = ChatWindows[ind];

                    ChatWindows.RemoveAt(ind);

                    wnd.Dispose();
                }
            });
        }
Esempio n. 11
0
        private void InitWindows()
        {
            ChatWindows.Clear();
            App.Settings.ChatWindowsSettings.ToList().ForEach(s =>
            {
                if (s.Tabs.Count == 0)
                {
                    return;
                }
                var m = new ChatViewModel(s);
                var w = new ChatWindow(m);
                ChatWindows.Add(w);
                m.LoadTabs(s.Tabs);
            });

            if (ChatWindows.Count != 0)
            {
                return;
            }
            {
                Log.CW("No chat windows found, initializing default one.");
                var ws = new ChatWindowSettings(0, 1, 200, 500, true, ClickThruMode.Never, 1, false, 1, false, true,
                                                false)
                {
                    HideTimeout = 10, FadeOut = true, LfgOn = false
                };
                var m = new ChatViewModel(ws);
                var w = new ChatWindow(m);
                App.BaseDispatcher.InvokeAsync(() =>
                {
                    App.Settings.ChatWindowsSettings.Add((ChatWindowSettings)w.WindowSettings);
                });
                ChatWindows.Add(w);
                m.LoadTabs();
                if (App.Settings.ChatEnabled)
                {
                    w.Show();
                }
            }
        }
Esempio n. 12
0
 internal void SetPaused(bool v, ChatMessage dc)
 {
     ChatWindows.ToList().ForEach(w =>
     {
         if (w.VM == null)
         {
             return;
         }
         if (w.VM.CurrentTab == null)
         {
             return;
         }
         if (w.VM.CurrentTab.Messages == null)
         {
             return;                                   //whatever
         }
         if (w.VM.CurrentTab.Messages.Contains(dc))
         {
             w.VM.Paused = v;
         }
     });
 }
Esempio n. 13
0
        public void InitWindows()
        {
            ChatWindows.Clear();
            SettingsHolder.ChatWindowsSettings.ToList().ForEach(s =>
            {
                if (s.Tabs.Count == 0)
                {
                    return;
                }
                var m = new ChatViewModel();
                var w = new ChatWindow(s, m);
                ChatWindows.Add(w);
                m.LoadTabs(s.Tabs);
            });

            if (ChatWindows.Count != 0)
            {
                return;
            }
            {
                Log.CW("No chat windows found, initializing default one.");
                var ws = new ChatWindowSettings(0, 1, 200, 500, true, ClickThruMode.Never, 1, false, 1, false, true, false)
                {
                    HideTimeout = 10, FadeOut = true, LfgOn = false
                };
                var m = new ChatViewModel();
                var w = new ChatWindow(ws, m);
                SettingsHolder.ChatWindowsSettings.Add(w.WindowSettings as ChatWindowSettings);
                ChatWindows.Add(w);
                m.LoadTabs();
                if (SettingsHolder.ChatEnabled)
                {
                    w.Show();
                }
            }
        }