Beispiel #1
0
 private void ColorSlider_ColorChanged(object sender, Color color)
 {
     Utility.HSBColor hsbcolorcp = Utility.HSBColor.FromColor(ColorPicker.Color);
     Utility.HSBColor hsbcolorcs = Utility.HSBColor.FromColor(color);
     hsbcolorcp.H = hsbcolorcs.H;
     //hsbcolorcp.S = hsbcolorcs.S;
     ColorPicker.Color = hsbcolorcp.ToColor();
     //
     _submitColorChange();
 }
Beispiel #2
0
        private void _submitcommanddelay_Tick(object sender, EventArgs e)
        {
            _submitcommanddelay.Stop();
            Module module = (Module)((FrameworkElement)this).DataContext;

            //
            Utility.HSBColor hsbcolor = Utility.HSBColor.FromColor(ColorPicker.Color);
            //
            string url = "/api/" + module.Domain + "/" + module.Address + "/Control.ColorHsb/" +
                         (hsbcolor.H / 360d).ToString(CultureInfo.InvariantCulture) + ',' +
                         (hsbcolor.S).ToString(CultureInfo.InvariantCulture) + ',' +
                         (hsbcolor.B).ToString(CultureInfo.InvariantCulture) + "/" + DateTime.Now.Ticks.ToString();

            App.HttpManager.AddToQueue("Control.ColorHsb", url, (WebRequestCompletedArgs args) =>
            {
                //this.Dispatcher.BeginInvoke(() =>
                //{
                App.ViewModel.UpdateCurrentGroup();
                //});
            });
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Color color = new Color();

            try
            {
                foreach (ModuleParameter p in (ObservableCollection <ModuleParameter>)value)
                {
                    if (p.Name == (string)parameter && p.Value != null && p.Value != "")
                    {
                        string[] colors = p.Value.Split(',');
                        if (colors.Length == 3)
                        {
                            double h = 0;
                            double s = 0;
                            double b = 0;
                            if (double.TryParse(colors[0], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out h) &&
                                double.TryParse(colors[1], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out s) &&
                                double.TryParse(colors[2], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out b))
                            {
                                Utility.HSBColor hsbcolor = new Utility.HSBColor();
                                hsbcolor.A = 255;
                                hsbcolor.H = h * 360d;
                                hsbcolor.S = s;
                                hsbcolor.B = b;
                                color      = hsbcolor.ToColor();
                            }
                        }
                        break;
                    }
                }
            }
            catch (Exception)
            {
            }
            return(color);
        }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     Color color = new Color();
     try
     {
         foreach (ModuleParameter p in (ObservableCollection<ModuleParameter>)value)
         {
             if (p.Name == (string)parameter && p.Value != null && p.Value != "")
             {
                 string[] colors = p.Value.Split(',');
                 if (colors.Length == 3)
                 {
                     double h = 0;
                     double s = 0;
                     double b = 0;
                     if (double.TryParse(colors[0], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out h) &&
                         double.TryParse(colors[1], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out s) &&
                         double.TryParse(colors[2], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out b))
                     {
                         Utility.HSBColor hsbcolor = new Utility.HSBColor();
                         hsbcolor.A = 255;
                         hsbcolor.H = h * 360d;
                         hsbcolor.S = s;
                         hsbcolor.B = b;
                         color = hsbcolor.ToColor();
                     }
                 }
                 break;
             }
         }
     }
     catch (Exception)
     {
     }
     return color;
 }