コード例 #1
0
 public static void remove_menuItemSelect(ContextMenuItem that, Action<ContextMenuEvent> value)
 {
     CommonExtensions.RemoveDelegate(that, value, ContextMenuEvent.MENU_ITEM_SELECT);
 }
コード例 #2
0
        public ApplicationSprite()
        {

            var ctx = new ContextMenu();

            ctx.hideBuiltInItems();

            var dict = new
            {
                blog = "zproxy.zapto.org",
                project = "jsc.sourceforge.net"
            };

            var a = new ContextMenuItem(dict.blog);

            a.menuItemSelect +=
                e =>
                {
                    if (a.caption == dict.blog)
                        a.caption = dict.project;
                    else
                        a.caption = dict.blog;
                };


            ctx.customItems = ctx.customItems.Concat(new[] { a }).ToArray();

            this.contextMenu = ctx;




            var f1 = new TextField
            {
                text = "powered by jsc",
                x = 20,
                y = 40,
                selectable = false,
                multiline = true,
                autoSize = TextFieldAutoSize.LEFT,
                sharpness = -400,
                textColor = 0xffffff
            };
            stage.mouseMove +=
                ev =>
                {
                    f1.x = ev.stageX + 32;
                    f1.y = ev.stageY + 4;
                };


            addChild(f1);

            Action Toggle =
                delegate
                {
                    if (f1.parent == null)
                        addChild(f1);
                    else
                        removeChild(f1);
                };

            a.menuItemSelect +=
                delegate
                {
                    Toggle();
                };



            var circle1 = new Sprite();
            circle1.graphics.beginFill(0xFFCC00);
            circle1.graphics.drawCircle(40, 40, 20);
            circle1.graphics.endFill();

            circle1.buttonMode = true;
            circle1.click += delegate { Toggle(); };


            circle1.filters = new[]
                {
                    new GlowFilter
                    {
                        color = 0x00ff00,
                        blurX = 10,
                        blurY = 10
                    }
                };

            circle1.mouseOver +=
                delegate
                {
                    circle1.alpha = 1;
                };

            circle1.mouseOut +=
                delegate
                {
                    circle1.alpha = 0.3;
                };

            circle1.alpha = 0.1;
            var circle2 = new Sprite();
            circle2.graphics.beginFill(0xFFCC00);
            circle2.graphics.drawCircle(120, 40, 20);
            circle1.graphics.endFill();

            circle2.buttonMode = false;
            circle2.click += delegate { Toggle(); };

            addChild(circle1);
            addChild(circle2);

            var Header = new TextField
            {
                text = "Clicking on the orange buttons or on the context menu item will toggle the visibility of the white text near the cursor.",
                selectable = false,
                mouseEnabled = false,
                x = 2,
                y = 2,
                autoSize = TextFieldAutoSize.LEFT
            }.AttachTo(this);

            //try
            //{
            //     var BaseType = ctx.GetType().BaseType;


            //     Header.text = BaseType.FullName;

            //}
            //catch
            //{ 
            
            //}

            var input = new TextField
            {
                text = f1.text,
                type = TextFieldType.INPUT,
                width = 200,
                height = 60,
                multiline = true,
                background = true,
                backgroundColor = 0xffffff,

                y = 80,
                x = 20,
                border = true
            }.AttachTo(this);

            input.change +=
                delegate
                {
                    f1.text = input.text;
                };

        }
コード例 #3
0
		private void AddFullscreenMenu()
		{
			var GoFullScreen = new ContextMenuItem("Fullscreen");

			GoFullScreen.menuItemSelect +=
				delegate
				{
					stage.SetFullscreen(true);
				};

			this.contextMenu = new ContextMenu
			{
				customItems = new[] { GoFullScreen }
			};
		}