diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 8f6217bac..4a852ab25 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -2401,6 +2401,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/BeWo/Ressources/Icons/glucklicher.png b/BeWo/Ressources/Icons/glucklicher.png new file mode 100644 index 000000000..5464d2670 Binary files /dev/null and b/BeWo/Ressources/Icons/glucklicher.png differ diff --git a/BeWo/Ressources/Icons/klient-avatar.png b/BeWo/Ressources/Icons/klient-avatar.png new file mode 100644 index 000000000..d6b59083e Binary files /dev/null and b/BeWo/Ressources/Icons/klient-avatar.png differ diff --git a/BeWo/Ressources/Icons/mitarbeiter-avatar.png b/BeWo/Ressources/Icons/mitarbeiter-avatar.png new file mode 100644 index 000000000..34a3a8bf0 Binary files /dev/null and b/BeWo/Ressources/Icons/mitarbeiter-avatar.png differ diff --git a/BeWo/Ressources/Icons/mitarbeiter-team-avatar.png b/BeWo/Ressources/Icons/mitarbeiter-team-avatar.png new file mode 100644 index 000000000..dac4e73e3 Binary files /dev/null and b/BeWo/Ressources/Icons/mitarbeiter-team-avatar.png differ diff --git a/BeWo/Ressources/Icons/sortiert.png b/BeWo/Ressources/Icons/sortiert.png new file mode 100644 index 000000000..400b5333b Binary files /dev/null and b/BeWo/Ressources/Icons/sortiert.png differ diff --git a/BeWo/Ressources/Icons/unsortiert.png b/BeWo/Ressources/Icons/unsortiert.png new file mode 100644 index 000000000..7900b8320 Binary files /dev/null and b/BeWo/Ressources/Icons/unsortiert.png differ diff --git a/BeWo/View/ChatView.xaml b/BeWo/View/ChatView.xaml index 027d39cc5..f910f089c 100644 --- a/BeWo/View/ChatView.xaml +++ b/BeWo/View/ChatView.xaml @@ -5,44 +5,45 @@ Title="Chat View" Height="800" Width="800" WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True" Background="Transparent" - ResizeMode="NoResize" + ResizeMode="CanResizeWithGrip" x:Name="ChatViewName"> - - + + - + + - - + + + VerticalContentAlignment="Center" Width="416" MinHeight="25" ToolTip="Schreiben Sie hier eine Nachricht hinein" KeyDown="OnKeyDownHandler" GotFocus="OnFocus" Foreground="DarkGray" > + + - - + @@ -78,7 +79,7 @@ - - - - + + + - + - + + - + @@ -113,19 +115,23 @@ - + - + - + + + + + @@ -143,9 +149,9 @@ - - - + + + @@ -160,18 +166,50 @@ - + + + + + + + + + + - - - + @@ -180,20 +218,23 @@ + + + - + - + - + diff --git a/BeWo/View/ChatView.xaml.cs b/BeWo/View/ChatView.xaml.cs index b2b6465bc..5792caf34 100644 --- a/BeWo/View/ChatView.xaml.cs +++ b/BeWo/View/ChatView.xaml.cs @@ -64,6 +64,9 @@ namespace BeWo.View protected PropertyGroupDescription groupDescription; protected bool isOnFocus = false; + + protected bool sortLabelSwitch = false; + protected ContextMenu context; public ChatView(String nameinf, String Chatinf, TcpClient tcpClient) @@ -77,11 +80,11 @@ namespace BeWo.View CloseWindow(); LoadallChatKontakts(); ErstelleContextMenue(); - SetChatSetting(); + // SetChatSetting(); } - private void SetChatSetting() + /*private void SetChatSetting() { try { @@ -97,7 +100,7 @@ namespace BeWo.View { MessageBox.Show("Das Aufbauen der Chat-Settings ist fehlgeschlagen. " + edf.Message + "\n" + edf.StackTrace, "Fehler: 2200 ", MessageBoxButton.OK); } - } + }*/ public void UpdateTcp(TcpClient tcpClient) { @@ -212,6 +215,36 @@ namespace BeWo.View } } + public void SetAnzahlErhalteneNachricht(long personoid) + { + try + { + foreach (var abc in ita) + { + + if (abc.EmpfaengerOid == personoid && abc.TypeChat != ChatType.Team) + { + int x; + bool wasdrin = int.TryParse(abc.Receivems, out x); + + if (wasdrin) + { + x++; + abc.Receivems = x.ToString(); + + } + else + abc.Receivems = 1.ToString(); + } + } + view.Refresh(); + } + catch (Exception edf) + { + MessageBox.Show("Beim Setzen der Anzahl angekommender Nachrichten ist ein Fehler aufgetreten. " + edf.Message + "\n" + edf.StackTrace, "Fehler 2391", MessageBoxButton.OK); + } + } + public void RefreshViewModel() { view.Refresh(); @@ -233,7 +266,7 @@ namespace BeWo.View { var mitarbeiter = ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeWithPersonOid(personoid)); - KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname,StatusType.Online, BuildImg(mitarbeiter.EmployeeImage), personoid, ChatType.Mitarbeiter);//"Online" + KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname,StatusType.Online, BuildImg(mitarbeiter.EmployeeImage,ChatType.Mitarbeiter), personoid, ChatType.Mitarbeiter);//"Online" var zugehorigkeit = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(personoid)); @@ -253,7 +286,14 @@ namespace BeWo.View } } } - view.Refresh(); + // if (SortCheckBox.IsChecked.Value) + // { + view.Refresh(); + // } + // else + // { + // ChatViewName.RefreshUI(); + // } } else if (a == PersonType.Customer) { @@ -268,7 +308,7 @@ namespace BeWo.View customerCompact.LastName = klienten.LastName; customerCompact.DateOfBirth = klienten.DateOfBirth; - KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname, StatusType.Online, BuildImg(klienten.CustomerImage), personoid, ChatType.Klienten, customerCompact);//"Online" + KontaktlistBuilder konbuild = new KontaktlistBuilder(clientname, StatusType.Online, BuildImg(klienten.CustomerImage,ChatType.Klienten), personoid, ChatType.Klienten, customerCompact);//"Online" foreach (var variable in ita) { @@ -413,7 +453,7 @@ namespace BeWo.View public void SetServerStats(String servstats) { - ServerStats.Text = servstats; + //ServerStats.Text = servstats; } private void SendButton_Click(object sender, RoutedEventArgs e) @@ -510,25 +550,19 @@ namespace BeWo.View try { var employeeteamoids = ServiceFacade.DoEmployeeServiceSync(s => s.GetTeamOidsByEmployee(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); - var offmitarbeiter = - ServiceFacade.DoEmployeeServiceSync(s => s.GetAllChatActiveEmployeesCompact()); - var offklienten = ServiceFacade.DoCustomerServiceSync(s => s.GetAllChatActiveCustomersCompact(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); // dieser code muss erweitert werden - - /* var employee = ServiceFacade.DoEmployeeServiceSync( - s => s.GetEmployeeWithPersonOid(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); - - employee.Employee2CustomerList.Select(s => s.CustomerOid.Value);*/ + var offmitarbeiter = ServiceFacade.DoEmployeeServiceSync(s => s.GetAllChatActiveEmployeesCompact()); + var offklienten = ServiceFacade.DoCustomerServiceSync(s => s.GetAllChatActiveCustomersCompact(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); foreach (var team in employeeteamoids) { - Clientlist.Items.Add(new KontaktlistBuilder(team.Name, StatusType.Offline, BuildImg(null), team.TeamOid, ChatType.Team)); + Clientlist.Items.Add(new KontaktlistBuilder(team.Name, StatusType.Offline, BuildImg(null,ChatType.Team), team.TeamOid, ChatType.Team)); } foreach (var list in offmitarbeiter) { if(list.PersonOid != BeWoApp.LoggedOnUser.Employee.PersonOid){ Clientlist.Items.Add(new KontaktlistBuilder(list.FirstName + " " + list.LastName, StatusType.Offline, - BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeImage(list.EmployeeOid))), + BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeImage(list.EmployeeOid)),ChatType.Mitarbeiter), list.PersonOid, ChatType.Mitarbeiter)); } } @@ -536,7 +570,7 @@ namespace BeWo.View { Clientlist.Items.Add(new KontaktlistBuilder(list.FirstName + " " + list.LastName, StatusType.Offline, - BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerImage(list.CustomerOid))), + BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerImage(list.CustomerOid)),ChatType.Klienten), list.PersonOid, ChatType.Klienten,list)); } @@ -552,8 +586,16 @@ namespace BeWo.View Clientlist.ItemsSource = ita; view = (CollectionView)CollectionViewSource.GetDefaultView(Clientlist.ItemsSource); - groupDescription = new PropertyGroupDescription("TypeChat"); - view.GroupDescriptions.Add(groupDescription); + view.SortDescriptions.Add(new SortDescription("Receivems", ListSortDirection.Ascending)); + view.SortDescriptions.Add(new SortDescription("StatusType", ListSortDirection.Ascending)); + view.Filter = UserFilter; + + + if (sortLabelSwitch == true) + { + groupDescription = new PropertyGroupDescription("TypeChat"); + view.GroupDescriptions.Add(groupDescription); + } } catch (Exception edf) { @@ -593,7 +635,7 @@ namespace BeWo.View { if (!idteamspeicher.Contains(var.TeamOid) && idteamspeicher.Count <= employeeteamoids.Count) { - ita.Add(new KontaktlistBuilder(var.Name,StatusType.Offline, BuildImg(null), var.TeamOid, ChatType.Team)); + ita.Add(new KontaktlistBuilder(var.Name,StatusType.Offline, BuildImg(null,ChatType.Team), var.TeamOid, ChatType.Team)); view.Refresh(); } @@ -606,7 +648,7 @@ namespace BeWo.View if (!idMitarbeitspeicher.Contains(var.PersonOid) && idMitarbeitspeicher.Count <= offmitarbeiter.Count && var.PersonOid != BeWoApp.LoggedOnUser.Employee.PersonOid) { ita.Add(new KontaktlistBuilder(var.FirstName + " " + var.LastName,StatusType.Offline, - BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeImage(var.EmployeeOid))), + BuildImg(ServiceFacade.DoEmployeeServiceSync(s => s.GetEmployeeImage(var.EmployeeOid)),ChatType.Mitarbeiter), var.PersonOid, ChatType.Mitarbeiter)); view.Refresh(); } @@ -620,7 +662,7 @@ namespace BeWo.View if (!idKlientspeicher.Contains(var.PersonOid) && idKlientspeicher.Count <= offklienten.Count) { ita.Add(new KontaktlistBuilder(var.FirstName + " " + var.LastName, StatusType.Offline, - BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerImage(var.CustomerOid))), + BuildImg(ServiceFacade.DoCustomerServiceSync(s => s.GetCustomerImage(var.CustomerOid)),ChatType.Klienten), var.PersonOid, ChatType.Klienten,var)); view.Refresh(); } @@ -658,6 +700,20 @@ namespace BeWo.View view.Refresh(); } + + if (sortLabelSwitch == true) + { + groupDescription = new PropertyGroupDescription("TypeChat"); + view.GroupDescriptions.Add(groupDescription); + view.Refresh(); + } + else + { + view.GroupDescriptions.Clear(); + view.Refresh(); + } + + } catch (Exception edf) { @@ -672,7 +728,7 @@ namespace BeWo.View list.StatusTyp = StatusType.Offline; } - view.Refresh(); + view.Refresh(); } public void SetUserBeschäftigt(long oid, DataIdentifier type) @@ -768,60 +824,62 @@ namespace BeWo.View } - private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void ComboBox_SelectionChanged(object sender, RoutedEventArgs e) { try { - switch (StatusSetting.SelectedIndex) - { - case 0: + if (RadioButtonOnline.IsChecked.Value) + { if (tcpClient == null) { - StatusSetting.SelectedIndex = 1; + RadioButtonOffline.IsChecked = true; } else if (!tcpClient.Connected) { - StatusSetting.SelectedIndex = 1; + RadioButtonOffline.IsChecked = true; } else { SendUserStatus(DataIdentifier.StatusNotificationOnline); } + } - break; - case 1: + + if (RadioButtonOffline.IsChecked.Value) + { if (tcpClient == null) { - StatusSetting.SelectedIndex = 1; + RadioButtonOffline.IsChecked = true; } else if (!tcpClient.Connected) { - StatusSetting.SelectedIndex = 1; + RadioButtonOffline.IsChecked = true; } else - { + { SendUserStatus(DataIdentifier.StatusNotificationOffline); } - break; + } - case 2: + if (RadioButtonBeschaeftigt.IsChecked.Value) + { if (tcpClient == null) { - StatusSetting.SelectedIndex = 1; + RadioButtonOffline.IsChecked = true; } else if (!tcpClient.Connected) { - StatusSetting.SelectedIndex = 1; + RadioButtonOffline.IsChecked = true; } else { SendUserStatus(DataIdentifier.StatusNotificationBeschäftigt); } - break; - } + } + } catch (Exception edf) { @@ -918,40 +976,47 @@ namespace BeWo.View AktChatUser.Items.Clear(); - if (!curItem.Receivems.Equals("")) - { - curItem.Receivems = ""; - } - if (curItem.TypeChat == ChatType.Klienten) - { - AktChatUser.Items.Add(new KontaktlistBuilder(curItem.Name, curItem.StatusTyp, curItem.Image, curItem.EmpfaengerOid, curItem.TypeChat, curItem.Customer)); - } - else - { - AktChatUser.Items.Add(new KontaktlistBuilder(curItem.Name, curItem.StatusTyp, curItem.Image, curItem.EmpfaengerOid, curItem.TypeChat)); - } + if(curItem != null){ + + if (!curItem.Receivems.Equals("")) + { + curItem.Receivems = ""; + } + + if (curItem.TypeChat == ChatType.Klienten) + { + AktChatUser.Items.Add(new KontaktlistBuilder(curItem.Name, curItem.StatusTyp, curItem.Image, curItem.EmpfaengerOid, curItem.TypeChat, curItem.Customer)); + } + else + { + AktChatUser.Items.Add(new KontaktlistBuilder(curItem.Name, curItem.StatusTyp, curItem.Image, curItem.EmpfaengerOid, curItem.TypeChat)); + } - LoadChatMessagefromDB(BeWoApp.LoggedOnEmployee.PersonOid.Value, curItem.EmpfaengerOid, curItem); - Chat.Items.MoveCurrentToLast(); - Chat.ScrollIntoView(Chat.Items.CurrentItem); - view.Refresh(); - + LoadChatMessagefromDB(BeWoApp.LoggedOnEmployee.PersonOid.Value, curItem.EmpfaengerOid, curItem); + Chat.Items.MoveCurrentToLast(); + Chat.ScrollIntoView(Chat.Items.CurrentItem); - if (curItem.TypeChat == ChatType.Klienten) - { - context.Visibility = Visibility.Visible; - Chat.SelectionMode = SelectionMode.Extended; - Chat.Focusable = true; - } - else - { - context.Visibility = Visibility.Collapsed; - Chat.SelectionMode = SelectionMode.Single; - Chat.Focusable = false; - } + Suche.Text = ""; + + view.Refresh(); + + + if (curItem.TypeChat == ChatType.Klienten) + { + context.Visibility = Visibility.Visible; + Chat.SelectionMode = SelectionMode.Extended; + Chat.Focusable = true; + } + else + { + context.Visibility = Visibility.Collapsed; + Chat.SelectionMode = SelectionMode.Single; + Chat.Focusable = false; + } + } } } catch (Exception s) @@ -961,7 +1026,7 @@ namespace BeWo.View } } - public ImageSource BuildImg(Byte[] c) + public ImageSource BuildImg(Byte[] c ,ChatType x) { try { @@ -983,12 +1048,40 @@ namespace BeWo.View { //return null; //return new BitmapImage(new Uri(@"..\..\Ressources\Icons\UserHomeBoyDisabled.png", UriKind.Relative)); - BitmapImage bi = new BitmapImage(); - bi.BeginInit(); - bi.UriSource = new Uri("pack://application:,,,/Ressources/icons/UserHomeBoyDisabled.png"); - bi.EndInit(); - return bi; + if (x == ChatType.Klienten) + { + BitmapImage bix = new BitmapImage(); + bix.BeginInit(); + bix.UriSource = new Uri("pack://application:,,,/Ressources/icons/klient-avatar.png"); + bix.EndInit(); + return bix; + }else + if (x == ChatType.Mitarbeiter) + { + BitmapImage biy = new BitmapImage(); + biy.BeginInit(); + biy.UriSource = new Uri("pack://application:,,,/Ressources/icons/mitarbeiter-avatar.png"); + biy.EndInit(); + return biy; + }else + if (x == ChatType.Team) + { + BitmapImage biz = new BitmapImage(); + biz.BeginInit(); + biz.UriSource = new Uri("pack://application:,,,/Ressources/icons/mitarbeiter-team-avatar.png"); + biz.EndInit(); + return biz; + } + else + { + BitmapImage bi = new BitmapImage(); + bi.BeginInit(); + bi.UriSource = new Uri("pack://application:,,,/Ressources/icons/UserHomeBoyDisabled.png"); + bi.EndInit(); + return bi; + } + //return new ImageSource new BitmapImage(new Uri(@"..\..\Ressources\Icons\UserHomeBoyDisabled.png", UriKind.Relative)); //(ImageSource) @@ -1042,7 +1135,7 @@ namespace BeWo.View serverStream.Write(outStream, 0, outStream.Length); serverStream.Flush(); - ServerStats.Text = "Nachricht erfolgreich gesendet"; + // ServerStats.Text = "Nachricht erfolgreich gesendet"; } else { @@ -1056,7 +1149,7 @@ namespace BeWo.View MessageBox.Show("Beim Senden einer Nachricht zum Server ist ein Fehler aufgetreten. " + xe.Message + "\n" + xe.StackTrace, "Fehler: 2300 ", MessageBoxButton.OK); - ServerStats.Text = "Fehler: Die Nachricht konnte nicht gesendet werden."; + //ServerStats.Text = "Fehler: Die Nachricht konnte nicht gesendet werden."; } } } @@ -1134,7 +1227,7 @@ namespace BeWo.View if (anzeige.IstGelesen != 1) { - ServiceFacade.DoCustomerServiceAsync(s => s.UpdateIstGelesen(anzeige.EmpfängerPersonOid.Value,anzeige.SenderPersonOid.Value,true)); + ServiceFacade.DoCustomerServiceSync(s => s.UpdateIstGelesen(anzeige.EmpfängerPersonOid.Value,anzeige.SenderPersonOid.Value,true)); } } @@ -1193,7 +1286,7 @@ namespace BeWo.View } } } - ServiceFacade.DoCustomerServiceAsync(s => s.UpdateIstGelesen(empfaengerOid, senderoid, true)); + ServiceFacade.DoCustomerServiceSync(s => s.UpdateIstGelesen(empfaengerOid, senderoid, true)); } } catch (Exception edf) @@ -1202,7 +1295,6 @@ namespace BeWo.View } } - //placeholder private void OnFocus(object sender, EventArgs e) { try @@ -1231,7 +1323,7 @@ namespace BeWo.View } - //Rechte Maus Taste an dem Chat + public void OnRightClickEvent(object sender, RoutedEventArgs e) { e.Handled = true; @@ -1345,6 +1437,70 @@ namespace BeWo.View MessageBox.Show("Fehler :" + e.Message + "\n" + e.StackTrace, "Info", MessageBoxButton.OK); } } + + private void SortCheckBox_OnChecked(object sender, RoutedEventArgs e) + { + //AktualisiereChatKontakt(); + } + + private void Suche_OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Return) + { + Suche.Text = ""; + } + } + + private void Suche_OnTextChanged(object sender, TextChangedEventArgs e) + { + CollectionViewSource.GetDefaultView(Clientlist.ItemsSource).Refresh(); + } + + private bool UserFilter(object item) + { + if (String.IsNullOrEmpty(Suche.Text)) + return true; + else + return ((item as KontaktlistBuilder).Name.IndexOf(Suche.Text, StringComparison.OrdinalIgnoreCase) >= 0); + } + + private void Suche_OnLostFocus(object sender, RoutedEventArgs e) + { + // Suche.Text = ""; + } + + + private void ButtonSortLabel_OnClick(object sender, RoutedEventArgs e) + { + + //if() clicked dann immer wechseln + abfrage true und false ; + + if (sortLabelSwitch == false) + { + BitmapImage biy = new BitmapImage(); + biy.BeginInit(); + biy.UriSource = new Uri("pack://application:,,,/Ressources/icons/sortiert.png"); + biy.EndInit(); + + SortLabel.Source = biy; + + sortLabelSwitch = true; + AktualisiereChatKontakt(); + + } + else + { + BitmapImage biy = new BitmapImage(); + biy.BeginInit(); + biy.UriSource = new Uri("pack://application:,,,/Ressources/icons/unsortiert.png"); + biy.EndInit(); + + SortLabel.Source = biy; + sortLabelSwitch = false; + AktualisiereChatKontakt(); + + } + } } public class KontaktlistBuilder : INotifyPropertyChanged @@ -1372,6 +1528,19 @@ namespace BeWo.View { this.Color = new SolidColorBrush(Colors.Orange); } + + if (typeChat == ChatType.Team) + { + _colorType = new SolidColorBrush(Colors.DarkViolet); + } + else if (typeChat == ChatType.Klienten) + { + _colorType = new SolidColorBrush(Colors.Blue); + } + else + { + _colorType = new SolidColorBrush(Colors.Green); + } } public KontaktlistBuilder(string name, StatusType statustyp, ImageSource image, long empfaengerid, ChatType typeChat, CompactCustomerDC customer) @@ -1397,6 +1566,19 @@ namespace BeWo.View { this.Color = new SolidColorBrush(Colors.Orange); } + + if (typeChat == ChatType.Team) + { + _colorType = new SolidColorBrush(Colors.DarkViolet); + } + else if (typeChat == ChatType.Klienten) + { + _colorType = new SolidColorBrush(Colors.Blue); + } + else + { + _colorType = new SolidColorBrush(Colors.Green); + } } public string Name { get; private set; } @@ -1452,7 +1634,33 @@ namespace BeWo.View //_color = value; OnPropertyChanged("Color"); } } - + + private Brush _colorType; + public Brush ColorType + { + get + { + return _colorType; + } + set + { + if (TypeChat == ChatType.Team) + { + _colorType = new SolidColorBrush(Colors.DarkViolet); + } + else if (TypeChat == ChatType.Klienten) + { + _colorType = new SolidColorBrush(Colors.Blue); + } + else + { + _colorType = new SolidColorBrush(Colors.Green); + } + + //_color = value; + OnPropertyChanged("ColorType"); + } + } public CompactCustomerDC Customer { get; set; } public event PropertyChangedEventHandler PropertyChanged; diff --git a/BeWo/View/Detail/CustomerView.xaml b/BeWo/View/Detail/CustomerView.xaml index 45e3b3ebc..113ca84d5 100644 --- a/BeWo/View/Detail/CustomerView.xaml +++ b/BeWo/View/Detail/CustomerView.xaml @@ -183,6 +183,11 @@ + + + + + @@ -983,6 +988,7 @@ + @@ -1005,10 +1011,12 @@