public async Task SendFriendLinkViaSms()
        {
            IsLoading = true;
            var result = await ChatMessageManager.GetTransportsAsync();

            if (!result.Any())
            {
                IsLoading = false;
                await ResultChecker.SendMessageDialogAsync(_loader.GetString("NoSMS/Text"), false);

                return;
            }
            var link = await CreateFriendLink();

            if (!string.IsNullOrEmpty(link))
            {
                var chat = new ChatMessage
                {
                    Subject = _loader.GetString("FriendRequestBody/Text"),
                    Body    = string.Format("{0} {1}", _loader.GetString("FriendRequestBody/Text"), link)
                };
                await ChatMessageManager.ShowComposeSmsMessageAsync(chat);
            }
            IsLoading = false;
        }
Beispiel #2
0
        public static ServerPacket SerializeTicketChatlog(SupportTicket Ticket, RoomData RoomData, double Timestamp)
        {
            Room         room    = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(RoomData.Id);
            ServerPacket message = new ServerPacket(ServerPacketHeader.ModeratorTicketChatlogMessageComposer);

            message.WriteInteger(Ticket.TicketId);
            message.WriteInteger(Ticket.SenderId);
            message.WriteInteger(Ticket.ReportedId);
            message.WriteInteger(RoomData.Id);

            message.WriteBoolean(false);
            message.WriteInteger(RoomData.Id);
            message.WriteString(RoomData.Name);

            if (room == null)
            {
                message.WriteInteger(0);
                return(message);
            }
            else
            {
                ChatMessageManager chatMessageManager = room.GetChatMessageManager();
                message.WriteInteger(chatMessageManager.messageCount);
                chatMessageManager.Serialize(ref message);
                return(message);
            }
        }
Beispiel #3
0
        public static ServerPacket SerializeRoomChatlog(int roomID)
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(roomID);

            ServerPacket Message = new ServerPacket(ServerPacketHeader.ModeratorRoomChatlogMessageComposer);

            Message.WriteByte(1);

            Message.WriteShort(2);

            Message.WriteString("roomName");
            Message.WriteByte(2);
            Message.WriteString(room.RoomData.Name);

            Message.WriteString("roomId");
            Message.WriteByte(1);
            Message.WriteInteger(room.RoomData.Id);

            if (room == null)
            {
                Message.WriteShort(0);
                return(Message);
            }
            else
            {
                ChatMessageManager chatMessageManager = room.GetChatMessageManager();
                Message.WriteShort(chatMessageManager.messageCount);
                chatMessageManager.Serialize(ref Message);
                return(Message);
            }
        }
        private async void ProcessEContactClick(EContactItem selectedItem)
        {
            string content = string.Format("Call or message {0}?\nPress back to cancel.", selectedItem.Name);
            string title   = "Information";

            string[]      cmdString = new string[] { "call", "message" };
            MessageDialog md        = new MessageDialog(content, title);

            md.Commands.Add(new UICommand(cmdString[0]));
            md.Commands.Add(new UICommand(cmdString[1]));

            IUICommand result = await md.ShowAsync();

            if (result == null)
            {
                return;
            }

            string resultString = result.Label;

            if (resultString == cmdString[0])
            {
                // Process call
                Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI(selectedItem.Contact, selectedItem.Name);
            }
            else if (resultString == cmdString[1])
            {
                // Process message
                Windows.ApplicationModel.Chat.ChatMessage chatMsg = new Windows.ApplicationModel.Chat.ChatMessage();
                chatMsg.Recipients.Add(selectedItem.Contact);
                chatMsg.Body = "";
                await ChatMessageManager.ShowComposeSmsMessageAsync(chatMsg);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Shows the Messaging application, using the specified recipient list and message body.
        /// </summary>
        /// <param name="recipient">The recipient list for the new SMS message.</param>
        /// <param name="body">The body text of the new SMS message.</param>
        /// <returns>The <see cref="Task"/> object representing the asynchronous operation.</returns>
        public virtual Task ShowAsync(string recipient, string body)
        {
#if WINDOWS_PHONE || WINDOWS_PHONE_81
            new SmsComposeTask()
            {
                To   = recipient,
                Body = body
            }.Show();

            return(Task.FromResult(0));
#elif WINDOWS_PHONE_APP || WINDOWS_UWP
            var chatMessage = new ChatMessage
            {
                Body = body
            };

            if (!string.IsNullOrEmpty(recipient))
            {
                chatMessage.Recipients.Add(recipient);
            }

            return(ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage).AsTask());
#else
            var smsUri = new UriBuilder("sms:")
                         .SetPath(recipient)
                         .AppendQueryParameterIfValueNotEmpty("body", body)
                         .Uri;

            return(Launcher.LaunchUriAsync(smsUri).AsTask());
#endif
        }
Beispiel #6
0
        // Initialize Stuff
        public async void Initialize()
        {
            BackgroundTaskUtils.RegisterToastNotificationBackgroundTasks();
            ContactUtils.AssignAppToPhoneContacts();
            _store = await ChatMessageManager.RequestStoreAsync();

            ChatConversations = await GetChats();

            if (ChatConversations.Count != 0)
            {
                SelectedItem = ChatConversations[0];
            }

            if (!(await PerformMandatoryChecks()))
            {
                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                              async() =>
                {
                    await new CellularUnavailableContentDialog().ShowAsync();
                });
            }

            _store.ChangeTracker.Enable();
            _store.StoreChanged += Store_StoreChanged;
        }
        /// <summary>
        /// Shows the Messaging application, using the specified recipient list and message body.
        /// </summary>
        /// <param name="recipient">The recipient list for the new SMS message.</param>
        /// <param name="body">The body text of the new SMS message.</param>
        /// <returns>The <see cref="Task"/> object representing the asynchronous operation.</returns>
        public async Task ShowAsync(string recipient, string body)
        {
#if WINDOWS_PHONE
            new SmsComposeTask()
            {
                To   = recipient,
                Body = body
            }.Show();

            await Task.FromResult(0);
#elif WINDOWS_PHONE_APP
            var chatMessage = new ChatMessage
            {
                Body = body
            };

            chatMessage.Recipients.Add(recipient);

            await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage);
#else
            var smsUrl = "sms:" + Uri.EscapeDataString(recipient);

            if (!string.IsNullOrEmpty(body))
            {
                smsUrl += "?body=" + Uri.EscapeDataString(body);
            }

            await Launcher.LaunchUriAsync(new Uri(smsUrl, UriKind.Absolute));
#endif
        }
        // Initialize Stuff
        public async void Initialize(string ConvoId)
        {
            if (string.IsNullOrEmpty(ConvoId))
            {
                return;
            }

            _store = await ChatMessageManager.RequestStoreAsync();

            _conversationid = ConvoId;

            var convo = await _store.GetConversationAsync(_conversationid);

            if (convo == null)
            {
                DropEvents();
                return;
            }

            (var tmpContact, var tmpDisplayName) = await GetContactInformation();

            (DisplayDescription, TimeStamp) = await GetLastMessageInfo();

            (Contact, DisplayName) = (tmpContact, tmpDisplayName);

            _store.ChangeTracker.Enable();
            Subscribe(true);
        }
        private async void btFinalizaPedido_Click(object sender, RoutedEventArgs e)
        {
            ChatMessage sms = new ChatMessage();

            sms.Body = String.Format("Pedido {0} concluído com sucesso", novoPedido);
            sms.Recipients.Add(((Cliente)listaClientes.SelectedItem).Telefone);
            await ChatMessageManager.ShowComposeSmsMessageAsync(sms);
        }
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="toPhoneNumber">目标电话号码</param>
        /// <param name="body">短信主体</param>
        /// <returns></returns>
        public static async Task ComposeSms(string toPhoneNumber, string body)
        {
            var chatMessage = new Windows.ApplicationModel.Chat.ChatMessage();

            chatMessage.Body = body;
            chatMessage.Recipients.Add(toPhoneNumber);
            await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage);
        }
Beispiel #11
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var message = new ChatMessage();

            message.Recipients.Add("512-363-3198");
            message.Body = "This is a text message from an app!";
            await ChatMessageManager.ShowComposeSmsMessageAsync(message);
        }
Beispiel #12
0
        private async void btn_send_Click(object sender, RoutedEventArgs e)
        {
            var sms = new ChatMessage();

            sms.Body = lv_results.SelectedItem as string;

            await ChatMessageManager.ShowComposeSmsMessageAsync(sms);
        }
        public async void SendSMS(string body, string phoneNumber)
        {
            var chat = new ChatMessage {
                Body = body
            };

            chat.Recipients.Add(phoneNumber);
            await ChatMessageManager.ShowComposeSmsMessageAsync(chat);
        }
        /// <summary>
        ///     Sends the SMS.
        /// </summary>
        /// <param name="to">To.</param>
        /// <param name="body">The body.</param>
        public async void SendSMS(string to, string body)
        {
            var msg = new ChatMessage();

            msg.Recipients.Add(to);
            msg.Body = body;

            await ChatMessageManager.ShowComposeSmsMessageAsync(msg);
        }
        private async void btnChat_Click(object sender, RoutedEventArgs e)
        {
            var chat = new ChatMessage( );

            chat.Body = "Hello there";
            chat.Recipients.Add("123456789");

            await ChatMessageManager.ShowComposeSmsMessageAsync(chat);
        }
        // Initialize Stuff
        public async void Initialize(string MessageId)
        {
            if (string.IsNullOrEmpty(MessageId))
            {
                return;
            }

            _store = await ChatMessageManager.RequestStoreAsync();

            _messageid = MessageId;

            var _tmpContact = await GetContactInformation();

            (var _align, var _visi) = await GetMessageVisuals();

            (MessageBody, TimeStamp) = await GetMessageInfo();

            (Alignment, IncomingVisibility) = (_align, _visi);

            Contact = _tmpContact;

            var message = await _store.GetMessageAsync(_messageid);

            foreach (var attachment in message.Attachments)
            {
                try
                {
                    if (attachment.MimeType == "application/smil")
                    {
                    }

                    if (attachment.MimeType == "text/vcard")
                    {
                    }

                    if (attachment.MimeType.StartsWith("image/", StringComparison.InvariantCulture))
                    {
                        var imageextension = attachment.MimeType.Split('/').Last();
                        var img            = new BitmapImage();
                        await img.SetSourceAsync(await attachment.DataStreamReference.OpenReadAsync());

                        Image = img;
                    }

                    if (attachment.MimeType.StartsWith("audio/", StringComparison.InvariantCulture))
                    {
                        var audioextension = attachment.MimeType.Split('/').Last();
                    }
                }
                catch
                {
                }
            }

            _store.ChangeTracker.Enable();
            Subscribe(true);
        }
        private async void SendButton_Click(object sender, RoutedEventArgs e)
        {
            ChatMessageStore store = await ChatMessageManager.RequestStoreAsync();

            var mess = new ChatMessage
            {
                Body        = MessageTB.Text,
                TransportId = "0"
            };

            foreach (var rec in messagethread.ChatConversation.Participants)
            {
                mess.Recipients.Add(rec);
            }
            if (MessageTB.Text.Length > 0)
            {
                try
                {
                    foreach (var recipient in messagethread.ChatConversation.Participants)
                    {
                        sendtext(MessageTB.Text, recipient);
                    }
                    try
                    {
                        await store.SendMessageAsync(mess);
                    }
                    catch (Exception ex)
                    {
                        var nsg = new MessageDialog(ex.Message);
                        await nsg.ShowAsync();

                        //try
                        //{
                        //    await Windows.ApplicationModel.Chat.ChatMessageManager.ShowComposeSmsMessageAsync(mess);
                        //}
                        //catch (Exception ex2)
                        //{
                        //    var nsg2 = new MessageDialog(ex2.Message);
                        //    await nsg2.ShowAsync();
                        //}
                    }
                    var mesage = new Message
                    {
                        Body      = MessageTB.Text,
                        Alignment = HorizontalAlignment.Right,
                        Color     = (Windows.UI.Color)Application.Current.Resources["SystemAccentColorLight1"],
                        DateTime  = DateTime.Now.ToString("MM/dd, HH:mm"),
                        Margin    = new Thickness(60, 10, 10, 10)
                    };
                    Conversation.Add(mesage);
                }
                catch
                {
                }
            }
        }
Beispiel #18
0
        public ShellViewModel()
        {
            _name = string.Format("WPF Client {0}", DateTime.Now.Ticks);
            _chatMessageManager = new ChatMessageManager();
            MessageCollection   = new BindableCollection <ChatMessage>();

            Task.Run(async() => await _chatMessageManager.ConnectAsync());

            _chatMessageManager.MessageReceived += ChatMessageManagerOnMessageReceived;
        }
Beispiel #19
0
        public void SendSMS(string body, string phoneNumber)
        {
            var chatMessage = new ChatMessage {
                Body = body
            };

            chatMessage.Recipients.Add(phoneNumber);

            Task.Run(() => ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage));
        }
Beispiel #20
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            DataPackage dataPackage = new DataPackage();

            try
            {
                if (args.Kind == ActivationKind.Protocol)
                {
                    ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
                    // TODO: Handle URI activation
                    // The received URI is eventArgs.Uri.AbsoluteUri
                    var sms = new ChatMessage();

                    uridata = WebUtility.HtmlDecode(eventArgs.Uri.OriginalString);
                    query   = WebUtility.HtmlDecode(eventArgs.Uri.Query);

                    if (!String.IsNullOrEmpty(query)) // Has content
                    {
                        // Try to copy number and content between ? and =
                        // Try to get number
                        sms.Recipients.Add(getbetween(uridata, ":", "?"));
                        sms.Body = getbetween(uridata, "=");

                        p.rec = getbetween(uridata, ":", "?");
                        p.msg = (uridata.Substring(uridata.IndexOf("="))).Replace("=", "");
                    }
                    else
                    {
                        string n = (uridata.Substring(uridata.IndexOf(":"))).Replace(":", "");

                        if (Regex.Match(n, @"^[0-9]+(-[0-9]+)+$").Success)
                        {
                            // Just copy number
                            sms.Recipients.Add(n);
                            p.rec = n;
                            p.msg = "";
                        }
                        else
                        {
                            sms.Body = n;
                            p.rec    = "";
                            p.msg    = n;
                        }
                    }

                    dataPackage.RequestedOperation = DataPackageOperation.Copy;
                    dataPackage.SetText(p.rec + " " + p.msg);

                    Clipboard.SetContent(dataPackage);

                    await ChatMessageManager.ShowComposeSmsMessageAsync(sms);
                }
            }
            catch { }
        }
Beispiel #21
0
    //绑定聊天记录
    public void DataBindChatMessage(string chatId)
    {
        List <Message> list = ChatMessageManager.GetChatMessageByChatId(chatId);

        if (list != null)
        {
            foreach (Message ms in list)
            {
                this.lblMessage.Text += "<a style='font-size:12px; color:#06F;'>[" + ms.Source + "]&nbsp;<a style='color:#999;'>" + ms.SentDate.ToString() + "</a><a style= 'color:#06F;'>说:</a>&nbsp;&nbsp;" + ms.Text + "<br>";
            }
        }
    }
Beispiel #22
0
        public void SendSOSSMS(string message, string mobileNumber)
        {
            Task.Run(async() =>
            {
                var chatMessage = new ChatMessage
                {
                    Body = message,
                };
                chatMessage.Recipients.Add(mobileNumber);

                await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage);
            });
        }
Beispiel #23
0
        /// <summary>
        /// Method invoked when the user clicks on Scrivi messaggio button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AppBarButton_Tapped_3(object sender, TappedRoutedEventArgs e)
        {
            FrameworkElement element = (FrameworkElement)sender;
            Message          message = (Message)element.DataContext;

            try
            {
                ChatMessage chat = new ChatMessage();
                chat.Recipients.Add(message.Sender);

                await ChatMessageManager.ShowComposeSmsMessageAsync(chat);
            }
            catch (Exception ex) { ShellPage.Current.HandleExceptionNotification(ex); }
        }
        public virtual async Task ShowAsync(string recipient, string body)
        {
            var chatMessage = new ChatMessage
            {
                Body = body
            };

            if (!string.IsNullOrEmpty(recipient))
            {
                chatMessage.Recipients.Add(recipient);
            }

            await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage);
        }
Beispiel #25
0
        internal void InitInformation(UserData data)
        {
            this.SubscriptionManager = new SubscriptionManager(Id, data);
            this.BadgeComponent      = new BadgeComponent(Id, data);
            this.quests             = data.quests;
            this.chatMessageManager = new ChatMessageManager();

            this.Messenger = new HabboMessenger(Id);
            this.Messenger.Init(data.friends, data.requests);

            this.SpectatorMode = false;
            this.Disconnected  = false;
            this.UsersRooms    = data.rooms;
        }
Beispiel #26
0
 //发短信
 public static async void MsgFunc()
 {
     try
     {
         var chatMessage = new ChatMessage();
         chatMessage.Recipients.Add("18317722768");
         chatMessage.Body = "hello world";
         await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
Beispiel #27
0
        static Task PlatformComposeAsync(SmsMessage message)
        {
            var chat = new ChatMessage();

            if (!string.IsNullOrWhiteSpace(message?.Body))
            {
                chat.Body = message.Body;
            }
            if (!string.IsNullOrWhiteSpace(message?.Recipient))
            {
                chat.Recipients.Add(message.Recipient);
            }

            return(ChatMessageManager.ShowComposeSmsMessageAsync(chat).AsTask());
        }
Beispiel #28
0
 public void Init(GameClient client, UserData.UserData data)
 {
     this.mClient            = client;
     this.BadgeComponent     = new BadgeComponent(this.Id, data.badges);
     this.InventoryComponent = new InventoryComponent(this.Id, client);
     this.InventoryComponent.SetActiveState(client);
     this.quests             = data.quests;
     this.chatMessageManager = new ChatMessageManager();
     this.chatMessageManager.LoadUserChatlogs(this.Id);
     this.Messenger = new HabboMessenger(this.Id);
     this.Messenger.AppearOffline = this.HideOnline;
     this.Messenger.Init(data.friends, data.requests, data.Relationships);
     this.MyGroups = data.MyGroups;
     this.UpdateRooms();
 }
Beispiel #29
0
        public virtual async Task ComposeSMS(string recipient, string message = null)
        {
            if (!CanComposeSMS)
            {
                throw new FeatureNotAvailableException();
            }

            var sms = new ChatMessage
            {
                Recipients = { recipient },
                Body       = message
            };

            await ChatMessageManager.ShowComposeSmsMessageAsync(sms);
        }
Beispiel #30
0
        private async void ComposeMessage_Click(object sender, RoutedEventArgs e)
        {
            //Check if the current device has any transports that can deliver
            //a text message. Note that calling this API requires the chat
            //capability (see Package.appxmanifest)
            var transports = await ChatMessageManager.GetTransportsAsync();

            //If there are transports available, call ShowComposeSmsMessageAsync
            if (transports.Any())
            {
                var textMessage = new ChatMessage();
                textMessage.Body = Message.Text;
                await ChatMessageManager.ShowComposeSmsMessageAsync(textMessage);
            }
        }