public AvalonExampleGalleryCanvas(bool EnableBackground, Func<string, OptionPosition> GetOptionPosition) { Width = DefaultWidth; Height = DefaultHeight; var navbar = new AeroNavigationBar(); var Container = new Canvas { Width = DefaultWidth, Height = DefaultHeight, Name = "AvalonExampleGalleryCanvas_Container" }.AttachTo(this); Container.ClipTo(0, 0, DefaultWidth, DefaultHeight); var Pages = new Canvas { Width = DefaultWidth, Height = DefaultHeight, Name = "AvalonExampleGalleryCanvas_Pages" }.AttachTo(this); var CarouselPages = new Canvas { Width = DefaultWidth, Height = DefaultHeight, Name = "AvalonExampleGalleryCanvas_CarouselPages" }.AttachTo(this); var Overlay = new Canvas { Width = DefaultWidth, Height = DefaultHeight, Name = "AvalonExampleGalleryCanvas_Overlay" }.AttachTo(this); if (EnableBackground) { #region background var bg = new TiledBackgroundImage( "assets/AvalonExampleGallery/bg.png".ToSource(), 96, 96, 9, 8 ).AttachContainerTo(Container); #endregion } var Toolbar = new Canvas { Width = DefaultWidth, Height = navbar.Height, Opacity = 0, Name = "Toolbar" }.AttachTo(this); 1000.AtDelay( Toolbar.FadeIn ); #region shadow Colors.Black.ToTransparentGradient(40).Select( (c, i) => { return new Rectangle { Fill = new SolidColorBrush(c), Width = DefaultWidth, Height = 1, Opacity = c.A / 255.0 }.MoveTo(0, i).AttachTo(Toolbar); } ).ToArray(); #endregion var cc = new SimpleCarouselControl(DefaultWidth, DefaultHeight); const string cc_Caption = "Click on a thumbnail!"; cc.Caption.Text = cc_Caption; cc.Timer.Stop(); var btnCarouselCanvas = new Canvas { Width = 128, Height = 32, }.AttachTo(this).MoveTo(DefaultWidth - 128, 4); #region Options var AllPages = KnownPages.Value; AllPages.ForEach( (k, i) => { var o = new OptionWithShadowAndType(k.Key, k.Value); var ce = new SimpleCarouselControl.EntryInfo { Source = (k.Key + "/Preview.png").ToSource(), Position = i * Math.PI * 2 / AllPages.Count, MouseEnter = delegate { cc.Caption.Text = o.Caption.Text; }, MouseLeave = delegate { cc.Caption.Text = cc_Caption; }, Click = delegate { o.InitializeHint(); navbar.History.Add( delegate { cc.Timer.Start(); o.Target.Orphanize(); CarouselPages.Show(); Overlay.Show(); btnCarouselCanvas.Show(); }, delegate { if (AtViewSelected != null) AtViewSelected(o.Caption.Text); btnCarouselCanvas.Hide(); cc.Timer.Stop(); CarouselPages.Hide(); Overlay.Hide(); o.Target.AttachTo(Container); } ); } }; cc.AddEntry(ce); OptionPosition p = null; if (GetOptionPosition != null) p = GetOptionPosition(o.Caption.Text); if (p == null) { o.MoveTo( 48 + (180) * (i % 4), 36 + Convert.ToInt32(i / 4) * 128 ); } else { p.Clear(); o.MoveTo( p.X, p.Y ); } o.AttachContainerTo(Pages); o.Overlay.AttachTo(Overlay); o.TargetInitialized += delegate { o.Target.MoveTo( (DefaultWidth - o.Target.Width) / 2, (DefaultHeight - o.Target.Height) / 2 ); //o.Target.ClipTo(0, 0, Convert.ToInt32( o.Target.Width), Convert.ToInt32(o.Target.Height)); }; o.Click += delegate { navbar.History.Add( delegate { o.Target.Orphanize(); Pages.Show(); Overlay.Show(); btnCarouselCanvas.Show(); }, delegate { if (AtViewSelected != null) AtViewSelected(o.Caption.Text); btnCarouselCanvas.Hide(); Pages.Hide(); Overlay.Hide(); o.Target.AttachTo(Container); } ); }; } ); #endregion #region btnCarousel var btnCarousel = new TextButtonControl { Width = btnCarouselCanvas.Width, Height = btnCarouselCanvas.Height, Text = "View as carousel...", Foreground = Brushes.White }.AttachContainerTo(btnCarouselCanvas); btnCarousel.MouseEnter += delegate { btnCarousel.Foreground = Brushes.Blue; }; btnCarousel.MouseLeave += delegate { btnCarousel.Foreground = Brushes.White; }; btnCarousel.Click += delegate { navbar.History.Add( delegate { Pages.Show(); btnCarousel.Container.Show(); CarouselPages.Hide(); cc.Hide(); cc.Timer.Stop(); }, delegate { Pages.Hide(); CarouselPages.Show(); btnCarousel.Container.Hide(); cc.Show(); cc.Timer.Start(); } ); }; #endregion cc.Hide(); CarouselPages.Hide(); cc.AttachContainerTo(CarouselPages); cc.Overlay.Name = "cc_Overlay"; cc.Overlay.AttachTo(Overlay); #region logo var logo = new Image { Source = "assets/AvalonExampleGallery/jsc.png".ToSource(), Width = 96, Height = 96 }.MoveTo(DefaultWidth - 96, DefaultHeight - 96).AttachTo(Container); var logo_Overlay = new Rectangle { Width = 96, Height = 96, Fill = Brushes.Blue, Opacity = 0, Cursor = Cursors.Hand }.MoveTo(DefaultWidth - 96, DefaultHeight - 96).AttachTo(Overlay); logo_Overlay.MouseEnter += delegate { Pages.Opacity = 0.5; CarouselPages.Opacity = 0.5; }; logo_Overlay.MouseLeave += delegate { Pages.Opacity = 1; CarouselPages.Opacity = 1; }; logo_Overlay.MouseLeftButtonUp += delegate { new Uri("http://jsc.sourceforge.net").NavigateTo(); }; #endregion navbar.MoveContainerTo(4, 4).AttachContainerTo(Toolbar); }
// See more: // http://members.chello.at/theodor.lauppert/games/pipe.htm // tile themes to add: // moon lander/ space // grass/farmer/trees public AvalonPipeManiaCanvas() { this.Width = DefaultWidth; this.Height = DefaultHeight; #region background new[] { //Colors.White, //Colors.Blue, Colors.Black, Colors.White, Colors.Black }.ToGradient(DefaultHeight / 4).ForEach( (c, i) => new Rectangle { Fill = new SolidColorBrush(c), Width = DefaultWidth, Height = 5, }.MoveTo(0, i * 4).AttachTo(this) ); #endregion // we selecting an implementation here: // this should be dynamic in the UI for labs entrypoint var Options = new Dictionary<Type, Func<Canvas>> { { typeof(TileFieldTest), () => new TileFieldTest { PlaySound = e => PlaySound(e), Visibility = Visibility.Hidden } }, { typeof(ColorTest), () => new ColorTest { Visibility = Visibility.Hidden } }, { typeof(SimplePipeTest), () => new SimplePipeTest { Visibility = Visibility.Hidden } }, { typeof(FieldTest), () => new FieldTest { Visibility = Visibility.Hidden } }, { typeof(InteractiveFieldTest), () => new InteractiveFieldTest { Visibility = Visibility.Hidden } }, { typeof(ScrollTest), () => new ScrollTest { Visibility = Visibility.Hidden } }, { typeof(ExtendedFieldTest), () => new ExtendedFieldTest { Visibility = Visibility.Hidden } }, { typeof(ColoredFieldTest), () => new ColoredFieldTest { Visibility = Visibility.Hidden } }, { typeof(SpaceInvaderTest), () => new SpaceInvaderTest { Visibility = Visibility.Hidden } }, { typeof(AnimationsTest), () => new AnimationsTest { Visibility = Visibility.Hidden } }, }; var Content = new Canvas { Width = DefaultWidth, Height = DefaultHeight }.AttachTo(this); var Buttons = new Canvas { Width = DefaultWidth, Height = DefaultHeight }.AttachTo(this); var Navigationbar = new AeroNavigationBar(); Navigationbar.Container.MoveTo(4, 4).AttachTo(this); #region generate the menu const int ButtonHeight = 30; // x:\jsc.svn\examples\actionscript\Test\TestDictionaryOfTypeAndFunc\TestDictionaryOfTypeAndFunc\ApplicationCanvas.cs Options //.ForEach( .Select(Option => new { Option.Key, Option.Value }) .WithEachIndex( (Option, Index) => { var x = 72; var y = 16 + Index * ButtonHeight; var Button = new TextButtonControl { Text = (Index + 1) + ". Open " + Option.Key.Name, Width = 200, Height = ButtonHeight }; Button.Background.Fill = Brushes.Black; Button.Background.Opacity = 0.5; Button.Foreground = Brushes.Blue; Button.MouseEnter += delegate { Button.Background.Fill = Brushes.Blue; Button.Background.Opacity = 0.5; Button.Foreground = Brushes.White; }; Button.MouseLeave += delegate { Button.Background.Fill = Brushes.Black; Button.Background.Opacity = 0.5; Button.Foreground = Brushes.Blue; }; var OptionCanvas = default(Canvas); Button.Click += delegate { if (OptionCanvas == null) OptionCanvas = Option.Value(); Navigationbar.History.Add( delegate { OptionCanvas.Orphanize().Hide(); Buttons.Show(); }, delegate { OptionCanvas.AttachTo(Content).Show(); Buttons.Hide(); } ); }; Button.Container.MoveTo(x, y).AttachTo(Buttons); } ); #endregion }