void HandleCallDenyRequest(ClientSocket clientsocket, Packet pak) { this.Dispatcher.Invoke((MethodInvoker) delegate { int MemberID = pak.Readint(); Contact contact = Contacts[MemberID]; contact.CallActive = false; VCallCore.EndCall(MemberID); SoundManager.VoiceCallingSound.Stop(); NotificationWindow.RemoveCallNotification(contact); }, null); }
void HandleCallRequest(ClientSocket clientsocket, Packet pak) { this.Dispatcher.Invoke((MethodInvoker) delegate { int MemberID = pak.Readint(); Contact contact = Contacts[MemberID]; string UDPAddress = pak.Readstring(); int Port = pak.Readint(); NotificationWindow.ShowCallNotification(contact, UDPAddress, Port); }, null); }
public static void ShowNotification(string Title, string Message, Contact contact) { NotificationWindow wnd = new NotificationWindow(); wnd.Left = (SystemParameters.FullPrimaryScreenWidth - wnd.Width) - 10; wnd.Top = 10; wnd.txt_notificationtitle.Content = Title; wnd.txt_notificationcontent.Text = Message; wnd.Show(); Windows.Add(wnd); ReDraw(); }
void HandleMemberInfoResponse(ClientSocket clientSocket, Packet pak) { this.Dispatcher.Invoke((MethodInvoker) delegate { ReceivedFriendCount++; if (pak.Readbool()) { int MemberID = pak.Readint(); string MemberNickname = pak.Readstring(); string MemberStatus = pak.Readstring(); int MemberAuth = pak.Readint(); byte StatusCode = pak.Readbyte(); bool PendingRequest = pak.Readbool(); string FirstName = pak.Readstring(); string LastName = pak.Readstring(); if (!Contacts.ContainsKey(MemberID)) { Contacts.Add(MemberID, new Contact(MemberID, MemberNickname, FirstName, LastName, PendingRequest, (Status)StatusCode, MemberStatus, MemberAuth)); } else { Contact contact = Contacts[MemberID]; contact.NickName = MemberNickname; contact.StatusUpdate = MemberStatus; contact.Authority = MemberAuth; contact.status = (Status)StatusCode; contact.Pending = PendingRequest; contact.FirstName = FirstName; contact.LastName = LastName; contact.FullName = FirstName + " " + LastName; } if (PendingRequest && ConfigManager.Instance.GetBool("txt_newrequestnotification", true) && ConfigManager.Instance.GetBool("txt_notifications", true)) { NotificationWindow.ShowNotification("Pending Contact", String.Format("{0} has requested you be added to their contact list.", MemberNickname)); } if (ReceivedFriendCount >= FriendCount) { BlazeGames.IM.Client.MainWindow.Instance.page_Contacts.Draw(); } } if (ReceivedFriendCount == FriendCount) { clientSocket.SendPacket(Packet.New(Packets.PAK_CLI_OFFLNMSGRQST)); } }, null); }
private void btn_add_Click(object sender, RoutedEventArgs e) { string FriendEmail = txt_Friend.Text; if (FriendEmail != "") { App.Instance.CSocket.SendPacket(Packet.New(Packets.PAK_CLI_FRNDADDRQST, FriendEmail)); NotificationWindow.ShowNotification("Friend Request Sent", string.Format("Your friend request to {0} has been sent", FriendEmail)); } txt_Friend.Text = ""; this.Visibility = Visibility.Collapsed; }
void Input_SentMessage_Execute(object target, ExecutedRoutedEventArgs e) { rtf_input.SelectAll(); if (rtf_input.Selection.Text.Trim() == "") { return; } MemoryStream ms = new MemoryStream(); rtf_input.Selection.Save(ms, DataFormats.Xaml); rtf_input.Selection.Text = ""; string Message = Encoding.Default.GetString(ms.ToArray()).Replace("Typography.StandardLigatures=\"True\" Typography.ContextualLigatures=\"True\" Typography.DiscretionaryLigatures=\"False\" Typography.HistoricalLigatures=\"False\" Typography.AnnotationAlternates=\"0\" Typography.ContextualAlternates=\"True\" Typography.HistoricalForms=\"False\" Typography.Kerning=\"True\" Typography.CapitalSpacing=\"False\" Typography.CaseSensitiveForms=\"False\" Typography.StylisticSet1=\"False\" Typography.StylisticSet2=\"False\" Typography.StylisticSet3=\"False\" Typography.StylisticSet4=\"False\" Typography.StylisticSet5=\"False\" Typography.StylisticSet6=\"False\" Typography.StylisticSet7=\"False\" Typography.StylisticSet8=\"False\" Typography.StylisticSet9=\"False\" Typography.StylisticSet10=\"False\" Typography.StylisticSet11=\"False\" Typography.StylisticSet12=\"False\" Typography.StylisticSet13=\"False\" Typography.StylisticSet14=\"False\" Typography.StylisticSet15=\"False\" Typography.StylisticSet16=\"False\" Typography.StylisticSet17=\"False\" Typography.StylisticSet18=\"False\" Typography.StylisticSet19=\"False\" Typography.StylisticSet20=\"False\" Typography.Fraction=\"Normal\" Typography.SlashedZero=\"False\" Typography.MathematicalGreek=\"False\" Typography.EastAsianExpertForms=\"False\" Typography.Variants=\"Normal\" Typography.Capitals=\"Normal\" Typography.NumeralStyle=\"Normal\" Typography.NumeralAlignment=\"Normal\" Typography.EastAsianWidths=\"Normal\" Typography.EastAsianLanguage=\"Normal\" Typography.StandardSwashes=\"0\" Typography.ContextualSwashes=\"0\" Typography.StylisticAlternates=\"0\"", "").Replace("xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"", "xmlns=\"default\""); Message = Regex.Replace(Message, "<Paragraph>", "", RegexOptions.IgnoreCase); Message = Regex.Replace(Message, "</Paragraph>", "\r", RegexOptions.IgnoreCase); Message = Regex.Replace(Message, "<Paragraph(.|\n)*?>", "", RegexOptions.IgnoreCase); Message = Regex.Replace(Message, "<Section", "<Span", RegexOptions.IgnoreCase); Message = Regex.Replace(Message, "</Section>", "</Span>", RegexOptions.IgnoreCase); Message = Regex.Replace(Message, "TextAlignment=\"(.|\n)*?\"", "", RegexOptions.IgnoreCase); Message = Regex.Replace(Message, "LineHeight=\"(.|\n)*?\"", "", RegexOptions.IgnoreCase); Message = Regex.Replace(Message, "IsHyphenationEnabled=\"(.|\n)*?\"", "", RegexOptions.IgnoreCase); Message = Message.Replace("<Run", "<Span").Replace("</Run>", "</Span>"); Regex urlRx = new Regex(@"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'"".,<>?«»“”‘’]))", RegexOptions.IgnoreCase); MatchCollection matches = urlRx.Matches(Message); foreach (Match match in matches) { var url = match.Groups[0].Value; Message = Message.Replace(url, string.Format("<Hyperlink NavigateUri=\"{0}\">{0}</Hyperlink>", url)); } if (ChattingWith != null) { if (App.Instance.Contacts.ContainsKey(ChattingWith.ID)) { App.Instance.Contacts[ChattingWith.ID].SendMessage(Message); HandleMessage(App.FullName, Message); } else { NotificationWindow.ShowNotification("Unable To Deliver Message", string.Format("{0} is no longer in your contact list.", ChattingWith.FullName)); } } }
private void wnd_Closing(object sender, CancelEventArgs e) { if (!Minimum) { ConfigManager.Instance.SetValue("WndWidth", this.Width.ToString()); ConfigManager.Instance.SetValue("WndHeight", this.Height.ToString()); ConfigManager.Instance.Save(); } NotificationWindow.ForceClose(); try { ConsoleWindow.Instance.Close(); } catch { } }
void dialog_FileOk(object sender, CancelEventArgs e) { try { using (Stream stream = dialog.OpenFile()) { MemoryStream ms = new MemoryStream(); System.Drawing.Image img = System.Drawing.Image.FromStream(stream); ProfileImage = img; img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); WebClient wc_uploader = new WebClient(); wc_uploader.UploadDataCompleted += new UploadDataCompletedEventHandler(wc_uploader_UploadDataCompleted); wc_uploader.UploadDataAsync(new Uri(String.Format("https://blaze-games.com/api/uploadimage/?account={0}&password={1}", App.Account, App.Password)), ms.ToArray()); } } catch { NotificationWindow.ShowNotification("Upload Failed", "Unable to upload your profile image since it was not a valid image file."); } }
private void NotifyNewMessage(string Message) { try { NewMessages++; if (ConfigManager.Instance.GetBool("sound_notifications", true) && ConfigManager.Instance.GetBool("sound_newmessagenotification", true)) { SoundManager.NewMessageSound.Play(); } if (ConfigManager.Instance.GetBool("txt_notifications", true) && ConfigManager.Instance.GetBool("txt_newmessagenotification", true)) { System.Windows.Controls.RichTextBox rtf = new System.Windows.Controls.RichTextBox(); rtf.Selection.Load(new MemoryStream(System.Text.Encoding.Default.GetBytes(Message.Replace("xmlns=\"default\"", "xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\""))), DataFormats.Xaml); NotificationWindow.ShowNotification(string.Format("New Message From {0}", NickName), rtf.Selection.Text); } WindowExtensions.FlashWindow(MainWindow.Instance); } catch { } }
void HandleStatusChangeDeliver(ClientSocket clientSocket, Packet pak) { this.Dispatcher.Invoke((MethodInvoker) delegate { int MemberID = pak.Readint(); Status NewStatus = (Status)pak.Readbyte(); Contact contact = Contacts[MemberID]; if (contact.status == Status.Offline && NewStatus != Status.Offline && ConfigManager.Instance.GetBool("txt_loginnotification", true) && ConfigManager.Instance.GetBool("txt_notifications", true)) { NotificationWindow.ShowNotification(String.Format("{0} Has Signed In", contact.FullName), String.Format("{0} has just signed in.", contact.FullName), contact); } if (contact.status != Status.Offline && NewStatus == Status.Offline && ConfigManager.Instance.GetBool("txt_logoutnotification", true) && ConfigManager.Instance.GetBool("txt_notifications", true)) { VCallCore.EndCall(contact.ID); NotificationWindow.ShowNotification(String.Format("{0} Has Signed Out", contact.FullName), String.Format("{0} has just signed out.", contact.FullName), contact); } contact.status = NewStatus; BlazeGames.IM.Client.MainWindow.Instance.page_Contacts.Draw(); }, null); }
private void rtf_DragDrop(object s, DragEventArgs ev) { if (ev.Data.GetDataPresent(DataFormats.FileDrop)) { string[] docPath = (string[])ev.Data.GetData(DataFormats.FileDrop); foreach (string file in docPath) { FileInfo fi = new FileInfo(file); if (!fi.Exists) { continue; } bool IsImage = (fi.Extension == ".png" || fi.Extension == ".jpg" || fi.Extension == ".gif"); string icon = "http://blaze-games.com/files/icon/file-" + fi.Name + "/"; string UID = Guid.NewGuid().ToString().Replace("-", ""); int lastprogress = 0; byte[] DeCompressedFileData = File.ReadAllBytes(fi.FullName); byte[] filedata = BlazeGames.IM.Client.Core.Utilities.Compress(DeCompressedFileData); if (filedata.Length >= 10485760) { NotificationWindow.ShowNotification("Upload Failed", "The file " + fi.Name + " is larger than 10MB when compressed."); return; } HandleMessage(App.FullName, @"<Span xmlns=""default""> <Grid Name=""upload_" + UID + @"_control"" Background=""Transparent"" Width=""400"" Height=""100""> <Grid.ColumnDefinitions> <ColumnDefinition Width=""100""/> <ColumnDefinition Width=""*""/> </Grid.ColumnDefinitions> <ProgressBar Name=""upload_" + UID + @"_progress"" HorizontalAlignment=""Stretch"" Height=""20"" Margin=""15,42,15,15"" VerticalAlignment=""Center"" Grid.Column=""1""/> <Image Name=""upload_" + UID + @"_thumbnail"" Grid.Column=""0"" HorizontalAlignment=""Stretch"" Margin=""15"" VerticalAlignment=""Stretch""/> <Label Name=""upload_" + UID + @"_filename"" Content=""" + fi.Name + @""" Grid.Column=""1"" Margin=""15,15,15,40"" VerticalAlignment=""Center"" FontSize=""18"" Foreground=""#FF363636"" /> <Label Name=""upload_" + UID + @"_progresstxt"" Content=""Uploading (0%)..."" Grid.Column=""1"" Margin=""15,42,15,15"" VerticalAlignment=""Center"" FontSize=""14"" Foreground=""#FF5F5F5F"" /> </Grid> <LineBreak /> </Span>"); if (IsImage) { UpdateUploadThumbnail(UID, new System.Windows.Media.Imaging.BitmapImage(new Uri(fi.FullName))); } else { UpdateUploadThumbnail(UID, new System.Windows.Media.Imaging.BitmapImage(new Uri(icon))); } using (WebClient wc = new WebClient()) { Uploads.Add(UID); wc.UploadDataCompleted += (sender, e) => { Uploads.Remove(UID); string Url = Encoding.Default.GetString(e.Result); UpdateUploadComplete(UID, Url); if (IsImage) { icon = Url; } ChattingWith.SendMessage(@"<Span xmlns=""default""> <Grid Name=""upload_" + UID + @"_control"" Cursor=""Hand"" Background=""Transparent"" Width=""400"" Height=""100"" Tag=""" + Url + @"""> <Grid.ColumnDefinitions> <ColumnDefinition Width=""100""/> <ColumnDefinition Width=""*""/> </Grid.ColumnDefinitions> <Image Name=""upload_" + UID + @"_thumbnail"" Grid.Column=""0"" HorizontalAlignment=""Stretch"" Margin=""15"" VerticalAlignment=""Stretch"" Source=""" + icon + @"""/> <Label Name=""upload_" + UID + @"_filename"" Content=""" + fi.Name + @""" Grid.Column=""1"" Margin=""15,15,15,40"" VerticalAlignment=""Center"" FontSize=""18"" Foreground=""#FF363636"" /> <Label Name=""upload_" + UID + @"_progresstxt"" Content=""" + Url + @""" Grid.Column=""1"" Margin=""15,42,15,15"" VerticalAlignment=""Center"" FontSize=""14"" Foreground=""#FF5F5F5F"" /> </Grid> <LineBreak /> </Span>"); }; wc.UploadProgressChanged += (sender, e) => { if (lastprogress != e.ProgressPercentage) { UpdateUploadProgress(UID, (e.ProgressPercentage * 2) - 1); } lastprogress = e.ProgressPercentage; }; wc.UploadDataAsync(new Uri("http://blaze-games.com/files/upload/&file_name=" + fi.Name), filedata); } } } ev.Handled = false; }
public void StartChattingWith(Contact contact) { if (ChattingWith != null) { if (ChattingWith.ID == contact.ID) { return; } } if (Uploads.Count > 0) { NotificationWindow.ShowNotification("Upload In Progress", string.Format("Unable to start chatting with {0} since you are currently uploading files.", contact.FullName)); return; } new Thread(new ThreadStart(delegate { this.Dispatcher.Invoke((App.MethodInvoker) delegate { rtf_input.IsEnabled = false; }, null); this.Dispatcher.Invoke((App.MethodInvoker) delegate { ChattingWith = contact; LastMessageFrom = ""; profile_image_source.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(contact.ProfileImage)); profile_image.BorderBrush = (SolidColorBrush) new BrushConverter().ConvertFromString(contact.status.GetColor()); txt_chattingwith_nickname.Text = contact.FullName; txt_chattingwith_statusupdate.Text = contact.StatusUpdate; rtf_output.SelectAll(); rtf_output.Selection.Text = ""; }, null); this.Dispatcher.Invoke((App.MethodInvoker) delegate { SlideFade.CreateProfileImgAnimationOut(profile_image); App.Instance.Contacts[contact.ID].LastMessage = DateTime.Now; }, null); var Messages = contact.Messages; int MessagesToLoad = 50; if (Messages.Count > MessagesToLoad) { Messages.Reverse(); Messages.RemoveRange(MessagesToLoad - 1, Messages.Count - MessagesToLoad); Messages.Reverse(); } foreach (Message msg in Messages) { if ((msg.SendTime - DateTime.Now).Days > 7) { continue; } this.Dispatcher.Invoke((App.MethodInvoker) delegate { HandleMessage(msg.From, msg.Msg, true); }, null); } this.Dispatcher.Invoke((App.MethodInvoker) delegate { rtf_input.IsEnabled = true; rtf_output.ScrollToEnd(); SubscribeAll(); }, null); })).Start(); }
void UploadImage(BitmapSource img_wpf) { System.Drawing.Image img = ImageWpfToGDI(img_wpf); string UID = Guid.NewGuid().ToString().Replace("-", ""); int lastprogress = 0; MemoryStream ImageStream = new MemoryStream(); img.Save(ImageStream, System.Drawing.Imaging.ImageFormat.Png); byte[] image = BlazeGames.IM.Client.Core.Utilities.Compress(ImageStream.ToArray()); if (image.Length > 10485760) { NotificationWindow.ShowNotification("Upload Failed", "The image you are trying to upload is larger than 10MB when compressed."); return; } HandleMessage(App.FullName, @"<Span xmlns=""default""> <Grid Name=""upload_" + UID + @"_control"" Background=""Transparent"" Width=""400"" Height=""100""> <Grid.ColumnDefinitions> <ColumnDefinition Width=""100""/> <ColumnDefinition Width=""*""/> </Grid.ColumnDefinitions> <ProgressBar Name=""upload_" + UID + @"_progress"" HorizontalAlignment=""Stretch"" Height=""20"" Margin=""15,42,15,15"" VerticalAlignment=""Center"" Grid.Column=""1""/> <Image Name=""upload_" + UID + @"_thumbnail"" Grid.Column=""0"" HorizontalAlignment=""Stretch"" Margin=""15"" VerticalAlignment=""Stretch""/> <Label Name=""upload_" + UID + @"_filename"" Content=""UploadedImage.png"" Grid.Column=""1"" Margin=""15,15,15,40"" VerticalAlignment=""Center"" FontSize=""18"" Foreground=""#FF363636"" /> <Label Name=""upload_" + UID + @"_progresstxt"" Content=""Uploading (0%)..."" Grid.Column=""1"" Margin=""15,42,15,15"" VerticalAlignment=""Center"" FontSize=""14"" Foreground=""#FF5F5F5F"" /> </Grid> <LineBreak /> </Span>"); UpdateUploadThumbnail(UID, img_wpf); using (WebClient wc = new WebClient()) { Uploads.Add(UID); wc.UploadDataCompleted += (sender, e) => { Uploads.Remove(UID); string Url = Encoding.Default.GetString(e.Result); UpdateUploadComplete(UID, Url); ChattingWith.SendMessage(@"<Span xmlns=""default""> <Grid Name=""upload_" + UID + @"_control"" Cursor=""Hand"" Background=""Transparent"" Width=""400"" Height=""100"" Tag=""" + Url + @"""> <Grid.ColumnDefinitions> <ColumnDefinition Width=""100""/> <ColumnDefinition Width=""*""/> </Grid.ColumnDefinitions> <Image Name=""upload_" + UID + @"_thumbnail"" Grid.Column=""0"" HorizontalAlignment=""Stretch"" Margin=""15"" VerticalAlignment=""Stretch"" Source=""" + Url + @"""/> <Label Name=""upload_" + UID + @"_filename"" Content=""UploadedImage.png"" Grid.Column=""1"" Margin=""15,15,15,40"" VerticalAlignment=""Center"" FontSize=""18"" Foreground=""#FF363636"" /> <Label Name=""upload_" + UID + @"_progresstxt"" Content=""" + Url + @""" Grid.Column=""1"" Margin=""15,42,15,15"" VerticalAlignment=""Center"" FontSize=""14"" Foreground=""#FF5F5F5F"" /> </Grid> <LineBreak /> </Span>"); }; wc.UploadProgressChanged += (sender, e) => { if (lastprogress != e.ProgressPercentage) { UpdateUploadProgress(UID, (e.ProgressPercentage * 2) - 1); } lastprogress = e.ProgressPercentage; }; wc.UploadDataAsync(new Uri("http://blaze-games.com/files/upload/&file_name=UploadedImage.png"), image); } }