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);


		}
        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);
        }