public SpiderCanvas() { Width = DefaultWidth; Height = DefaultHeight; this.ClipTo(0, 0, DefaultWidth, DefaultHeight); new TiledBackgroundImage( (global::ScriptCoreLib.Shared.Avalon.Cards.KnownAssets.Path.DefaultCards + "/felt.png").ToSource(), 64, 64, 14, 10 ).AttachContainerTo(this); var ShadowHeight = 40; new GameBorders(DefaultWidth, DefaultHeight, ShadowHeight).AttachContainerTo(this); var Margin = (DefaultWidth - CardInfo.Width * 10) / 11; new Image { Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource(), Width = 96, Height = 96 }.MoveTo(DefaultWidth - 96, DefaultHeight - 96 - 17 - Margin).AttachTo(this); var Content = new Canvas { Width = DefaultWidth, Height = DefaultHeight }.AttachTo(this); var Game = default(SpiderGame); var GameFocusBoost = false; new GameSocialLinks(this) { new GameSocialLinks.Button { Source = (KnownAssets.Path.Assets + "/plus_google.png").ToSource(), Width = 62, Height = 17, Hyperlink = new Uri(Info.GoogleGadgetAddLink) }, new GameSocialLinks.Button { Source = (KnownAssets.Path.Assets + "/su.png").ToSource(), Width = 16, Height = 16, Hyperlink = new Uri( "http://www.stumbleupon.com/submit?url=" + Info.URL) } }; // Select a difficulty for a new game! // redefine the ctor to fit our context Func<string, string, string, GameMenu.Option> Option = (Text, Image, href) => new GameMenu.Option { Text = "Play " + Text + "!", Source = (KnownAssets.Path.Assets + "/" + Image + ".png").ToSource(), Hyperlink = new Uri(href), MarginAfter = Math.PI / 4 }; Func<string, string, Func<SpiderGame>, GameMenu.Option> Level = (Text, Image, ctor) => new GameMenu.Option { Text = Text, Source = (KnownAssets.Path.Assets + "/" + Image + ".png").ToSource(), MarginAfter = Math.PI / 4, Click = delegate { GameFocusBoost = true; Game.Orphanize(); Game = ctor(); Game.AttachTo(Content); Game.MyDeck.Sounds = Sounds; Menu.Hide(); 500.AtDelay(() => GameFocusBoost = false); } }; this.Menu = new GameMenu(DefaultWidth, DefaultHeight, ShadowHeight) { Level("Play easy Spider Solitaire!", "PreviewEasy", () => new SpiderGame(LevelEasy)), Level("Play medium Spider Solitaire!", "PreviewMedium", () => new SpiderGame(LevelMedium)), Level("Play hard Spider Solitaire!", "PreviewHard", () => new SpiderGame(LevelHard)), //Option("Spider Solitaire", "Preview_Spider", "http://nonoba.com/zproxy/avalon-spider-solitaire"), Option("Treasure Hunt", "Preview_TreasureHunt", "http://nonoba.com/zproxy/treasure-hunt").Apply(k => k.MarginBefore = Math.PI / 4), Option("FlashMinesweeper:MP", "Preview_Minesweeper", "http://nonoba.com/zproxy/flashminesweepermp"), Option("Multiplayer Mahjong", "Preview_Mahjong", "http://nonoba.com/zproxy/mahjong-multiplayer"), Option("Multiplayer SpaceInvaders", "Preview_SpaceInvaders", "http://nonoba.com/zproxy/flashspaceinvaders"), }; Menu.AttachContainerTo(this); Menu.ValidateHide = () => Game != null; Menu.ValidateShow = () => !GameFocusBoost; Menu.Show(); }
public SpiderCanvas() { Width = DefaultWidth; Height = DefaultHeight; //this.ClipTo(0, 0, DefaultWidth, DefaultHeight); new TiledBackgroundImage( new felt().Source, 64, 64, // repeaters x: 32, y: 24 ).AttachContainerTo(this); var ShadowHeight = 40; new GameBorders(DefaultWidth, DefaultHeight, ShadowHeight, this).AttachContainerTo(this); var Margin = (DefaultWidth - CardInfo.Width * 10) / 11; //new Image //{ // Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource(), // Width = 96, // Height = 96 //}.MoveTo(DefaultWidth - 96, DefaultHeight - 96 - 17 - Margin).AttachTo(this); var Content = new Canvas { Width = DefaultWidth, Height = DefaultHeight }.AttachTo(this); var Game = default(SpiderGame); var GameFocusBoost = false; //new GameSocialLinks(this) //{ // new GameSocialLinks.Button { // Source = (KnownAssets.Path.Assets + "/plus_google.png").ToSource(), // Width = 62, // Height = 17, // Hyperlink = new Uri(Info.GoogleGadgetAddLink) // }, // new GameSocialLinks.Button { // Source = (KnownAssets.Path.Assets + "/su.png").ToSource(), // Width = 16, // Height = 16, // Hyperlink = new Uri( "http://www.stumbleupon.com/submit?url=" + Info.URL) // } //}; // Select a difficulty for a new game! // redefine the ctor to fit our context //Func<string, string, string, GameMenu.Option> Option = // (Text, Image, href) => // new GameMenu.Option // { // Text = "Play " + Text + "!", // Source = (KnownAssets.Path.Assets + "/" + Image + ".png").ToSource(), // Hyperlink = new Uri(href), // MarginAfter = Math.PI / 4 // }; Action AtSizeChanged = delegate { if (Game != null) Game.MoveTo( (this.Width - DefaultWidth) / 2, (this.Height - DefaultHeight) ); }; this.SizeChanged += delegate { AtSizeChanged(); }; Func<string, Image, Func<SpiderGame>, GameMenuOption> Level = (Text, Image, ctor) => new GameMenuOption { Text = Text, Source = Image.Source, MarginAfter = Math.PI / 4, Click = delegate { GameFocusBoost = true; Game.Orphanize(); Game = ctor(); Game.AttachTo(Content); Game.MyDeck.Sounds = Sounds; AtSizeChanged(); Menu.Hide(); 500.AtDelay(() => GameFocusBoost = false); } }; this.Menu = new GameMenu(DefaultWidth, DefaultHeight, ShadowHeight, this) { Level("Play easy Spider Solitaire!", new PreviewEasy(), () => new SpiderGame(LevelEasy)), Level("Play medium Spider Solitaire!", new PreviewMedium(), () => new SpiderGame(LevelMedium)), Level("Play hard Spider Solitaire!", new PreviewHard(), () => new SpiderGame(LevelHard)), //Option("Spider Solitaire", "Preview_Spider", "http://nonoba.com/zproxy/avalon-spider-solitaire"), //Option("Treasure Hunt", "Preview_TreasureHunt", "http://nonoba.com/zproxy/treasure-hunt").Apply(k => k.MarginBefore = Math.PI / 4), //Option("FlashMinesweeper:MP", "Preview_Minesweeper", "http://nonoba.com/zproxy/flashminesweepermp"), //Option("Multiplayer Mahjong", "Preview_Mahjong", "http://nonoba.com/zproxy/mahjong-multiplayer"), //Option("Multiplayer SpaceInvaders", "Preview_SpaceInvaders", "http://nonoba.com/zproxy/flashspaceinvaders"), }; Menu.AttachContainerTo(this); Menu.ValidateHide = () => Game != null; Menu.ValidateShow = () => !GameFocusBoost; Menu.Show(); }