Esempio n. 1
0
        private void PuzzleSourceChanged(object sender, SelectionChangedEventArgs e)
        {
            var cb   = (ComboBox)sender;
            var item = (ComboBoxItem)cb.SelectedValue;
            var tag  = (string)item.Tag;

            _stylingPuzzle = true;

            if (_masterVideoElement != null)
            {
                _masterVideoElement.Stop();
                _masterVideoElement = null;
            }

            switch (tag)
            {
            case "Untemplated":
                _stylingPuzzle = false;
                break;

            case "StaticBitmap":
            {
                var masterImage = (Image)Resources["MasterImage"];
                _elementToChopUp = masterImage;
                var bitmap = (BitmapSource)masterImage.Source;
                _puzzleSize = new Size(bitmap.PixelWidth / 1.5, bitmap.PixelHeight / 1.5);
            }
            break;

            case "StaticVectorContent":
            {
                _elementToChopUp = new VectorContent();
                _puzzleSize      = new Size(500, 500);
            }
            break;

            case "VideoContent":
            {
                _elementToChopUp = PrepareVideoElement(out _puzzleSize);
            }
            break;

            case "AnimateVectorContent":
            {
                var vc = new VectorContent();

                // Must explicitly start storyboards that only appear in VisualBrushes
                vc.BeginStoryboard(vc.MyStoryboard);

                _elementToChopUp = vc;
                _puzzleSize      = new Size(500, 500);
            }

            break;

            case "Document":
            {
                FrameworkElement elt = new Document();
                _elementToChopUp = elt;
                _puzzleSize      = new Size(elt.Width, elt.Height);
            }
            break;

            case "FormsContent":
            {
                FrameworkElement elt = new FormContent();
                _elementToChopUp = elt;
                _puzzleSize      = new Size(700, 500);
            }
            break;

            case "SpinningCube":
            {
                var vc = new VectorContent();
                vc.BeginStoryboard(vc.MyStoryboard);
                // Must explicitly start storyboards that only appear in VisualBrushes
                var masterImage = (Image)Resources["TableImage"];

                var sc = new SpinningCube
                {
                    CubeMaterial  = { Brush = new ImageBrush(masterImage.Source) },
                    CubeMaterial2 = { Brush = new VisualBrush(vc) }
                };


                var myStoryboard = (Storyboard)sc.Resources["MyStoryboard"];
                sc.BeginStoryboard(myStoryboard);
                // Must explicitly start storyboards that only appear in VisualBrushes
                _elementToChopUp = sc;
                _puzzleSize      = new Size(500, 500);
            }

            break;

            default:
                Debug.Assert(false, "Unexpected Puzzle Source");
                break;
            }

            NewPuzzleGrid();
        }
Esempio n. 2
0
        private void PuzzleSourceChanged(object sender, SelectionChangedEventArgs e)
        {
            var cb = (ComboBox) sender;
            var item = (ComboBoxItem) cb.SelectedValue;
            var tag = (string) item.Tag;

            _stylingPuzzle = true;

            if (_masterVideoElement != null)
            {
                _masterVideoElement.Stop();
                _masterVideoElement = null;
            }

            switch (tag)
            {
                case "Untemplated":
                    _stylingPuzzle = false;
                    break;

                case "StaticBitmap":
                {
                    var masterImage = (Image) Resources["MasterImage"];
                    _elementToChopUp = masterImage;
                    var bitmap = (BitmapSource) masterImage.Source;
                    _puzzleSize = new Size(bitmap.PixelWidth/1.5, bitmap.PixelHeight/1.5);
                }
                    break;

                case "StaticVectorContent":
                {
                    _elementToChopUp = new VectorContent();
                    _puzzleSize = new Size(500, 500);
                }
                    break;

                case "VideoContent":
                {
                    _elementToChopUp = PrepareVideoElement(out _puzzleSize);
                }
                    break;

                case "AnimateVectorContent":
                {
                    var vc = new VectorContent();

                    // Must explicitly start storyboards that only appear in VisualBrushes
                    vc.BeginStoryboard(vc.MyStoryboard);

                    _elementToChopUp = vc;
                    _puzzleSize = new Size(500, 500);
                }

                    break;

                case "Document":
                {
                    FrameworkElement elt = new Document();
                    _elementToChopUp = elt;
                    _puzzleSize = new Size(elt.Width, elt.Height);
                }
                    break;

                case "FormsContent":
                {
                    FrameworkElement elt = new FormContent();
                    _elementToChopUp = elt;
                    _puzzleSize = new Size(700, 500);
                }
                    break;

                case "SpinningCube":
                {
                    var vc = new VectorContent();
                    vc.BeginStoryboard(vc.MyStoryboard);
                    // Must explicitly start storyboards that only appear in VisualBrushes
                    var masterImage = (Image) Resources["TableImage"];

                    var sc = new SpinningCube
                    {
                        CubeMaterial = {Brush = new ImageBrush(masterImage.Source)},
                        CubeMaterial2 = {Brush = new VisualBrush(vc)}
                    };


                    var myStoryboard = (Storyboard) sc.Resources["MyStoryboard"];
                    sc.BeginStoryboard(myStoryboard);
                    // Must explicitly start storyboards that only appear in VisualBrushes
                    _elementToChopUp = sc;
                    _puzzleSize = new Size(500, 500);
                }

                    break;

                default:
                    Debug.Assert(false, "Unexpected Puzzle Source");
                    break;
            }

            NewPuzzleGrid();
        }