Пример #1
0
        private InteractiveHeaderedItem MessageToContent(ContentBody content, InteractiveItemsStack item, bool reply)
        {
            InteractiveHeaderedItem headerContent = PrepareMessagesHeader(content, item, reply);

            nodeContents.Add(headerContent);
            nodeContentNames.Add(headerContent, lineHeaderContent.ToString());
            nodeContentsByName.Add(lineHeaderContent.ToString(), headerContent);

            lineHeaderContent++;

            return(headerContent);
        }
Пример #2
0
        // создание заголовка раскрывающихся полей, и кнопки +/- для раскрытия Reply/Option
        protected InteractiveHeaderedItem PrepareMessagesHeader(ContentBody content, IDrawableRectangle item, bool reply)
        {
            #region Prepare Container
            DrawableItemsStack headerPlus  = new DrawableItemsStack();
            DrawableItemsStack headerMinus = new DrawableItemsStack();

            headerPlus.OrientationAxis  = Axis.X;
            headerMinus.OrientationAxis = Axis.X;
            #endregion

            #region Create Header

            TextSegment titleSegment = new TextSegment(Graphics, (reply) ? @"""" + content.msgText + @""""
                                                                             : (nodeLowDetails) ? "\u25CF " + content.msgText : content.msgText,
                                                       content.index, MessagesFont, true, reply);                       // GroupTitleFont

            if (!nodeLowDetails)
            {
                PlusShape plus = new PlusShape();
                plus.Border     = 4;
                plus.ScaleShape = false;
                plus.Width      = plus.ShapeWidth;
                plus.Height     = plus.ShapeHeight;
                headerPlus.Add(plus);

                MinusShape minus = new MinusShape();
                minus.Border     = 4;
                minus.ScaleShape = false;
                minus.Width      = minus.ShapeWidth;
                minus.Height     = minus.ShapeHeight;
                headerMinus.Add(minus);
            }
            headerPlus.Add(titleSegment);
            headerMinus.Add(titleSegment);

            //пиктограмма
            //if (!reply) {
            //    DrawableItemsStack<VectorShape> image = new DrawableItemsStack<VectorShape>();
            //    image.OrientationAxis = Axis.X;
            //    image.KeepAspectRatio = true;
            //    image.Border = -3.0f;
            //    image.Add(new OptionsCircleShape());

            //    headerPlus.Add(image);
            //    headerMinus.Add(image);
            //}

            DrawableItemsStack headerCollapsed = new DrawableItemsStack();
            DrawableItemsStack headerExpanded  = new DrawableItemsStack();

            headerCollapsed.OrientationAxis = Axis.Z;
            headerExpanded.OrientationAxis  = Axis.Z;

            headerCollapsed.Add(new DrawableRectangle((reply) ? ReplyTitlesBackground : OptionTitlesBackground, null, 5, 5, 5, 5));
            headerCollapsed.Add(headerPlus);

            headerExpanded.Add(new DrawableRectangle((reply) ? ReplyTitlesBackground : OptionTitlesBackground, null, 5, 5, 0, 0));
            headerExpanded.Add(headerMinus);

            #endregion

            InteractiveHeaderedItem tg = new InteractiveHeaderedItem(headerCollapsed, headerExpanded, item);

            tg.Collapsed = true;

            // событие, клик мышкой по элементу строки кода
            tg.HeaderClicked += delegate(object sender, PointF e)
            {
                if (Math.Abs(tg.AbsoluteX - e.X) < 20 && Math.Abs(tg.AbsoluteY - e.Y) < 20)
                {
                    tg.Collapsed = !tg.Collapsed;
                }
                else
                {
                    ContentClick(this, titleSegment);
                }
            };

            // старый вариант
            //IMouseInteractable interactive = content as IMouseInteractable;
            //if (interactive != null) {
            //    tg.ContentClicked += delegate { tgContentClicked(interactive, tg); };
            //    //оригинальное событие
            //    //tg.ContentClicked += delegate (object sender, PointF pos) {
            //    //    interactive.HandleMouseClick(pos);
            //    //};
            //}

            tg.RedrawNeeded += HandleRedraw;

            return(tg);
        }