public void InitializeContent()
        {
            var DefaultWidth  = Convert.ToInt32(Width);
            var DefaultHeight = Convert.ToInt32(Height);

            this.ClipToBounds = true;

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

            var logo = new Avalon.Images.white_jsc().AttachTo(this);

            logo.MoveTo(
                DefaultWidth - Avalon.Images.white_jsc.ImageDefaultWidth,
                DefaultHeight - Avalon.Images.white_jsc.ImageDefaultHeight
                );

            this.SizeChanged +=
                delegate
            {
                logo.MoveTo(
                    this.Width - Avalon.Images.white_jsc.ImageDefaultWidth,
                    this.Height - Avalon.Images.white_jsc.ImageDefaultHeight
                    );
            };

            var t = new TextBox
            {
                FontSize        = 10,
                Text            = "powered by jsc",
                BorderThickness = new Thickness(0),
                Foreground      = 0xffffffff.ToSolidColorBrush(),
                Background      = Brushes.Transparent,
                IsReadOnly      = true,
                Width           = DefaultWidth
            }.MoveTo(8, 8).AttachTo(this);

            #region Initialize
            AffineContent = new Canvas
            {
            }.AttachTo(this);



            InfoContent = new Canvas
            {
            }.AttachTo(this);



            var a = new AffineMesh();



            for (int i = -5; i <= 5; i++)
            {
                if (Math.Abs(i) > 1)
                {
                    AddCube(a, new AffinePoint(210 * i, 0, 0));
                    AddCube(a, new AffinePoint(0, 210 * i, 0));
                    AddCube(a, new AffinePoint(0, 0, 210 * i));
                }
            }

            // AddCubeFace(a, "back",
            //    new AffinePoint(-100, -100, -100),
            //    new AffinePoint(100, -100, -100),
            //    new AffinePoint(-100, 100, -100),
            //    new AffinePoint(100, 100, -100)
            //);


            //a = a.ToZoom(new AffineZoom { X = 2 });


            //a = a.ToZoom(0.8);
            //a = a.ToZoom(1.2);

            var pp = new Point();

            // while jsc initializes local structs it does not do that for fields
            pp = new Point(0, 0);

            var pp_XZ = 0.0;

            Action Update =
                delegate
            {
                var Rotation = new AffineRotation
                {
                    XY = 0.01 * pp.X * 0.5,
                    YZ = 0.02 * pp.X * 0.5,
                    XZ = 0.03 * pp.X * 0.5 + pp_XZ
                };

                t.Text = new
                {
                    XY = Rotation.XZ.RadiansToDegrees(),
                    YZ = Rotation.YZ.RadiansToDegrees(),
                    XZ = Rotation.XZ.RadiansToDegrees()
                }.ToString();

                // rotate floor
                var _a = a.ToZoom(0.2 * (DefaultHeight / 2 + pp.Y) / (DefaultHeight)).ToRotation(Rotation);



                foreach (var k in _a.Vertecies)
                {
                    k.Element.Orphanize();
                    k.Element.AttachTo(AffineContent);
                    k.Element.RenderTransform = new AffineTransform
                    {
                        Left   = 0,
                        Top    = 0,
                        Width  = k.ElementWidth,
                        Height = k.ElementHeight,

                        X1 = k.B.X + DefaultWidth / 2,
                        Y1 = k.B.Y + DefaultHeight / 2,

                        X2 = k.C.X + DefaultWidth / 2,
                        Y2 = k.C.Y + DefaultHeight / 2,

                        X3 = k.A.X + DefaultWidth / 2,
                        Y3 = k.A.Y + DefaultHeight / 2,
                    };

                    //((Action<AffineVertex>)k.Tag)(k);
                }
            };

            this.MouseMove +=
                (sender, args) =>
            {
                pp = args.GetPosition(this);

                Update();
            }
            ;
            #endregion


            var tt = new DispatcherTimer();

            tt.Tick +=
                delegate
            {
                pp_XZ += 0.02;
                Update();
            };

            tt.Interval = TimeSpan.FromMilliseconds(1000 / 30);

            tt.Start();
        }
        public void InitializeContent()
        {
            var DefaultWidth = Convert.ToInt32(Width);
            var DefaultHeight = Convert.ToInt32(Height);

            this.ClipToBounds = true;

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

            var logo = new Avalon.Images.white_jsc().AttachTo(this);

            logo.MoveTo(
                DefaultWidth - Avalon.Images.white_jsc.ImageDefaultWidth,
                DefaultHeight - Avalon.Images.white_jsc.ImageDefaultHeight
            );

            this.SizeChanged +=
                delegate
                {
                    logo.MoveTo(
                          this.Width - Avalon.Images.white_jsc.ImageDefaultWidth,
                          this.Height - Avalon.Images.white_jsc.ImageDefaultHeight
                      );

                };

            var t = new TextBox
            {
                FontSize = 10,
                Text = "powered by jsc",
                BorderThickness = new Thickness(0),
                Foreground = 0xffffffff.ToSolidColorBrush(),
                Background = Brushes.Transparent,
                IsReadOnly = true,
                Width = DefaultWidth
            }.MoveTo(8, 8).AttachTo(this);

            #region Initialize
            AffineContent = new Canvas
            {

            }.AttachTo(this);




            InfoContent = new Canvas
            {

            }.AttachTo(this);



            var a = new AffineMesh();




            for (int i = -5; i <= 5; i++)
            {
                if (Math.Abs(i) > 1)
                {
                    AddCube(a, new AffinePoint(210 * i, 0, 0));
                    AddCube(a, new AffinePoint(0, 210 * i, 0));
                    AddCube(a, new AffinePoint(0, 0, 210 * i));
                }
            }

            // AddCubeFace(a, "back",
            //    new AffinePoint(-100, -100, -100),
            //    new AffinePoint(100, -100, -100),
            //    new AffinePoint(-100, 100, -100),
            //    new AffinePoint(100, 100, -100)
            //);


            //a = a.ToZoom(new AffineZoom { X = 2 });


            //a = a.ToZoom(0.8);
            //a = a.ToZoom(1.2);

            var pp = new Point();

            // while jsc initializes local structs it does not do that for fields
            pp = new Point(0, 0);

            var pp_XZ = 0.0;

            Action Update =
                delegate
                {
                    var Rotation = new AffineRotation
                 {
                     XY = 0.01 * pp.X * 0.5,
                     YZ = 0.02 * pp.X * 0.5,
                     XZ = 0.03 * pp.X * 0.5 + pp_XZ
                 };

                    t.Text = new
                    {
                        XY = Rotation.XZ.RadiansToDegrees(),
                        YZ = Rotation.YZ.RadiansToDegrees(),
                        XZ = Rotation.XZ.RadiansToDegrees()
                    }.ToString();

                    // rotate floor
                    var _a = a.ToZoom(0.2 * (DefaultHeight / 2 + pp.Y) / (DefaultHeight)).ToRotation(Rotation);



                    foreach (var k in _a.Vertecies)
                    {
                        k.Element.Orphanize();
                        k.Element.AttachTo(AffineContent);
                        k.Element.RenderTransform = new AffineTransform
                        {
                            Left = 0,
                            Top = 0,
                            Width = k.ElementWidth,
                            Height = k.ElementHeight,

                            X1 = k.B.X + DefaultWidth / 2,
                            Y1 = k.B.Y + DefaultHeight / 2,

                            X2 = k.C.X + DefaultWidth / 2,
                            Y2 = k.C.Y + DefaultHeight / 2,

                            X3 = k.A.X + DefaultWidth / 2,
                            Y3 = k.A.Y + DefaultHeight / 2,


                        };

                        //((Action<AffineVertex>)k.Tag)(k);
                    }
                };

            this.MouseMove +=
                (sender, args) =>
                {
                    pp = args.GetPosition(this);

                    Update();

                }
            ;
            #endregion


            var tt = new DispatcherTimer();

            tt.Tick +=
                delegate
                {
                    pp_XZ += 0.02;
                    Update();
                };

            tt.Interval = TimeSpan.FromMilliseconds(1000 / 30);

            tt.Start();
        }
Пример #3
0
        public ApplicationCanvas()
        {
            Width  = DefaultWidth;
            Height = DefaultHeight;

            this.ClipToBounds = true;

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


            {
                var bg = new Rectangle
                {
                    Fill = Brushes.Red
                }.AttachTo(this).MoveTo(32, 64).SizeTo(200, 20);

                var t = new TextBox
                {
                    Text = "AutoSize until resized... from then on explicitly sized",
                }.AttachTo(this).MoveTo(32, 64);
                //.SizeTo(200, 20);
            }

            {
                var bg = new Rectangle
                {
                    Fill = Brushes.Red
                }.AttachTo(this).MoveTo(32, 96).SizeTo(200, 100);

                var t = new TextBox().AttachTo(this).MoveTo(32, 96);
                t.AcceptsReturn   = true;
                t.Background      = Brushes.Black;
                t.Foreground      = Brushes.Yellow;
                t.BorderThickness = new System.Windows.Thickness(0);

                t.Text = "AutoSize until resized\n1\n2\n3";
                //.SizeTo(200, 20);

                var logo = new Avalon.Images.white_jsc().AttachTo(this).MoveTo(
                    DefaultWidth - Avalon.Images.white_jsc.ImageDefaultWidth,
                    DefaultHeight - Avalon.Images.white_jsc.ImageDefaultHeight
                    );

                logo.Cursor = Cursors.Hand;

                logo.MouseLeftButtonUp +=
                    delegate
                {
                    t.Text = "0. AutoSize until resized\n1\n2\n3";
                };
            }
        }
        public ApplicationCanvas()
        {
            Width = DefaultWidth;
            Height = DefaultHeight;

            this.ClipToBounds = true;

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


            {
                var bg = new Rectangle
                {
                    Fill = Brushes.Red
                }.AttachTo(this).MoveTo(32, 64).SizeTo(200, 20);

                var t = new TextBox
                {
                    Text = "AutoSize until resized... from then on explicitly sized",
                }.AttachTo(this).MoveTo(32, 64);
                //.SizeTo(200, 20);
            }

            {
                var bg = new Rectangle
                {
                    Fill = Brushes.Red
                }.AttachTo(this).MoveTo(32, 96).SizeTo(200, 100);

                var t = new TextBox().AttachTo(this).MoveTo(32, 96);
                t.AcceptsReturn = true;
                t.Background = Brushes.Black;
                t.Foreground = Brushes.Yellow;
                t.BorderThickness = new System.Windows.Thickness(0);

                t.Text = "AutoSize until resized\n1\n2\n3";
                //.SizeTo(200, 20);

                var logo = new Avalon.Images.white_jsc().AttachTo(this).MoveTo(
                        DefaultWidth - Avalon.Images.white_jsc.ImageDefaultWidth,
                        DefaultHeight - Avalon.Images.white_jsc.ImageDefaultHeight
                    );

                logo.Cursor = Cursors.Hand;

                logo.MouseLeftButtonUp +=
                    delegate
                    {
                        t.Text = "0. AutoSize until resized\n1\n2\n3";
                    };
            }

        }