Neu ist Immer Besser
This commit is contained in:
@@ -16,6 +16,7 @@ using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Media.TextFormatting;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
@@ -32,6 +33,7 @@ namespace ChatController
|
||||
/// </summary>
|
||||
public partial class ChatMainControl : UserControl
|
||||
{
|
||||
#region Vokabeln :)
|
||||
private Chat _chat;
|
||||
private AktuellerKontakt _aktuellerKontakt;
|
||||
|
||||
@@ -58,6 +60,11 @@ namespace ChatController
|
||||
|
||||
private Dictionary<String, Action<string>> menuItemName2Callback = new Dictionary<string, Action<string>>();
|
||||
|
||||
public delegate void CloseDelegate();
|
||||
|
||||
public event CloseDelegate OnClose;
|
||||
#endregion
|
||||
|
||||
public ChatMainControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -121,6 +128,59 @@ namespace ChatController
|
||||
}
|
||||
}
|
||||
|
||||
public void SetzteStyleAufNull()
|
||||
{
|
||||
EmojiButton.Style = null;
|
||||
MediaButton.Style = null;
|
||||
ReloadGruppen.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
public void SynchronisationVeranlassen()
|
||||
{
|
||||
try
|
||||
{
|
||||
bool doSync = true;
|
||||
|
||||
do
|
||||
{
|
||||
doSync = _chat.DoSynchronisation(_chatDaten.ApiKey, _chatDaten.Kundennummer);
|
||||
|
||||
if (true || doSync)
|
||||
{
|
||||
var aktuelleGruppen = _chat.GruppenAktuallisieren();
|
||||
|
||||
var x = _chat.GroupklassenAktuallisieren(aktuelleGruppen);
|
||||
|
||||
_kontaktlist = x;
|
||||
|
||||
Dispatcher.BeginInvoke(
|
||||
DispatcherPriority.Normal,
|
||||
(Action) delegate
|
||||
{
|
||||
Clientlist.Items.Refresh();
|
||||
});
|
||||
//this.Dispatch(delegate // hä ??
|
||||
//{
|
||||
// Clientlist.Items.Refresh();
|
||||
//});
|
||||
|
||||
Thread.Sleep(TimeSpan.FromMinutes(5));
|
||||
}
|
||||
|
||||
} while (doSync);
|
||||
|
||||
//sobald nicht mehr in der Schleife dann Close weil dann Sync false
|
||||
if (OnClose != null)
|
||||
{
|
||||
OnClose();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Ein Fehler bei der Synchronisation ist aufgetreten.\nFehler:\n" + e.Message, "Fehler",MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
#region Lade KontaktDaten und Lade sie in den Chat
|
||||
private void AktChatUser_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
@@ -778,7 +838,9 @@ namespace ChatController
|
||||
|
||||
if (item != null && item.ImageSources != null)
|
||||
{
|
||||
|
||||
_chat.ShowPicture(item);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -873,5 +935,53 @@ namespace ChatController
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ReloadGruppen (For Stand Alone version)
|
||||
private void ButtonReloadGruppen_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//Thread newThread = new Thread(DoSynchro);
|
||||
//newThread.IsBackground = true;
|
||||
//newThread.Start();
|
||||
DoSynchro();
|
||||
}
|
||||
|
||||
private void DoSynchro()
|
||||
{
|
||||
try
|
||||
{
|
||||
Cursor = Cursors.Wait;
|
||||
|
||||
//StartWaiting();
|
||||
|
||||
var doSync = _chat.DoSynchronisation(_chatDaten.ApiKey, _chatDaten.Kundennummer);
|
||||
|
||||
if (doSync)
|
||||
{
|
||||
var aktuelleGruppen = _chat.GruppenAktuallisieren();
|
||||
|
||||
var x = _chat.GroupklassenAktuallisieren(aktuelleGruppen);
|
||||
|
||||
_kontaktlist = x;
|
||||
|
||||
Clientlist.Items.Refresh();
|
||||
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor = Cursors.Arrow;
|
||||
// EndWaiting();
|
||||
if (OnClose != null)
|
||||
{
|
||||
OnClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Ein Fehler bei der Synchronisation ist aufgetreten.\nFehler:\n" + e.Message, "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user