Example #1
0
        private Material SetMaterial(PartColors materialColor)
        {
            PartColor pc = KnownPartColors.GetColor(materialColor);

            //SolidColorBrush sb = new SolidColorBrush(color.Color);
            //if (color.Alpha > 0)
            //    sb.Opacity = color.Alpha / 255.0;

            return(new DiffuseMaterial(pc.Color));
        }
Example #2
0
        public static PartColor GetColor(PartColors color)
        {
            PartColor c = null;

            try {
                c = KnownPartColors.Colors[(int)color];
            }
            catch (Exception) {
                c = KnownPartColors.GetColor(PartColors.Black);
            }

            return(c);
        }
Example #3
0
        private static void ColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PartUI s = (PartUI)d;

            if (s.Visual3DModel != null)
            {
                s.PartColor = (PartColors)e.NewValue;
                Model3DGroup    mg  = (Model3DGroup)s.Visual3DModel;
                DiffuseMaterial mat = ((GeometryModel3D)mg.Children[0]).Material as DiffuseMaterial;

                PartColor newColor = KnownPartColors.GetColor(s.PartColor);
                if (mat != null)
                {
                    mat.Brush = newColor.Color;
                }
            }
        }