public ViewCubeCameraControllerSample() { InitializeComponent(); int fontSize = 27; // 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 backgroundBrush = Brushes.LightGreen; // Default Brush is the same as ViewCubeCameraController.Foreground var selectedBackgroundBrush = new RadialGradientBrush(Colors.White, Colors.LightGreen); 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 = ViewCubeCameraController3.DefaultCubePlaneTexts[i]; _normalViewCubeBitmaps[i] = ViewCubeCameraController.RenderViewCubeBitmap(planeText, fontSize - 2, textColor, borderBrush, backgroundBrush); _selectedViewCubeBitmaps[i] = ViewCubeCameraController.RenderViewCubeBitmap(planeText, fontSize + 2, textColor, borderBrush, selectedBackgroundBrush); // To render standard selection bitmap with thick border use the following: //_selectedViewCubeBitmaps[i] = ViewCubeCameraController.RenderViewCubeBitmap(planeText, fontSize + 2, textColor, borderBrush, Brushes.White, backgroundBrush, 2, 16, 128); } ViewCubeCameraController3.SetViewCubeBitmaps(_normalViewCubeBitmaps); ViewCubeCameraController3.SetSelectedViewCubeBitmaps(_selectedViewCubeBitmaps); // Set also Foreground and SelectionBrush - this is used to color the rotation circle ViewCubeCameraController3.Foreground = backgroundBrush; ViewCubeCameraController3.SelectionBrush = new SolidColorBrush(Color.FromRgb(200, 255, 200)); // very light green // We could also set bitmaps with the SetViewCubeBitmaps method that does not take array of BitmapSources: //ViewCubeCameraController3.SetViewCubeBitmaps(/* right */ ViewCubeCameraController.RenderViewCubeBitmap("EAST", fontSize, textColor, borderBrush, backgroundBrush), // /* left */ ViewCubeCameraController.RenderViewCubeBitmap("WEST", fontSize, textColor, borderBrush, backgroundBrush), // /* top */ ViewCubeCameraController.RenderViewCubeBitmap("UP", fontSize, textColor, borderBrush, backgroundBrush), // /* bottom */ ViewCubeCameraController.RenderViewCubeBitmap("DOWN", fontSize, textColor, borderBrush, backgroundBrush), // /* front */ ViewCubeCameraController.RenderViewCubeBitmap("SOUTH", fontSize, textColor, borderBrush, backgroundBrush), // /* back */ ViewCubeCameraController.RenderViewCubeBitmap("NORTH", fontSize, textColor, borderBrush, backgroundBrush)); // If we would like to further customize the appearance of the ViewCubeCameraController // when mouse enters and leaves a plane, we can use the following methods // (the code below just sets the bitmaps that are also set by SetViewCubeBitmaps and SetSelectedViewCubeBitmaps methods): //ViewCubeCameraController3.ViewCubePlaneEnter += delegate(object sender, ViewCubePlaneEventArgs e) //{ // int index = (int) e.Plane; // ViewCubeCameraController3.SetViewCubeBitmap(e.Plane, _selectedViewCubeBitmaps[index]); // e.CancelEventHandling = true; // We have manually updated the plane's bitmap so prevent ViewCubeCameraController doing that also //}; //ViewCubeCameraController3.ViewCubePlaneLeave += delegate(object sender, ViewCubePlaneEventArgs e) //{ // int index = (int) e.Plane; // ViewCubeCameraController3.SetViewCubeBitmap(e.Plane, _normalViewCubeBitmaps[index]); // e.CancelEventHandling = true; // We have manually updated the plane's bitmap so prevent ViewCubeCameraController doing that also //}; //ViewCubeCameraController3.RotationCircleEnter += delegate (object sender, EventArgs args) //{ // ViewCubeCameraController3.SetRotationCircleBrush(Brushes.Red); //}; //ViewCubeCameraController3.RotationCircleLeave += delegate (object sender, EventArgs args) //{ // ViewCubeCameraController3.SetRotationCircleBrush(Brushes.Yellow); //}; // If you would like to customize how the RenderViewCubeBitmap renders the bitmap, see the method source code below. }
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. }