diff --git a/ChatController/ChatControlWaitLayer.xaml.cs b/ChatController/ChatControlWaitLayer.xaml.cs index d09d0a6..5cad866 100644 --- a/ChatController/ChatControlWaitLayer.xaml.cs +++ b/ChatController/ChatControlWaitLayer.xaml.cs @@ -24,7 +24,7 @@ namespace ChatController DataContext = this; - DialogText = dialogText ?? "Daten werden übertragen. Bitte warten..."; + DialogText = string.IsNullOrWhiteSpace(dialogText) ? "Daten werden übertragen. Bitte warten..." : dialogText; } public event PropertyChangedEventHandler PropertyChanged; diff --git a/ChatController/ChatController.csproj b/ChatController/ChatController.csproj index eb04b1d..5a4de0d 100644 --- a/ChatController/ChatController.csproj +++ b/ChatController/ChatController.csproj @@ -77,7 +77,6 @@ - @@ -140,18 +139,8 @@ - - - - - - - - - - @@ -168,7 +157,6 @@ - diff --git a/ChatController/ChatKlassen/ChatControlExtensions.cs b/ChatController/ChatKlassen/ChatControlExtensions.cs index 0207ef9..123db63 100644 --- a/ChatController/ChatKlassen/ChatControlExtensions.cs +++ b/ChatController/ChatKlassen/ChatControlExtensions.cs @@ -6,7 +6,7 @@ namespace ChatController.ChatKlassen { public static class ChatControlExtensions { - private static Action EmptyDelegatee = delegate() { }; + private static readonly Action EmptyDelegatee = delegate { }; public static void RefreshChatUI(this UIElement uiElement) { diff --git a/ChatController/ChatKlassen/ChatMessage.cs b/ChatController/ChatKlassen/ChatMessage.cs index 1114d7f..49ff9ab 100644 --- a/ChatController/ChatKlassen/ChatMessage.cs +++ b/ChatController/ChatKlassen/ChatMessage.cs @@ -180,7 +180,7 @@ namespace ChatController.ChatKlassen get => _PicturePlaceholderHeight; set { - if (!Equals(_PicturePlaceholderHeight, value)) + if(!Equals(_PicturePlaceholderHeight, value)) { _PicturePlaceholderHeight = value; OnPropertyChanged(nameof(PicturePlaceholderHeight)); @@ -188,7 +188,7 @@ namespace ChatController.ChatKlassen } } - public string FilePath { get; } + public string FilePath { get; } public long GroupId { get; } diff --git a/ChatController/ChatKlassen/Contact.cs b/ChatController/ChatKlassen/Contact.cs index 3c38fe9..d57a250 100644 --- a/ChatController/ChatKlassen/Contact.cs +++ b/ChatController/ChatKlassen/Contact.cs @@ -126,12 +126,7 @@ namespace ChatController.ChatKlassen public override bool Equals(object obj) { - if(obj is Contact y) - { - return GroupId == y.GroupId; - } - - return false; + return obj is Contact y && GroupId == y.GroupId; } public override int GetHashCode() diff --git a/ChatController/ChatMainControl.xaml b/ChatController/ChatMainControl.xaml index e0245e3..6666eb4 100644 --- a/ChatController/ChatMainControl.xaml +++ b/ChatController/ChatMainControl.xaml @@ -17,7 +17,6 @@ - @@ -111,7 +110,6 @@ Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/> - diff --git a/ChatController/Converter/BoolToVisibilityConverter.cs b/ChatController/Converter/BoolToVisibilityConverter.cs index 005bdd4..83c3497 100644 --- a/ChatController/Converter/BoolToVisibilityConverter.cs +++ b/ChatController/Converter/BoolToVisibilityConverter.cs @@ -11,17 +11,7 @@ namespace ChatController.Converter { if(value is bool boolValue) { - if(parameter is string reverseString && Equals(reverseString, "reverse")) - { - return boolValue ? Visibility.Visible : Visibility.Collapsed; - } - - if(parameter is string reverseHiddenString && Equals(reverseHiddenString, "reverse_hidden")) - { - return boolValue ? Visibility.Visible : Visibility.Hidden; - } - - return boolValue ? Visibility.Collapsed : Visibility.Visible; + return parameter is string reverseString && Equals(reverseString, "reverse") ? boolValue ? Visibility.Visible : Visibility.Collapsed : boolValue ? Visibility.Collapsed : Visibility.Visible; } return Visibility.Visible; diff --git a/ChatController/Converter/BroadcastCheckBoxVisibilityMultiConverter.cs b/ChatController/Converter/BroadcastCheckBoxVisibilityMultiConverter.cs index 91c5ab9..7613f54 100644 --- a/ChatController/Converter/BroadcastCheckBoxVisibilityMultiConverter.cs +++ b/ChatController/Converter/BroadcastCheckBoxVisibilityMultiConverter.cs @@ -11,12 +11,7 @@ namespace ChatController.Converter { if(values.Length == 2 && values[0] is bool isInBroadcastMode && values[1] is bool isChatMessageInputGridVisible) { - if(isInBroadcastMode) - { - return isChatMessageInputGridVisible ? Visibility.Visible : Visibility.Hidden; - } - - return Visibility.Collapsed; + return isInBroadcastMode ? isChatMessageInputGridVisible ? Visibility.Visible : Visibility.Hidden : Visibility.Collapsed; } return Visibility.Collapsed; diff --git a/ChatController/Core/OwnChatCache.cs b/ChatController/Core/OwnChatCache.cs index 599995d..06b923e 100644 --- a/ChatController/Core/OwnChatCache.cs +++ b/ChatController/Core/OwnChatCache.cs @@ -56,19 +56,6 @@ namespace ChatController.Core return _Instance ?? (_Instance = new OwnChatCache()); } - public void ClearAll() - { - ClearImageSources(); - } - - public void ClearImageSources() - { - lock(_Lock) - { - _ImageSourceCache.Clear(); - } - } - public ImageSource GetImageSourceFromCache(string key, string name, CacheCategory cacheCategory) { lock(_Lock) diff --git a/ChatController/Core/OwnChatRichTextBox.cs b/ChatController/Core/OwnChatRichTextBox.cs index f375d47..d74f3eb 100644 --- a/ChatController/Core/OwnChatRichTextBox.cs +++ b/ChatController/Core/OwnChatRichTextBox.cs @@ -37,7 +37,7 @@ namespace ChatController.Core var flowDocument = new FlowDocument(); var paragraph = new Paragraph { - Margin = new Thickness(0) // remove indent between paragraphs + Margin = new Thickness(0) }; paragraph.Inlines.AddRange(inlines); diff --git a/ChatController/Data/OwnChatApi.cs b/ChatController/Data/OwnChatApi.cs deleted file mode 100644 index 1506f6a..0000000 --- a/ChatController/Data/OwnChatApi.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.IO; -using System.Net; -using ChatController.LoginKlassen; -using ChatController.Utilities; -using Newtonsoft.Json; - -namespace ChatController.Data -{ - public class OwnChatApi - { - public static string ServerUrl { get; set; } - public static string ApiKey { get; set; } - public static string Tenant { get; set; } - - public static long GetMaximumAllowedFileUploadSize(string pApiKey, string pCustomerId) - { - var url = ServerUrl + Constants.MaxUploadFileSizeUrl; - - var webRequest = WebRequest.Create(url); - webRequest.Headers[Constants.Token] = pApiKey; - webRequest.Headers[Constants.CustomerId] = pCustomerId; - - webRequest.Credentials = CredentialCache.DefaultCredentials; - webRequest.Proxy = null; - - using (var response = webRequest.GetResponse()) - { - var responseFromServer = ReadStream(response); - - var definiti = new {file_upload_max_size = ""}; - - var jsonDatentyp = JsonConvert.DeserializeAnonymousType(responseFromServer, definiti); - - return Convert.ToInt64(jsonDatentyp.file_upload_max_size); - } - } - - public static UserMessages GetMessages(long pGroupId) - { - - var url = ServerUrl + Constants.LoadMessagesForGroupUrl + pGroupId; - - var webRequest = WebRequest.Create(url); - - webRequest.Credentials = CredentialCache.DefaultCredentials; - webRequest.Headers[Constants.Token] = ApiKey; - webRequest.Headers[Constants.CustomerId] = Tenant; - - using (var response = webRequest.GetResponse()) - { - var serverResponse = ReadStream(response); - - if (!string.IsNullOrEmpty(serverResponse)) - { - return JsonConvert.DeserializeObject(serverResponse); - } - } - - return null; - } - - public ChatGruppenDaten GetAllChatGroups() - { - var endurl = ServerUrl + Constants.GetChatGroupsUrl; - - var webRequest = WebRequest.Create(endurl); - - webRequest.Credentials = CredentialCache.DefaultCredentials; - webRequest.Headers[Constants.Token] = ApiKey; - webRequest.Headers[Constants.CustomerId] = Tenant; - - using (var response = webRequest.GetResponse()) - { - var serverResponse = ReadStream(response); - return JsonConvert.DeserializeObject(serverResponse); - } - } - - public static string ReadStream(WebResponse response) - { - try - { - var serverResponse = string.Empty; - - using (var dataStream = response.GetResponseStream()) - { - if(dataStream is null) - { - return serverResponse; - } - - using (var reader = new StreamReader(dataStream)) - { - serverResponse = reader.ReadToEnd(); - - return serverResponse; - } - } - } - catch (Exception exception) - { - return null; - } - } - } -} diff --git a/ChatController/HauptKlassen/Chat.cs b/ChatController/HauptKlassen/Chat.cs index 6ef5b95..593e5b8 100644 --- a/ChatController/HauptKlassen/Chat.cs +++ b/ChatController/HauptKlassen/Chat.cs @@ -4,7 +4,6 @@ using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; -using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; @@ -16,7 +15,6 @@ using System.Runtime.CompilerServices; using System.Security.Cryptography.X509Certificates; using System.Threading; using System.Threading.Tasks; -using System.Web; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -595,12 +593,12 @@ namespace ChatController.HauptKlassen fileName = fileName.Replace(".bmp", ".jpg"); } - await SendMediaMessage(fileName, currentContact.GroupId, mediaFile, message, pFile); + await SendMediaMessage(fileName, currentContact.GroupId, mediaFile, message); } private HttpRequestMessage _HttpRequest; - private async Task SendMediaMessage(string fileName, long groupId, byte[] mediaFile, string message, string pathToTempFile) + private async Task SendMediaMessage(string fileName, long groupId, byte[] mediaFile, string message) { try { @@ -761,7 +759,7 @@ namespace ChatController.HauptKlassen pChatMainControl.ChatListBox.Items.MoveCurrentToLast(); pChatMainControl.ChatListBox.ScrollIntoView(pChatMainControl.ChatListBox.Items.CurrentItem); - await SendMediaMessage(fileName, pGroupOid, mediaFile, null, pathToFile); + await SendMediaMessage(fileName, pGroupOid, mediaFile, null); } } } @@ -800,7 +798,7 @@ namespace ChatController.HauptKlassen pChatMainControl.ChatListBox.Items.MoveCurrentToLast(); pChatMainControl.ChatListBox.ScrollIntoView(pChatMainControl.ChatListBox.Items.CurrentItem); - await SendMediaMessage(imageName, pGroupOid, Utils.ImageToByteArray(image), null, null); + await SendMediaMessage(imageName, pGroupOid, Utils.ImageToByteArray(image), null); } else { @@ -1134,10 +1132,6 @@ namespace ChatController.HauptKlassen } } - - - - public event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] @@ -1151,12 +1145,7 @@ namespace ChatController.HauptKlassen { public int Compare(object x, object y) { - if(x is ChatMessage message1 && y is ChatMessage message2) - { - return message1.SendTime.CompareTo(message2.SendTime); - } - - return 0; + return x is ChatMessage message1 && y is ChatMessage message2 ? message1.SendTime.CompareTo(message2.SendTime) : 0; } } } diff --git a/ChatController/HauptKlassen/Login.cs b/ChatController/HauptKlassen/Login.cs index 84b823f..f37885b 100644 --- a/ChatController/HauptKlassen/Login.cs +++ b/ChatController/HauptKlassen/Login.cs @@ -121,11 +121,11 @@ namespace ChatController.HauptKlassen ConnectWithChatServerAsync( isSuccessfullyLoggedIn => { - if (isSuccessfullyLoggedIn) + if(isSuccessfullyLoggedIn) { GetGroupsAsync(wasSuccessful => { - if (wasSuccessful) + if(wasSuccessful) { GetMaximumAllowedFileUploadSizeAsync(maxUploadFileSize => { @@ -140,7 +140,7 @@ namespace ChatController.HauptKlassen } }, errorMessage => { exceptionCallback?.Invoke(errorMessage); }); } - catch (Exception exception) + catch(Exception) { callback?.Invoke(null); } @@ -170,7 +170,7 @@ namespace ChatController.HauptKlassen var result = false; - switch (lookupResult.Status) + switch(lookupResult.Status) { case 0: result = true; @@ -187,7 +187,7 @@ namespace ChatController.HauptKlassen callback?.Invoke(result); }); } - catch (Exception exception) + catch(Exception) { exceptionCallback?.Invoke("Fehler: Es konnte keine Verbindung aufgebaut werden."); } @@ -211,7 +211,7 @@ namespace ChatController.HauptKlassen { response = request.GetResponse(); } - catch (Exception e) + catch(Exception) { if (_ShouldShowMessageBox) { @@ -247,7 +247,7 @@ namespace ChatController.HauptKlassen _BaseUrl = jsonDatentyp.Url; } - catch (Exception eds) + catch(Exception) { try { @@ -273,9 +273,9 @@ namespace ChatController.HauptKlassen _BaseUrl = jsonDatentyp.Url; } - catch (Exception e) + catch(Exception e) { - if (_ShouldShowMessageBox) + if(_ShouldShowMessageBox) { MessageBox.Show("Fehler: " + e.Message, "ownChat Fehler", MessageBoxButton.OK, MessageBoxImage.Error); } @@ -287,9 +287,9 @@ namespace ChatController.HauptKlassen ServerUrl = _BaseUrl; return true; } - catch (Exception e) + catch(Exception e) { - if (_ShouldShowMessageBox) + if(_ShouldShowMessageBox) { MessageBox.Show("Fehler: " + e.Message, "ownChat Fehler", MessageBoxButton.OK, MessageBoxImage.Error); } diff --git a/ChatController/LoginControl.xaml.cs b/ChatController/LoginControl.xaml.cs index 0d6bafc..5292911 100644 --- a/ChatController/LoginControl.xaml.cs +++ b/ChatController/LoginControl.xaml.cs @@ -6,7 +6,6 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using System.Windows; -using System.Windows.Forms; using System.Windows.Threading; using ChatController.Annotations; using ChatController.HauptKlassen; @@ -298,7 +297,7 @@ namespace ChatController try { var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); - var companyFilePath = Path.Combine(localAppData, "beyondSoft"); + var companyFilePath = Path.Combine(localAppData, "ownSoft"); if(!Directory.Exists(companyFilePath)) { diff --git a/ChatController/Ressourcen/BeyondsoftChat.jpg b/ChatController/Ressourcen/BeyondsoftChat.jpg deleted file mode 100644 index b6b0064..0000000 Binary files a/ChatController/Ressourcen/BeyondsoftChat.jpg and /dev/null differ diff --git a/ChatController/Ressourcen/ClipboardDisabled.png b/ChatController/Ressourcen/ClipboardDisabled.png deleted file mode 100644 index 9cbc0e4..0000000 Binary files a/ChatController/Ressourcen/ClipboardDisabled.png and /dev/null differ diff --git a/ChatController/Ressourcen/SymbolRefresh32.png b/ChatController/Ressourcen/SymbolRefresh32.png deleted file mode 100644 index 5661375..0000000 Binary files a/ChatController/Ressourcen/SymbolRefresh32.png and /dev/null differ diff --git a/ChatController/Ressourcen/TasksSolid.png b/ChatController/Ressourcen/TasksSolid.png deleted file mode 100644 index e7a4501..0000000 Binary files a/ChatController/Ressourcen/TasksSolid.png and /dev/null differ diff --git a/ChatController/Ressourcen/glucklicher.png b/ChatController/Ressourcen/glucklicher.png deleted file mode 100644 index 5464d26..0000000 Binary files a/ChatController/Ressourcen/glucklicher.png and /dev/null differ diff --git a/ChatController/Ressourcen/paperclip.png b/ChatController/Ressourcen/paperclip.png deleted file mode 100644 index 9c42987..0000000 Binary files a/ChatController/Ressourcen/paperclip.png and /dev/null differ diff --git a/ChatController/Ressourcen/paperclip2.png b/ChatController/Ressourcen/paperclip2.png deleted file mode 100644 index 431afa0..0000000 Binary files a/ChatController/Ressourcen/paperclip2.png and /dev/null differ diff --git a/ChatController/Utilities/Constants.cs b/ChatController/Utilities/Constants.cs index c8de4c6..4cb6252 100644 --- a/ChatController/Utilities/Constants.cs +++ b/ChatController/Utilities/Constants.cs @@ -5,12 +5,7 @@ namespace ChatController.Utilities public static class Constants { public static readonly List ImageFileExtensions = new List { ".JPG", ".JPE", ".BMP", ".GIF", ".PNG", ".JPEG" }; - public static readonly List DocumentFileExtension = new List { ".TXT", ".PPT", ".XLS", ".DOC", ".PDF" }; - public static readonly string TeamDefaultImagePath = "pack://application:,,,/ChatController;component/Ressourcen/team_default.png"; - public static readonly string EmployeeDefaultImagePath = "pack://application:,,,/ChatController;component/Ressourcen/employee_default.png"; - public static readonly string CustomerDefaultImagePath = "pack://application:,,,/ChatController;component/Ressourcen/client_default.png"; - public static readonly string NormalGroupDefaultImagePath = "pack://application:,,,/ChatController;component/Ressourcen/mitarbeiter-team-avatar.png"; public static readonly string ImagePlaceholderPath = "pack://application:,,,/ChatController;component/Ressourcen/ownchat_image_placeholder.png"; public static readonly string Token = "Token"; @@ -23,16 +18,11 @@ namespace ChatController.Utilities public static readonly string LoadOwnChatNewsUrl = "/api/ownchat/news/"; public static readonly string SendMessageUrl = "/api/chat/messages/send"; - public static readonly string UrlPageParameter = "&page="; - public static readonly int NotificationTimeout = 1500; public static readonly string ContentTypeKey = "content-type"; public static readonly string FormUrlEncodedContentTypeValue = "application/x-www-form-urlencoded"; - public static readonly string MultipartContentTypeValue = "multipart/form-data"; public static readonly string TenantAndChatCodeFileName = "ownChat.txt"; - - public static readonly string ProfilePictureCacheName = "profile-picture"; } } diff --git a/ChatController/Utilities/Utils.cs b/ChatController/Utilities/Utils.cs index 58f9efa..1d859f0 100644 --- a/ChatController/Utilities/Utils.cs +++ b/ChatController/Utilities/Utils.cs @@ -171,29 +171,6 @@ namespace ChatController.Utilities }); } - private static ImageSource GetDefaultImageSource(bool pIsGroup, bool pIsEmployee) - { - var defaultImage = Constants.EmployeeDefaultImagePath; - - if(pIsGroup) - { - defaultImage = pIsEmployee ? Constants.TeamDefaultImagePath : Constants.NormalGroupDefaultImagePath; - } - else if(!pIsEmployee) - { - defaultImage = Constants.CustomerDefaultImagePath; - } - - var resultBitmapImage = new BitmapImage(); - - resultBitmapImage.BeginInit(); - resultBitmapImage.UriSource = new Uri(defaultImage); - resultBitmapImage.EndInit(); - resultBitmapImage.Freeze(); - - return resultBitmapImage; - } - public static ImageSource GetPicturePlaceholder() { var cache = OwnChatCache.GetInstance(); @@ -422,56 +399,6 @@ namespace ChatController.Utilities } } - /* - * try - { - using (var form = new Form()) - { - using (var ms = new MemoryStream(e.Result)) - { - var image = System.Drawing.Image.FromStream(ms); - - using (var bitmap = new Bitmap(image)) - { - short orient = 0; - const int orientationId = 0x0112; - - if (image.PropertyIdList.Contains(orientationId)) - { - var item = image.GetPropertyItem(orientationId); - - orient = BitConverter.ToInt16(item.Value, 0); - - bitmap.SetPropertyItem(item); - } - - var flipType = Utils.OrientationToFlipType(orient.ToString()); - - bitmap.RotateFlip(flipType); - - form.StartPosition = FormStartPosition.CenterScreen; - form.ClientSize = bitmap.Size; - form.FormBorderStyle = FormBorderStyle.Sizable; - form.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); - - using (var pictureBox = new PictureBox()) - { - pictureBox.Dock = DockStyle.Fill; - pictureBox.Image = bitmap; - - pictureBox.SizeMode = PictureBoxSizeMode.Zoom; - - form.Controls.Add(pictureBox); - - downloadCompletedCallback?.Invoke(); - - form.ShowDialog(); - } - } - } - } - */ - public static int GetHeightFromThumbnailUri(string uri) { /*