Exemplo n.º 1
0
 public static Timer AutoRotate(this Dude e, double multiplier)
 {
     return(new Timer(
                t => e.Rotation16 = System.Convert.ToInt32(t.Counter * multiplier), 0, 100
                ));
 }
Exemplo n.º 2
0
        //public const string Alias = "Class1";
        //public const string DefaultData = "Class1Data";

        /// <summary>
        /// Creates a new control
        /// </summary>
        /// <param name="DataElement">The hidden data element</param>
        public Class1(IHTMLElement DataElement)
        {
            IStyleSheet.Default.AddRule("*", "cursor: url('assets/NatureBoy/cursor.cur'), auto;", 0);

            IStyleSheet.Default.AddRule("body",
                r =>
                {
                    r.style.backgroundColor = Color.Gray;
                    r.style.overflow = IStyle.OverflowEnum.hidden;
                    r.style.padding = "0px";
                }
            );

            IStyleSheet.Default.AddRule(".stage",
                r =>
                {
                    r.style.backgroundColor = Color.White;

                    r.style.position = IStyle.PositionEnum.absolute;
                    r.style.left = "0px";
                    r.style.top = "0px";
                    r.style.right = "0px";
                    r.style.bottom = "0px";
                    r.style.Opacity = 0.0;
                }
            );



            var bg = new IHTMLImage("assets/NatureBoy/back/IMG_0572.jpg");

            bg.style.position = IStyle.PositionEnum.absolute;
            bg.style.SetLocation(0, 0);
            bg.style.width = "100%";
            bg.AttachToDocument();



            var stage = new IHTMLDiv { className = "stage" };

            stage.AttachToDocument();


            var dude4 = new Dude { ZoomFunc = y => (y + 300) / (600) };

            dude4.TeleportTo(200, 200);
            dude4.Control.AttachToDocument();
            dude4.AutoRotate(1);

            var dude5 = new Dude { ZoomFunc = dude4.ZoomFunc };

            dude5.TeleportTo(600, 300);
            dude5.Control.AttachToDocument();
            dude5.AutoRotateToCursor(stage);

            var dude6 = new Dude { ZoomFunc = dude4.ZoomFunc };

            dude6.TeleportTo(300, 400);
            dude6.Control.AttachToDocument();

            var dude7 = new Dude { ZoomFunc = dude4.ZoomFunc };

            dude7.TeleportTo(200, 400);
            dude7.Control.AttachToDocument();

            var dude8 = new Dude { ZoomFunc = dude4.ZoomFunc };

            dude8.TeleportTo(250, 300);
            dude8.Control.AttachToDocument();

            var CurrentDude = default(Dude);

            Action<Dude> SelectDude = i =>
                                          {
                                              if (CurrentDude != null)
                                                  CurrentDude.IsSelected = false;

                                              CurrentDude = i;
                                              CurrentDude.IsSelected = true;
                                          };

            Action<Dude> BindSelectDude =
                i => i.Control.onclick += delegate { SelectDude(i); };

            BindSelectDude(dude6);
            BindSelectDude(dude7);
            BindSelectDude(dude8);


            stage.onclick +=
                delegate(IEvent ev)
                {
                    CurrentDude.WalkTo(ev.CursorPosition);

                    dude5.WalkTo(ev.CursorPosition);
                };

        }