Пример #1
0
        private void CreateCollage()
        {
            if (EventAction.Equals("Collage"))
            {
                Random     rand      = new Random(DateTime.Now.Millisecond);
                List <Uri> uriSource = new List <Uri>()
                {
                    new Uri(@".\Collage\tiles.jpg", UriKind.Relative),
                    new Uri(@".\AlbumPhoto\1.jpg", UriKind.Relative),
                    new Uri(@".\AlbumPhoto\2.jpg", UriKind.Relative),
                    new Uri(@".\AlbumPhoto\3.jpg", UriKind.Relative),
                    new Uri(@".\AlbumPhoto\4.jpg", UriKind.Relative),
                };

                ImageBrush ib = new ImageBrush();
                ib.ImageSource    = new BitmapImage(uriSource[0]);
                canvas.Background = ib;



                Image img = new Image();
                img.Width   = 200;
                img.Height  = 200;
                img.Stretch = Stretch.UniformToFill;
                img.Source  = new BitmapImage(uriSource[1]);
                //img.RenderTransform = new RotateTransform(rand.NextDouble() * 360);
                Canvas.SetLeft(img, 200);
                Canvas.SetTop(img, 100);
                canvas.Children.Add(img);

                img         = new Image();
                img.Width   = 200;
                img.Height  = 200;
                img.Stretch = Stretch.UniformToFill;
                img.Source  = new BitmapImage(uriSource[2]);
                //img.RenderTransform = new RotateTransform(rand.NextDouble() * 360);
                Canvas.SetLeft(img, 400);
                Canvas.SetTop(img, 120);
                canvas.Children.Add(img);

                img         = new Image();
                img.Width   = 200;
                img.Height  = 200;
                img.Stretch = Stretch.UniformToFill;
                img.Source  = new BitmapImage(uriSource[3]);
                //img.RenderTransform = new RotateTransform(rand.NextDouble() * 360);
                Canvas.SetLeft(img, 600);
                Canvas.SetTop(img, 100);
                canvas.Children.Add(img);

                img         = new Image();
                img.Width   = 200;
                img.Height  = 200;
                img.Stretch = Stretch.UniformToFill;
                img.Source  = new BitmapImage(uriSource[4]);
                //img.RenderTransform = new RotateTransform(rand.NextDouble() * 360);
                Canvas.SetLeft(img, 670);
                Canvas.SetTop(img, 120);
                canvas.Children.Add(img);
                // img.MouseDown += new MouseButtonEventHandler(img_MouseDown);
                img.MouseLeftButtonDown += new MouseButtonEventHandler(img_MouseLeftButtonDown);
                img.MouseMove           += new MouseEventHandler(img_MouseMove);
                img.MouseLeftButtonUp   += new MouseButtonEventHandler(img_MouseLeftButtonUp);
            }
            else if (EventAction.Equals("PhotoBook"))
            {
                TabItem ti = new TabItem();
                ti.Header = "Untilted_2";
                Thickness margin = ti.Margin;
                margin.Left = 3;
                ti.Margin   = margin;
                //ti.Margin.Left = 3;
                ti.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFEDF3F9"));

                tabControl.Items.Insert(tabControl.Items.Count, ti);
                tabControl.SelectedIndex = tabControl.Items.Count - 1;
                _control = new UserControl1();

                Grid _grid = new Grid();

                _grid.Children.Add(_control);
                ti.Content = _grid;
            }
        }