Пример #1
0
        private static void PositionValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GImage myGImage = (GImage)d;

            //myGImage.setToolTip();
            //Debug.Print("Position Changed");
            myGImage.UpdateRenderTransform();
        }
Пример #2
0
        // Code to create and display objects goes here.
        public Window1()
        {
            InitializeComponent();
            InitializeCommands();

            // Now add some graphical items in the main drawing area, whose name is "Paper"
            gp = this.FindName("Paper") as GraphPaper;


            // Track mouse activity in this window
            MouseLeftButtonDown += MyMouseButtonDown;
            MouseLeftButtonUp   += MyMouseButtonUp;
            MouseMove           += MyMouseMove;

            #region Triangles, segments, dots
            // A triangle, whose top point can be moved using the slider.
            myTriangle = new Polygon();
            myTriangle.Points.Add(new Point(0, 10));
            myTriangle.Points.Add(new Point(10, 0));
            myTriangle.Points.Add(new Point(-10, 0));
            myTriangle.Stroke          = Brushes.Black;
            myTriangle.StrokeThickness = 1; // 1 mm thick line
            myTriangle.Fill            = Brushes.LightSeaGreen;
            gp.Children.Add(myTriangle);

            // A draggable Dot, which is the basepoint of an arrow.
            Dot dd = new Dot(new Point(-40, 60));
            dd.MakeDraggable(gp);
            gp.Children.Add(dd);

            Arrow ee = new Arrow(dd, new Point(10, 10), Arrow.endtype.END);
            gp.Children.Add(ee);

            // a dot and a segment that's attached to it; the dot is animated
            Dot p1 = new Dot(new Point(20, 20));
            gp.Children.Add(p1);
            Point   p2        = new Point(50, 50);
            Segment mySegment = new Segment(p1, p2);
            gp.Children.Add(mySegment);

            PointAnimation animaPoint1 = new PointAnimation(
                new Point(-20, -20),
                new Point(-40, 20),
                new Duration(new TimeSpan(0, 0, 5)));
            animaPoint1.AutoReverse    = true;
            animaPoint1.RepeatBehavior = RepeatBehavior.Forever;
            p1.BeginAnimation(Dot.PositionProperty, animaPoint1);
            #endregion
            #region Images

            // And a photo from a file, then another that's
            // created on-the-fly instead of read from a file.

            myImage1          = new GImage("./foo.jpg");
            myImage1.Width    = GraphPaper.wpf(200);
            myImage1.Position = new Point(10, 40);
            Point pq = new Point(10, 40);

            gp.Children.Add(myImage1);

            // Now add a second image, based on first building an array of color values
            // Create source array
            byte[, ,] stripes = createStripeImageArray();

            myImage2 = new GImage(stripes);

            // Establish the width and height for this image on the GraphPaper
            myImage2.Width  = GraphPaper.wpf(128);
            myImage2.Height = GraphPaper.wpf(128);

            myImage2.Position = new Point(-40, 20);
            gp.Children.Add(myImage2);
            #endregion
            #region Mesh, Quiver, and Text labels

            myMesh = this.createSampleMesh();
            gp.Children.Add(myMesh);

            Text myText = new Text("THIS IS TEXT");
            myText.Position = new Point(20, 50);
            gp.Children.Add(myText);

            myQuiver = makeQuiver();
            foreach (Shape q in myQuiver)
            {
                gp.Children.Add(q);
            }

            #endregion
            ready = true; // Now we're ready to have sliders and buttons influence the display.
        }