示例#1
0
        public static void KeepInCenter(this IHTMLElement e)
        {
            Action MoveToCenter =
                delegate
            {
                var w = Native.window.Width;
                var h = Native.window.Height;


                e.SetCenteredLocation(Native.document.body.scrollLeft + w / 2, Native.document.body.scrollTop + h / 2);
            };

            Native.window.onresize += delegate { MoveToCenter(); };

            MoveToCenter();
        }
        public HoverElement(string text, HoverManager m)
        {
            TextContent.nodeValue = text;

            Manager = m;

            ElementHeader.appendChild(Image, TextContent);
            ElementHeader.style.cursor = IStyle.CursorEnum.pointer;

            Element.appendChild(ElementHeader);

            Element.style.position         = IStyle.PositionEnum.relative;
            ElementHeader.style.fontWeight = "bold";
            Element.style.padding          = "2px";

            ImageStan.style.cursor = IStyle.CursorEnum.help;

            ImageStan.onclick +=
                delegate
            {
                Fader.FadeAndRemove(ImageStan, 9000, 400);

                Application.StreamLoremIpsum(Element);

                Element.style.width    = "400px";
                Element.style.overflow = IStyle.OverflowEnum.hidden;
            };

            Native.Document.body.onmousedown
                += e =>
                {
                bool b = IsNodeOrChildOfNode(ElementHeader, e.Element);

                if (b && !bDead)
                {
                    if (!isClone)
                    {
                        Clone();
                    }

                    Element.style.backgroundColor = Color.Black;
                    Element.style.color           = Color.White;
                    Element.style.Opacity         = 0.5;

                    bISDragging = true;

                    Element.SetCenteredLocation(e.CursorX, e.CursorY);

                    e.CaptureMouse();
                    //e.PreventDefault();
                    //e.StopPropagation();

                    Element.parentNode.appendChild(Element);
                }
                };

            Native.Document.onmouseup
                += delegate(IEvent e)
                {
                if (bISDragging)
                {
                    Element.style.backgroundColor = Color.White;
                    Element.style.color           = Color.Black;


                    bISDragging           = false;
                    Element.style.Opacity = 1;


                    bDead = !(--cTTL > 0);

                    if (bDead)
                    {
                        Fader.FadeAndRemove(Element);
                    }

                    e.preventDefault();
                    e.stopPropagation();
                }
                };

            Native.Document.onmousemove +=
                delegate(IEvent e)
            {
                if (bISDragging)
                {
                    Element.SetCenteredLocation(e.CursorX, e.CursorY);

                    e.preventDefault();
                    e.stopPropagation();
                }
            };

            Element.oncontextmenu +=
                delegate(IEvent e)
            {
                e.preventDefault();
            };

            Element.onmouseover +=
                delegate
            {
                if (!bDead && !bISDragging)
                {
                    ElementHeader.style.color = Color.Red;
                }
            };

            Element.onmouseout +=
                delegate
            {
                if (!bDead && !bISDragging)
                {
                    ElementHeader.style.color = "";
                }
            };
        }