public void Send()
        {
            var chat = Chat as TLEncryptedChat;

            if (chat == null)
            {
                return;
            }

            if (!CanSend)
            {
                return;
            }

            var text = DialogDetailsViewModel.GetTrimmedText(Text);

            if (ProcessSpecialCommands(text))
            {
                return;
            }

            //check maximum message length
            if (text.Length > Constants.MaximumMessageLength)
            {
                MessageBox.Show(
                    String.Format(AppResources.MaximumMessageLengthExceeded, Constants.MaximumMessageLength),
                    AppResources.Error, MessageBoxButton.OK);

                return;
            }

            var decryptedTuple = GetDecryptedMessageAndObject(new TLString(text), new TLDecryptedMessageMediaEmpty(), chat);

            Items.Insert(0, decryptedTuple.Item1);
            RaiseScrollToBottom();
            NotifyOfPropertyChange(() => DescriptionVisibility);
            Text = string.Empty;

            SendEncrypted(chat, decryptedTuple.Item2, MTProtoService, CacheService);
        }
        public void Send()
        {
            var chat = Chat as TLEncryptedChat;

            if (chat == null)
            {
                return;
            }

            if (!CanSend)
            {
                return;
            }

            var text = DialogDetailsViewModel.GetTrimmedText(Text);

            if (ProcessSpecialCommands(text))
            {
                return;
            }

            //check maximum message length
            if (text.Length > Constants.MaximumMessageLength)
            {
                MessageBox.Show(
                    String.Format(AppResources.MaximumMessageLengthExceeded, Constants.MaximumMessageLength),
                    AppResources.Error, MessageBoxButton.OK);

                return;
            }

            var decryptedTuple = GetDecryptedMessageAndObject(new TLString(text), new TLDecryptedMessageMediaEmpty(), chat);

            var chat17 = chat as TLEncryptedChat17;

            if (chat17 != null && chat17.Layer.Value >= Constants.MinSecretChatWithRepliesLayer)
            {
                if (Reply != null && IsWebPagePreview(Reply))
                {
                    var webPageMedia = ((TLDecryptedMessagesContainter)Reply).WebPageMedia as TLMessageMediaWebPage;
                    if (webPageMedia != null)
                    {
                        var webPage = webPageMedia.WebPage as TLWebPage;
                        if (webPage != null)
                        {
                            ((TLDecryptedMessage45)decryptedTuple.Item1).Media = new TLDecryptedMessageMediaWebPage {
                                Url = new TLString(Text), WebPage = webPage
                            };
                            ((TLDecryptedMessage45)decryptedTuple.Item1).SetMedia();
                            Reply = _previousReply;
                        }
                    }
                }
            }

            InsertSendingMessage(decryptedTuple.Item1);
            RaiseScrollToBottom();
            NotifyOfPropertyChange(() => DescriptionVisibility);
            Text = string.Empty;

            SendEncrypted(chat, decryptedTuple.Item2, MTProtoService, CacheService);
        }