Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/Chat
This commit is contained in:
@@ -10,7 +10,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'io.fabric.tools:gradle:1.25.4'
|
||||
classpath 'io.fabric.tools:gradle:1.28.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ dependencies {
|
||||
exclude group: 'com.android.support'
|
||||
}
|
||||
|
||||
implementation('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
|
||||
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
|
||||
transitive = true
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.4.2'
|
||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
||||
classpath 'io.realm:realm-gradle-plugin:5.3.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#Tue May 14 14:34:33 CEST 2019
|
||||
#Fri Aug 07 14:18:13 CEST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
|
||||
@@ -149,6 +149,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ownchat_favicon.ico" />
|
||||
<Resource Include="Ressourcen\warning-exclamation-mark.png" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Resources\oC-favico_NewMessage.ico" />
|
||||
<Content Include="Resources\ownchat_favicon.ico" />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Media;
|
||||
@@ -65,11 +64,9 @@ namespace ChatController.ChatKlassen
|
||||
|
||||
public DateTime TimeStamp { get; set; }
|
||||
|
||||
public int GroupId { get; set; }
|
||||
public int GroupId { get; }
|
||||
|
||||
public int UserOid { get; set; }
|
||||
|
||||
public string UserIdManage { get; set; }
|
||||
public string UserIdManage { get; }
|
||||
|
||||
public bool IsChatMessageInputGridVisible { get; }
|
||||
|
||||
@@ -88,63 +85,67 @@ namespace ChatController.ChatKlassen
|
||||
|
||||
IsChatMessageInputGridVisible = isChatMessageInputGridVisible;
|
||||
|
||||
AccentColorBrush = new BrushConverter().ConvertFromString($"#{accentColorBrushString}") as SolidColorBrush ?? new SolidColorBrush(Colors.Black);
|
||||
if(accentColorBrushString == null)
|
||||
{
|
||||
if(pUserIdManage != null)
|
||||
{
|
||||
accentColorBrushString = "3B7799";
|
||||
}
|
||||
else if(pOnlyEmployees && pUserCount > 2)
|
||||
{
|
||||
accentColorBrushString = "45993B";
|
||||
}
|
||||
else
|
||||
{
|
||||
accentColorBrushString = "000000";
|
||||
}
|
||||
}
|
||||
|
||||
AccentColorBrush = new BrushConverter().ConvertFromString($"#{accentColorBrushString}") as SolidColorBrush;
|
||||
|
||||
Image = image;
|
||||
}
|
||||
|
||||
private sealed class ContactEqualityComparer : IEqualityComparer<Contact>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
public bool Equals(Contact x, Contact y)
|
||||
if(obj is Contact y)
|
||||
{
|
||||
if(ReferenceEquals(x, y))
|
||||
if(ReferenceEquals(this, y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(x is null)
|
||||
if(GetType() != y.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(y is null)
|
||||
{
|
||||
return Name == y.Name &&
|
||||
IsNewMessage == y.IsNewMessage &&
|
||||
Equals(ProfilePicture, y.ProfilePicture) &&
|
||||
TimeStamp.Equals(y.TimeStamp) &&
|
||||
GroupId == y.GroupId &&
|
||||
UserIdManage == y.UserIdManage &&
|
||||
IsChatMessageInputGridVisible == y.IsChatMessageInputGridVisible;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(x.GetType() != y.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return x.Name == y.Name &&
|
||||
x.IsNewMessage == y.IsNewMessage &&
|
||||
Equals(x.ProfilePicture, y.ProfilePicture) &&
|
||||
x.TimeStamp.Equals(y.TimeStamp) &&
|
||||
x.GroupId == y.GroupId &&
|
||||
x.UserOid == y.UserOid &&
|
||||
x.UserIdManage == y.UserIdManage &&
|
||||
x.IsChatMessageInputGridVisible == y.IsChatMessageInputGridVisible;
|
||||
}
|
||||
|
||||
public int GetHashCode(Contact obj)
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hashCode = obj.Name != null ? obj.Name.GetHashCode() : 0;
|
||||
var hashCode = Name != null ? Name.GetHashCode() : 0;
|
||||
|
||||
hashCode = (hashCode * 397) ^ obj.IsNewMessage.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ (obj.ProfilePicture != null ? obj.ProfilePicture.GetHashCode() : 0);
|
||||
hashCode = (hashCode * 397) ^ obj.TimeStamp.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ obj.GroupId;
|
||||
hashCode = (hashCode * 397) ^ obj.UserOid;
|
||||
hashCode = (hashCode * 397) ^ (obj.UserIdManage != null ? obj.UserIdManage.GetHashCode() : 0);
|
||||
hashCode = (hashCode * 397) ^ obj.IsChatMessageInputGridVisible.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ (ProfilePicture != null ? ProfilePicture.GetHashCode() : 0);
|
||||
hashCode = (hashCode * 397) ^ GroupId;
|
||||
hashCode = (hashCode * 397) ^ (UserIdManage != null ? UserIdManage.GetHashCode() : 0);
|
||||
hashCode = (hashCode * 397) ^ IsChatMessageInputGridVisible.GetHashCode();
|
||||
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SolidColorBrush AccentColorBrush { get; }
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
<Setter Property="Template" Value="{StaticResource ContactListBoxTemplate}" />
|
||||
</Style>
|
||||
|
||||
<!-- Kontaktliste -->
|
||||
<Style x:Key="ContactListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
|
||||
<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type ItemsControl}, Mode=FindAncestor}}" />
|
||||
<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type ItemsControl}, Mode=FindAncestor}}" />
|
||||
@@ -210,29 +211,20 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ListBox x:Name="AktChatUserList" HorizontalAlignment="Left" Margin="0" Grid.Row="0" Background="Transparent" BorderBrush="Transparent" VerticalAlignment="Bottom" ItemTemplate="{DynamicResource DataTemplate2}" MouseDoubleClick="AktChatUser_OnMouseDoubleClick" >
|
||||
<ListBox.Resources>
|
||||
<DataTemplate x:Key="DataTemplate2" DataType="chatKlassen:Contact">
|
||||
<Grid>
|
||||
<Grid Grid.Row="0" HorizontalAlignment="Left" Background="Transparent" VerticalAlignment="Center" Height="50" PreviewMouseDown="CurrentContactImage_OnMouseDoubleClick">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="10*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Ellipse Width='40' Height='40' VerticalAlignment="Center" RenderOptions.BitmapScalingMode="HighQuality">
|
||||
<Ellipse.Fill >
|
||||
<ImageBrush ImageSource='{Binding Image}' Stretch="UniformToFill"/>
|
||||
<ImageBrush ImageSource='{Binding Path=ThreadExceptionImageSource, UpdateSourceTrigger=PropertyChanged}' Stretch="UniformToFill"/>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
|
||||
<TextBlock Grid.Column="1" Margin="8" Text="{Binding Path=Name, FallbackValue=FirstName}" FontSize="16" Foreground="{Binding AccentColorBrush}" />
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="8" TextWrapping="Wrap" Text="{Binding CurrentContactInformationString}" FontSize="16" Foreground="{Binding CurrencContactInfoForeground}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.Resources>
|
||||
</ListBox>
|
||||
|
||||
<ListBox x:Name="ChatListBox" ItemsSource="{Binding CurrentChatMessages, UpdateSourceTrigger=PropertyChanged}"
|
||||
HorizontalAlignment="Stretch" ScrollViewer.CanContentScroll="False" VerticalAlignment="Stretch" Grid.Row="1"
|
||||
@@ -366,7 +358,8 @@
|
||||
Margin="2"
|
||||
VerticalAlignment="Stretch"
|
||||
GotFocus="Chatbox_OnGotFocus"
|
||||
KeyDown="Chatbox_OnKeyDownHandler">
|
||||
KeyDown="Chatbox_OnKeyDownHandler"
|
||||
TextChanged="Chatbox_OnTextChanged">
|
||||
<TextBox.Resources>
|
||||
<Style TargetType="{x:Type Border}">
|
||||
<Setter Property="CornerRadius" Value="2"/>
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.Windows.Data;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Threading;
|
||||
using ChatController.Annotations;
|
||||
@@ -23,6 +24,7 @@ using ChatController.HauptKlassen;
|
||||
using ChatController.LoginKlassen;
|
||||
using ChatController.Utilities;
|
||||
using ChatController.Utilities.Extensions;
|
||||
using Application = System.Windows.Forms.Application;
|
||||
using Button = System.Windows.Controls.Button;
|
||||
using Cursors = System.Windows.Input.Cursors;
|
||||
using DataFormats = System.Windows.DataFormats;
|
||||
@@ -43,6 +45,33 @@ namespace ChatController
|
||||
|
||||
private readonly Dictionary<int, SyncFileInfoStruct> _GroupId2DateTime = new Dictionary<int, SyncFileInfoStruct>();
|
||||
|
||||
private string _ThreadExceptionMessage;
|
||||
|
||||
public string ThreadExceptionMessage
|
||||
{
|
||||
get => _ThreadExceptionMessage;
|
||||
|
||||
set
|
||||
{
|
||||
if(!Equals(_ThreadExceptionMessage, value))
|
||||
{
|
||||
_ThreadExceptionMessage = value;
|
||||
OnPropertyChanged(nameof(ThreadExceptionMessage));
|
||||
OnPropertyChanged(nameof(CurrentContactInformationString));
|
||||
OnPropertyChanged(nameof(CurrencContactInfoForeground));
|
||||
OnPropertyChanged(nameof(ThreadExceptionImageSource));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ImageSource _ThreadExceptionImageSource;
|
||||
|
||||
public ImageSource ThreadExceptionImageSource => ThreadExceptionMessage != null ? _ThreadExceptionImageSource : CurrentContact?.Image;
|
||||
|
||||
public SolidColorBrush CurrencContactInfoForeground => ThreadExceptionMessage != null ? new SolidColorBrush(Color.FromRgb(185, 65, 0)) : CurrentContact?.AccentColorBrush ?? new SolidColorBrush(Colors.Transparent);
|
||||
|
||||
public string CurrentContactInformationString => ThreadExceptionMessage ?? CurrentContact?.Name;
|
||||
|
||||
private Window _ContainingWindow;
|
||||
|
||||
public Window ContainingWindow
|
||||
@@ -79,6 +108,9 @@ namespace ChatController
|
||||
OnPropertyChanged(nameof(CurrentContact));
|
||||
OnPropertyChanged(nameof(ChatMessageInputGridVisibility));
|
||||
OnPropertyChanged(nameof(CurrentChatMessages));
|
||||
OnPropertyChanged(nameof(CurrentContactInformationString));
|
||||
OnPropertyChanged(nameof(CurrencContactInfoForeground));
|
||||
OnPropertyChanged(nameof(ThreadExceptionImageSource));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +154,8 @@ namespace ChatController
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_ThreadExceptionImageSource = new BitmapImage(new Uri("pack://application:,,,/ChatController;component/Ressourcen/warning-exclamation-mark.png", UriKind.Absolute));
|
||||
|
||||
DataContext = this;
|
||||
|
||||
ReloadGruppen.Visibility = Visibility.Collapsed;
|
||||
@@ -140,10 +174,23 @@ namespace ChatController
|
||||
public void InitMitChatdaten(ChatDatenUebergabe cdu)
|
||||
{
|
||||
_Chat = new Chat(cdu, exception => {
|
||||
this.Dispatch(() => {
|
||||
this.Dispatch(
|
||||
() => {
|
||||
EndWaiting();
|
||||
|
||||
MessageBox.Show($"Fehler: {exception.Message}", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
});
|
||||
},
|
||||
exception => {
|
||||
this.Dispatch(
|
||||
() => {
|
||||
if(exception == null)
|
||||
{
|
||||
ThreadExceptionMessage = null;
|
||||
}
|
||||
|
||||
ThreadExceptionMessage = exception?.Message?.Contains("500") ?? false ? "ownChat ist vorrübergehend nicht verfügbar. Bitte versuchen Sie es später noch einmal." : null;
|
||||
});
|
||||
});
|
||||
|
||||
_ContactList = _Chat.AddContacts();
|
||||
@@ -201,6 +248,7 @@ namespace ChatController
|
||||
|
||||
notifyIcon.BalloonTipClosed += (sender, args) =>
|
||||
{
|
||||
// TODO: wird beim ausblenden bzw. automatischem Schließen des "Balloons" ausgelöst
|
||||
DisposeAndRemoveNotification((NotifyIcon)sender, pGroupId);
|
||||
};
|
||||
|
||||
@@ -215,7 +263,9 @@ namespace ChatController
|
||||
{
|
||||
foreach(var notifyIcon in group2NotifyIcon.Value)
|
||||
{
|
||||
notifyIcon.Icon = null;
|
||||
notifyIcon.Dispose();
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,6 +276,8 @@ namespace ChatController
|
||||
{
|
||||
pNotification.Dispose();
|
||||
_Group2NotifyIcons.Remove(pGroupId);
|
||||
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
public void ResetStyle()
|
||||
@@ -236,10 +288,13 @@ namespace ChatController
|
||||
_IsDesktopVersion = false;
|
||||
}
|
||||
|
||||
private void AktChatUser_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
private void CurrentContactImage_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if(e.ClickCount == 2)
|
||||
{
|
||||
_Chat.ShowProfilePicture(_CurrentContact);
|
||||
}
|
||||
}
|
||||
|
||||
private void Clientlist_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
@@ -262,8 +317,6 @@ namespace ChatController
|
||||
Cursor = Cursors.Wait;
|
||||
_ScrollPrueferAktivieren = false;
|
||||
|
||||
AktChatUserList.Items.Clear();
|
||||
|
||||
if (pContact.HasUnreadMessages)
|
||||
{
|
||||
pContact.HasUnreadMessages = false;
|
||||
@@ -280,7 +333,6 @@ namespace ChatController
|
||||
ContainingWindow.Icon = Utils.GetImageSourceFromIcon(Resource.ownchat_favicon);
|
||||
}
|
||||
|
||||
AktChatUserList.Items.Add(currentContact);
|
||||
CurrentContact = currentContact;
|
||||
|
||||
if(Clientlist.Items.Contains(pContact))
|
||||
@@ -368,8 +420,7 @@ namespace ChatController
|
||||
|
||||
private void PasteOnClick(object sender, RoutedEventArgs routedEventArgs)
|
||||
{
|
||||
var kontakt = (Contact)AktChatUserList.Items[0];
|
||||
_Chat.Paste(kontakt.GroupId,this);
|
||||
_Chat.Paste(CurrentContact.GroupId,this);
|
||||
}
|
||||
|
||||
private void CopyOnClick(object sender, RoutedEventArgs routedEventArgs)
|
||||
@@ -468,9 +519,8 @@ namespace ChatController
|
||||
ContextItemSpeichernUnter.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
//prüfe ob dokumentation erlaubt
|
||||
var kontakt = (Contact)AktChatUserList.Items[0];
|
||||
if(kontakt.UserIdManage == null && ChatListBox.ContextMenu.Items.Count > 3)
|
||||
// Prüfe, ob Dokumentation erlaubt
|
||||
if(CurrentContact.UserIdManage == null && ChatListBox.ContextMenu.Items.Count > 3)
|
||||
{
|
||||
var contextItems = ChatListBox.ContextMenu.Items;
|
||||
var ContextItemSpeichernUnter = (MenuItem)contextItems[3];
|
||||
@@ -492,7 +542,7 @@ namespace ChatController
|
||||
|
||||
private void MediaButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (AktChatUserList.Items.Count > 0)
|
||||
if(CurrentContact != null)
|
||||
{
|
||||
var fileToOpen = _Chat.OpenFile();
|
||||
|
||||
@@ -510,7 +560,7 @@ namespace ChatController
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
//_Chat.AddNewFile(filePath, fileToOpen, CurrentContact.GroupId);
|
||||
_Chat.AddNewFile(filePath, fileToOpen, CurrentContact.GroupId);
|
||||
|
||||
OnPropertyChanged(nameof(CurrentChatMessages));
|
||||
|
||||
@@ -534,7 +584,7 @@ namespace ChatController
|
||||
|
||||
private void SendButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!AktChatUserList.Items.IsEmpty && !string.IsNullOrEmpty(Chatbox.Text))
|
||||
if(CurrentContact != null && !string.IsNullOrEmpty(Chatbox.Text))
|
||||
{
|
||||
_Chat.AddNewMessage(Chatbox.Text, CurrentContact.GroupId);
|
||||
|
||||
@@ -564,7 +614,7 @@ namespace ChatController
|
||||
{
|
||||
if (e.Key == Key.Return)
|
||||
{
|
||||
if (!AktChatUserList.Items.IsEmpty && !string.IsNullOrEmpty(Chatbox.Text))
|
||||
if(CurrentContact != null && !string.IsNullOrEmpty(Chatbox.Text))
|
||||
{
|
||||
_Chat.AddNewMessage(Chatbox.Text, CurrentContact.GroupId);
|
||||
|
||||
@@ -646,7 +696,7 @@ namespace ChatController
|
||||
{
|
||||
EmojisListeningThreadTimer?.Stop();
|
||||
EmojisListeningThreadTimer = null;
|
||||
InitListeningThread((Contact)AktChatUserList.Items[0]);
|
||||
InitListeningThread(CurrentContact);
|
||||
}
|
||||
|
||||
public Timer EmojisListeningThreadTimer;
|
||||
@@ -656,7 +706,7 @@ namespace ChatController
|
||||
{
|
||||
GlobalListeningThreadtimer = new Timer();
|
||||
GlobalListeningThreadtimer.Tick += GlobalListeningThreadTimerTickEvent;
|
||||
GlobalListeningThreadtimer.Interval = 2000;
|
||||
GlobalListeningThreadtimer.Interval = 10000;
|
||||
GlobalListeningThreadtimer.Start();
|
||||
}
|
||||
|
||||
@@ -677,17 +727,15 @@ namespace ChatController
|
||||
{
|
||||
var contacts = _Chat.NeueGroupklassenKontakte().ToList();
|
||||
|
||||
Contact currentContact = null;
|
||||
|
||||
if (AktChatUserList.HasItems)
|
||||
{
|
||||
currentContact = (Contact) AktChatUserList.Items[0];
|
||||
}
|
||||
|
||||
foreach (var contact in _ContactList)
|
||||
{
|
||||
foreach (var newContact in contacts)
|
||||
{
|
||||
if(newContact == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (contact.GroupId == newContact.GroupId)
|
||||
{
|
||||
// ReceivedMessage kann null sein!
|
||||
@@ -696,15 +744,23 @@ namespace ChatController
|
||||
contact.ReceivedMessage = newContact.ReceivedMessage;
|
||||
contact.TimeStamp = newContact.TimeStamp;
|
||||
|
||||
// TODO: Prüfen, ob die App im Hintergrund oder minimiert ist
|
||||
if (Clientlist.SelectedItem != null && !((Contact)Clientlist.SelectedItem).GroupId.Equals(newContact.GroupId) || Clientlist.SelectedItem == null || _IsInBackground)
|
||||
var selectedContact = (Contact) Clientlist.SelectedItem;
|
||||
// Angemeldeter Benutzer
|
||||
var userOid = _Chat.ChatDaten.LoggedInUser.Response.User.Oid;
|
||||
|
||||
var senderId = contact.ReceivedMessage?.UserId;
|
||||
var receiverId = userOid;
|
||||
var receiverGroupId = newContact.GroupId;
|
||||
var selectedGroupId = selectedContact?.GroupId;
|
||||
|
||||
if(senderId != receiverId && (_IsInBackground || receiverGroupId != selectedGroupId))
|
||||
{
|
||||
ContainingWindow.Icon = Utils.GetImageSourceFromIcon(Resource.oC_favico_NewMessage);
|
||||
ShowNotification(newContact.Name, newContact.ReceivedMessage, newContact.GroupId);
|
||||
}
|
||||
|
||||
// Wenn der momentan ausgewählte Kontakt der aktuelle Kontakt in der Schleife ist, werden die Nachrichten nicht als ungelesen angezeigt, sonst schon.
|
||||
if (currentContact != null && newContact.GroupId == currentContact.GroupId)
|
||||
if (CurrentContact != null && newContact.GroupId == CurrentContact.GroupId)
|
||||
{
|
||||
contact.HasUnreadMessages = false;
|
||||
}
|
||||
@@ -737,7 +793,7 @@ namespace ChatController
|
||||
{
|
||||
EmojisListeningThreadTimer = new Timer {Tag = currentContact};
|
||||
EmojisListeningThreadTimer.Tick += ListeningThreadTimerTickEvent;
|
||||
EmojisListeningThreadTimer.Interval = 2000;
|
||||
EmojisListeningThreadTimer.Interval = 10000;
|
||||
EmojisListeningThreadTimer.Start();
|
||||
}
|
||||
|
||||
@@ -912,6 +968,8 @@ namespace ChatController
|
||||
|
||||
ReadNewSyncFile();
|
||||
|
||||
AddViewFilterToClientlist();
|
||||
|
||||
EndWaiting();
|
||||
});
|
||||
});
|
||||
@@ -1050,14 +1108,7 @@ namespace ChatController
|
||||
// Wird im BeWoPlaner benutzt
|
||||
public Contact GetCurrentContact()
|
||||
{
|
||||
if(AktChatUserList != null && AktChatUserList.Items.Count > 0)
|
||||
{
|
||||
var contact = (Contact) AktChatUserList.Items[0];
|
||||
|
||||
return contact.UserIdManage == null ? null : contact;
|
||||
}
|
||||
|
||||
return null;
|
||||
return CurrentContact?.UserIdManage != null ? CurrentContact : null;
|
||||
}
|
||||
|
||||
// Wird im BeWoPlaner benutzt
|
||||
@@ -1096,9 +1147,22 @@ namespace ChatController
|
||||
}
|
||||
|
||||
private void ChatMainControl_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AddViewFilterToClientlist();
|
||||
}
|
||||
|
||||
private void AddViewFilterToClientlist()
|
||||
{
|
||||
var view = (CollectionView)CollectionViewSource.GetDefaultView(Clientlist.ItemsSource);
|
||||
view.Filter = UserFilter;
|
||||
}
|
||||
|
||||
private void Chatbox_OnTextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(Chatbox.Text))
|
||||
{
|
||||
Chatbox.Height = 25;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace ChatController.HauptKlassen
|
||||
public class Chat
|
||||
{
|
||||
public Action<Exception> ExceptionCallback { get; set; }
|
||||
public Action<Exception> ThreadExceptionCallback { get; set; }
|
||||
|
||||
private readonly List<Contact> _Contacts = new List<Contact>();
|
||||
|
||||
@@ -49,10 +50,11 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
public long LastTimeStamp { get; set; }
|
||||
|
||||
public Chat(ChatDatenUebergabe chatDaten, Action<Exception> exceptionCallback)
|
||||
public Chat(ChatDatenUebergabe chatDaten, Action<Exception> exceptionCallback, Action<Exception> threadExceptionCallback)
|
||||
{
|
||||
ChatDaten = chatDaten;
|
||||
ExceptionCallback = exceptionCallback;
|
||||
ThreadExceptionCallback = threadExceptionCallback;
|
||||
}
|
||||
|
||||
// WebRequest
|
||||
@@ -82,14 +84,7 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
try
|
||||
{
|
||||
var bitmapImage = new BitmapImage();
|
||||
|
||||
bitmapImage.BeginInit();
|
||||
bitmapImage.UriSource = new Uri(pUri);
|
||||
bitmapImage.CacheOption = BitmapCacheOption.OnDemand;
|
||||
bitmapImage.EndInit();
|
||||
|
||||
return bitmapImage;
|
||||
return DownloadImageWithRestRequest(pUri);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -98,6 +93,38 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
}
|
||||
|
||||
private ImageSource DownloadImageWithRestRequest(string uri)
|
||||
{
|
||||
Bitmap bitmap = null;
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(uri))
|
||||
{
|
||||
var client = new RestClient(uri);
|
||||
|
||||
var request = new RestRequest(Method.GET)
|
||||
{
|
||||
ResponseWriter = responseStream =>
|
||||
{
|
||||
try
|
||||
{
|
||||
bitmap = new Bitmap(responseStream);
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
request.AddHeader(Constants.Token, ChatDaten.AuthToken);
|
||||
request.AddHeader(Constants.CustomerId, ChatDaten.Kundennummer);
|
||||
|
||||
client.DownloadData(request);
|
||||
}
|
||||
|
||||
return bitmap != null ? Utils.ImageSourceForBitmap(bitmap) : null;
|
||||
}
|
||||
|
||||
// WebRequest
|
||||
private void LoadMessagesFromServer(long pGroupId)
|
||||
{
|
||||
@@ -131,10 +158,12 @@ namespace ChatController.HauptKlassen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ThreadExceptionCallback?.Invoke(null);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
ThreadExceptionCallback?.Invoke(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,11 +350,12 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
var messageCounter = JsonConvert.DeserializeObject<MessageCounter>(responseFromServer);
|
||||
|
||||
ThreadExceptionCallback?.Invoke(null);
|
||||
return messageCounter.MessageCount;
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
ExceptionCallback?.Invoke(exception);
|
||||
ThreadExceptionCallback?.Invoke(exception);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -521,7 +551,7 @@ namespace ChatController.HauptKlassen
|
||||
{
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Filter = Resource.OpenFileDialogFilter_Test //Resource.OpenFileDialogFilter_DocumentsAndImages
|
||||
Filter = Resource.OpenFileDialogFilter_Test
|
||||
};
|
||||
|
||||
var result = openFileDialog.ShowDialog();
|
||||
|
||||
@@ -90,6 +90,13 @@ namespace ChatController
|
||||
DataContext = this;
|
||||
|
||||
LeseDateiFallsVorhanden();
|
||||
|
||||
#if DEBUG
|
||||
_Kundennummer = "4368658436";
|
||||
_ChatCode = "ZMCKb-BckTt";
|
||||
_Benutzername = "muellerp";
|
||||
Password = "F5aTk9Co47JFJCWB2Z7Y";
|
||||
#endif
|
||||
}
|
||||
|
||||
private void AnmeldenButton_OnClick(object sender, RoutedEventArgs e)
|
||||
|
||||
BIN
ChatController/Ressourcen/warning-exclamation-mark.png
Normal file
BIN
ChatController/Ressourcen/warning-exclamation-mark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 677 B |
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
|
||||
using ChatController.LoginKlassen;
|
||||
@@ -43,6 +44,9 @@ namespace ownChat
|
||||
ChatMainControl.DeleteTempFiles();
|
||||
ChatMainControl.WriteToNewSyncFile();
|
||||
ChatMainControl.ClearNotifications();
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user