Exemplo n.º 1
0
        private async void OnCallBack(object sender, CallbackQueryEventArgs e)
        {
            string[] data = e.CallbackQuery.Data.Split(':');
            int      userRole;

            if (int.TryParse(data[2], out userRole) && userRole == 0)
            {
                _imageHolder.Images = null;
                var presentationEntity = await _presentationRepository.GetByName(data[1]);

                using (Stream stream = new MemoryStream(presentationEntity.File))
                {
                    IPresentation presentation = Syncfusion.Presentation.Presentation.Open(stream);
                    foreach (var i in presentation.Slides)
                    {
                        _imageHolder.Images.Add(((MemoryStream)i.ConvertToImage(ExportImageFormat.Png)).ToArray());
                    }
                    _imageHolder.Current = 1;
                    _imageHolder.Guid    = new Guid();
                }

                InlineKeyboardButton button = new InlineKeyboardButton();
                button.CallbackData = $"{data[1]}:1:{1}";
                button.Text         = "\\|/";

                InlineKeyboardMarkup markup = new InlineKeyboardMarkup(button);

                await _client.SendTextMessageAsync(data[1], "Next page", replyMarkup : markup);
            }
            else if (int.TryParse(data[1], out userRole) && userRole == 1)
            {
                _imageHolder.Current++;
                int i = _imageHolder.Current;

                InlineKeyboardButton button = new InlineKeyboardButton();
                button.CallbackData = $"{data[1]}:{i}:{1}";
                button.Text         = "\\|/";

                InlineKeyboardMarkup markup = new InlineKeyboardMarkup(button);

                await _client.EditMessageReplyMarkupAsync(data[1], markup);
            }
            //else if (int.TryParse(data[1], out userRole) && userRole == 2)
            //{

            //}
        }