public void MoveEnemy( int direction, short speed, Character character) { switch (direction) { case 0: // Up to down MoveTo(X, (short)(Y + speed)); EnemyImage.MoveTo(X, (short)(Y + speed)); break; case 1: // Right to left MoveTo((short)(X - speed), Y); EnemyImage.MoveTo((short)(X - speed), Y); break; case 2: // Down to up MoveTo(X, (short)(Y - speed)); EnemyImage.MoveTo(X, (short)(Y - speed)); break; case 3: // Left to right MoveTo((short)(X + speed), Y); EnemyImage.MoveTo((short)(X + speed), Y); break; default: break; } }
public Token(short num) { switch (num) { case 1: tokenImg = new Image("Images/iron.png", 50, 50); break; case 2: tokenImg = new Image("Images/ship.png", 50, 52); break; case 3: tokenImg = new Image("Images/boot.png", 50, 52); break; case 4: tokenImg = new Image("Images/car.png", 50, 38); break; case 5: tokenImg = new Image("Images/hat.png", 67, 50); break; } X = Y = 530; tokenImg.MoveTo(X, Y); }
public NumPlayersScreen(Hardware hardware) : base(hardware) { //Fonts font20 = new Font("Fonts/riffic-bold.ttf", 20); font25 = new Font("Fonts/comic.ttf", 25); NumPlayers = 2; exit = false; background = new Image("Images/background.jpg", 1440, 1000); arrow = new Image("Images/arrowRed.png", 19, 100); xArrow = 360; arrow.MoveTo(xArrow, 400); //Future array iron = new Image("Images/iron.png", 50, 50); iron.MoveTo(340, 350); ship = new Image("Images/ship.png", 50, 52); ship.MoveTo(420, 350); boot = new Image("Images/boot.png", 50, 52); boot.MoveTo(500, 350); car = new Image("Images/car.png", 50, 38); car.MoveTo(580, 350); hat = new Image("Images/hat.png", 67, 50); hat.MoveTo(660, 350); }
public override void Show() { audio.PlayMusic(0, -1); bakcGround.MoveTo(0, 0); spacePressed = false; Draw(); do { int keyPressed = hardware.KeyPressed(); /*Two conditions to equalize the joystick movement with the * keyboard pulsations*/ if (Hardware.JoystickPressed(0)) { keyPressed = Hardware.KEY_SPACE; Thread.Sleep(70); } else if (Hardware.JoystickPressed(1)) { keyPressed = Hardware.KEY_ESC; Thread.Sleep(70); } if (keyPressed == Hardware.KEY_SPACE || keyPressed == Hardware.KEY_ESC) { spacePressed = true; } Thread.Sleep(10); } while (spacePressed != true); audio.StopMusic(); }
public override void Show() { //add bool enterPressed = false; Lenguage len = new Lenguage(); do { hardware.ClearScreen(); hardware.DrawImage(imgWelcome); hardware.DrawImage(imgChosenOption); fontSpanish = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), len.Change(option, 19), yellow); hardware.WriteText(fontSpanish, 325, 430); fontEnglish = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), len.Change(option, 18), yellow); hardware.WriteText(fontEnglish, 325, 475); int keyPressed = hardware.KeyPressed(); if (keyPressed == Hardware.KEY_UP && chosenOption > 1) { audio.PlayWAV(0, 1, 0); chosenOption--; option = 0; imgChosenOption.MoveTo(245, (short)(imgChosenOption.Y - 45)); } else if (keyPressed == Hardware.KEY_DOWN && chosenOption < 2) { audio.PlayWAV(0, 1, 0); chosenOption++; option = 1; imgChosenOption.MoveTo(245, (short)(imgChosenOption.Y + 45)); } else if (keyPressed == Hardware.KEY_ENTER && chosenOption == 1) { enterPressed = true; exit = true; } else if (keyPressed == Hardware.KEY_ENTER && chosenOption == 2) { enterPressed = true; exit = true; } hardware.UpdateScreen(); }while (!enterPressed); }
public OptionsScreen(Hardware hardware) : base(hardware) { font = new Font("fonts/Nashville.ttf", 33); bakcGround = new Image("imgs/Options.png", 1200, 720); audio = new Audio(44100, 2, 4096); audio.AddMusic("sound/adagio-for-strings.mid"); bakcGround.MoveTo(0, 0); }
public HelpScreen(Hardware hardware) : base(hardware) { font = new Font("fonts/Nashville.ttf", 33); bakcGround = new Image("imgs/Help.png", 1200, 720); audio = new Audio(44100, 2, 4096); audio.AddMusic("sound/Wistful-for-piano.mid"); bakcGround.MoveTo(0, 0); }
public MenuScreen(Hardware hardware) : base(hardware) { menuImage = new Image("imgs/background2.png", 932, 600); imgSelectOption = new Image("imgs/choose_player.png", 48, 48); imgSelectOption.MoveTo(300, 200); font = new Font("font/menu_text.ttf", 40); bigFont = new Font("font/chargen.ttf", 70); MenuOption = 0; }
public HordeModeScreen(Hardware hardware) : base(hardware) { GameController.lastGame = 2; level0 = new Image("imgs/Map2.png", 1200, 720); audio = new Audio(44100, 2, 4096); audio.AddMusic("sound/Apocalypse.mid"); level0.MoveTo(0, 0); NewEnemy(); }
public ControllerScreen(Hardware hardware) : base(hardware) { exit = false; audio = new Audio(44100, 2, 4096); audio.AddWAV("music/reset.wav"); imgController = new Image("imgs/ControllerScreen.png", 840, 755); imgController.MoveTo(0, 0); font = new Font("font/Joystix.ttf", 10); yellow = new Sdl.SDL_Color(255, 255, 0); }
public ControllerScreen(Hardware hardware) : base(hardware) { exit = false; audio = new Audio(44100, 2, 4096); audio.AddWAV("music/reset.wav"); imgController = new Image("imgs/SettingsScreen.png", 800, 700); //imgChosenOption = new Image("imgs/BombMenu1.png", 50, 50); imgController.MoveTo(0, 0); //imgChosenOption.MoveTo(240, 390); }
private void drawTokens() { hardware.DrawImage(boot); hardware.DrawImage(hat); hardware.DrawImage(car); hardware.DrawImage(iron); hardware.DrawImage(ship); hardware.DrawImage(arrow); arrow.MoveTo(xArrow, 400); }
public Action this[int x, int y] { get { return(delegate { Image.MoveTo(-x * Width, -y * Height); }); } }
public WelcomeScreen(Hardware hardware) : base(hardware) { exit = false; audio = new Audio(44100, 2, 4096); audio.AddWAV("music/reset.wav"); imgWelcome = new Image("imgs/MenuPrincipal.png", 840, 755); imgChosenOption = new Image("imgs/BombMenu1.png", 50, 50); imgWelcome.MoveTo(0, 0); imgChosenOption.MoveTo(245, 420); }
public override void Show() { background.MoveTo(0, 0); do { // Draw everything. hardware.ClearScreen(); hardware.DrawImage(background); hardware.WriteText(enterName, 10, 10); hardware.UpdateScreen(); }while (!getExit()); }
public void Draw(Hardware h) { imageLeft.MoveTo(X, Y); imageRight.MoveTo(X, Y); if (lookingLeft) { h.DrawImage(imageLeft); } else { h.DrawImage(imageRight); } }
public override void Show() { bool isOptionSelected = false; background.MoveTo(0, 0); do { hardware.ClearScreen(); hardware.DrawImage(background); for (int level = 0; level < amountOfTexts; level++) { if (level == ActualLevel) { hardware.WriteText( levelsTextWhite[level], 40, (short)(50 * level)); } else { hardware.WriteText( levelsTextRed[level], 40, (short)(50 * level)); } } if (languageController.isInSpanish) { hardware.WriteText( pressEnterSpanish, (short)(GameController.SCREEN_WIDTH / 2 - 150), (short)(GameController.SCREEN_HEIGHT - 30)); } else { hardware.WriteText( pressEnterEnglish, (short)(GameController.SCREEN_WIDTH / 2 - 150), (short)(GameController.SCREEN_HEIGHT - 30)); } hardware.UpdateScreen(); isOptionSelected = CheckInput(); if (isOptionSelected) { selectedLevel = levelPaths[ActualLevel]; } }while (!isOptionSelected); GameScreen game = new GameScreen( hardware, new Level(selectedLevel), languageController); game.Show(); }
public SelectLenguage(Hardware hardware) : base(hardware) { exit = false; audio = new Audio(44100, 2, 4096); audio.AddWAV("music/reset.wav"); imgWelcome = new Image("imgs/MenuPrincipal.png", 840, 755); imgChosenOption = new Image("imgs/BombMenu1.png", 50, 50); font = new Font("font/Joystix.ttf", 28); imgWelcome.MoveTo(0, 0); imgChosenOption.MoveTo(245, 420); yellow = new Sdl.SDL_Color(255, 255, 0); }
public IntroScreen(Hardware hardware) : base(hardware) { bakcGround = new Image("imgs/IntroScreen2.png", 1200, 720); audio = new Audio(44100, 2, 4096); audio.AddMusic("sound/IntroTheme.mid"); font = new Font("fonts/NexaRustSlab-BlackShadow01.otf", 35); bakcGround.MoveTo(0, 0); Sdl.SDL_Color white = new Sdl.SDL_Color(255, 255, 255); Englis = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Press space/A escape/B to continue", white); Castellano = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Espacio o A para Castellano", white); Englis = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Escape or B for English", white); }
public SettingScreen(Hardware hardware) : base(hardware) { exit = false; audio = new Audio(44100, 2, 4096); audio.AddWAV("music/reset.wav"); font = new Font("font/Joystix.ttf", 28); imgSetting = new Image("imgs/SettingsScreen.png", 840, 755); imgChosenOption = new Image("imgs/select.png", 40, 35); game = new GameScreen(hardware); imgSetting.MoveTo(0, 0); imgChosenOption.MoveTo(170, 240); white = new Sdl.SDL_Color(255, 255, 255); }
public MainMenuScreen(Hardware hardware) : base(hardware) { font = new Font("fonts/Abberancy.ttf", 45); InitText(); bakcGround = new Image("imgs/Test.png", 1200, 720); imgChoseOption = new Image("imgs/choose_player.png", 48, 48); audio = new Audio(44100, 2, 4096); audio2 = new Audio(44100, 2, 4096); audio.AddMusic("sound/song_a.mid"); audio2.AddWAV("sound/fire.Wav"); imgChoseOption.MoveTo((short)(470 + len), 105); bakcGround.MoveTo(0, 0); }
public ScoreBoardScreen(Hardware hardware) : base(hardware) { scoreList = GameScreen.scoreList; scorePtr = new IntPtr[scoreList.Count]; font = new Font("fonts/Abberancy.ttf", 35); bakcGround = new Image("imgs/fondoNegro.png", 1200, 720); audio = new Audio(44100, 2, 4096); audio.AddMusic("sound/Wistful-for-piano.mid"); audio2 = new Audio(44100, 2, 4096); audio2.AddWAV("sound/fire.Wav"); bakcGround.MoveTo(0, 0); InitText(); }
public MapCreationScreen(Hardware hardware) : base(hardware) { font20 = new Font("font/Joystix.ttf", 20); imgMap = new Image("imgs/MapScreen.png", 840, 105); imgFloor = new Image("imgs/Floor.png", 840, 680); imgCursor = new Image("imgs/cursor.png", 40, 40); imgMap.MoveTo(0, 640); imgFloor.MoveTo(0, 0); imgCursor.MoveTo(40, 40); white = new Sdl.SDL_Color(255, 255, 255); Bricks = new List <Sprite>(); BricksDestroyable = new List <Sprite>(); font32 = new Font("font/Joystix.ttf", 32); font16 = new Font("font/Joystix.ttf", 16); yellow = new Sdl.SDL_Color(255, 255, 0); }
public override void OnPointerClick(PointerEventData eventData) { if (!blocker) { blocker = true; if (equip) { image.transform.SetParent(transform.GetParentCanvas().transform, true); image.ScaleTo(new Vector2(0.2f, 0.2f), 0.4f); image.MoveTo(330f, -600f, 0.4f).SetFinalMessage(gameObject, "OnArrivedToHome", null, SendMessageOptions.DontRequireReceiver); bg.SetActive(false); } else { Destroy(gameObject); } } }
public ApplicationCanvas() { // http://msdn.microsoft.com/en-us/library/system.windows.controls.childwindow(VS.95).aspx // http://jsprunger.com/getting-started-with-lucene-net/ //r.Opacity = 0.1; // if we only had this... // http://forum.tabletpcreview.com/microsoft-windows-7-forum/34430-windows-7-multi-touch-magnifier.html // http://www.fredshead.info/2010/02/windows-7-magnifier.html r.Stretch = Stretch.Fill; r.AttachTo(this); r.MoveTo(8, 8); this.SizeChanged += (s, e) => r.SizeTo(this.Width - 16.0, this.Height - 16.0); // DPI? :) CreateWindow( new Position { Top = 72, Left = 48, Width = 100, Height = 100 } ); var p2 = new Position { Top = 128, Left = 72, Width = 400, Height = 300 }; CreateWindow( p2, value => Selection = value ); }
public GameScreen(Hardware hardware) : base(hardware) { // preload text font28 = new Font("font/Joystix.ttf", 28); font36 = new Font("font/Joystix.ttf", 36); white = new Sdl.SDL_Color(255, 255, 255); fontLives = SdlTtf.TTF_RenderText_Solid(font28.GetFontType(), lives.ToString(), white); // preload images imgFloor = new Image("imgs/Floor.png", 840, 680); imgFloor.MoveTo(0, 0); imgInfo = new Image("imgs/InfoPanel.png", 840, 75); imgInfo.MoveTo(0, 680); // preload level level = new Level("levels/level1.txt"); playerWhite = new PlayerWhite(); playerRed = new PlayerRed(); }
public override void Show() { int animCoordinates = 0; background.MoveTo(0, 0); Canexit = false; do { if (animCoordinates < 250) { title.MoveTo( (short)((Program.SCREEN_WIDTH / 2) - (title.ImageWidth / 2)), (short)(-200 + animCoordinates)); } hardware.ClearScreen(); hardware.DrawImage(background); hardware.DrawImage(title); AnimateSamus(); hardware.UpdateScreen(); if (hardware.IsKeyPressed(Hardware.KEY_SPACE)) { Canexit = true; } if (!hardware.IsKeyPressed(Hardware.KEY_SPACE) && Canexit) { exit = true; } animCoordinates++; }while (!exit); }
public GameScreen(Hardware hardware) : base(hardware) { // preload text font28 = new Font("font/Joystix.ttf", 28); font36 = new Font("font/Joystix.ttf", 36); white = new Sdl.SDL_Color(255, 255, 255); // preload images imgFloor = new Image("imgs/Floor.png", 840, 680); imgFloor.MoveTo(0, 0); imgInfo = new Image("imgs/InfoPanel.png", 840, 75); imgInfo.MoveTo(0, 680); bomb1 = new Image("imgs/bomb1.png", 40, 40); bomb2 = new Image("imgs/bomb2.png", 40, 40); bomb3 = new Image("imgs/bomb3.png", 40, 40); playerWhite = new PlayerWhite(); playerRed = new PlayerRed(); bomb = new Bombs(); audio = new Audio(44100, 2, 4096); audio.AddMusic("music/BombermanNES.wav"); controller = new ControllerScreen(hardware); }
public OrcasAvalonApplicationCanvas() { Width = DefaultWidth; Height = DefaultHeight; this.ClipToBounds = true; Colors.Blue.ToGradient(Colors.Red, DefaultHeight / 4).Select( (c, i) => new Rectangle { Fill = new SolidColorBrush(c), Width = DefaultWidth, Height = 4, }.MoveTo(0, i * 4).AttachTo(this) ).ToArray(); var help_idle = new Image { Source = (KnownAssets.Path.Assets + "/help_idle.png").ToSource() }.AttachTo(this); var help = new Image { Source = (KnownAssets.Path.Assets + "/help.png").ToSource() }.AttachTo(this); help.Opacity = 0; var img = new Image { Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource() }.MoveTo(DefaultWidth - 128, DefaultHeight - 128).AttachTo(this); (1000 / 30).AtIntervalWithCounter( c => { img.MoveTo(DefaultWidth - 128, DefaultHeight - 128 + Math.Sin(c * 0.1) * 4 ); } ); var t = new TextBox { AcceptsReturn = true, FontSize = 10, Text = "powered by jsc", BorderThickness = new Thickness(0), Foreground = Brushes.Blue, Background = Brushes.White, IsReadOnly = true, Width = 400, Height = 400 }.MoveTo(32, 32).AttachTo(this); var cc = 0; this.MouseLeftButtonUp += delegate { cc++; if (cc % 2 == 1) { t.Text = "saving..."; var r = new FileDialog(); var z = new ZIPFile { {"default.txt", "hello world"}, {"readme.txt", "this was created in flash via c#"} }; var m = z.ToBytes(); r.Save(new MemoryStream(m), "archive1.zip"); var w = new StringBuilder(); var xxi = 0; foreach (var xx in m) { xxi++; w.Append(" " + xx.ToString("x2")); if ((xxi % 16) == 0) w.AppendLine(); } t.Text = w.ToString(); } else { t.Text = "loading..."; var r = new FileDialog(); r.Open( m => { m.Position = 0; ZIPFile z = m; var w = new StringBuilder(); foreach (var zf in z.Entries) { w.AppendLine(zf.FileName); var xxi = 0; foreach (var xx in zf.Bytes) { xxi++; w.Append(" " + xx.ToString("x2")); if ((xxi % 16) == 0) w.AppendLine(); } w.AppendLine(); w.AppendLine(zf.Text); } t.Text = w.ToString(); } ); } }; }
public OrcasAvalonApplicationCanvas() { Width = DefaultWidth; Height = DefaultHeight; this.ClipToBounds = true; Colors.Blue.ToGradient(Colors.Black, DefaultHeight / 4).Select( (c, i) => new Rectangle { Fill = new SolidColorBrush(c), Width = DefaultWidth, Height = 5, }.MoveTo(0, i * 4).AttachTo(this) ).ToArray(); var mouse = new Image { Source = (KnownAssets.Path.Assets + "/mouse.png").ToSource(), Width = 32, Height = 32 }.MoveTo(0, 0).AttachTo(this); var img = new Image { Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource() }.MoveTo(DefaultWidth - 96, 0).AttachTo(this); var Content = new Canvas { Width = DefaultWidth, Height = DefaultHeight, }.AttachTo(this); var ContentY = new AnimatedDouble(0); ContentY.ValueChanged += y => Content.MoveTo(0, y); { var maze = new MazeGenerator(12, 8, null); var blocks = new BlockMaze(maze); var w = new BlockMaze(maze); Colors.Black.ToGradient(Colors.Yellow, 30).ForEach( (c, i) => RenderMaze(60 + i * 0.1, w, new SolidColorBrush(c), Content) ); } var TouchOverlay = new Rectangle { Fill = Brushes.Yellow, Opacity = 0, Width = DefaultWidth, Height = DefaultHeight }.AttachTo(this); TouchOverlay.MouseEnter += delegate { mouse.Show(); }; TouchOverlay.MouseLeave += delegate { mouse.Hide(); }; TouchOverlay.Cursor = Cursors.None; TouchOverlay.MouseMove += (s, args) => { var p = args.GetPosition(this); mouse.MoveTo(p.X - 4, p.Y - 4); }; TouchOverlay.MouseLeftButtonUp += (s, args) => { var p = args.GetPosition(this); ShowExplosion(Convert.ToInt32(p.X), Convert.ToInt32(p.Y), Content); ("assets/AvalonMouseMaze/explosion.mp3").PlaySound(); 150.AtDelay( delegate { ShowExplosion(Convert.ToInt32(p.X + 6), Convert.ToInt32(p.Y - 6), Content); } ); 300.AtDelay( delegate { ShowExplosion(Convert.ToInt32(p.X + 4), Convert.ToInt32(p.Y + 6), Content); ContentY.SetTarget(DefaultHeight); } ); 1500.AtDelay( delegate { ContentY.SetTarget(0); } ); }; new GameMenuWithGames(DefaultWidth, DefaultHeight, 32).AttachContainerTo(this).Hide(); }
public SimpleCarouselControl(int DefaultWidth, int DefaultHeight) { this.Container = new Canvas { Width = DefaultWidth, Height = DefaultHeight }; var ContentContainer = new Canvas { Width = DefaultWidth, Height = DefaultHeight }.AttachTo(this.Container); this.Caption = new TextBox { Width = DefaultWidth, Height = 32, TextAlignment = TextAlignment.Center, Foreground = Brushes.White, BorderThickness = new Thickness(0), Background = Brushes.Transparent, IsReadOnly = true }.MoveTo(0, (DefaultHeight - 32) / 2).AttachTo(this.Container); this.Overlay = new Canvas { Width = DefaultWidth, Height = DefaultHeight, }; var OverlayFill = new Rectangle { Width = DefaultWidth, Height = DefaultHeight, Fill = Brushes.Red, Opacity = 0 }.AttachTo(this.Overlay); var a = new List <Entry>(); var OverlayReorderingEnabled = true; #region Timer this.Timer = (1000 / 30).AtInterval( delegate { a.ForEach(k => k.Tick()); a.OrderBy(k => k.cy).ForEach( k => { if (OverlayReorderingEnabled) { // in javascript reordering an element under mouse // will leave you without the leave event // we could sort other nodes around it tho k.Overlay.Orphanize(); k.Overlay.AttachTo(this.Overlay); } k.pc.Orphanize(); k.pc.AttachTo(this.Container); } ); } ); #endregion var s = 0.01; this.AddEntry = e => { var pc_Width = 166 + 9; var pc_Height = 90 + 9 * 2; var pc = new Canvas { //Background = Brushes.Green, Width = pc_Width, Height = pc_Height }.AttachTo(ContentContainer); const string Assets = "assets/ScriptCoreLib.Avalon.Carousel"; var p = new Image { Width = 166, Height = 90, Stretch = Stretch.Fill, Source = (Assets + "/PreviewShadow.png").ToSource() }.AttachTo(pc); var ps = new Image { Width = 138, Height = 108, Stretch = Stretch.Fill, Source = (Assets + "/PreviewSelection.png").ToSource() }.AttachTo(pc); var pi = new Image { Width = 120, Height = 90, Stretch = Stretch.Fill, Source = e.Source, Cursor = Cursors.Hand }.AttachTo(pc); var Overlay_Width = 120; var Overlay_Height = 90; var Overlay = new Rectangle { Fill = Brushes.Black, Width = Overlay_Width, Height = Overlay_Height, Cursor = Cursors.Hand, Opacity = 0 }.AttachTo(this.Overlay); ps.Hide(); Overlay.TouchDown += (sender, ee) => { ee.Handled = true; if (e.Click != null) { e.Click(); } }; Overlay.TouchMove += (sender, ee) => { ee.Handled = true; }; Overlay.TouchUp += (sender, ee) => { ee.Handled = true; }; Overlay.MouseLeftButtonUp += (sender, ee) => { ee.Handled = true; if (e.Click != null) { e.Click(); } }; var IsHot = false; Overlay.MouseLeave += delegate { OverlayReorderingEnabled = true; if (e.Text != null) { this.Caption.Text = ""; } if (Idle != null) { Idle(); } }; Overlay.MouseEnter += delegate { OverlayReorderingEnabled = false; if (e.MouseEnter != null) { e.MouseEnter(); } if (Hover != null) { Hover(e); } if (e.Text != null) { this.Caption.Text = e.Text; } IsHot = true; s = 0.004; p.Opacity = 1; pi.Opacity = 1; a.ForEach( k => { if (k.ps == ps) { ps.Show(); } else { k.ps.Hide(); } } ); }; var MyEntry = new Entry { o = 1, cy = 0, pc = (Canvas)pc, ps = (Image)ps, Overlay = (Rectangle)Overlay, Info = e }; //var o = new Boxed<double>(); //var _cy = new Boxed<double>(); Overlay.MouseLeave += delegate { if (e.MouseLeave != null) { e.MouseLeave(); } IsHot = false; p.Opacity = MyEntry.o; pi.Opacity = MyEntry.o; s = 0.01; ps.Hide(); }; #region Tick MyEntry.Tick = delegate { var x = Math.Cos(e.Position); var y = Math.Sin(e.Position); var z = (y + 3) / 4; MyEntry.o = z; if (!IsHot) { pi.Opacity = MyEntry.o; //p.Opacity = MyEntry.o; } e.Position += s * z; pc.Width = pc_Width * z; pc.Height = pc_Height * z; Overlay.Width = Overlay_Width * z; Overlay.Height = Overlay_Height * z; p.Width = 166 * z; p.Height = 90 * z; pi.Width = 120 * z; pi.Height = 90 * z; ps.Width = 138 * z; ps.Height = 108 * z; var cx = x * (DefaultWidth - 160) / 2 + DefaultWidth / 2; var cy = y * (DefaultHeight / 2) / 2 + DefaultHeight / 2; MyEntry.cy = cy; pc.MoveTo( cx - pc.Width / 2, cy - pc.Height / 2 ); p.MoveTo( z * 9, z * 9 ); pi.MoveTo( z * 9, z * 9 ); ps.MoveTo( 0, 0 ); Overlay.MoveTo( cx - pc.Width / 2 + 9 * z, cy - pc.Height / 2 + 9 * z ); }; #endregion a.Add( MyEntry ); MyEntry.Tick(); }; }
public SimpleCarouselControl(int DefaultWidth, int DefaultHeight) { this.Container = new Canvas { Width = DefaultWidth, Height = DefaultHeight }; var ContentContainer = new Canvas { Width = DefaultWidth, Height = DefaultHeight }.AttachTo(this.Container); this.Caption = new TextBox { Width = DefaultWidth, Height = 32, TextAlignment = TextAlignment.Center, Foreground = Brushes.White, BorderThickness = new Thickness(0), Background = Brushes.Transparent, IsReadOnly = true }.MoveTo(0, (DefaultHeight - 32) / 2).AttachTo(this.Container); this.Overlay = new Canvas { Width = DefaultWidth, Height = DefaultHeight, }; var OverlayFill = new Rectangle { Width = DefaultWidth, Height = DefaultHeight, Fill = Brushes.Red, Opacity = 0 }.AttachTo(this.Overlay); var a = new List<Entry>(); var OverlayReorderingEnabled = true; #region Timer this.Timer = (1000 / 30).AtInterval( delegate { a.ForEach(k => k.Tick()); a.OrderBy(k => k.cy).ForEach( k => { if (OverlayReorderingEnabled) { // in javascript reordering an element under mouse // will leave you without the leave event // we could sort other nodes around it tho k.Overlay.Orphanize(); k.Overlay.AttachTo(this.Overlay); } k.pc.Orphanize(); k.pc.AttachTo(this.Container); } ); } ); #endregion var s = 0.01; this.AddEntry = e => { var pc_Width = 166 + 9; var pc_Height = 90 + 9 * 2; var pc = new Canvas { //Background = Brushes.Green, Width = pc_Width, Height = pc_Height }.AttachTo(ContentContainer); const string Assets = "assets/ScriptCoreLib.Avalon.Carousel"; var p = new Image { Width = 166, Height = 90, Stretch = Stretch.Fill, Source = (Assets + "/PreviewShadow.png").ToSource() }.AttachTo(pc); var ps = new Image { Width = 138, Height = 108, Stretch = Stretch.Fill, Source = (Assets + "/PreviewSelection.png").ToSource() }.AttachTo(pc); var pi = new Image { Width = 120, Height = 90, Stretch = Stretch.Fill, Source = e.Source, Cursor = Cursors.Hand }.AttachTo(pc); var Overlay_Width = 120; var Overlay_Height = 90; var Overlay = new Rectangle { Fill = Brushes.Black, Width = Overlay_Width, Height = Overlay_Height, Cursor = Cursors.Hand, Opacity = 0 }.AttachTo(this.Overlay); ps.Hide(); Overlay.TouchDown += (sender, ee) => { ee.Handled = true; if (e.Click != null) e.Click(); }; Overlay.TouchMove += (sender, ee) => { ee.Handled = true; }; Overlay.TouchUp += (sender, ee) => { ee.Handled = true; }; Overlay.MouseLeftButtonUp += (sender, ee) => { ee.Handled = true; if (e.Click != null) e.Click(); }; var IsHot = false; Overlay.MouseLeave += delegate { OverlayReorderingEnabled = true; if (e.Text != null) this.Caption.Text = ""; if (Idle != null) Idle(); }; Overlay.MouseEnter += delegate { OverlayReorderingEnabled = false; if (e.MouseEnter != null) e.MouseEnter(); if (Hover != null) Hover(e); if (e.Text != null) this.Caption.Text = e.Text; IsHot = true; s = 0.004; p.Opacity = 1; pi.Opacity = 1; a.ForEach( k => { if (k.ps == ps) { ps.Show(); } else { k.ps.Hide(); } } ); }; var MyEntry = new Entry { o = 1, cy = 0, pc = (Canvas)pc, ps = (Image)ps, Overlay = (Rectangle)Overlay, Info = e }; //var o = new Boxed<double>(); //var _cy = new Boxed<double>(); Overlay.MouseLeave += delegate { if (e.MouseLeave != null) e.MouseLeave(); IsHot = false; p.Opacity = MyEntry.o; pi.Opacity = MyEntry.o; s = 0.01; ps.Hide(); }; #region Tick MyEntry.Tick = delegate { var x = Math.Cos(e.Position); var y = Math.Sin(e.Position); var z = (y + 3) / 4; MyEntry.o = z; if (!IsHot) { pi.Opacity = MyEntry.o; //p.Opacity = MyEntry.o; } e.Position += s * z; pc.Width = pc_Width * z; pc.Height = pc_Height * z; Overlay.Width = Overlay_Width * z; Overlay.Height = Overlay_Height * z; p.Width = 166 * z; p.Height = 90 * z; pi.Width = 120 * z; pi.Height = 90 * z; ps.Width = 138 * z; ps.Height = 108 * z; var cx = x * (DefaultWidth - 160) / 2 + DefaultWidth / 2; var cy = y * (DefaultHeight / 2) / 2 + DefaultHeight / 2; MyEntry.cy = cy; pc.MoveTo( cx - pc.Width / 2, cy - pc.Height / 2 ); p.MoveTo( z * 9, z * 9 ); pi.MoveTo( z * 9, z * 9 ); ps.MoveTo( 0, 0 ); Overlay.MoveTo( cx - pc.Width / 2 + 9 * z, cy - pc.Height / 2 + 9 * z ); }; #endregion a.Add( MyEntry ); MyEntry.Tick(); }; }
public ApplicationCanvas() { var Container720X = new Canvas().AttachTo(this); Container720 = new Canvas().AttachTo(Container720X); //Container720A = Container720.ToAnimatedOpacity(); i = new Avalon.Images.Promotion3D_controller_720p(); i.AttachTo(Container720); iA = i.ToAnimatedOpacity(); iA.Opacity = 0.8; var ShadowOverlay = new Rectangle { Fill = Brushes.Black }; var ShadowOverlayA = ShadowOverlay.ToAnimatedOpacity(); ShadowOverlay.AttachTo(Container720); ShadowOverlay.SizeTo(1280, 720); ii = new Avalon.Images.Promotion3D_controller_android_720(); ii.AttachTo(Container720); var iiA = ii.ToAnimatedOpacity(); var Title = new Avalon.Images.Title(); Title.AttachTo(Container720X); this.SizeChanged += (s, e) => { Container720X.MoveTo( (this.Width - 1280) / 2, (this.Height - 720) / 2 ); Console.WriteLine(new { this.Width, this.Height }); }; enter = new Avalon.Images.start { Cursor = Cursors.Hand }.AttachTo(this); entero = enter.ToAnimatedOpacity(); this.SizeChanged += (s, e) => enter.MoveTo( (this.Width - 128) * 0.8 + 64, (this.Height - 128) / 2 + 32); #region Black { Rectangle r = new Rectangle(); r.Fill = Brushes.Black; r.AttachTo(this); r.MoveTo(0, 0); this.SizeChanged += (s, e) => { r.Width = this.Width; r.Height = ((this.Height - 720) / 2).Max(0); }; } { Rectangle r = new Rectangle(); r.Fill = Brushes.Black; r.AttachTo(this); r.MoveTo(0, 0); this.SizeChanged += (s, e) => { r.Width = this.Width; // NotImplementedException //at ScriptCoreLib.ActionScript.BCLImplementation.System.Windows::__UIElement/InternalGetHeight_100663344() //at ScriptCoreLib.ActionScript.BCLImplementation.System.Windows::__UIElement/VirtualGetHeight_100663342() //at ScriptCoreLib.ActionScript.BCLImplementation.System.Windows::__FrameworkElement/get Height() var Height = ((this.Height - 720) / 2).Max(0); r.Height = Height; r.MoveTo(0, this.Height - Height); }; } #endregion var hotzone = new Rectangle { Fill = Brushes.Green, Opacity = 0 }.AttachTo(Container720X); hotzone.Cursor = Cursors.Hand; hotzone.MoveTo(1280 / 3, 720 * 2 / 3); hotzone.SizeTo(1280 / 3, 720 / 3); hotzone.MouseEnter += delegate { ShadowOverlayA.Opacity = 0.4; iiA.Opacity = 1.0; entero.Opacity = 0.2; //Container720A.Opacity = 1; }; hotzone.MouseLeave += delegate { ShadowOverlayA.Opacity = 0; iiA.Opacity = 0; entero.Opacity = 0.8; //Container720A.Opacity = VideoPlayingOpacity; }; hotzone.MouseLeftButtonUp += delegate { new Uri("http://young-beach-4377.herokuapp.com/android").NavigateTo(); }; #region enter enter.MouseEnter += delegate { entero.Opacity = 1; ShadowOverlayA.Opacity = 0.4; //Container720A.Opacity = 1; }; enter.MouseLeave += delegate { entero.Opacity = 0.8; ShadowOverlayA.Opacity = 0; // got video? //Container720A.Opacity = VideoPlayingOpacity; //Container720A.Opacity = 1.0; }; #endregion ShadowOverlayA.Opacity = 0; iiA.Opacity = 0; entero.Opacity = 0.8; }
public InteractiveSketchupWarehouseCanvas() { Width = DefaultWidth; Height = DefaultHeight; Background = Brushes.White; this.ClipToBounds = true; //Colors.Cyan.ToGradient(Colors.White, DefaultHeight / 4).Select( // (c, i) => // new Rectangle // { // Fill = new SolidColorBrush(c), // Width = DefaultWidth, // Height = 4, // }.MoveTo(0, i * 4).AttachTo(this) //).ToArray(); var img = new Image { Width = 400, Height = 300 }; img.AttachTo(this); new TextBox { Foreground = Brushes.Red, Width = DefaultWidth, BorderThickness = new Thickness(0), Background = Brushes.Transparent, IsReadOnly = true, Height = 32, Text = "Flash version will only work in web context!" }.AttachTo(this); var imagenum = 34; var src_uri = ApplyFrame(imagenum); img.Cursor = Cursors.Hand; var xoverlay = new Rectangle { Width = DefaultWidth, Height = DefaultHeight, Fill = Brushes.Black, Opacity = 0, Cursor = Cursors.Hand, }.AttachTo(this); var bg = new Rectangle { Width = DefaultWidth, Height = DefaultHeight, Fill = Brushes.Black, }.AttachTo(this); var bga = bg.ToAnimatedOpacity(); bg.Opacity = 0.5; var c = new ScriptCoreLib.Shared.Avalon.Carousel.SimpleCarouselControl(DefaultWidth, DefaultHeight); var options = new[] { "58eca9d1551fde5a3b70edf326d07e86", "6e006174683f7372de48c10a5a3895c4", "5ff285283e8ec610434fdb742d7e0cea", "8d4d82e8807c3823bd4169514fca71f2", "bad472a435d3fab41992a70eb6b3a2a6", "3a4a2c47e8d8fdbb7302a5e36ce363de", "982a7381b7c5f4d36dce312d2cfb61e8", "84bafa682ff9c15b665aa76cf50df2c3", "9533d2d07d433ac072f17dbd3c237580", "d7222464c02cca18e92340be97470aea", "67a2216e4253e3f75eb112e8bc6bbc53", "5f310d576a8180e2ae504fdbdb5a7e96", "d106aaeaa51217cc465e08d496c0420f", "d2f505aca92ee65fbdb8512730b99253" }; var position = 0.0; var a = c.Container.ToAnimatedOpacity(); a.Opacity = 1; foreach (var mid_ in options.Randomize()) { var mid = mid_; position += 0.6; c.AddEntry( new ScriptCoreLib.Shared.Avalon.Carousel.SimpleCarouselControl.EntryInfo { Position = position, Source = new Sketchup { mid = mid }, Click = delegate { if (this.Current.mid == mid) { Uri u = new Sketchup { mid = Current.mid, IsPreview = true }; u.NavigateTo(); return; } this.Current.mid = mid; c.Overlay.Hide(); a.Opacity = 0; Update(img, imagenum); 1500.AtDelay( delegate { bga.Opacity = 0; } ); } } ); } xoverlay.MouseLeftButtonUp += delegate { if (a.Opacity == 0) { c.Overlay.Show(); a.Opacity = 1; bga.Opacity = 0.7; } else { a.Opacity = 0; bga.Opacity = 0; c.Overlay.Hide(); } }; this.MouseMove += (sender, args) => { var p = args.GetPosition(this); var z = (p.Y / DefaultHeight) * 0.7; img.MoveTo((DefaultWidth - DefaultWidth * z) / 2, (DefaultHeight - DefaultHeight * z) / 2); img.Width = DefaultWidth * z; img.Height = DefaultHeight * z; if (a.Opacity < 0.5) { imagenum = Convert.ToInt32((p.X / DefaultWidth + 0.5) * 35) % 36; img.Source = ApplyFrame(imagenum); } }; c.AttachContainerTo(this); c.Overlay.AttachTo(this); c.Show(); }