Cole neue Features
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
Background="Transparent"
|
||||
ResizeMode="CanResizeWithGrip"
|
||||
x:Name="ChatViewName"
|
||||
StateChanged="ChatView_OnStateChanged">
|
||||
StateChanged="ChatView_OnStateChanged"
|
||||
>
|
||||
|
||||
<GroupBox Header="Chat" x:Name="rootGroupBox" Style="{DynamicResource MainContentGroupBoxWithoutMaximizeBtnStyle}" MouseLeftButtonDown="RootGroupBox_OnMouseLeftButtonDown">
|
||||
<Grid Background="{StaticResource ObjectEditBackgroundBrush}" >
|
||||
@@ -212,7 +213,7 @@
|
||||
<Image x:Name="AlarmLabel" ToolTip="Zurzeit nicht Verbunden" Source="" />
|
||||
</Button>
|
||||
|
||||
<!--####################### Test Zwecke ###############################################################-->
|
||||
<!--####################### Media Gedöns ###############################################################-->
|
||||
<Grid Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="35"/>
|
||||
@@ -226,18 +227,17 @@
|
||||
<Button Content="Video Chatten" Grid.Column="1" Click="ButtonVideoChat_OnClick" HorizontalAlignment="Center" Width="120" Margin="1" Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
|
||||
<!--####################################################################################################-->
|
||||
|
||||
<ListBox x:Name="Chat" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="3" Grid.Row="1" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" SelectionMode="Extended" MouseRightButtonDown="OnRightClickEvent">
|
||||
<ListBox x:Name="Chat" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="3" Grid.Row="1" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" SelectionMode="Extended" MouseRightButtonDown="OnRightClickEvent" >
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalAlignment" Value="{Binding Posi}" />
|
||||
<Setter Property="HorizontalAlignment" Value="{Binding Posi}" />
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="3"/>
|
||||
<Setter Property="Padding" Value="10,0,0,0" />
|
||||
<Setter Property="CornerRadius" Value="3" />
|
||||
<Setter Property="Padding" Value="10,0,0,0" />
|
||||
</Style>
|
||||
</ListBox.Resources>
|
||||
<ListBox.ItemTemplate>
|
||||
|
||||
@@ -18,11 +18,13 @@ using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq.Expressions;
|
||||
using System.Media;
|
||||
using System.Net;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -47,7 +49,11 @@ using Brush = System.Windows.Media.Brush;
|
||||
using Button = System.Windows.Forms.Button;
|
||||
using Color = System.Drawing.Color;
|
||||
using ContextMenu = System.Windows.Controls.ContextMenu;
|
||||
using DataFormats = System.Windows.Forms.DataFormats;
|
||||
using DragEventArgs = System.Windows.DragEventArgs;
|
||||
using GiveFeedbackEventArgs = System.Windows.GiveFeedbackEventArgs;
|
||||
using GroupBox = System.Windows.Forms.GroupBox;
|
||||
using IDataObject = System.Windows.Forms.IDataObject;
|
||||
using Image = System.Windows.Controls.Image;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MenuItem = System.Windows.Controls.MenuItem;
|
||||
@@ -792,9 +798,11 @@ namespace BeWo.View
|
||||
|
||||
MenuItem item1 = new MenuItem();
|
||||
MenuItem item2 = new MenuItem();
|
||||
MenuItem item3 = new MenuItem();
|
||||
|
||||
context.Items.Add(item1);
|
||||
context.Items.Add(item2);
|
||||
context.Items.Add(item3);
|
||||
|
||||
item1.Header = "Dokumentieren";
|
||||
item1.Visibility = Visibility.Visible;
|
||||
@@ -804,6 +812,10 @@ namespace BeWo.View
|
||||
item2.Visibility = Visibility.Visible;
|
||||
item2.Click += onChatRightClickItem2;
|
||||
|
||||
item3.Header = "Einfügen";
|
||||
item3.Visibility = Visibility.Visible;
|
||||
item3.Click += onChatRightClickItem3;
|
||||
|
||||
Image icon = new Image();
|
||||
icon.Source = new BitmapImage(new Uri(@"..\..\Ressources\Icons\ClipboardDisabled.png", UriKind.Relative));
|
||||
icon.SetSize(new Size(16, 16));
|
||||
@@ -813,10 +825,106 @@ namespace BeWo.View
|
||||
}
|
||||
catch (Exception edf)
|
||||
{
|
||||
MessageBox.Show("Beim Setzen einer Neuen Chat Einstellung ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2380 ", MessageBoxButton.OK);
|
||||
MessageBox.Show("Beim Setzen eines neuen Chat Contextes ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2380 ", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
public void onChatRightClickItem3(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var item = context.Items[2] as MenuItem;
|
||||
|
||||
item.Visibility = Visibility.Collapsed;
|
||||
Chat.SelectionMode = SelectionMode.Single;
|
||||
Chat.Focusable = true;
|
||||
|
||||
var d = System.Windows.Forms.Clipboard.GetDataObject();
|
||||
|
||||
if (d.GetDataPresent(DataFormats.FileDrop))
|
||||
{
|
||||
string[] files = (String[])d.GetData(DataFormats.FileDrop);
|
||||
|
||||
string imgFileString = files[0];
|
||||
|
||||
|
||||
if (isAnImage(imgFileString))
|
||||
{
|
||||
ZeigeProgressWärendUpload(1, imgFileString);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZeigeProgressWärendUpload(2, imgFileString);
|
||||
}
|
||||
|
||||
System.Windows.Forms.Clipboard.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d.GetDataPresent(DataFormats.Text))
|
||||
{
|
||||
string files = (String)d.GetData(DataFormats.Text);
|
||||
|
||||
string imgFileString = files;
|
||||
|
||||
|
||||
byte[] data;
|
||||
using (WebClient client = new WebClient())
|
||||
{
|
||||
data = client.DownloadData(imgFileString);
|
||||
}
|
||||
|
||||
string filename = Path.GetFileName(imgFileString);
|
||||
|
||||
string isloaded = LoadDokumentFromInet(data, filename);
|
||||
|
||||
if(!isloaded.IsNullOrEmpty()){
|
||||
ZeigeProgressWärendUpload(1, isloaded);
|
||||
}
|
||||
|
||||
System.Windows.Forms.Clipboard.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d.GetDataPresent(DataFormats.Bitmap))
|
||||
{
|
||||
Bitmap pic = (Bitmap)d.GetData(DataFormats.Bitmap);
|
||||
|
||||
var bildname = GeneriereZuffalsNamen() + ".jpg";
|
||||
|
||||
System.Drawing.Image img = pic;
|
||||
|
||||
var data = Utils.CreateByteArrayFromImage(img);
|
||||
|
||||
string isloaded = LoadDokumentFromInet(data, bildname);
|
||||
|
||||
if (!isloaded.IsNullOrEmpty())
|
||||
{
|
||||
ZeigeProgressWärendUpload(1, isloaded);
|
||||
}
|
||||
|
||||
System.Windows.Forms.Clipboard.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Der Chat kann den Zwischen-Speicher nicht verarbeiten.", "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GeneriereZuffalsNamen()
|
||||
{
|
||||
int lenght = 6;
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
||||
"abcdefghijklmnopqrstuvwxyz" +
|
||||
"0123456789";
|
||||
var random = new Random();
|
||||
String Code = new string(Enumerable.Repeat(chars, lenght)
|
||||
.Select(s => s[random.Next(s.Length)]).ToArray());
|
||||
|
||||
return Code;
|
||||
}
|
||||
|
||||
|
||||
public void onChatRightClickItem2(object sender, RoutedEventArgs e)
|
||||
{
|
||||
KontakMessageBuilder Item2;
|
||||
@@ -1107,7 +1215,7 @@ namespace BeWo.View
|
||||
}
|
||||
|
||||
|
||||
private void ListBoxSelectedIndexChanged(object sender, System.EventArgs e)
|
||||
private void ListBoxSelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
KontaktlistBuilder curItem;
|
||||
try
|
||||
@@ -1166,6 +1274,7 @@ namespace BeWo.View
|
||||
Chat.SelectionMode = SelectionMode.Single;
|
||||
Chat.Focusable = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1176,6 +1285,9 @@ namespace BeWo.View
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ImageSource BuildImg(Byte[] c ,ChatType x)
|
||||
{
|
||||
try
|
||||
@@ -1339,7 +1451,7 @@ namespace BeWo.View
|
||||
ServiceFacade.DoCustomerServiceSync(
|
||||
s => s.FindAllChatMessagesFromTeam(senderoid, empfaengerOid,itemGrenze));
|
||||
|
||||
ShowTeamMessageInChat(allTeamItems,true);
|
||||
ShowTeamMessageInChat(allTeamItems,true,0);
|
||||
|
||||
foreach (var item in allTeamItems)
|
||||
{
|
||||
@@ -1352,7 +1464,7 @@ namespace BeWo.View
|
||||
ServiceFacade.DoCustomerServiceSync(
|
||||
s => s.FindAllChatMessages(senderoid, empfaengerOid, itemGrenze));
|
||||
|
||||
ShowMessageInChat(allitems2, true, senderoid, empfaengerOid);
|
||||
ShowMessageInChat(allitems2, true, senderoid, empfaengerOid,0);
|
||||
|
||||
foreach (var item in allitems2)
|
||||
{
|
||||
@@ -1397,9 +1509,63 @@ namespace BeWo.View
|
||||
|
||||
public void OnRightClickEvent(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//################ Kopie und Paste gedönse ##########################
|
||||
var d = System.Windows.Forms.Clipboard.GetDataObject();
|
||||
|
||||
var item = context.Items[2] as MenuItem;
|
||||
|
||||
|
||||
//Daraus Switch case bastelln
|
||||
if (d.GetDataPresent(DataFormats.FileDrop))
|
||||
{
|
||||
item.Visibility = Visibility.Visible;
|
||||
Chat.SelectionMode = SelectionMode.Single;
|
||||
Chat.Focusable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d.GetDataPresent(DataFormats.Text))
|
||||
{
|
||||
item.Visibility = Visibility.Visible;
|
||||
Chat.SelectionMode = SelectionMode.Single;
|
||||
Chat.Focusable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d.GetDataPresent(DataFormats.Bitmap))
|
||||
{
|
||||
item.Visibility = Visibility.Visible;
|
||||
Chat.SelectionMode = SelectionMode.Single;
|
||||
Chat.Focusable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Visibility = Visibility.Collapsed;
|
||||
Chat.SelectionMode = SelectionMode.Single;
|
||||
Chat.Focusable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//##############################################
|
||||
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private bool isAnImage(string file)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Drawing.Image newImage = System.Drawing.Image.FromFile(file);
|
||||
}
|
||||
catch (OutOfMemoryException ex)
|
||||
{
|
||||
// Ist kein Image
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SmileyButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -1978,7 +2144,7 @@ namespace BeWo.View
|
||||
|
||||
serverStream.Flush();
|
||||
|
||||
|
||||
|
||||
if (form1 != null)
|
||||
{
|
||||
form1.Close();
|
||||
@@ -2133,6 +2299,7 @@ namespace BeWo.View
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Process.Start(path);
|
||||
|
||||
if (!Speicherpfad.ContainsKey(file))
|
||||
@@ -2145,6 +2312,50 @@ namespace BeWo.View
|
||||
}
|
||||
}
|
||||
|
||||
private string LoadDokumentFromInet(byte[] dokBytes, String file)
|
||||
{
|
||||
if (dokBytes != null)
|
||||
{
|
||||
string path = @"c:\temp\" + file;
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(path);
|
||||
|
||||
using (FileStream SourceStream = File.Open(path, FileMode.OpenOrCreate))
|
||||
{
|
||||
SourceStream.Seek(0, SeekOrigin.End);
|
||||
SourceStream.Write(dokBytes, 0, dokBytes.Length);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (FileStream SourceStream = File.Open(path, FileMode.OpenOrCreate))
|
||||
{
|
||||
SourceStream.Seek(0, SeekOrigin.End);
|
||||
SourceStream.Write(dokBytes, 0, dokBytes.Length);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Speicherpfad.ContainsKey(file))
|
||||
Speicherpfad.Add(file, path);
|
||||
|
||||
return path;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Die Datei wurde nicht Gefunden", "Info", MessageBoxButton.OK);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//private void myProcess_Exited(object sender, EventArgs e)
|
||||
//{
|
||||
// var x = (Process)sender;
|
||||
@@ -2262,7 +2473,7 @@ namespace BeWo.View
|
||||
if (zahl == 0)
|
||||
WeitereNachrichtSchalter = true;
|
||||
|
||||
ShowTeamMessageInChat(newitems,false);
|
||||
ShowTeamMessageInChat(newitems,false,1);
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -2280,7 +2491,7 @@ namespace BeWo.View
|
||||
if (zahl == 0)
|
||||
WeitereNachrichtSchalter = true;
|
||||
|
||||
ShowMessageInChat(newitems, false,chatlist[0].SenderPersonOid,chatlist[0].EmpfängerPersonOid);
|
||||
ShowMessageInChat(newitems, false,chatlist[0].SenderPersonOid,chatlist[0].EmpfängerPersonOid,1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2304,7 +2515,7 @@ namespace BeWo.View
|
||||
}
|
||||
|
||||
#region ChatMessagebuilder
|
||||
private void ShowMessageInChat(List<ChatMessageDC> allitems2, bool firstTime, long? sendoid, long? empfangOid)
|
||||
private void ShowMessageInChat(List<ChatMessageDC> allitems2, bool firstTime, long? sendoid, long? empfangOid, int i)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2327,7 +2538,7 @@ namespace BeWo.View
|
||||
|
||||
var person = ServiceFacade.DoCustomerServiceSync(s => s.GetPersonsById(x));
|
||||
|
||||
int i = 0;
|
||||
//int i = 0;
|
||||
|
||||
foreach (var list in allitems)
|
||||
{
|
||||
@@ -2547,11 +2758,11 @@ namespace BeWo.View
|
||||
|
||||
#region ChatTeamMessageBuilder
|
||||
|
||||
private void ShowTeamMessageInChat(List<ChatMessageDC> allTeamItems2,bool firstTime)
|
||||
private void ShowTeamMessageInChat(List<ChatMessageDC> allTeamItems2,bool firstTime, int sx)
|
||||
{
|
||||
try
|
||||
{
|
||||
int sx = 0;
|
||||
// int sx = 0;
|
||||
|
||||
var allTeamItems = allTeamItems2.OrderBy(dc => dc.Uhrzeit).ToList();
|
||||
|
||||
|
||||
@@ -411,7 +411,8 @@ namespace BeWoChatServer
|
||||
InsUser = dataPacket.ClientName,
|
||||
TeamOid = dataPacket.RecipientPersonOid,
|
||||
IsDelivered = true,
|
||||
MessageId = dataPacket.MessageId
|
||||
MessageId = dataPacket.MessageId,
|
||||
MediaTyp = dataPacket.MediaTyp
|
||||
};
|
||||
|
||||
var team = DAOFactory.GenericDAO.LoadByID<Team>(dataPacket.RecipientPersonOid);
|
||||
@@ -419,6 +420,30 @@ namespace BeWoChatServer
|
||||
Console.WriteLine(DateTime.Now + ": Speichere Team-Nachricht in der Datenbank");
|
||||
DAOFactory.GenericDAO.Insert(chatMessage);
|
||||
|
||||
//Media Bereich mit Bild und Dok.
|
||||
if (dataPacket.MediaDatei != null)
|
||||
{
|
||||
byte[] media = dataPacket.MediaDatei;
|
||||
byte[] ThImage = null;
|
||||
|
||||
if (dataPacket.MediaTyp == 1)
|
||||
{
|
||||
ThImage = media;
|
||||
}
|
||||
|
||||
var chatMediaMessage = new ChatMediaMessage
|
||||
{
|
||||
Media = media,
|
||||
InsUser = dataPacket.ClientName,
|
||||
ImageThumpNail = BS.Shared.Core.Utils.ErstelleThumbnail(ThImage, 150, 150),
|
||||
ChatMessageOid = chatMessage.Oid
|
||||
};
|
||||
|
||||
Console.WriteLine(DateTime.Now + ": Speichere die Chat-Media-Nachricht in der Datenbank");
|
||||
|
||||
DAOFactory.GenericDAO.Insert(chatMediaMessage);
|
||||
}
|
||||
|
||||
var personOids = team.MemberList.Select(s => s.Person.Oid.Value);
|
||||
|
||||
if (chatMessage.Oid != null)
|
||||
|
||||
Reference in New Issue
Block a user