Example #1
0
        protected virtual InteractiveItemsStack PrepareMessageContent(string message, bool reply)
        {
            // пиктограмма стрелки
            DrawableItemsStack <VectorShape> image = new DrawableItemsStack <VectorShape>();

            image.OrientationAxis = Axis.X;          // stack image components one on top of the other
            image.KeepAspectRatio = true;
            image.Add(new ArrowShape());             //OptionsCircleShape
            image.Border = 1;

            // текст
            InteractiveItemsStack replyText = new InteractiveItemsStack();

            replyText.OrientationAxis = Axis.X;
            replyText.Border          = 1;
            replyText.Add(image);

            TextSegment text = new TextSegment(Graphics, message, GroupTitleFont, true);

            text.Brush = (reply) ? Brushes.DarkBlue : Brushes.Crimson;
            replyText.Add(text);

            // Background контейнер
            InteractiveItemsStack content = new InteractiveItemsStack();

            content.OrientationAxis = Axis.Z;
            content.Add(new DrawableRectangle((reply)? ReplyTextTitlesBackground : OptionTextTitlesBackground, null, 0, 0, 5, 5));
            content.Add(replyText);

            return(content);
        }
Example #2
0
        /*
         * void tgContentClicked(IMouseInteractable interactive, InteractiveHeaderedItem tg)
         * {
         *      if (ContentClick == null) return;
         *
         *      foreach (var i in (InteractiveItemsStack)interactive)
         *      {
         *              if (!(i is InteractiveItemsStack)) continue;
         *              foreach (var ts in (InteractiveItemsStack)i)
         *              {
         *                      if (ts is TextSegment)
         *                              ContentClick(this, (TextSegment)ts);
         *              }
         *      }
         * }
         */

        protected virtual void PrepareNodeContent()
        {
            if (dataNode == null)
            {
                return;
            }

            InteractiveItemsStack itemReply;
            InteractiveItemsStack itemOptions;
            DrawableItemsStack <InteractiveHeaderedItem> tileHeader;

            foreach (ContentBody content in dataNode.NodeContent)
            {
                switch (content.type)
                {
                case OpcodeType.Reply:
                case OpcodeType.Message:
                    itemReply = PrepareMessageContent(content.scrText, true);

                    tileHeader = new DrawableItemsStack <InteractiveHeaderedItem>();
                    tileHeader.Add(MessageToContent(content, itemReply, true));

                    items.Add(tileHeader);
                    break;

                case OpcodeType.Option:
                case OpcodeType.giq_option:
                case OpcodeType.gsay_option:
                    itemOptions = PrepareMessageContent(content.scrText, false);

                    tileHeader = new DrawableItemsStack <InteractiveHeaderedItem>();
                    tileHeader.Add(MessageToContent(content, itemOptions, false));

                    items.Add(tileHeader);
                    break;

                case OpcodeType.call:
                    //var callContent = new DrawableItemsStack(); //InteractiveItemsStack();
                    //callContent.OrientationAxis = Axis.Z;

                    //callContent.Add(new DrawableRectangle(CallTextTitlesBackground, null, 8, 8, 8, 8));
                    //callContent.Add(new TextSegment(Graphics, content.scrText, GroupTitleFont, true));

                    /*
                     * Код метода выше вызывает некорректную отрисовку высоты для элемента DrawableRectangle
                     * поэтому был использован нижний способ добавления элементов
                     */
                    var callText = new DrawableItemsStack();
                    callText.Add(new TextSegment(Graphics, content.scrText, GroupTitleFont, true));

                    var background = new DrawableItemsStack();
                    background.OrientationAxis = Axis.Z;
                    background.Add(new DrawableRectangle(CallTextTitlesBackground, null, 8, 8, 8, 8));
                    background.Add(callText);

                    var header = new InteractiveHeaderedItem(background, new DrawableItemsStack(), new DrawableItemsStack());
                    header.Collapsed = true;
                    //header.RedrawNeeded += HandleRedraw;

                    items.Add(header);
                    break;

                default:
                    items.Add(new TextSegment(Graphics, content.scrText, ScriptFont, true));
                    break;
                }
            }
        }