Example #1
0
        private void RemoveCustomViewCubeBitmaps()
        {
            ViewCubeCameraController1.SetViewCubeBitmaps(null);
            ViewCubeCameraController1.SetSelectedViewCubeBitmaps(null);

            _isCustomViewCubeBitmaps = false;
        }
Example #2
0
        private void SetupCustomViewCubeBitmaps()
        {
            int fontSize    = 30;                                             // Same as default size
            var textColor   = Colors.DarkBlue;                                // default color is Color.FromRgb(40, 40, 40);
            var borderBrush = new SolidColorBrush(Color.FromRgb(40, 40, 40)); // Same as default brush

            var foregroundColor = GetColorFromComboBox(ForegroundComboBox);
            var selectionColor  = GetColorFromComboBox(SelectionBrushComboBox);

            // IMPORTANT:
            // When IsEdgeSelectionEnabled is true, then the backgroundBrush must be transparent.
            // If not, then the edge and corner selection will not be visible through the background.
            Brush bitmapBackgroundBrush;

            if (ViewCubeCameraController1.IsEdgeSelectionEnabled)
            {
                bitmapBackgroundBrush = new RadialGradientBrush(foregroundColor, Colors.Transparent);
            }
            else
            {
                bitmapBackgroundBrush = new RadialGradientBrush(selectionColor, foregroundColor);
            }

            var selectedBackgroundBrush = new RadialGradientBrush(foregroundColor, selectionColor);

            var viewCubePlaneTexts = new string[] { "EAST", "WEST", "UP", "DOWN", "SOUTH", "NORTH" };


            _normalViewCubeBitmaps   = new BitmapSource[6];
            _selectedViewCubeBitmaps = new BitmapSource[6];

            for (var i = 0; i < 6; i++)
            {
                string planeText = viewCubePlaneTexts[i];

                // To get default text use:
                //string planeText = ViewCubeCameraController1.DefaultCubePlaneTexts[i];

                _normalViewCubeBitmaps[i]   = ViewCubeCameraController.RenderViewCubeBitmap(planeText, fontSize - 2, textColor, borderBrush, bitmapBackgroundBrush, innerBorderBrush: null, borderThickness: 1, innerBorderThickness: 16, bitmapSize: 128);
                _selectedViewCubeBitmaps[i] = ViewCubeCameraController.RenderViewCubeBitmap(planeText, fontSize + 2, textColor, borderBrush, selectedBackgroundBrush, innerBorderBrush: null, borderThickness: 1, innerBorderThickness: 16, bitmapSize: 128);
            }

            ViewCubeCameraController1.SetViewCubeBitmaps(_normalViewCubeBitmaps);

            // IMPORTANT:
            // Custom selection bitmaps can be only used when edge selection is disabled (otherwise an exception is thrown)
            if (!ViewCubeCameraController1.IsEdgeSelectionEnabled)
            {
                ViewCubeCameraController1.SetSelectedViewCubeBitmaps(_selectedViewCubeBitmaps);
            }


            // Set also Foreground and SelectionBrush - this is used to color the rotation circle and
            // when IsEdgeSelectionEnabled is true to color the cube, edges and corners.
            ViewCubeCameraController1.Foreground     = new SolidColorBrush(foregroundColor);
            ViewCubeCameraController1.SelectionBrush = new SolidColorBrush(selectionColor);

            _isCustomViewCubeBitmaps = true;


            //If we would like to further customize the appearance of the ViewCubeCameraController
            // when mouse enters and leaves a plane, we can use the following events
            // (the code below just sets the bitmaps that are also set by SetViewCubeBitmaps and SetSelectedViewCubeBitmaps methods):

            //ViewCubeCameraController1.ViewCubePlaneEnter += delegate (object sender, ViewCubePlaneEventArgs e)
            //{
            //    int index = (int)e.Plane;
            //    ViewCubeCameraController1.SetViewCubeBitmap(e.Plane, _selectedViewCubeBitmaps[index]);

            //    e.CancelEventHandling = true; // We have manually updated the plane's bitmap so prevent ViewCubeCameraController doing that also
            //};

            //ViewCubeCameraController1.ViewCubePlaneLeave += delegate (object sender, ViewCubePlaneEventArgs e)
            //{
            //    int index = (int)e.Plane;
            //    ViewCubeCameraController1.SetViewCubeBitmap(e.Plane, _normalViewCubeBitmaps[index]);

            //    e.CancelEventHandling = true; // We have manually updated the plane's bitmap so prevent ViewCubeCameraController doing that also
            //};

            //ViewCubeCameraController1.RotationCircleEnter += delegate (object sender, EventArgs args)
            //{
            //    ViewCubeCameraController1.SetRotationCircleBrush(Brushes.Red);
            //};

            //ViewCubeCameraController1.RotationCircleLeave += delegate (object sender, EventArgs args)
            //{
            //    ViewCubeCameraController1.SetRotationCircleBrush(Brushes.Yellow);
            //};


            // For further customization see below for the source code of the SetDefaultViewCubeBitmaps and RenderViewCubeBitmap methods.
        }