FizVizController/FizVizController/Views/BackgroundColorConfig.xaml.cs
/// <summary>
/// Generate an array of background colors that is split into three segments,
/// one per user specified color
/// </summary>
/// <param name="colors"></param>
/// <returns></returns>
Generate an array of background colors that is split into three segments,
one per user specified color
Generate an array of background colors that is split into three segments one per user specified color
private bool GetSegment(IList<Color> colors)
        {
            double angle1, angle2, angle3;
            int color1Pixel, color2Pixel, color3Pixel;
            if (Color1ComboBox_Gradient.SelectedValue == null)
            {
                Color1ComboBox_Gradient.BorderBrush = new SolidColorBrush(Colors.Red);
                return false;
            }
            if (Color2ComboBox.SelectedValue == null)
            {
                Color2ComboBox.BorderBrush = new SolidColorBrush(Colors.Red);
                return false;
            }
            if (Color3ComboBox.SelectedValue == null)
            {
                Color3ComboBox.BorderBrush = new SolidColorBrush(Colors.Red);
                return false;
            }
            if (!ReadAngle(Angle1TextBox, out angle1))
                return false;
            if (!ReadAngle(Angle2TextBox, out angle2))
                return false;
            if (!ReadAngle(Angle3TextBox, out angle3))
                return false;
            if (angle1 >= angle2)
            {
                Angle1TextBox.BorderBrush = new SolidColorBrush(Colors.Red);
                Angle2TextBox.BorderBrush = new SolidColorBrush(Colors.Red);
                return false;
            }
            if (angle2 >= angle3)
            {
                Angle2TextBox.BorderBrush = new SolidColorBrush(Colors.Red);
                Angle3TextBox.BorderBrush = new SolidColorBrush(Colors.Red);
                return false;
            }
            color1Pixel = PixelForAngle(angle1);
            color2Pixel = PixelForAngle(angle2);
            color3Pixel = PixelForAngle(angle3);
            if (color3Pixel == 0)
            {
                color3Pixel = BackgroundColor.NEOPIXEL_COUNT - 1;
            }
            Color color1 = (Color)Color1ComboBox_Gradient.SelectedValue;
            Color color2 = (Color)Color2ComboBox.SelectedValue;
            Color color3 = (Color)Color3ComboBox.SelectedValue;
            for (int i = 0; i < BackgroundColor.NEOPIXEL_COUNT; i++)
            {
                colors[i] = color3;
            }
            for (int i = color1Pixel; i < color2Pixel; i++)
            {
                colors[i] = color1;
            }
            for (int i = color2Pixel; i < color3Pixel; i++)
            {
                colors[i] = color2;
            }
            return true;
        }
private bool GetSegment ( IList < Color > colors ) { double angle1 , angle2 , angle3 ; int color1Pixel , color2Pixel , color3Pixel ; if ( Color1ComboBox_Gradient . SelectedValue == null ) { Color1ComboBox_Gradient . BorderBrush = new SolidColorBrush ( Colors . Red ) ; return false ; } if ( Color2ComboBox . SelectedValue == null ) { Color2ComboBox . BorderBrush = new SolidColorBrush ( Colors . Red ) ; return false ; } if ( Color3ComboBox . SelectedValue == null ) { Color3ComboBox . BorderBrush = new SolidColorBrush ( Colors . Red ) ; return false ; } if ( ! ReadAngle ( Angle1TextBox , out angle1 ) ) return false ; if ( ! ReadAngle ( Angle2TextBox , out angle2 ) ) return false ; if ( ! ReadAngle ( Angle3TextBox , out angle3 ) ) return false ; if ( angle1 >= angle2 ) { Angle1TextBox . BorderBrush = new SolidColorBrush ( Colors . Red ) ; Angle2TextBox . BorderBrush = new SolidColorBrush ( Colors . Red ) ; return false ; } if ( angle2 >= angle3 ) { Angle2TextBox . BorderBrush = new SolidColorBrush ( Colors . Red ) ; Angle3TextBox . BorderBrush = new SolidColorBrush ( Colors . Red ) ; return false ; } color1Pixel = PixelForAngle ( angle1 ) ; color2Pixel = PixelForAngle ( angle2 ) ; color3Pixel = PixelForAngle ( angle3 ) ; if ( color3Pixel == 0 ) { color3Pixel = BackgroundColor . NEOPIXEL_COUNT - 1 ; } Color color1 = ( Color ) Color1ComboBox_Gradient . SelectedValue ; Color color2 = ( Color ) Color2ComboBox . SelectedValue ; Color color3 = ( Color ) Color3ComboBox . SelectedValue ; for ( int i = 0 ; i < BackgroundColor . NEOPIXEL_COUNT ; i ++ ) { colors [ i ] = color3 ; } for ( int i = color1Pixel ; i < color2Pixel ; i ++ ) { colors [ i ] = color1 ; } for ( int i = color2Pixel ; i < color3Pixel ; i ++ ) { colors [ i ] = color2 ; } return true ; }
Generate an array of background colors that is split into three segments,
one per user specified color
Generate an array of background colors that is split into three segments one per user specified color
None
colors
IList<Color>
None