Пример #1
0
 //	Updates the color history combobox
 private void updateHistory(ColorfulRestProperty color)
 {
     if (!ColorHistory.Items.Contains(color))
     {
         ColorHistory.Items.Add(color);
         ColorHistory.SelectedIndex = ColorHistory.Items.Count - 1;
     }
 }
Пример #2
0
        //	Gets Colorful Rest Data from user input.
        private async void hitApi_Click(object sender, RoutedEventArgs e)
        {
            int r = Convert.ToInt32(redInt.Text);
            int g = Convert.ToInt32(greenInt.Text);
            int b = Convert.ToInt32(blueInt.Text);

            object json = await ApiHelpers.getColorApiJson(r, g, b);

            ColorfulRestProperty cProp = new ColorfulRestProperty(json);

            updateUI(cProp);
        }
Пример #3
0
        private async void buttonPin_ValueChanged(object sender, GpioPinValueChangedEventArgs e)
        {
            if (e.Edge == GpioPinEdge.RisingEdge)
            {
                ColorfulRestProperty color = await colorSensor.getColorfulRestData();
                await SpeakColor(color.Name.Value);

                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    updateUI(color, updText: true);
                }).AsTask().Wait();
            }
        }
Пример #4
0
        //	Updates the UI with colorful rest data.
        private void updateUI(ColorfulRestProperty colorData, bool updHistory = true, bool updText = false)
        {
            byte r = (byte)colorData.RGB.Values.Red;
            byte g = (byte)colorData.RGB.Values.Green;
            byte b = (byte)colorData.RGB.Values.Blue;

            colorDetail.Text  = colorData.ToString(true);
            ColorPreview.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, r, g, b));

            if (updHistory)
            {
                updateHistory(colorData);
            }

            if (updText)
            {
                redInt.Text   = colorData.RGB.Values.Red.ToString();
                greenInt.Text = colorData.RGB.Values.Green.ToString();
                blueInt.Text  = colorData.RGB.Values.Blue.ToString();
            }
        }
Пример #5
0
		//	Gets Colorful Rest Data from user input.
		private async void hitApi_Click(object sender, RoutedEventArgs e)
		{
			int r = Convert.ToInt32(redInt.Text);
			int g = Convert.ToInt32(greenInt.Text);
			int b = Convert.ToInt32(blueInt.Text);

			object json = await ApiHelpers.getColorApiJson(r, g, b);

			ColorfulRestProperty cProp = new ColorfulRestProperty(json);
			updateUI(cProp);
		}
Пример #6
0
		//	Updates the UI with colorful rest data.
		private void updateUI(ColorfulRestProperty colorData, bool updHistory = true, bool updText = false)
		{
			byte r = (byte)colorData.RGB.Values.Red;
			byte g = (byte)colorData.RGB.Values.Green;
			byte b = (byte)colorData.RGB.Values.Blue;

			colorDetail.Text = colorData.ToString(true);
			ColorPreview.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, r, g, b));

			if (updHistory)	updateHistory(colorData);

			if (updText)
			{
				redInt.Text = colorData.RGB.Values.Red.ToString();
				greenInt.Text = colorData.RGB.Values.Green.ToString();
				blueInt.Text = colorData.RGB.Values.Blue.ToString();
            }
		}
Пример #7
0
		//	Updates the color history combobox
		private void updateHistory(ColorfulRestProperty color)
		{
			if (!ColorHistory.Items.Contains(color))
			{
				ColorHistory.Items.Add(color);
				ColorHistory.SelectedIndex = ColorHistory.Items.Count - 1;
			}
		}
Пример #8
0
        //	Updates UI with the history item selected
        private void ColorHistory_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ColorfulRestProperty cProp = (ColorfulRestProperty)ColorHistory.SelectedItem;

            updateUI(cProp, false);
        }