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

            _stylingPuzzle = true;

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

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

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

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

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

                case "AnimateVectorContent":
                    {
                        VectorContent 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 PuzzleProject.MyDocument();
                        _elementToChopUp = elt;
                        _puzzleSize = new Size(elt.Width, elt.Height);
                    }
                    break;

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

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

                        SpinningCube sc = new SpinningCube();

                        sc.CubeMaterial.Brush = new ImageBrush(masterImage.Source);
                        sc.CubeMaterial2.Brush = new VisualBrush(vc);

                        Storyboard 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();
        }
Example #2
0
        private void PuzzleSourceChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox     cb   = (ComboBox)sender;
            ComboBoxItem item = (ComboBoxItem)cb.SelectedValue;
            string       tag  = (string)item.Tag;

            _stylingPuzzle = true;

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

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

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

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

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

            case "AnimateVectorContent":
            {
                VectorContent 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 PuzzleProject.MyDocument();
                _elementToChopUp = elt;
                _puzzleSize      = new Size(elt.Width, elt.Height);
            }
            break;

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

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

                SpinningCube sc = new SpinningCube();

                sc.CubeMaterial.Brush  = new ImageBrush(masterImage.Source);
                sc.CubeMaterial2.Brush = new VisualBrush(vc);

                Storyboard 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();
        }