Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/Chat

This commit is contained in:
Lyndon
2017-11-14 10:48:34 +01:00
4 changed files with 124 additions and 63 deletions

View File

@@ -124,15 +124,15 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="1" >
<StackPanel Orientation="Horizontal" TextBlock.FontWeight="Bold" >
<StackPanel Orientation="Horizontal" TextBlock.FontSize="14" >
<TextBlock Text="{Binding Path=Name, FallbackValue=FirstName}" />
</StackPanel>
<!-- <TextBlock Text="{Binding Path=StatusTyp, FallbackValue=Message}" />-->
</StackPanel>
<!--Für die anzeige der anzahl ungelesener Nachrichten Height="30"-->
<!--Für die anzeige der anzahl ungelesener Nachrichten Height="30" FontWeight="Bold"-->
<StackPanel Margin="1" Grid.Row="1">
<TextBlock Text="{Binding Path=ReceiveMs}" FontWeight="Bold" FontSize="8" Foreground="{Binding Path=Color}" />
<TextBlock Text="{Binding Path=ReceiveMs}" FontSize="11" Foreground="{Binding Path=Color}" />
</StackPanel>
</Grid>

View File

@@ -33,7 +33,7 @@ namespace ChatController
/// </summary>
public partial class ChatMainControl : UserControl
{
#region Vokabeln :)
#region Vokabeln
private Chat _chat;
private AktuellerKontakt _aktuellerKontakt;
@@ -43,9 +43,7 @@ namespace ChatController
private IOrderedEnumerable<KontaktMessageBuilder> _Orderedmessagelist;
private IOrderedEnumerable<KontaktlistBuilder> _kontaktlist;
private readonly List<KontaktMessageBuilder> _messagelist = new List<KontaktMessageBuilder>();
private ChatDatenUebergabe _chatDaten;
private bool scrollPrueferAktivieren = false;
@@ -86,6 +84,8 @@ namespace ChatController
HorcheAlleGruppenNachrichten();
LeseMessageInfoAusDatei();
Clientlist.Items.Refresh();
}
public AktuellerKontakt GetAktuellenKontakt()
@@ -153,12 +153,15 @@ namespace ChatController
doSync = _chat.DoSynchronisation(_chatDaten.ApiKey, _chatDaten.Kundennummer);
if (doSync)
{
{
SpeichereMessageInfoInDatei();
var aktuelleGruppen = _chat.GruppenAktuallisieren();
var x = _chat.GroupklassenAktuallisieren(aktuelleGruppen);
_kontaktlist = x;
LeseMessageInfoAusDatei();
Dispatcher.BeginInvoke(
DispatcherPriority.Normal,
@@ -196,11 +199,10 @@ namespace ChatController
{
if(Clientlist.SelectedItem != null)
{
StartWaiting();
// StartWaiting();
Cursor = Cursors.Wait;
scrollPrueferAktivieren = false;
scrollPrueferAktivieren = false;
Chat.ItemsSource = null;
AktChatUser.Items.Clear();
@@ -218,24 +220,23 @@ namespace ChatController
AktChatUser.Items.Add(aktuellerKontakt);
_aktuellerKontakt = aktuellerKontakt;
var x = _chat.LadeChatNachrichtenVomKontakt(aktuellerKontakt);
var x = _chat.LadeChatNachrichtenVomKontakt(aktuellerKontakt);
Chat.ItemsSource = x;
Chat.Items.MoveCurrentToLast();
Chat.ScrollIntoView(Chat.Items.CurrentItem);
Chat.ContextMenu = _chat.ErstelleKontextMenue();
SetContextHandler();
scrollPrueferAktivieren = true;
HorcheAktivNachNachrichten();
Cursor = Cursors.Arrow;
EndWaiting();
// EndWaiting();
}
}
#endregion
#region Context Menue
@@ -457,7 +458,6 @@ namespace ChatController
_chat.SendMessage(Chatbox.Text, kontakt.GroupId);
//UebergebeNachrichtAnKontaktList(Chatbox.Text);
Chatbox.Text = "";
if (Chatbox.Text.Equals(""))
@@ -503,8 +503,6 @@ namespace ChatController
}
//hier bereich wie Dokumentieren
}
private void Chatbox_OnKeyDownHandler(object sender, KeyEventArgs e)
@@ -525,8 +523,7 @@ namespace ChatController
_chat.SendMessage(Chatbox.Text, kontakt.GroupId);
//UebergebeNachrichtAnKontaktList(Chatbox.Text);
Chatbox.Text = "";
}
@@ -549,36 +546,6 @@ namespace ChatController
}
}
private void UebergebeNachrichtAnKontaktList(string nachricht)
{
try
{
var aktuellerKontakt = (AktuellerKontakt)AktChatUser.Items[0];
foreach (var liste in _kontaktlist)
{
if (liste.GroupId == aktuellerKontakt.GroupId)
{
liste.ReceiveMs = nachricht;
//var clientZone = TimeZoneInfo.Local;
var x = DateTime.Now;
//var timeformated = TimeZoneInfo.ConvertTimeToUtc(x);
liste.TimeStamp = x;
liste.SetzeGelesen = 0;
}
}
CollectionViewSource.GetDefaultView(Clientlist.Items).Refresh();
}
catch (Exception e)
{
//einfach ignorieren
}
}
#endregion
#region Add Emoji To ChatBox
@@ -1002,8 +969,8 @@ namespace ChatController
}
#endregion
#region speichern sowie lesen der MessageSyncDatei / stylezwecke
#region speichern sowie lesen der MessageSyncDatei / stylezwecke (OwnChat only)
public void SpeichereMessageInfoInDatei()
{
List<KontaktlistBuilder> aa = new List<KontaktlistBuilder>();
@@ -1039,9 +1006,49 @@ namespace ChatController
}
}
}
}
}
}
#endregion
#region Speichern Und LEsen Der MesageSyncDatei (Bewoplaner only)
public List<KontaktlistBuilder> UebergebeMessageInfoDatenFuerDb()
{
List < KontaktlistBuilder > aa = new List<KontaktlistBuilder>();
Clientlist.Items.Refresh();
foreach (var item in Clientlist.Items)
{
var kontakt = item as KontaktlistBuilder;
if (kontakt != null && kontakt.SetzeGelesen == 0 && !kontakt.ReceiveMs.Equals(""))
{
aa.Add(kontakt);
}
}
return aa;
}
public void ErhalteMessageInfoVonDb(Dictionary<long,DateTime> liste)
{
if (liste != null)
{
foreach (var kon in _kontaktlist)
{
foreach (var item in liste)
{
if (kon.GroupId == item.Key)
{
kon.SetzeGelesen = 0;
}
}
}
}
}
#endregion
}
}

View File

@@ -4,6 +4,7 @@ using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
@@ -19,6 +20,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using Application = System.Windows.Forms.Application;
using Clipboard = System.Windows.Forms.Clipboard;
using Color = System.Drawing.Color;
using ContextMenu = System.Windows.Controls.ContextMenu;
using DataFormats = System.Windows.Forms.DataFormats;
using Image = System.Windows.Controls.Image;
@@ -950,9 +952,53 @@ namespace ChatController.HauptKlassen
string filename = Path.GetFileName(file);
SendMediaMessage(filename, kontakt.GroupId, mdatei);
//Medium auflösung auf 80 % vom original setzen
//Image x = (Bitmap)((new ImageConverter()).ConvertFrom(mdatei));
// image wieder in byte[] umwandeln und übergeben
if (ImageExtensions.Contains(Path.GetExtension(filename).ToUpperInvariant())){
var scaledImage = ScaleImage(mdatei);
SendMediaMessage(filename, kontakt.GroupId, scaledImage);
}
else
{
SendMediaMessage(filename, kontakt.GroupId, mdatei);
}
}
private byte[] ScaleImage(byte[] mdatei)
{
try
{
MemoryStream ms = new MemoryStream(mdatei);
System.Drawing.Image Image = System.Drawing.Image.FromStream(ms);
int width = (int) (Image.Width / 100 * 80);
int height = (int) (Image.Height / 100 * 80);
System.Drawing.Bitmap bmpScaled = new System.Drawing.Bitmap(Image);
using (Graphics gr = Graphics.FromImage(Image))
{
gr.Clear(Color.Transparent);
// falls jemand mekert, muss die intergedönse erhöht werden
gr.InterpolationMode = InterpolationMode.NearestNeighbor; // InterpolationMode.HighQualityBicubic;
gr.DrawImage(bmpScaled, 0, 0, width, height);
}
ImageConverter converter = new ImageConverter();
byte[] imageData = (byte[]) converter.ConvertTo(bmpScaled, typeof(byte[]));
return imageData;
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Fehler");
return mdatei;
}
}
private static byte[] ReadFully(Stream stream)
@@ -1283,7 +1329,10 @@ namespace ChatController.HauptKlassen
form.StartPosition = FormStartPosition.CenterScreen;
form.Size = imgbit.Size;
form.MinimumSize = new Size(150,150);
form.MaximumSize = new Size(500,500);
var width = (int)Math.Round(System.Windows.SystemParameters.PrimaryScreenWidth / 1.25);
var height = (int)Math.Round(System.Windows.SystemParameters.PrimaryScreenWidth / 2);
form.MaximumSize = new Size(width,height);
form.FormBorderStyle = FormBorderStyle.Sizable;
form.MaximizeBox = false;
@@ -1353,7 +1402,10 @@ namespace ChatController.HauptKlassen
form.StartPosition = FormStartPosition.CenterScreen;
form.Size = imgbit.Size;
form.MinimumSize = new Size(150,150);
form.MaximumSize = new Size(500,500);
var width = (int)Math.Round(System.Windows.SystemParameters.PrimaryScreenWidth / 1.25);
var height = (int)Math.Round(System.Windows.SystemParameters.PrimaryScreenWidth / 2);
form.MaximumSize = new Size(width, height);
form.FormBorderStyle = FormBorderStyle.Sizable;
form.MaximizeBox = false;
@@ -1366,8 +1418,7 @@ namespace ChatController.HauptKlassen
pb.Image = imgbit;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
//pb.MaximumSize = new Size(500,500);
form.Controls.Add(pb);
form.ShowDialog();
}
@@ -1409,7 +1460,7 @@ namespace ChatController.HauptKlassen
switch (jsonDatentyp.result)
{
case "0": MessageBox.Show("Syncanforderung wurde für fünf Minuten in der Zukunft hinterlegt.", "Fehler", MessageBoxButton.OK); return true;// gebe grünes licht für Aktualieserung des Chattes / Bei Invalid access ChatMaincontroll Schließen
case "0": /*MessageBox.Show("Syncanforderung wurde für fünf Minuten in der Zukunft hinterlegt.", "Info", MessageBoxButton.OK);*/ return true;// gebe grünes licht für Aktualieserung des Chattes / Bei Invalid access ChatMaincontroll Schließen
break;
case "11": MessageBox.Show("Kundennummer unbekannt.\nDer Chat wird jetzt geschlossen", "Fehler", MessageBoxButton.OK); return false; //rausschmeißen ?!
break;

View File

@@ -117,6 +117,9 @@ namespace ownChat
//// Environment.Exit(0);
//LoginMaske newLogin = new LoginMaske();
//newLogin.Show();
ChatMainControl.SpeichereMessageInfoInDatei();
Environment.Exit(0);
}
private void ChatMainControl_OnOnClose()