Esempio n. 1
0
        public async Task <ActionResult <string> > Command(
            string token,
            string team_id,
            string channel_id,
            string channel_name,
            string user_id,
            string user_name,
            string command,
            string text)
        {
            if (!string.IsNullOrEmpty(text))
            {
                ICommandModel commandModel;
                if (text.StartsWith("fblikes", StringComparison.OrdinalIgnoreCase))
                {
                    commandModel = new FbLikesCommandModel();
                }
                else
                {
                    commandModel = new MessageCommandModel()
                    {
                        Text     = text,
                        UserName = user_name
                    };
                }
                await Service.AddCommandAsync(commandModel);
            }

            // add to command queue
            // raise an event
            return("OK");
        }
Esempio n. 2
0
        private void Draw(DrawContext context, MessageCommandModel command)
        {
            if (command.Command == MessageCommand.PrintText)
            {
                DrawText(context, command);
            }
            else if (command.Command == MessageCommand.PrintComplex)
            {
                DrawText(context, command);
            }
            else if (command.Command == MessageCommand.PrintIcon)
            {
                DrawIcon(context, command.Data[0]);
            }
            else if (command.Command == MessageCommand.Color)
            {
                SetColor(context, command.Data);
            }
            else if (command.Command == MessageCommand.Reset)
            {
                context.Reset();
            }
            else if (command.Command == MessageCommand.Clear)
            {
                context.NewLine(_msgContext.FontHeight);
                context.y += 4;
                _drawing.FillRectangle(
                    8,
                    (float)context.y,
                    Math.Max(1.0f, (float)(context.WindowWidth - 16)),
                    2,
                    ColorF.White);
                context.y += 4;
            }
            else if (command.Command == MessageCommand.Position)
            {
                context.x = command.PositionX;
                context.y = command.PositionY;
            }
            else if (command.Command == MessageCommand.TextWidth)
            {
                context.WidthMultiplier = command.TextWidth;
            }
            else if (command.Command == MessageCommand.TextScale)
            {
                context.Scale = command.TextScale;
            }
            else if (command.Command == MessageCommand.Tabulation)
            {
                context.x += 16; // TODO this is not the real tabulation size
            }
            else if (command.Command == MessageCommand.NewLine)
            {
                context.NewLine(_msgContext.FontHeight);
            }

            context.Width  = Math.Max(context.Width, context.x);
            context.Height = Math.Max(context.Height, context.y + _msgContext.FontHeight * context.Scale);
        }
Esempio n. 3
0
        public void SerializePlainSimpleText()
        {
            var entry = new MessageCommandModel
            {
                Command = MessageCommand.PrintText,
                Text    = "Hello world!"
            };

            var element = MsgSerializer.SerializeText(new[] { entry });

            Assert.Equal(entry.Text, element);
        }
Esempio n. 4
0
        private void DrawText(DrawContext context, MessageCommandModel command)
        {
            if (_msgContext.Encoder == null)
            {
                return;
            }

            var data = _msgContext.Encoder.Encode(new List <MessageCommandModel>
            {
                command
            });

            DrawText(context, data);
        }
Esempio n. 5
0
        public void SerializeXmlIcon(byte id, string content)
        {
            var entry = new MessageCommandModel
            {
                Command = MessageCommand.PrintIcon,
                Data    = new[] { id }
            };

            var actual   = MsgSerializer.SerializeXEntries(MessageId, new[] { entry });
            var expected = new XElement("message",
                                        new XAttribute("id", MessageId),
                                        new XElement("icon", new XAttribute("value", content))
                                        );

            Assert.Equal(expected.ToString(xmlFormatting), actual.ToString(xmlFormatting));
        }
Esempio n. 6
0
        public void SerializeXmlSimpleText()
        {
            var entry = new MessageCommandModel
            {
                Command = MessageCommand.PrintText,
                Text    = "Hello world!"
            };

            var element = MsgSerializer.SerializeXEntries(MessageId, new[] { entry });
            var content = new XElement("message",
                                       new XAttribute("id", MessageId),
                                       new XElement("text", "Hello world!")
                                       );

            Assert.Equal(content.ToString(xmlFormatting), element.ToString(xmlFormatting));
        }
Esempio n. 7
0
 private void AppendEncodedMessageCommand(List <byte> list, MessageCommandModel messageCommand)
 {
     if (messageCommand.Command == MessageCommand.PrintText)
     {
         AppendEncodedText(list, messageCommand.Text);
     }
     else if (messageCommand.Command == MessageCommand.PrintComplex)
     {
         AppendEncodedComplex(list, messageCommand.Text);
     }
     else if (messageCommand.Command == MessageCommand.Unsupported)
     {
         list.AddRange(messageCommand.Data);
     }
     else
     {
         AppendEncodedCommand(list, messageCommand.Command, messageCommand.Data);
     }
 }