Einige updates darunter fixes und Link und Kopieren funktion
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
@@ -30,7 +31,17 @@ namespace ChatController.ChatKlassen
|
||||
Posi = "Left";
|
||||
}
|
||||
|
||||
ChatVisibility = Visibility.Visible;
|
||||
if (IsHyperlink(message))
|
||||
{
|
||||
HyperlinkVisibility = Visibility.Visible;
|
||||
ChatVisibility = Visibility.Collapsed;
|
||||
}
|
||||
else {
|
||||
ChatVisibility = Visibility.Visible;
|
||||
HyperlinkVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
|
||||
SoundVisibility = Visibility.Collapsed;
|
||||
_pictureVisibility = Visibility.Collapsed;
|
||||
DokumentVisibility = Visibility.Collapsed;
|
||||
@@ -74,7 +85,7 @@ namespace ChatController.ChatKlassen
|
||||
|
||||
ChatVisibility = Visibility.Collapsed;
|
||||
SoundVisibility = Visibility.Collapsed;
|
||||
|
||||
HyperlinkVisibility = Visibility.Collapsed;
|
||||
DokumentVisibility = Visibility.Collapsed;
|
||||
_herunterladen = Visibility.Collapsed;
|
||||
}
|
||||
@@ -107,8 +118,65 @@ namespace ChatController.ChatKlassen
|
||||
ChatVisibility = Visibility.Collapsed;
|
||||
SoundVisibility = Visibility.Collapsed;
|
||||
_herunterladen = Visibility.Collapsed;
|
||||
HyperlinkVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
#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})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?");
|
||||
|
||||
public static bool IsHyperlink(string word)
|
||||
{
|
||||
// First check to make sure the word has at least one of the characters we need to make a hyperlink
|
||||
try
|
||||
{
|
||||
if (word.IndexOfAny(@":.\/".ToCharArray()) != -1)
|
||||
{
|
||||
if (Uri.IsWellFormedUriString(word, UriKind.Absolute))
|
||||
{
|
||||
// The string is an Absolute URI
|
||||
if (word.StartsWith("http://")) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (UrlRegex.IsMatch(word))
|
||||
{
|
||||
//hier der Bereich hin der die uri splittet wenn neben dem link auch text gesendet wird
|
||||
|
||||
|
||||
Uri uri = new Uri(word, UriKind.RelativeOrAbsolute);
|
||||
|
||||
if (!uri.IsAbsoluteUri)
|
||||
{
|
||||
// rebuild it it with http to turn it into an Absolute URI
|
||||
uri = new Uri(@"http://" + word, UriKind.Absolute);
|
||||
}
|
||||
|
||||
if (uri.IsAbsoluteUri)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region kram der sortiert werden muss
|
||||
//Alter Kram
|
||||
@@ -281,6 +349,7 @@ namespace ChatController.ChatKlassen
|
||||
|
||||
public Visibility MainVisibility { get; set; }
|
||||
public Visibility ChatVisibility { get; set; }
|
||||
public Visibility HyperlinkVisibility { get; set; }
|
||||
|
||||
public Visibility LoadNextVisibility { get; set; }
|
||||
public object LoadObject { get; set; }
|
||||
|
||||
@@ -246,6 +246,17 @@
|
||||
<!-- Message Bereich -->
|
||||
<StackPanel DockPanel.Dock="Bottom" Visibility="{Binding ChatVisibility}" >
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding UserMessage}" MinWidth="0" MaxWidth="500" TextWrapping="Wrap" />
|
||||
<!-- <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" />
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
<!-- <RichTextBox VerticalAlignment="Center" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" local:RichTextBoxHelper.DocumentXaml="{Binding UserMessage}" MinWidth="0" MaxWidth="500" />-->
|
||||
</StackPanel>
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -31,8 +32,6 @@ namespace ChatController
|
||||
/// </summary>
|
||||
public partial class ChatMainControl : UserControl
|
||||
{
|
||||
|
||||
|
||||
private Chat _chat;
|
||||
private AktuellerKontakt _aktuellerKontakt;
|
||||
|
||||
@@ -867,6 +866,12 @@ namespace ChatController
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region link request
|
||||
private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(e.Uri.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +242,7 @@ namespace ChatController.HauptKlassen
|
||||
bix.BeginInit();
|
||||
bix.UriSource = new Uri(link);
|
||||
bix.EndInit();
|
||||
|
||||
return bix;
|
||||
}
|
||||
catch (Exception edf)
|
||||
@@ -1145,7 +1146,7 @@ namespace ChatController.HauptKlassen
|
||||
else
|
||||
if (d.GetDataPresent(DataFormats.Text))
|
||||
{
|
||||
string text = (String)d.GetData(DataFormats.Text);
|
||||
string text = (string)d.GetData(DataFormats.StringFormat);
|
||||
|
||||
SendMessage(text, groupOid);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ namespace ChatController
|
||||
|
||||
public event LoginDelegate OnLogin;
|
||||
|
||||
private string _dateiPfad = "ChatAnmeldeDaten.txt";
|
||||
private string _dateiPfad = "ChatAnmeldeDaten.txt"; //OwnChatX1253781
|
||||
|
||||
private string _merkeDaten = "MerkeChatTeilAnmeldeDaten.txt"; //OwnChatX1253782
|
||||
|
||||
public LoginControl()
|
||||
{
|
||||
@@ -40,33 +42,32 @@ namespace ChatController
|
||||
{
|
||||
try
|
||||
{
|
||||
#if DEBUG
|
||||
Cursor = Cursors.Wait;
|
||||
|
||||
|
||||
Login _login = new Login("4368658435", "ZMCKb-BckTt", "RuppelW", "ABXT32wgtruppeldiedup");
|
||||
|
||||
var x = _login.AnmeldevorgangDurchFuehren();
|
||||
|
||||
//#if DEBUG
|
||||
// Cursor = Cursors.Wait;
|
||||
if (OnLogin != null)
|
||||
{
|
||||
AutosetDaten();
|
||||
if (Merken.IsChecked == true)
|
||||
{
|
||||
SpeichereDatenInDatei();
|
||||
}
|
||||
else
|
||||
{
|
||||
LoescheGespeicherteDatei();
|
||||
}
|
||||
|
||||
OnLogin(x);
|
||||
}
|
||||
|
||||
// Login _login = new Login("4368658435", "ZMCKb-BckTt", "RuppelW", "ABXT32wgtruppeldiedup");
|
||||
|
||||
// var x = _login.AnmeldevorgangDurchFuehren();
|
||||
|
||||
// if (OnLogin != null)
|
||||
// {
|
||||
// if (Merken.IsChecked == true)
|
||||
// {
|
||||
// SpeichereDatenInDatei();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LoescheGespeicherteDatei();
|
||||
// }
|
||||
|
||||
// OnLogin(x);
|
||||
// }
|
||||
|
||||
// Cursor = Cursors.Arrow;
|
||||
//#else
|
||||
if (!TextBoxKundennummer.Text.Equals("") && !TextBoxChatCode.Text.Equals("") &&
|
||||
Cursor = Cursors.Arrow;
|
||||
#else
|
||||
if (!TextBoxKundennummer.Text.Equals("") && !TextBoxChatCode.Text.Equals("") &&
|
||||
!TextBoxBenutzerName.Text.Equals("") && !TextBoxPasswort.Password.Equals(""))
|
||||
{
|
||||
Cursor = Cursors.Wait;
|
||||
@@ -77,6 +78,7 @@ namespace ChatController
|
||||
|
||||
if (OnLogin != null && x != null)
|
||||
{
|
||||
AutosetDaten();
|
||||
if (Merken.IsChecked == true)
|
||||
{
|
||||
SpeichereDatenInDatei();
|
||||
@@ -99,13 +101,14 @@ namespace ChatController
|
||||
{
|
||||
MessageBox.Show("Bitte alle Felder ausfüllen!", "Info", MessageBoxButton.OK);
|
||||
}
|
||||
//#endif
|
||||
#endif
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show("Fehler bei der Anmeldung!\n\n" + exception.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Asterisk);
|
||||
|
||||
//MessageBox.Show("Fehler bei der Anmeldung!\n\n" + exception.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Asterisk);
|
||||
MessageBox.Show("Fehler bei der Anmeldung. Bitte überprüfen Sie die Anmeldeinformationen.", "Info", MessageBoxButton.OK, MessageBoxImage.Asterisk);
|
||||
//throw;
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +119,31 @@ namespace ChatController
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(_merkeDaten))
|
||||
{
|
||||
List<string> merkdaten = new List<string>();
|
||||
using (StreamReader sr = new StreamReader(_merkeDaten, true))
|
||||
{
|
||||
string line = "";
|
||||
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
{
|
||||
var encodedTextBytes = Convert.FromBase64String(line);
|
||||
|
||||
string plainText = Encoding.UTF8.GetString(encodedTextBytes);
|
||||
|
||||
merkdaten.Add(plainText);
|
||||
}
|
||||
}
|
||||
|
||||
if (merkdaten.Count == 2)
|
||||
{
|
||||
TextBoxKundennummer.Text = merkdaten[0];
|
||||
TextBoxChatCode.Text = merkdaten[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (File.Exists(_dateiPfad)) {
|
||||
|
||||
List<string> daten = new List<string>();
|
||||
@@ -133,14 +161,42 @@ namespace ChatController
|
||||
}
|
||||
}
|
||||
|
||||
if(daten.Count == 5) {
|
||||
TextBoxKundennummer.Text = daten[0];
|
||||
TextBoxChatCode.Text = daten[1];
|
||||
TextBoxBenutzerName.Text = daten[2];
|
||||
TextBoxPasswort.Password = daten[3];
|
||||
Merken.IsChecked = Convert.ToBoolean(daten[4]);
|
||||
if(daten.Count == 3) {
|
||||
|
||||
TextBoxBenutzerName.Text = daten[0];
|
||||
TextBoxPasswort.Password = daten[1];
|
||||
Merken.IsChecked = Convert.ToBoolean(daten[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Ups, da ist was schief gelaufen: \n" + e.Message, "Fehler", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
//Kundenummer und ChatCode sollen Separat gespeichert werden
|
||||
private void AutosetDaten()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_merkeDaten))
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(_merkeDaten))
|
||||
{
|
||||
|
||||
Encoding enc = new UTF8Encoding();
|
||||
var byt = enc.GetBytes(TextBoxKundennummer.Text);
|
||||
var bytes = Convert.ToBase64String(byt);
|
||||
|
||||
var byt2 = enc.GetBytes(TextBoxChatCode.Text);
|
||||
var bytes2 = Convert.ToBase64String(byt2);
|
||||
|
||||
sw.WriteLine(bytes);
|
||||
sw.WriteLine(bytes2);
|
||||
|
||||
File.SetAttributes(_merkeDaten, FileAttributes.ReadOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -158,11 +214,11 @@ namespace ChatController
|
||||
{
|
||||
|
||||
Encoding enc = new UTF8Encoding();
|
||||
var byt = enc.GetBytes(TextBoxKundennummer.Text);
|
||||
var bytes = Convert.ToBase64String(byt);
|
||||
//var byt = enc.GetBytes(TextBoxKundennummer.Text);
|
||||
//var bytes = Convert.ToBase64String(byt);
|
||||
|
||||
var byt2 = enc.GetBytes(TextBoxChatCode.Text);
|
||||
var bytes2 = Convert.ToBase64String(byt2);
|
||||
//var byt2 = enc.GetBytes(TextBoxChatCode.Text);
|
||||
//var bytes2 = Convert.ToBase64String(byt2);
|
||||
|
||||
var byt3 = enc.GetBytes(TextBoxBenutzerName.Text);
|
||||
var bytes3 = Convert.ToBase64String(byt3);
|
||||
@@ -175,8 +231,8 @@ namespace ChatController
|
||||
var bytes5 = Convert.ToBase64String(byt5);
|
||||
|
||||
|
||||
sw.WriteLine(bytes);
|
||||
sw.WriteLine(bytes2);
|
||||
//sw.WriteLine(bytes);
|
||||
//sw.WriteLine(bytes2);
|
||||
sw.WriteLine(bytes3);
|
||||
sw.WriteLine(bytes4);
|
||||
sw.WriteLine(bytes5);
|
||||
@@ -197,6 +253,7 @@ namespace ChatController
|
||||
{
|
||||
if (File.Exists(_dateiPfad))
|
||||
{
|
||||
File.SetAttributes(_dateiPfad, FileAttributes.Normal);
|
||||
File.Delete(_dateiPfad);
|
||||
}
|
||||
}
|
||||
@@ -206,7 +263,7 @@ namespace ChatController
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user