Files
BeWoPlaner/BeWo/View/MiniChatView.xaml.cs

258 lines
7.8 KiB
C#
Raw Permalink Normal View History

2016-06-27 01:45:38 +02:00
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;
2016-09-30 12:55:01 +02:00
using System.Timers;
2016-06-27 01:45:38 +02:00
using System.Windows.Forms;
using System.Windows.Controls;
using BS.Shared;
2016-07-25 09:26:56 +02:00
using MessageBox = System.Windows.MessageBox;
2016-06-27 01:45:38 +02:00
namespace BeWo.View
{
public partial class MiniChatView
{
public UserVM ViewModel { get; set; }
public int abr = 0;
2016-07-25 09:26:56 +02:00
//protected TCPClient tcpClient;
//protected ChatView viewChat;
2016-06-27 01:45:38 +02:00
2016-07-18 09:15:00 +02:00
protected String incommingString;
2016-06-27 01:45:38 +02:00
2016-07-18 09:15:00 +02:00
protected String incommingName;
2016-06-27 01:45:38 +02:00
protected ChatType incomminType;
2016-07-18 09:15:00 +02:00
protected long incommingEmpfangOid;
2016-06-27 01:45:38 +02:00
2016-07-18 09:15:00 +02:00
protected String namenInfo;
2016-09-21 12:32:51 +02:00
protected String nachname;
2016-07-18 09:15:00 +02:00
protected Boolean AppendTrue = false;
protected List<string> myListDS = new List<string>();
2016-06-27 01:45:38 +02:00
//################## Variablen zum Zählen aktueller nachricht ###########
protected int anzahlDS = 0;
//#######################################################################
public MiniChatView(String CLientName,String ClientNachname, String chat, long oid, ChatType type)
2016-06-27 01:45:38 +02:00
{
InitializeComponent();
namenInfo = CLientName;
2016-09-21 12:32:51 +02:00
nachname = ClientNachname;
2016-06-27 01:45:38 +02:00
//viewChat = view;
2016-06-27 01:45:38 +02:00
2016-09-21 12:32:51 +02:00
rootGroupBox.Header = CLientName + " " + ClientNachname ;
2016-06-27 01:45:38 +02:00
Minichat.AppendText(chat);
incommingString = chat;
incommingName = CLientName;
incommingEmpfangOid = oid;
incomminType = type;
2016-06-27 01:45:38 +02:00
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
{
2016-08-18 12:52:26 +02:00
// 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;
//}
2016-07-29 13:11:34 +02:00
2016-06-27 01:45:38 +02:00
}
2016-07-25 09:26:56 +02:00
catch (Exception edf)
{
MessageBox.Show("Fehler beim anklicken des Mini-Chats.", "Fehler: 2400 ", MessageBoxButton.OK);
}
2016-06-27 01:45:38 +02:00
}
2016-09-30 12:55:01 +02:00
public ChatType GetChatType()
{
return incomminType;
}
2016-06-27 01:45:38 +02:00
public void closeWindow() {
CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) =>
{
abr = 1;
//Close();
//if (Visibility != Visibility.Collapsed)
//{
// anzahlDS = 0;
// viewChat.SetListBoxSelection(incommingEmpfangOid, incomminType);
2016-08-18 12:52:26 +02:00
// viewChat.Visibility = Visibility.Visible;
// myListDS.Clear();
// Visibility = Visibility.Collapsed;
//}
2016-06-27 01:45:38 +02:00
}));
}
public void SetText(String text, int nac)
{
2016-07-25 09:26:56 +02:00
try
{
2016-08-18 12:52:26 +02:00
anzahlDS = anzahlDS + nac;
2016-06-27 01:45:38 +02:00
2016-08-18 12:52:26 +02:00
Title = anzahlDS + " " + namenInfo;
2016-06-27 01:45:38 +02:00
2016-07-25 09:26:56 +02:00
incommingString = text;
myListDS.Add(incommingString);
Minichat.Text = namenInfo + ": " + text + "\n";
Minichat.ScrollToEnd();
2016-09-30 12:55:01 +02:00
2016-07-25 09:26:56 +02:00
}
catch (Exception edf)
{
MessageBox.Show("Fehler beim Setzen der Nachricht. ", "Fehler: 2410 ", MessageBoxButton.OK);
}
2016-06-27 01:45:38 +02:00
}
2016-09-30 12:55:01 +02:00
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;
}
});
}
2016-07-25 09:26:56 +02:00
2016-06-27 01:45:38 +02:00
public void AppendTextwhileViewOpen(String text, int nac)
{
2016-07-25 09:26:56 +02:00
try
{
AppendTrue = true;
2016-06-27 01:45:38 +02:00
2016-07-25 09:26:56 +02:00
anzahlDS = anzahlDS + nac; // <-- Hier das zählen aktueller nachrichten anzahl und dessen ausgabe
2016-06-27 01:45:38 +02:00
2016-07-25 09:26:56 +02:00
Title = anzahlDS + " " + namenInfo; // <-- Setzte die anzahl der aktuellen nachrichten
2016-06-27 01:45:38 +02:00
2016-07-25 09:26:56 +02:00
incommingString = text;
2016-06-27 01:45:38 +02:00
2016-07-25 09:26:56 +02:00
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);
}
2016-06-27 01:45:38 +02:00
}
private void Minichat_OnGotFocus(object sender, RoutedEventArgs e)
{
2016-07-25 09:26:56 +02:00
try
{
//if (viewChat != null && viewChat.Visibility != Visibility.Visible)
//{
// anzahlDS = 0;
// viewChat.SetListBoxSelection(incommingEmpfangOid, incomminType);
// viewChat.Visibility = Visibility.Visible;
// myListDS.Clear();
// Visibility = Visibility.Collapsed;
//}
2016-07-25 09:26:56 +02:00
}
catch (Exception edf)
{
MessageBox.Show("Fehler beim Fokusieren der Minichat-View.", "Fehler: 2430 ", MessageBoxButton.OK);
2016-07-18 09:15:00 +02:00
}
2016-06-27 01:45:38 +02:00
}
2016-07-25 09:26:56 +02:00
/* ##### ***** Sollte der Wunsch bestehen das man im kleinen fenster antworten möchte ***** #####
2016-06-27 01:45:38 +02:00
* private void SendButton_Click(object sender, RoutedEventArgs e)
{
//Minichat.AppendText("Server: "+MiniChatbox.Text+"\n");
SendMessage();
Minichat.ScrollToEnd();
Visibility = Visibility.Collapsed;
}
2016-07-25 09:26:56 +02:00
2016-06-27 01:45:38 +02:00
public void SendMessage()
{
2016-07-25 09:26:56 +02:00
* 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);
* }
}*/
2016-06-27 01:45:38 +02:00
}
}