258 lines
7.8 KiB
C#
258 lines
7.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Sockets;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using BeWo.ServiceProxy;
|
|
using BeWo.ViewModel;
|
|
|
|
using BS.Shared.Extensions;
|
|
using System.Windows.Threading;
|
|
using System.Threading;
|
|
using System.Timers;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Controls;
|
|
using BS.Shared;
|
|
using MessageBox = System.Windows.MessageBox;
|
|
|
|
namespace BeWo.View
|
|
{
|
|
public partial class MiniChatView
|
|
{
|
|
public UserVM ViewModel { get; set; }
|
|
public int abr = 0;
|
|
|
|
//protected TCPClient tcpClient;
|
|
//protected ChatView viewChat;
|
|
|
|
protected String incommingString;
|
|
|
|
protected String incommingName;
|
|
|
|
protected ChatType incomminType;
|
|
|
|
protected long incommingEmpfangOid;
|
|
|
|
protected String namenInfo;
|
|
protected String nachname;
|
|
protected Boolean AppendTrue = false;
|
|
protected List<string> myListDS = new List<string>();
|
|
//################## Variablen zum Zählen aktueller nachricht ###########
|
|
protected int anzahlDS = 0;
|
|
//#######################################################################
|
|
|
|
public MiniChatView(String CLientName,String ClientNachname, String chat, long oid, ChatType type)
|
|
{
|
|
InitializeComponent();
|
|
|
|
namenInfo = CLientName;
|
|
nachname = ClientNachname;
|
|
|
|
//viewChat = view;
|
|
|
|
rootGroupBox.Header = CLientName + " " + ClientNachname ;
|
|
Minichat.AppendText(chat);
|
|
|
|
incommingString = chat;
|
|
incommingName = CLientName;
|
|
incommingEmpfangOid = oid;
|
|
incomminType = type;
|
|
|
|
closeWindow();
|
|
|
|
setWindowlocationLeftBottom();
|
|
|
|
Minichat.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
|
|
Minichat.ScrollToEnd();
|
|
Minichat.IsReadOnly = true;
|
|
Minichat.IsEnabled = true;
|
|
|
|
}
|
|
|
|
|
|
public void setWindowlocationLeftBottom() {
|
|
this.WindowStartupLocation = WindowStartupLocation.Manual;
|
|
this.Left = System.Windows.SystemParameters.WorkArea.Width - this.Width;
|
|
this.Top = System.Windows.SystemParameters.WorkArea.Height - this.Height;
|
|
}
|
|
|
|
private void RootGroupBox_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// DragMove();
|
|
//if (viewChat != null && viewChat.Visibility != Visibility.Visible)
|
|
//{
|
|
// anzahlDS = 0;
|
|
// viewChat.SetListBoxSelection(incommingEmpfangOid, incomminType);
|
|
|
|
// viewChat.Visibility = Visibility.Visible;
|
|
// myListDS.Clear();
|
|
// Visibility = Visibility.Collapsed;
|
|
//}else
|
|
//{
|
|
// Visibility = Visibility.Collapsed;
|
|
//}
|
|
|
|
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Fehler beim anklicken des Mini-Chats.", "Fehler: 2400 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public ChatType GetChatType()
|
|
{
|
|
|
|
return incomminType;
|
|
}
|
|
|
|
|
|
public void closeWindow() {
|
|
CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) =>
|
|
{
|
|
abr = 1;
|
|
|
|
//Close();
|
|
//if (Visibility != Visibility.Collapsed)
|
|
//{
|
|
// anzahlDS = 0;
|
|
// viewChat.SetListBoxSelection(incommingEmpfangOid, incomminType);
|
|
|
|
// viewChat.Visibility = Visibility.Visible;
|
|
// myListDS.Clear();
|
|
// Visibility = Visibility.Collapsed;
|
|
//}
|
|
|
|
}));
|
|
}
|
|
|
|
|
|
public void SetText(String text, int nac)
|
|
{
|
|
try
|
|
{
|
|
anzahlDS = anzahlDS + nac;
|
|
|
|
Title = anzahlDS + " " + namenInfo;
|
|
|
|
incommingString = text;
|
|
myListDS.Add(incommingString);
|
|
Minichat.Text = namenInfo + ": " + text + "\n";
|
|
Minichat.ScrollToEnd();
|
|
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Fehler beim Setzen der Nachricht. ", "Fehler: 2410 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
public void setTimer()
|
|
{
|
|
try
|
|
{
|
|
System.Timers.Timer timer = new System.Timers.Timer(8000);
|
|
timer.Elapsed += new ElapsedEventHandler(timer_elapsed);
|
|
timer.Start();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
MessageBox.Show("Fehler beim Setzen des Timers. ", "Fehler: 2440 ", MessageBoxButton.OK);
|
|
}
|
|
|
|
}
|
|
|
|
private void timer_elapsed(object sender, ElapsedEventArgs e)
|
|
{
|
|
Dispatcher.Invoke(
|
|
DispatcherPriority.Normal,
|
|
(ThreadStart) delegate
|
|
{
|
|
|
|
if (Visibility == Visibility.Visible)
|
|
{
|
|
myListDS.Clear();
|
|
Visibility = Visibility.Collapsed;
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
public void AppendTextwhileViewOpen(String text, int nac)
|
|
{
|
|
try
|
|
{
|
|
AppendTrue = true;
|
|
|
|
anzahlDS = anzahlDS + nac; // <-- Hier das zählen aktueller nachrichten anzahl und dessen ausgabe
|
|
|
|
Title = anzahlDS + " " + namenInfo; // <-- Setzte die anzahl der aktuellen nachrichten
|
|
|
|
incommingString = text;
|
|
|
|
myListDS.Add(incommingString);
|
|
|
|
Minichat.AppendText(namenInfo + ": " + text + "\n");
|
|
Minichat.ScrollToEnd();
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Fehler beim Anfügen einer weiteren Nachricht.", "Fehler: 2420 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
private void Minichat_OnGotFocus(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
//if (viewChat != null && viewChat.Visibility != Visibility.Visible)
|
|
//{
|
|
// anzahlDS = 0;
|
|
|
|
// viewChat.SetListBoxSelection(incommingEmpfangOid, incomminType);
|
|
|
|
// viewChat.Visibility = Visibility.Visible;
|
|
// myListDS.Clear();
|
|
// Visibility = Visibility.Collapsed;
|
|
//}
|
|
|
|
}
|
|
catch (Exception edf)
|
|
{
|
|
MessageBox.Show("Fehler beim Fokusieren der Minichat-View.", "Fehler: 2430 ", MessageBoxButton.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/* ##### ***** Sollte der Wunsch bestehen das man im kleinen fenster antworten möchte ***** #####
|
|
|
|
* private void SendButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
//Minichat.AppendText("Server: "+MiniChatbox.Text+"\n");
|
|
SendMessage();
|
|
|
|
Minichat.ScrollToEnd();
|
|
|
|
Visibility = Visibility.Collapsed;
|
|
}
|
|
|
|
public void SendMessage()
|
|
{
|
|
* try{
|
|
Übernehme die SendMEssage von Chatview
|
|
}catch(Exception edf){
|
|
* MessageBox.show("Das Senden Einer Nachricht von der Mini-View konnte nicht ausgeführt werden.","Fehle: Hier Fehlercode",MessageButton.Ok);
|
|
* }
|
|
}*/
|
|
|
|
}
|
|
|
|
}
|