Interaction logic for Picture.xaml
Inheritance: System.Windows.Controls.UserControl
コード例 #1
0
        //Load pictures to the canvas
        private void LoadPictures()
        {
            string[] pictureLocations = GetPictureLocations();
            double angle = 0;
            double step = 360 / pictureLocations.Length;

            foreach (string filePath in pictureLocations)
            {
                try
                {
                    Picture p = new Picture();
                    p.ImagePath = filePath;
                    p.Width = 300;
                    p.Angle = 180 - angle;
                    double angleRad = angle * Math.PI / 180.0;
                    p.X = Math.Sin(angleRad) * 300 + (_canvas.ActualWidth - 300) / 2.0;
                    p.Y = Math.Cos(angleRad) * 300 + (_canvas.ActualHeight - 300) / 2.0;
                    _canvas.Children.Add(p);

                    angle += step;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine("Error:" + ex.Message);
                }
            }
        } 
コード例 #2
0
        private void BringPictureToFront(Picture picture)
        {
            if (picture == null)
                return;

            var children = (from UIElement child in _canvas.Children
                            where child != picture
                            orderby Canvas.GetZIndex(child)
                            select child).ToArray();

            for (int i = 0; i < children.Length; ++i)
            {
                Canvas.SetZIndex(children[i], i);
            }
            Canvas.SetZIndex(picture, children.Length);
        }