예제 #1
0
        public MyCanvas()
        {
            Width  = DefaultWidth;
            Height = DefaultHeight;

            Colors.Blue.ToGradient(Colors.Red, DefaultHeight / 4).Select(
                (color, i) =>
                new Rectangle
            {
                Fill   = new SolidColorBrush(color),
                Width  = DefaultWidth,
                Height = 5,
            }.MoveTo(0, i * 4).AttachTo(this)
                ).ToArray();

            // http://social.msdn.microsoft.com/forums/en-US/wpf/thread/21504c22-0d79-404e-ba0e-1cee91a02c2a/

            new Image
            {
                Source = (Assets.Shared.KnownAssets.Path.Assets + "/Preview.png").ToSource(),
                Width  = 120,
                Height = 90
            }.AttachTo(this);


            var n1 = new AeroNavigationBar();

            n1.Container.MoveTo(50, 50).AttachTo(this);

            n1.GoBack +=
                delegate
            {
                n1.ButtonGoBack.Enabled    = false;
                n1.ButtonGoForward.Enabled = true;
            };

            n1.GoForward +=
                delegate
            {
                n1.ButtonGoForward.Enabled = false;
                n1.ButtonGoBack.Enabled    = true;
            };


            var n2 = new AeroNavigationBar();

            n2.Container.MoveTo(120, 50).AttachTo(this);

            n2.GoBack +=
                delegate
            {
                n2.ButtonGoBack.Enabled    = false;
                n2.ButtonGoForward.Enabled = true;
            };

            n2.GoForward +=
                delegate
            {
                n2.ButtonGoForward.Enabled = false;
                n2.ButtonGoBack.Enabled    = true;
            };


            var fs = new FullscreenButtonControl();

            fs.Container.AttachTo(this).MoveTo(8, DefaultHeight - 8 - 24);


            var fs2 = new FullscreenButtonControl();

            fs2.ButtonGoFullscreen.Enabled = false;
            fs2.Container.AttachTo(this).MoveTo(8 + 24, DefaultHeight - 8 - 24);

            var h = new HelpButtonControl();

            h.ButtonHelp.Enabled = true;
            h.Container.AttachTo(this).MoveTo(8 + 24 + 24, DefaultHeight - 8 - 24);

            h.Help += () => h.ButtonHelp.Enabled = false;

            var con = new ConsoleButtonControl();

            con.ButtonConsole.Enabled = true;
            con.Container.AttachTo(this).MoveTo(8 + 24 + 24 + 24, DefaultHeight - 8 - 24);

            con.Console += () => h.ButtonHelp.Enabled = false;
        }
        public InteractiveOrderingCanvas()
        {
            Width  = DefaultWidth;
            Height = DefaultHeight;

            this.ClipToBounds = true;

            Colors.White.ToGradient(Colors.Blue, DefaultHeight / 4).Select(
                (c, i) =>
                new Rectangle
            {
                Fill   = new SolidColorBrush(c),
                Width  = DefaultWidth,
                Height = 4,
            }.MoveTo(0, i * 4).AttachTo(this)
                ).ToArray();

            var History = new AeroNavigationBar();

            History.AttachContainerTo(this).MoveContainerTo(8, 8);

            this.Title = new TextBox
            {
                AcceptsReturn   = true,
                Width           = DefaultWidth - (16 + History.Width),
                Height          = 96,
                TextWrapping    = TextWrapping.Wrap,
                Background      = Brushes.Transparent,
                BorderThickness = new Thickness(0),
                Text            = "...",
                IsReadOnly      = true,
                FontFamily      = new FontFamily("Verdana"),
                FontSize        = 32
            }.AttachTo(this).MoveTo(16 + History.Width, 8);

            var DataSet1 = new LinkImages {
                Text = "Cars"
            };
            var DataSet2 = new LinkImages {
                Text = "Bikes"
            };

            #region wait for all to load
            DefaultDataSets = new[]
            {
                DataSet1,
                DataSet2
            };

            DefaultDataSets.ForEach(
                k =>
                k.Loaded +=
                    delegate
            {
                if (DefaultDataSets.All(q => q.Images.Any()))
                {
                    Step1_ChooseImageSet(History.History, DefaultDataSets);
                }
            }
                );
            #endregion

            DataSet1.AddImages(
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_0(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_1(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_2(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_3(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_4(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_5(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_6()
                );


            DataSet2.AddImages(
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_0(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_1(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_2(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_3(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_4(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_5(),
                new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_6()
                );

            {
                var GoBackButton = new TextButtonControl
                {
                    Text   = "[Back]",
                    Width  = 50,
                    Height = 30,
                }.AttachContainerTo(this).MoveContainerTo(30, 100 + 40 * 11);


                var GoBackButtonBG = GoBackButton.Background.ToAnimatedOpacity();


                GoBackButton.Background.Fill = Brushes.White;
                GoBackButtonBG.Opacity       = 0;

                GoBackButton.Overlay.MouseEnter +=
                    delegate { GoBackButtonBG.Opacity = 1; };


                GoBackButton.Overlay.MouseLeave +=
                    delegate { GoBackButtonBG.Opacity = 0; };


                GoBackButton.Click +=
                    delegate
                {
                    if (History.History.GoBack.Any())
                    {
                        History.History.GoBack.Pop()();
                    }
                };
            }

            {
                var GoBackButton = new TextButtonControl
                {
                    Text   = "[Forward]",
                    Width  = 66,
                    Height = 30,
                }.AttachContainerTo(this).MoveContainerTo(80, 100 + 40 * 11);


                var GoBackButtonBG = GoBackButton.Background.ToAnimatedOpacity();


                GoBackButton.Background.Fill = Brushes.White;
                GoBackButtonBG.Opacity       = 0;

                GoBackButton.Overlay.MouseEnter +=
                    delegate { GoBackButtonBG.Opacity = 1; };


                GoBackButton.Overlay.MouseLeave +=
                    delegate { GoBackButtonBG.Opacity = 0; };


                GoBackButton.Click +=
                    delegate
                {
                    if (History.History.GoForward.Any())
                    {
                        History.History.GoForward.Pop()();
                    }
                };
            }
        }
        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);
        }