Anzeige von neuen Nachrichten und die Ladegeschwindigkeit von Konversationen verbessert

Aufgrund der Benutzung von Threads anstelle von Timern hat das Aufrufen der einzelnen Konversationen ca. 2 Sekunden gedauert.
Die Synchronisationsdatei enthält, ob die letzte Nachrichte bereits gelesen wurde, sodass man,
wenn man den Chat beendet bevor man eine neue Nachricht gelesen hat, diese nach dem erneuten Öffnen immer noch als neu angezeigt wird.

- Dateinamen verbessert
- Diverse Verbesserungen des Codes
This commit is contained in:
Lyndon
2019-05-14 13:37:20 +02:00
parent b82821d0c4
commit 3fbf8afe0d
25 changed files with 962 additions and 1131 deletions

View File

@@ -33,6 +33,9 @@
<PropertyGroup>
<ApplicationIcon>ownchat_favicon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="DevExpress.Mvvm.v17.1, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<Private>False</Private>
@@ -60,10 +63,10 @@
<Compile Include="ChatEmojiiControl.xaml.cs">
<DependentUpon>ChatEmojiiControl.xaml</DependentUpon>
</Compile>
<Compile Include="ChatKlassen\AktuellerKontakt.cs" />
<Compile Include="ChatKlassen\ChatControlExtensions.cs" />
<Compile Include="ChatKlassen\Contact.cs" />
<Compile Include="ChatKlassen\ChatMessage.cs" />
<Compile Include="ChatKlassen\CurrentContact.cs" />
<Compile Include="ChatKlassen\MessageCounter.cs" />
<Compile Include="ChatMainControl.xaml.cs">
<DependentUpon>ChatMainControl.xaml</DependentUpon>
@@ -74,12 +77,13 @@
<Compile Include="LoginControl.xaml.cs">
<DependentUpon>LoginControl.xaml</DependentUpon>
</Compile>
<Compile Include="LoginKlassen\AuthentifizierungsDaten.cs" />
<Compile Include="LoginKlassen\AuthenticationData.cs" />
<Compile Include="LoginKlassen\ChatDatenUebergabe.cs" />
<Compile Include="LoginKlassen\ChatGruppenDaten.cs" />
<Compile Include="HauptKlassen\Login.cs" />
<Compile Include="LoginKlassen\UserDaten.cs" />
<Compile Include="LoginKlassen\UserMessages.cs" />
<Compile Include="Properties\Annotations1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ChatControlWaitLayer.xaml.cs">
<DependentUpon>ChatControlWaitLayer.xaml</DependentUpon>
@@ -90,6 +94,8 @@
<DependentUpon>Resource.resx</DependentUpon>
</Compile>
<Compile Include="Utilities\Constants.cs" />
<Compile Include="Utilities\Extensions\DateTimeExtensions.cs" />
<Compile Include="Utilities\SyncFileInfoStruct.cs" />
<Compile Include="Utilities\Utils.cs" />
</ItemGroup>
<ItemGroup>
@@ -132,6 +138,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="ownchat_favicon.ico" />
<None Include="Resources\IconNewMessages.ico" />
<None Include="Resources\oC-favico_NewMessage.ico" />
<Content Include="Resources\ownchat_favicon.ico" />
<Resource Include="Ressourcen\ownchat_favicon.ico" />
<Resource Include="Ressourcen\client_default.png" />

View File

@@ -9,7 +9,7 @@ namespace ChatController.ChatKlassen
public class ChatMessage
{
//Chat-Ansicht
public ChatMessage(string username, string message, DateTime sendtime, bool isme)
public ChatMessage(string username, string message, DateTime sendtime, bool isme, long pGroupId)
{
Username = username;
UserMessage = message;
@@ -19,10 +19,12 @@ namespace ChatController.ChatKlassen
Farbgebung(isme);
VisibilityRegelung(IsHyperlink(message) ? "HyperlinkMessage" : "Message");
GroupId = pGroupId;
}
// Image-Ansicht
public ChatMessage(string username, string message, DateTime sendtime, bool isme, ImageSource image, string originalImage, string imageName)
public ChatMessage(string username, string message, DateTime sendtime, bool isme, ImageSource image, string originalImage, string imageName, long pGroupId)
{
Username = username;
UserMessage = message;
@@ -35,64 +37,49 @@ namespace ChatController.ChatKlassen
Farbgebung(isme);
VisibilityRegelung("Image");
}
//Image-PlaceHolder | wird nicht benutzt und wird nicht gebraucht ?
public ChatMessage(string username, string message, DateTime sendtime, bool isme, string originalImage, string imageName)
{
Username = username;
UserMessage = message;
SendTime = sendtime;
IsMyMessage = isme;
OriginalImage = originalImage;
OriginalImageName = imageName;
VisibilityRegelung("Image");
Farbgebung(isme);
VisibilityRegelung("Default_Image");
GroupId = pGroupId;
}
//Dokumenten-Ansicht
public ChatMessage(string username, string message, DateTime sendtime, string pSmallerImagePath, bool isme, string url)
public ChatMessage(string pUsername, string pMessageText, DateTime pSendTime, string pSmallerImagePath, bool pIsLoggedInUsersMessage, string pUrl, long pGroupId)
{
Username = username;
UserMessage = message;
SendTime = sendtime;
IsMyMessage = isme;
Username = pUsername;
UserMessage = pMessageText;
SendTime = pSendTime;
IsMyMessage = pIsLoggedInUsersMessage;
Dokpfad = url;
FilePath = pUrl;
Farbgebung(isme);
Farbgebung(pIsLoggedInUsersMessage);
Thumbnail = Utilities.Utils.CreateImageSourceFromPath(pSmallerImagePath);
VisibilityRegelung("Dokumente");
GroupId = pGroupId;
}
public ImageSource Thumbnail { get; }
#region Farbgebung
private void Farbgebung(bool isme)
{
if (isme)
{
ChatColor = new BrushConverter().ConvertFromString("#ff5e00") as SolidColorBrush;
Posi = "Right";
_farbeRechtsColor = new BrushConverter().ConvertFromString("#505050") as SolidColorBrush;
_farbeLinksColor = new BrushConverter().ConvertFromString("#505050") as SolidColorBrush;
}
else
{
ChatColor = new BrushConverter().ConvertFromString("#FFFFFF") as SolidColorBrush; //"#cccccc"
Posi = "Left";
_farbeRechtsColor = new BrushConverter().ConvertFromString("#505050") as SolidColorBrush;
_farbeLinksColor = new BrushConverter().ConvertFromString("#505050") as SolidColorBrush;
}
}
#endregion
#region Visibility Regelung
_farbeRechtsColor = new BrushConverter().ConvertFromString("#505050") as SolidColorBrush;
_farbeLinksColor = new BrushConverter().ConvertFromString("#505050") as SolidColorBrush;
}
private void VisibilityRegelung(string Ansicht)
{
switch (Ansicht)
@@ -141,9 +128,6 @@ namespace ChatController.ChatKlassen
break;
}
}
#endregion
#region Hyperlink Detection
private static readonly Regex UrlRegex = new Regex(@"(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~/|/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&amp;(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?");
@@ -186,10 +170,6 @@ namespace ChatController.ChatKlassen
return false;
}
#endregion
#region Variablen
public bool IsMyMessage { get; set; }
public string Username { get; }
public string UserMessage { get; }
@@ -210,7 +190,6 @@ namespace ChatController.ChatKlassen
public Visibility ChatVisibility { get; set; }
public Visibility HyperlinkVisibility { get; set; }
private Visibility _pictureVisibility;
public Visibility PictureVisibility
@@ -247,11 +226,10 @@ namespace ChatController.ChatKlassen
public Visibility DokumentVisibility { get; set; }
public ImageSource ImageSources { get; }
public object Dokpfad { get; }
public object FilePath { get; }
public long? ChatMessageOid { get; private set; }
//Farbe Links MEssageHeader
private Brush _farbeLinksColor;
public Brush FarbeLinksColor
{
@@ -264,7 +242,6 @@ namespace ChatController.ChatKlassen
}
}
//Farbe Rechts MessageHeader
private Brush _farbeRechtsColor;
public Brush FarbeRechtsColor
{
@@ -277,6 +254,8 @@ namespace ChatController.ChatKlassen
}
}
public long GroupId { get; }
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
@@ -284,6 +263,5 @@ namespace ChatController.ChatKlassen
var handler = PropertyChanged;
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}

View File

@@ -29,6 +29,8 @@ namespace ChatController.ChatKlassen
}
}
public bool IsNewMessage { get; set; }
private Brush _color;
public Brush Color
{
@@ -41,25 +43,25 @@ namespace ChatController.ChatKlassen
}
}
private int _NumberOfReadMessages;
public int NumberOfReadMessages
private bool _HasUnreadMessages;
public bool HasUnreadMessages
{
get => _NumberOfReadMessages;
get => _HasUnreadMessages;
set
{
_NumberOfReadMessages = value;
_HasUnreadMessages = value;
if (_NumberOfReadMessages == 1)
if (_HasUnreadMessages)
{
_color = new BrushConverter().ConvertFromString("#ff5e00") as SolidColorBrush;
}
else
else
{
_color = new SolidColorBrush(Colors.Gray);
}
OnPropertyChanged(nameof(NumberOfReadMessages));
OnPropertyChanged(nameof(HasUnreadMessages));
OnPropertyChanged(nameof(Color));
}
}
@@ -78,21 +80,21 @@ namespace ChatController.ChatKlassen
public ImageSource Image { get; }
public DateTime TimeStamp { get; set; }
public long GroupId { get; set; }
public long UserId { get; set; }
public long? CustomerOid { get; set; }
public int GroupId { get; set; }
public int UserOid { get; set; }
public string UserIdManage { get; set; }
public Contact(string pName, ImageSource pImage, string pLastMessageText, DateTime pTimeStamp, long pGroupId,long? pCustomerOid, bool pOnlyEmployees, int pUserCount)
public Contact(string pName, ImageSource pImage, string pLastMessageText, DateTime pTimeStamp, int pGroupId, string pUserIdManage, bool pOnlyEmployees, int pUserCount)
{
Name = pName;
ReceivedMessage = pLastMessageText;
Image = pImage;
TimeStamp = pTimeStamp;
GroupId = pGroupId;
CustomerOid = pCustomerOid;
NumberOfReadMessages = 1;
UserIdManage = pUserIdManage;
HasUnreadMessages = false;
if (CustomerOid != null)
if (UserIdManage != null)
{
_ContactChatColor = new BrushConverter().ConvertFromString("#3B7799") as SolidColorBrush;
}

View File

@@ -3,7 +3,7 @@ using System.Windows.Media;
namespace ChatController.ChatKlassen
{
public class AktuellerKontakt
public class CurrentContact
{
public Contact Contact { get; set; }
@@ -11,17 +11,17 @@ namespace ChatController.ChatKlassen
public ImageSource Image { get; }
public DateTime TimeStamp { get; set; }
public long GroupId { get; set; }
public long? CustomerOid { get; set; }
public string UserIdManage { get; set; }
public AktuellerKontakt(Contact pContact)
public CurrentContact(Contact pContact)
{
if(pContact != null) {
Contact = pContact;
Image = pContact.Image;
TimeStamp = pContact.TimeStamp;
Name = pContact.Name;
CustomerOid = pContact.CustomerOid;
UserIdManage = pContact.UserIdManage;
GroupId = pContact.GroupId;
}
}

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ChatController.ChatKlassen
namespace ChatController.ChatKlassen
{
public class MessageCounter
{

View File

@@ -35,7 +35,7 @@
Maximum="{TemplateBinding ScrollableHeight}"
ViewportSize="{TemplateBinding ViewportHeight}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
Grid.Column="1"/>
Grid.Row="0" Grid.Column="1"/>
<ScrollBar Name="PART_HorizontalScrollBar"
Orientation="Horizontal"
Grid.Row="1"
@@ -70,7 +70,6 @@
<ControlTemplate>
<Grid>
<Border x:Name="ItemBorder" MinHeight="20" Background="White" BorderThickness="0,0,0,1" BorderBrush="{StaticResource LightBackColor}">
</Border>
<Border x:Name="ItemContent" MinHeight="20">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5,3,5,3" OpacityMask="{x:Null}" SnapsToDevicePixels="True">
@@ -82,39 +81,30 @@
<ColumnDefinition Width="7"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Ellipse Grid.Column="1" Width='32' Height='32' RenderOptions.BitmapScalingMode="HighQuality">
<Ellipse.Fill>
<ImageBrush ImageSource='{Binding Image}' Stretch='Fill' RenderOptions.BitmapScalingMode="HighQuality" />
</Ellipse.Fill>
</Ellipse>
<Grid Grid.Column="3" >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Path=Name, FallbackValue=FirstName}" Foreground="{Binding Path=KontaktChatColor}" FontSize="16" Margin="1" />
<TextBlock Text="{Binding Path=ReceiveMs}" Grid.Row="1" FontSize="14" Foreground="{Binding Path=Color}" Margin="1" />
<TextBlock Text="{Binding Path=Name, FallbackValue=FirstName}" Foreground="{Binding Path=ContactChatColor}" FontSize="16" Margin="1" />
<TextBlock Text="{Binding Path=ReceivedMessage}" Grid.Row="1" FontSize="14" Foreground="{Binding Path=Color}" Margin="1" />
</Grid>
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="ItemBorder" Value="{StaticResource DarkBackColor}" />
</Trigger>
<Trigger Property="ListBoxItem.IsSelected" Value="True">
<Setter Property="Background" TargetName="ItemBorder" Value="{StaticResource DarkBackColor}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
@@ -122,11 +112,9 @@
<Condition Property="Selector.IsSelectionActive" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="ItemBorder" Value="{StaticResource DarkBackColor}" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
@@ -141,12 +129,8 @@
<Canvas Grid.Column="0" Width="14" Margin="3,4,2,2">
<Ellipse Stroke="#FFA0A0A0" Height="10" Width="10" StrokeThickness="2" Fill="{x:Null}" />
<Line Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FFA0A0A0" Canvas.Left="6" Canvas.Top="7.4" Y1="0" Y2="5" StrokeThickness="3" X2="4" />
</Canvas>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
@@ -159,9 +143,7 @@
<Grid>
<Border x:Name="rootBorder" Background="{StaticResource DarkBackColor}" Padding="0" Margin="0" BorderThickness="0">
<!--Style="{DynamicResource MainContentGroupBoxWithoutMaximizeBtnStyle}"-->
<Grid >
<!--Background="{StaticResource ObjectEditBackgroundBrush}"-->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250" />
<ColumnDefinition Width="*"/>
@@ -170,8 +152,6 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- ########################## Linkes panel ########################### -->
<Grid Grid.Column="0" Grid.Row="0" >
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
@@ -190,19 +170,15 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel x:Name="ReloadGruppen" Grid.Row="0" Grid.Column="1" Height="25" Width="25" HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Center" Visibility="Visible" Margin="0,0,3,0">
<Button Background="Transparent" HorizontalAlignment="Right" BorderThickness="0" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="25" Height="25" Click="ButtonReloadGruppen_OnClick" >
<Image ToolTip="Gruppen Aktualisieren" Margin="0,0,0,0" Width="20" Height="20" Source="pack://application:,,,/ChatController;component/Ressourcen/SymbolRefresh32.png" RenderOptions.BitmapScalingMode="HighQuality" HorizontalAlignment="Center" />
</Button>
</StackPanel>
<TextBox x:Name="Suche" Height="22" HorizontalAlignment="Stretch" Margin="5" TabIndex="0" Template="{DynamicResource SearchTextBoxTemplate}" BorderThickness="0,0,0,0" TextChanged="Suche_OnTextChanged" />
<TextBox Grid.Column="0" x:Name="Suche" Height="22" HorizontalAlignment="Stretch" Margin="5" TabIndex="0" Template="{DynamicResource SearchTextBoxTemplate}" BorderThickness="0,0,0,0" TextChanged="Suche_OnTextChanged" />
</Grid>
<Grid Grid.Column="0" Grid.Row="1" >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@@ -210,18 +186,12 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--###################################### Liste aller User ###################################################### -->
<ListView x:Name="Clientlist" HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="0" VerticalAlignment="Stretch" BorderThickness="0" Background="White"
ItemContainerStyle="{StaticResource ContactListBoxItemStyle}" SelectionChanged="Clientlist_OnSelectionChanged" Style="{StaticResource ContactListStyle}">
</ListView>
</Grid>
</Grid>
<!-- ####################### Rechtes Panel ################################-->
<Grid Grid.Column="1" Grid.Row="0" x:Name="GridRechts">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@@ -232,8 +202,7 @@
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListBox x:Name="AktChatUserList" HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Row="0" Background="Transparent" BorderBrush="Transparent" VerticalAlignment="Bottom" ItemTemplate="{DynamicResource DataTemplate2}" MouseDoubleClick="AktChatUser_OnMouseDoubleClick" >
<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">
<Grid>
@@ -257,12 +226,9 @@
</ListBox.Resources>
</ListBox>
<!--##### Chat Bereich ####-->
<ListBox x:Name="ChatListBox" HorizontalAlignment="Stretch" ScrollViewer.CanContentScroll="False" VerticalAlignment="Stretch" Grid.Row="1" VirtualizingStackPanel.IsVirtualizing="True" BorderThickness="0"
VirtualizingStackPanel.VirtualizationMode="Recycling" SelectionMode="Extended" MouseDoubleClick="Chat_OnMouseDoubleClick" ScrollViewer.ScrollChanged="Chat_OnScrollChanged" Background="{StaticResource LightBackColor}"
ContextMenuOpening="Chat_OnContextMenuOpening" Padding="20">
<!--MouseRightButtonDown="OnRightClickEvent"-->
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalAlignment" Value="{Binding Posi}" />
@@ -271,100 +237,49 @@
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Border BorderBrush="{Binding ChatColor}" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" Background="{Binding ChatColor}" >
<DockPanel MinHeight="15" Margin="5" LastChildFill="True" Background="{Binding ChatColor}" >
<!-- Message Bereich -->
<StackPanel DockPanel.Dock="Bottom" Visibility="{Binding ChatVisibility}" >
<TextBlock VerticalAlignment="Center" Text="{Binding UserMessage}" MinWidth="0" MaxWidth="500" TextWrapping="Wrap" FontSize="14"/>
<!-- <RichTextBox VerticalAlignment="Center" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" local:RichTextBoxHelper.DocumentXaml="{Binding UserMessage}" MinWidth="0" MaxWidth="500" />-->
</StackPanel>
<!-- MEssageBereich mit Url verwaltung -->
<StackPanel DockPanel.Dock="Bottom" Visibility="{Binding HyperlinkVisibility}" >
<TextBlock>
<Hyperlink NavigateUri="{Binding UserMessage}" RequestNavigate="Hyperlink_OnRequestNavigate" >
<TextBlock VerticalAlignment="Center" Text="{Binding UserMessage}" MinWidth="0" MaxWidth="500" TextWrapping="Wrap" FontSize="14"/>
</Hyperlink>
</TextBlock>
<!-- <RichTextBox VerticalAlignment="Center" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" local:RichTextBoxHelper.DocumentXaml="{Binding UserMessage}" MinWidth="0" MaxWidth="500" />-->
</StackPanel>
<!-- Bild bereich MaxHeight="200" MaxWidth="300" Stretch uniform-->
<DockPanel DockPanel.Dock="Bottom" Visibility="{Binding PictureVisibility}" >
<StackPanel Orientation="Vertical">
<Image MaxHeight="200" MaxWidth="300" Source="{Binding ImageSources}" x:Name="imgChatMessage" Stretch="None"/>
<TextBlock Text="{Binding UserMessage}" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="14"/>
</StackPanel>
</DockPanel>
<!-- Image Placeholder -->
<DockPanel DockPanel.Dock="Bottom" Visibility="{Binding PicturePlaceHolderVisibility}" >
<StackPanel Orientation="Vertical">
<Image Source="pack://application:,,,/ChatController;component/Ressourcen/ClipboardDisabled.png" Stretch="None" />
<TextBlock Text="{Binding UserMessage}" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="14" />
</StackPanel>
</DockPanel>
<!-- Gif BEreich ?? <MediaElement Source="" ></MediaElement> villeicht gif erstmal runterladen und dann den pfad ausgeben ? 200
<DockPanel DockPanel.Dock="Bottom" Visibility="{Binding GifPictureVisibility}" >
<StackPanel Orientation="Vertical">
<MediaElement LoadedBehavior="Play" UnloadedBehavior="Manual" MediaFailed="MediaElement_OnMediaFailed" MediaEnded="MediaElement_OnMediaEnded" Source="{Binding ImageSources}" Stretch="Uniform" MaxHeight="200" MaxWidth="300" >
<MediaElement.OpacityMask>
<ImageBrush ImageSource="{Binding ImageSources}"/>
</MediaElement.OpacityMask>
</MediaElement>
<TextBlock Text="{Binding UserMessage}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
</DockPanel>-->
<!--Dokument bereich -->
<DockPanel DockPanel.Dock="Bottom" Visibility="{Binding DokumentVisibility}" >
<StackPanel Orientation="Vertical">
<Image ToolTip="Dokument öffnen" Height="100" Width="150" Source="{Binding Path=Thumbnail}" Stretch="Uniform" VerticalAlignment="Center" HorizontalAlignment="Center" />
<TextBlock Margin="2,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding UserMessage}" FontSize="14"/>
<!-- <Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Dokument Anzeigen" Height="25" Tag="{Binding Dokpfad}" Click="OpenDokument_OnClick " >
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="3"/>
<Setter Property="Padding" Value="1,1,1,1" />
</Style>
</Button.Resources>
</Button>-->
</StackPanel>
</DockPanel>
<!--<StackPanel DockPanel.Dock="Left" Margin="0,0,0,5" >
<TextBlock Text="{Binding Username}" FontSize="11" MaxWidth="150" HorizontalAlignment="Left" TextAlignment="Left" VerticalAlignment="Center" Foreground="{Binding FarbeLinksColor}" />
</StackPanel>-->
<StackPanel DockPanel.Dock="Left" Margin="0,0,0,0" >
<TextBlock Text="{Binding UserTimeStringLeft}" MaxWidth="350" FontSize="11" HorizontalAlignment="Left" TextAlignment="Left" VerticalAlignment="Center" Foreground="{Binding FarbeRechtsColor}" />
</StackPanel>
<StackPanel DockPanel.Dock="Right" Margin="5,0,0,5" >
<TextBlock Text="{Binding UserTimeStringRight}" MaxWidth="350" FontSize="11" HorizontalAlignment="Right" TextAlignment="Right" VerticalAlignment="Center" Foreground="{Binding FarbeRechtsColor}" />
</StackPanel>
</DockPanel>
</Border>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid Grid.Row="2" Margin="10" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@@ -386,27 +301,22 @@
<TextBox.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="2"/>
<!-- <Setter Property="Padding" Value="10,0,60,0" />-->
</Style>
</TextBox.Resources>
</TextBox>
<!-- StackPanel Zur test zwecken Style="{x:Null}"-->
<StackPanel Grid.Column="1" Grid.ColumnSpan="2" Margin="1" Orientation="Horizontal">
<Button Grid.Column="1" Margin="1,0,0,0" x:Name="MediaButton" Background="Transparent" Height="25" Width="28" BorderThickness="0" Padding="0" VerticalAlignment="Bottom" ToolTip="Datei einfügen" Click="MediaButton_OnClick" >
<Button Margin="1,0,0,0" x:Name="MediaButton" Background="Transparent" Height="25" Width="28" BorderThickness="0" Padding="0" VerticalAlignment="Bottom" ToolTip="Datei einfügen" Click="MediaButton_OnClick" >
<Image Height="22" Width="22" Source='pack://application:,,,/ChatController;component/Ressourcen/paperclip2.png' RenderOptions.BitmapScalingMode="HighQuality" HorizontalAlignment="Center"/>
</Button>
<Button Grid.Column="2" Width="28" Height="25" BorderThickness="0" Background="Transparent" x:Name="EmojiButton" Margin="2,0,0,0" Padding="0" VerticalAlignment="Bottom" ToolTip="Emoji einfügen" Click="EmojiButton_OnClick">
<Button Width="28" Height="25" BorderThickness="0" Background="Transparent" x:Name="EmojiButton" Margin="2,0,0,0" Padding="0" VerticalAlignment="Bottom" ToolTip="Emoji einfügen" Click="EmojiButton_OnClick">
<Image Height="24" Width="24" Source='pack://application:,,,/ChatController;component/Ressourcen/glucklicher.png' RenderOptions.BitmapScalingMode="HighQuality" HorizontalAlignment="Center" />
</Button>
</StackPanel>
<!-- Stackpanel zu 12 testZwecken -->
</Grid>
<Button x:Name="SendButton" Content=" Senden " HorizontalAlignment="Stretch" Margin="2,0,0,0" Grid.Column="2" VerticalAlignment="Bottom" Click="SendButton_OnClick" Background="{StaticResource ButtonForeground}" Height="25" >
<Button x:Name="SendButton" Content=" Senden " HorizontalAlignment="Stretch" Margin="2,0,0,0" Grid.Column="1" VerticalAlignment="Bottom" Click="SendButton_OnClick" Background="{StaticResource ButtonForeground}" Height="25" >
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="3"/>
@@ -414,7 +324,6 @@
</Style>
</Button.Resources>
</Button>
</Grid>
</Grid>
</Grid>

File diff suppressed because it is too large Load Diff

View File

@@ -81,7 +81,7 @@ namespace ChatController.Data
{
try
{
var serverResponse = Empty;
var serverResponse = string.Empty;
using (var dataStream = response.GetResponseStream())
{

File diff suppressed because it is too large Load Diff

View File

@@ -5,8 +5,6 @@ using System.Net;
using System.Text;
using System.Web;
using System.Windows;
using ChatController.Klassen;
using ChatController.LoginKlassen;
using ChatController.Utilities;
@@ -34,7 +32,7 @@ namespace ChatController.HauptKlassen
private bool _ownchatVerbindungsaufbauOK;
private bool _gruppeholenverbindungsaufbauOK;
private AuthentifizierungsDaten _serverconect;
private AuthenticationData _serverconect;
private UserDaten _LoggedInUser;
private ChatGruppenDaten _AllGroups;
@@ -46,10 +44,10 @@ namespace ChatController.HauptKlassen
_ChatCode = pChatCode;
_UserName = pUserName;
_Password = pPassword;
_ApiKey = "0000";//default damit nichts kaput geht
_ApiKey = "0000";//default, damit nichts kaputt geht
}
public Login(string pTenant, string pChatCode, string pUserName, string pPassword,string pApiKey)
public Login(string pTenant, string pChatCode, string pUserName, string pPassword, string pApiKey)
{
_Tenant = pTenant;
_ChatCode = pChatCode;
@@ -69,31 +67,33 @@ namespace ChatController.HauptKlassen
public ChatDatenUebergabe AnmeldevorgangDurchFuehren()
{
if(ServerErmittlung()){
Dictionary<string, string> dic = new Dictionary<string, string>();
var dic = new Dictionary<string, string>
{
{"username", _UserName},
{ "password", _Password},
{ "chatcode", _ChatCode}
};
dic.Add("username", _UserName);
dic.Add("password", _Password);
dic.Add("chatcode",_ChatCode);
VerbindeMitChatServer(dic);
VerbindeMitChatServer(dic);
if (_ownchatVerbindungsaufbauOK)
{
GetGroups();
}
if (_ownchatVerbindungsaufbauOK)
{
GetGroups();
}
if (_gruppeholenverbindungsaufbauOK)
{
if (_gruppeholenverbindungsaufbauOK)
{
long maxUploadSize = GetMaiximumAllowedFileUploadSize(_AuthToken,_Tenant);
var maxUploadSize = GetMaiximumAllowedFileUploadSize(_AuthToken,_Tenant);
ChatDatenUebergabe ubergabe = new ChatDatenUebergabe(_serverconect, _LoggedInUser, _AllGroups, ServerUrl, _AuthToken, _UserId, _Tenant,_ApiKey, maxUploadSize);
var ubergabe = new ChatDatenUebergabe(_serverconect, _LoggedInUser, _AllGroups, ServerUrl, _AuthToken, _UserId, _Tenant,_ApiKey, maxUploadSize);
return ubergabe;
}
}
return null;
return ubergabe;
}
}
return null;
}
public bool ServerErmittlung()
@@ -128,7 +128,7 @@ namespace ChatController.HauptKlassen
try
{
var jsonDatentyp = JsonConvert.DeserializeObject<NewAuthentifizierungsDatenTyp1>(responseFromServer);
var jsonDatentyp = JsonConvert.DeserializeObject<AuthenticationDataType1>(responseFromServer);
switch(jsonDatentyp.Status)
{
@@ -154,7 +154,7 @@ namespace ChatController.HauptKlassen
{
try
{
var jsonDatentyp = JsonConvert.DeserializeObject<NewAuthentifizierungsDatenTyp2>(responseFromServer);
var jsonDatentyp = JsonConvert.DeserializeObject<AuthenticationDataType2>(responseFromServer);
switch(jsonDatentyp.Status)
{

View File

@@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ChatController"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
@@ -23,8 +22,6 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- <Image Source="Ressourcen/ownchat_logo.png" HorizontalAlignment="Right" VerticalAlignment="Top" Height="200" Width="200" RenderOptions.BitmapScalingMode="HighQuality"/>-->
<Border Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="GroupBoxLogin" >
<Grid>
<Grid.RowDefinitions>

View File

@@ -9,7 +9,6 @@ using System.Windows;
using System.Windows.Input;
using ChatController.HauptKlassen;
using ChatController.Klassen;
using ChatController.LoginKlassen;
using Newtonsoft.Json;
@@ -448,8 +447,11 @@ namespace ChatController
}
}
#endregion
public void Login()
{
Anmelden();
}
}
}

View File

@@ -1,18 +1,18 @@
namespace ChatController.LoginKlassen
{
public class AuthentifizierungsDaten
public class AuthenticationData
{
public string CustomerId { get; set; }
public string ServerName { get; set; }
}
public class NewAuthentifizierungsDatenTyp1
public class AuthenticationDataType1
{
public int Status { get; set; }
public string Url { get; set; }
}
public class NewAuthentifizierungsDatenTyp2
public class AuthenticationDataType2
{
public int Status { get; set; }
public string Url { get; set; }

View File

@@ -2,7 +2,7 @@
{
public class ChatDatenUebergabe
{
private AuthentifizierungsDaten _serverconect { get; }
private AuthenticationData _serverconect { get; }
private UserDaten _angemeldeterUser { get; }
private ChatGruppenDaten _alleGruppen { get; }
@@ -13,7 +13,7 @@
private string _ApiKey { get; }
private long _MaxUploadSize { get; }
public ChatDatenUebergabe(AuthentifizierungsDaten serverConect, UserDaten angemeldeterUser, ChatGruppenDaten alleGruppen, string serverUrl, string authToken, long? userid, string kundennummer, string apikey,long maxUploadSize)
public ChatDatenUebergabe(AuthenticationData serverConect, UserDaten angemeldeterUser, ChatGruppenDaten alleGruppen, string serverUrl, string authToken, long? userid, string kundennummer, string apikey,long maxUploadSize)
{
_serverconect = serverConect;
_angemeldeterUser = angemeldeterUser;
@@ -27,7 +27,7 @@
_MaxUploadSize = maxUploadSize;
}
public AuthentifizierungsDaten Serverconect => _serverconect;
public AuthenticationData Serverconect => _serverconect;
public UserDaten AngemeldeterUser => _angemeldeterUser;

View File

@@ -12,7 +12,7 @@ namespace ChatController.LoginKlassen
public class GroupInput
{
public long Oid { get; set; }
public int Oid { get; set; }
public string Name { get; set; }
public string Avatar { get; set; }
public string Mobile { get; set; }

View File

@@ -10,7 +10,7 @@
public class UserMessageInput
{
public string currentPage { get; set; }
public string CurrentPage { get; set; }
public bool HasMorePages { get; set; }
public string NextPage { get; set; }
public int PerPage { get; set; }

View File

@@ -23,10 +23,6 @@ namespace ChatController.Utilities
public static readonly string UrlPageParameter = "&page=";
public static readonly string ConfigFile = "ownChat.txt";
public static readonly string CompanyName = "beyondSoft";
public static readonly string ApplicationFolderName = "OwnChat";
public static readonly int NotificationTimeout = 1500;
}
}

View File

@@ -2,20 +2,26 @@
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using MessageBox = System.Windows.MessageBox;
using PixelFormat = System.Drawing.Imaging.PixelFormat;
namespace ChatController.Utilities
{
public class Utils
{
public static NotifyIcon NotifyIcon = new NotifyIcon {Icon = Resource.ownchat_favicon, Visible = true};
public static DateTime DefaultDate = new DateTime(1,1,1);
public static ImageSource AvatarToImageSourceConverter(string pAvatarPath, bool pIsEmployee)
public static ImageSource AvatarToImageSourceConverter(string pAvatarPath, bool pIsEmployee, bool pIsGroup)
{
return CreateImageSourceFromPath(pAvatarPath, false, pIsEmployee);
return CreateImageSourceFromPath(pAvatarPath, pIsGroup, pIsEmployee);
}
public static ImageSource CreateChatGroupPictureImageSource(string pPicturePath, bool pIsGroup, bool pIsEmployee)
@@ -145,5 +151,172 @@ namespace ChatController.Utilities
return responseFromServer;
}
public static string GetAndCreateUserAppDataPath()
{
try
{
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
var companyFilePath = Path.Combine(localAppData, Resource.CompanyName);
if (!Directory.Exists(companyFilePath))
{
Directory.CreateDirectory(companyFilePath);
}
var bewoFilePath = Path.Combine(companyFilePath, Resource.ApplicationFolderName);
if (!Directory.Exists(bewoFilePath))
{
Directory.CreateDirectory(bewoFilePath);
}
return bewoFilePath;
}
catch (Exception exception)
{
MessageBox.Show("Fehler beim Anlegen des Anwendungsordners. Sie besitzen nicht die erforderlichen Rechte, bitte wenden Sie sich an Ihren Systemadministrator.\n" + exception.Message, "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}
public static string GenerateTempName()
{
const int length = 6;
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var random = new Random();
var tempName = new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
return tempName;
}
public static byte[] ImageToByteArray(Image pImage)
{
try
{
using (var memoryStream = new MemoryStream())
{
pImage.Save(memoryStream, ImageFormat.Bmp);
return memoryStream.ToArray();
}
}
catch (Exception e)
{
MessageBox.Show("Fehler: " + e.Message, "Fehler", MessageBoxButton.OK);
return null;
}
}
public static ImageSource GetImageSourceFromIcon(Icon pIcon)
{
var bitmap = new Bitmap(pIcon.Width, pIcon.Height);
var graphics = Graphics.FromImage(bitmap);
graphics.DrawIcon(pIcon, 0, 0);
graphics.Dispose();
bitmap.Save("icon.ico", ImageFormat.Icon);
var imageSource = ImageSourceForBitmap(bitmap);
bitmap.Dispose();
return imageSource;
}
[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteObject([In] IntPtr hObject);
public static ImageSource ImageSourceForBitmap(Bitmap bmp)
{
var handle = bmp.GetHbitmap();
try
{
return Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
}
finally
{
DeleteObject(handle);
}
}
public static Icon ImageSourceToIcon(ImageSource pImageSource)
{
var bitmapSource = (BitmapSource) pImageSource;
var width = bitmapSource.PixelWidth;
var height = bitmapSource.PixelHeight;
var newWidth = width;
var newHeight = height;
var x = 0;
var y = 0;
if(width < height)
{
newHeight = width;
y = (height - width) / 2;
}
else
{
newWidth = height;
x = (width - height) / 2;
}
var stride = width * ((bitmapSource.Format.BitsPerPixel + 7) / 8);
var memoryBlockPointer = Marshal.AllocHGlobal(height * stride);
bitmapSource.CopyPixels(new Int32Rect(x, y, newWidth, newHeight), memoryBlockPointer, newHeight * stride, stride);
var bitmap = new Bitmap(newWidth, newHeight, stride, PixelFormat.Format32bppPArgb, memoryBlockPointer);
return Icon.FromHandle(bitmap.GetHicon());
}
public static DateTime FromUnixTimeStamp(long pUnixTimeStamp)
{
return new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(pUnixTimeStamp);
}
public static byte[] ReadFully(Stream pStream)
{
using (var memStream = new MemoryStream())
{
pStream.CopyTo(memStream);
return memStream.ToArray();
}
}
public static RotateFlipType OrientationToFlipType(string orientation)
{
switch (int.Parse(orientation))
{
case 1:
return RotateFlipType.RotateNoneFlipNone;
case 2:
return RotateFlipType.RotateNoneFlipX;
case 3:
return RotateFlipType.Rotate180FlipNone;
case 4:
return RotateFlipType.Rotate180FlipX;
case 5:
return RotateFlipType.Rotate90FlipX;
case 6:
return RotateFlipType.Rotate90FlipNone;
case 7:
return RotateFlipType.Rotate270FlipX;
case 8:
return RotateFlipType.Rotate270FlipNone;
default:
return RotateFlipType.RotateNoneFlipNone;
}
}
}
}