private void UpdateColor() { if (_parentColorObjectNew) { _currentColor = _parentColorObjectNew.CurrentColor; } switch (_currentColor) { case ColorOption.blue: _light.color = Color.blue; _maxIntensity = (_multipliers.Blue * _baseIntensity); break; case ColorOption.green: _light.color = Color.green; _maxIntensity = (_multipliers.Green * _baseIntensity); break; case ColorOption.red: _light.color = Color.red; _maxIntensity = (_multipliers.Red * _baseIntensity); break; case ColorOption.yellow: _light.color = Color.yellow; _maxIntensity = (_multipliers.Yellow * _baseIntensity); break; case ColorOption.invalid: Debug.LogWarning("Invalid color!"); break; } }
public void SetColorOptions() { //white, blue, red, silver, orange ColorOption.Add(new SelectListItem() { Value = "White", Text = "White" }); ColorOption.Add(new SelectListItem() { Value = "Blue", Text = "Blue" }); ColorOption.Add(new SelectListItem() { Value = "Red", Text = "Red" }); ColorOption.Add(new SelectListItem() { Value = "Silver", Text = "Silver" }); ColorOption.Add(new SelectListItem() { Value = "Orange", Text = "Orange" }); }
public string BuildColor(string Hex, ColorOption ColorOption, [Optional] double alpha, [Optional] int changevalue) { string CssVar = ""; int ChangeValue = 25; if (changevalue != 0) { ChangeValue = changevalue; } MudColor Color = ColorManager.FromHex(Hex); switch (ColorOption) { case ColorOption.Rgb: CssVar = $"rgb({Color.R},{Color.G},{Color.B})"; break; case ColorOption.RgbA: string Alpha = alpha.ToString("G", CultureInfo.InvariantCulture); CssVar = $"rgba({Color.R},{Color.G},{Color.B}, {Alpha})"; break; case ColorOption.Lighten: Color = ColorManager.ColorLighten(Color, ChangeValue); CssVar = $"rgb({Color.R},{Color.G},{Color.B})"; break; case ColorOption.Darken: Color = ColorManager.ColorDarken(Color, ChangeValue); CssVar = $"rgb({Color.R},{Color.G},{Color.B})"; break; } return(CssVar); }
public ColorOption GetColorOptionFromMaterial() { Color color = GetComponent <MeshRenderer>().material.color; CurrentColor = ColorOption.invalid; if (color == Color.red) { CurrentColor = ColorOption.red; } if (color == Color.blue) { CurrentColor = ColorOption.blue; } if (color == Color.yellow) { CurrentColor = ColorOption.yellow; } if (color == Color.green) { CurrentColor = ColorOption.green; } return(CurrentColor); }
public async Task <IActionResult> Create([Bind("ColorOptionId,Color,ProductId")] ColorOption colorOption, bool again) { // Check if user is authenticated if (User.Identity.IsAuthenticated) { if (ModelState.IsValid) { _context.Add(colorOption); await _context.SaveChangesAsync(); if (again) { return(RedirectToAction("Create", "ColorOptions", new { id = colorOption.ProductId })); } return(RedirectToAction("Create", "ProductImages", new { id = colorOption.ProductId })); } ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductId", colorOption.ProductId); return(View(colorOption)); } else { return(NotFound()); } }
public string BuildColor(string Hex, ColorOption ColorOption, [Optional] double alpha) { string CssVar = ""; MudColor Color = HexToRgb(Hex); switch (ColorOption) { case ColorOption.Rgb: CssVar = $"rgb({Color.R},{Color.G},{Color.B})"; break; case ColorOption.RgbA: string Alpha = alpha.ToString("G", CultureInfo.InvariantCulture); CssVar = $"rgba({Color.R},{Color.G},{Color.B}, {Alpha})"; break; case ColorOption.Lighten: Color = Lighten(Color); CssVar = $"rgb({Color.R},{Color.G},{Color.B})"; break; case ColorOption.Darken: Color = Darken(Color); CssVar = $"rgb({Color.R},{Color.G},{Color.B})"; break; } return(CssVar); }
public void UpdateCurrentColor(Color newColor) { Material material = GetComponent <MeshRenderer>().material; material.color = newColor; CurrentColor = GetColorOptionFromMaterial(); }
public ColorOption RandomizeColor() { int rndInt = UnityEngine.Random.Range(1, 5); ColorOption rndColor = (ColorOption)rndInt; return(rndColor); }
/// <summary> /// Sets the color for the LED on the Kinect. /// </summary> /// <param name="color"> /// Color value in KinectLED.ColorOption. /// </param> private void SetLEDColor(ColorOption color) { int result = KinectNative.freenect_set_led(this.parentDevice.devicePointer, color); if (result != 0) { throw new Exception("Could not set color to " + color + ". Error Code:" + result); } this.color = color; }
private void TryClearDesiredColor(Pawn pawn, Apparel apparel, ColorOption colorOption) { if (apparel.DesiredColor.HasValue && apparel.DesiredColor.Value == colorOption.GetColor(pawn)) { apparel.DesiredColor = null; if (pawn.CurJobDef == JobDefOf.RecolorApparel) { pawn.jobs.StopAll(); } } }
public void Generate(ColorOption colorOption, Vector2[] points) { RebuildMeshes(points); EnsureInternalHighlightable(); UpdateCollider(); ColorOption = colorOption; UpdateRendererColors(ColorOption.GetColor(), ColorOption.GetColor()); UpdateRendererCutoff(0.0f, 0.0f); }
public ColorSelectorDrawer() { this.InitializeComponent(); this.ContentArea.DataContext = this; List <ColorOption> colors = new List <ColorOption>(); PropertyInfo[] properties = typeof(Colors).GetProperties(BindingFlags.Static | BindingFlags.Public); foreach (PropertyInfo property in properties) { if (property == null) { continue; } object?obj = property.GetValue(null); if (obj == null) { continue; } if (property.Name == "Transparent") { continue; } colors.Add(new ColorOption((WpfColor)obj, property.Name)); } ColorConverter colorConverter = new ColorConverter(); colors.Sort((a, b) => { string aHex = colorConverter.ConvertToString(a.Color); string bHex = colorConverter.ConvertToString(b.Color); return(aHex.CompareTo(bHex)); }); foreach (ColorOption c in colors) { this.List.Items.Add(c); } if (FavoritesService.Colors != null) { foreach (Color4 color in FavoritesService.Colors) { ColorOption op = new ColorOption(color, string.Empty); this.RecentList.Items.Add(op); } } }
static ColorOption GetColorOptionFromRegKey(RegistryKey rk) { ColorOption co = new ColorOption(); if (lastColor.GetValue("r") != null && lastColor.GetValue("g") != null && lastColor.GetValue("b") != null) { co.r = (int)(rk.GetValue("r")); co.g = (int)(rk.GetValue("g")); co.b = (int)(rk.GetValue("b")); } return(co); }
bool InputEqualsPrompt(ColorOption input) { ColorOption promptColor = colorPromptGO.GetComponent <ColorObject>().currentColor; if (input == promptColor) { return(true); } else { return(false); } }
private static ColorOption GenerateColor(string color, string[] images) { var co = new ColorOption() { Color = color }; foreach (string img in images) { co.Images.Add(new ProductImage(img)); } return(co); }
// TODO: These are defined in the parent so don't need redefining in any page class.... //public event PropertyChangedEventHandler PropertyChanged; //protected virtual void OnPropertyChanged(string propertyName) //{ // var handler = this.PropertyChanged; // if (handler != null) // handler(this, new PropertyChangedEventArgs(propertyName)); //} #endregion ------------ Implement INotifyPropertyChanged ------------ #region ------------ Event handlers that are specific to this GUI implementation, so are not implemented as ICommand objects ------------ private async void lstJumpPoints_ItemTap(object sender, ItemTappedEventArgs e) { JumpPoint jp = e.Item as JumpPoint; if (jp == null) { return; } ColorOption colorOption = jp.ColorOption; ((ListView)sender).SelectedItem = null; // de-select the row lstColors.ScrollTo(colorOption, ScrollToPosition.Center, false);; }
private void InstantiateCells(List <ConvexPoly> polys, ColorOption[] pickedColors) { for (int polyIndex = 0; polyIndex < polys.Count; ++polyIndex) { ColorOption colorOption = pickedColors[polyIndex]; PaintingCell cell = Instantiate <PaintingCell>(cellPrefab); cell.name = string.Format("Cell #{0}", polyIndex + 1); cell.transform.SetParent(transform, false); cell.gameObject.SetActive(true); cell.Generate(colorOption, polys[polyIndex].GetInsetPoints(shapeBorderWidth * 0.5f)); Cells.Add(cell); } }
public bool isAllowed(ColorOption color) { bool contains = false; foreach (var allowed in this.allowed) { if (allowed.color == color.color) { contains = true; break; } } return(contains); }
// ---------------------- void ChangeSelection(enPropertyTarget propertyTarget, ColorOption colorOption, bool newValue) { if (newValue == false) { if (((propertyTarget == enPropertyTarget.BackgroundColor) && (BackgroundColorOption == colorOption)) || ((propertyTarget == enPropertyTarget.TextColor) && (TextColorOption == colorOption))) { // Can't deselect the current item, as we don't know what else to select instead colorOption.OnPropertyChanged("BackgroundSelected"); } else { colorOption.SetSelected(propertyTarget, false); } } else if ((propertyTarget == enPropertyTarget.BackgroundColor) && (colorOption == TextColorOption)) { // Text and Background cannot be the same //TODO: Show message? colorOption.OnPropertyChanged("BackgroundSelected"); } else if ((propertyTarget == enPropertyTarget.TextColor) && (colorOption == BackgroundColorOption)) { // Text and Background cannot be the same //TODO: Show message? colorOption.OnPropertyChanged("TextSelected"); } else { foreach (var item in _colorOptions) { if (item != colorOption) { item.SetSelected(propertyTarget, false); } } colorOption.SetSelected(propertyTarget, true); if (propertyTarget == enPropertyTarget.BackgroundColor) { BackgroundColorOption = colorOption; } else if (propertyTarget == enPropertyTarget.TextColor) { TextColorOption = colorOption; } } }
public void UpdateColor(GameObject colorGO) { ColorOption inputColor = 0; ColorOption newColorOption = 0; Material targetMaterial = colorGO.GetComponent <MeshRenderer>().material; // Check which type of input we received NOTE: this is now redundant. Only used for prompt. if (colorGO == colorPromptGO) // update prompt material { // Should probably make this into its own method. inputColor = PlayerController.Instance.DisplayRandomColor(); ColorObject colorObject = colorGO.GetComponent <ColorObject>(); newColorOption = RandomizeColor(); colorObject.currentColor = newColorOption; colorObject.LightColorPrompt(); } Color newColor = Color.black; switch (newColorOption) { case ColorOption.blue: newColor = Color.blue; break; case ColorOption.green: newColor = Color.green; break; case ColorOption.red: newColor = Color.red; break; case ColorOption.yellow: newColor = Color.yellow; break; case ColorOption.invalid: Debug.LogWarning("Invalid color!"); break; } if (targetMaterial.color != newColor) { targetMaterial.color = newColor; } }
private void AssignRandomColor() { _lastColor = GetColorOptionFromMaterial(); Color rndColor = _colors[Random.Range(0, _length)]; UpdateCurrentColor(rndColor); switch (_repetitionOption) { case RepetitionOption.TrueRandom: /*already shuffled*/; break; case RepetitionOption.ReduceRepeat: RandomizeReduceRepeat(rndColor); break; case RepetitionOption.NoRepeat: RandomizeNoRepeat(rndColor); break; default: RandomizeNoRepeat(rndColor); break; } }
private void HandleColorObjectButtonSelected(ColorObjectBase callingColorObject) { string message = callingColorObject.ToString(); ColorOption promptColor = GetColorOptionFromMaterial(); if (callingColorObject.CurrentColor == promptColor) { EventManager.RaiseColorMatch(callingColorObject.OwningPlayer); message += " SUCCESS!"; AssignRandomColor(); } else { EventManager.RaiseColorMismatch(callingColorObject.OwningPlayer); message += " FAIL!"; } print(message); }
public async Task <IActionResult> Edit(int id, [Bind("ColorOptionId,Color,ProductId")] ColorOption colorOption) { // Check if user is authenticated if (User.Identity.IsAuthenticated) { if (id != colorOption.ColorOptionId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(colorOption); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ColorOptionExists(colorOption.ColorOptionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductId", colorOption.ProductId); return(View(colorOption)); } else { return(NotFound()); } }
public ColorSelectorDrawer() { this.InitializeComponent(); PropertyInfo[] properties = typeof(Colors).GetProperties(BindingFlags.Static | BindingFlags.Public); foreach (PropertyInfo property in properties) { Color c = (Color)property.GetValue(null); if (c.A <= 0) { continue; } ColorOption op = new ColorOption(); op.Name = property.Name; op.Color = c; this.Selector.Items.Add(op); } this.Selector.FilterItems(); }
public ColorOptionVM(ColorOption colorOption) { Id = colorOption.Id; Name = colorOption.Name; }
public JumpPoint(string text, ColorOption colorOption) { _text = text; _colorOption = colorOption; }
/// <summary> /// Sets the color for the LED on the Kinect. /// </summary> /// <param name="color"> /// Color value in KinectLED.ColorOption. /// </param> private void SetLEDColor(ColorOption color) { int result = KinectNative.freenect_set_led(this.parentDevice.devicePointer, color); if(result != 0) { throw new Exception("Could not set color to " + color + ". Error Code:" + result); } this.color = color; }
private void blockColor_Click(object sender, EventArgs e) { mOption = ColorOption.Block; }
void InitColorOptions() { // ---------------------- Fill in _colorOptions List <ColorOption> list = new List <ColorOption>(); foreach (var item in NamedColor.All) { ColorOption colorOption = new ColorOption(this, item); list.Add(colorOption); } var list2 = list.OrderBy(x => x.NamedColor.Name); _colorOptions.Clear(); _colorOptions.AddRange(list2); // ---------------------- Create the Jump Points Dictionary <string, JumpPoint> dict = new Dictionary <string, JumpPoint>(); foreach (var item in list2) { string cName = item.NamedColor.Name; string key = cName.Substring(0, 1); if (!dict.ContainsKey(key)) { dict.Add(key, new JumpPoint(key, item)); } } List <JumpPoint> jumps = new List <JumpPoint>(); foreach (var item in dict) { jumps.Add(item.Value); } _jumpPoints.Clear(); _jumpPoints.AddRange(jumps); OnPropertyChanged("ColorOptions"); OnPropertyChanged("JumpPoints"); // ---------------------- if (Application.Current.Resources.ContainsKey(_backgroundColorKey)) { Color color = (Color)Application.Current.Resources[_backgroundColorKey]; BackgroundColorOption = FindColorOption(_colorOptions, color); if (_backgroundColorOption != null) { _backgroundColorOption.SetSelected(enPropertyTarget.BackgroundColor, true); } } if (Application.Current.Resources.ContainsKey(_textColorKey)) { Color color = (Color)Application.Current.Resources[_textColorKey]; _textColorOption = FindColorOption(_colorOptions, color); if (_textColorOption != null) { _textColorOption.SetSelected(enPropertyTarget.TextColor, true); } } }
public ColorProperty(ColorOption ContextColor) { Color = ContextColor; }
public ColorAttribute(ColorOption color):base("ColorAttribute") { this.Color = color; }
private void tileColor_Click(object sender, EventArgs e) { mOption = ColorOption.Tile; }
public ChatText(string text, ColorOption foregroundColor = ColorOption.White) { Text = text; ForegroundColor = foregroundColor; }
private static IOption CreateShellOptionInternal(Category shellSubCategory, OptionDefType uiOption, string defaultValue) { IOption shellOption = null; string s = !string.IsNullOrEmpty(string.Concat(uiOption.Text)) ? string.Concat(uiOption.Text) : defaultValue; if (string.IsNullOrEmpty(s)) { s = string.Empty; } bool canOverride = uiOption.IsOverrideAllowed; switch (uiOption.DataType) { case OptionDataTypeEnum.Boolean: { bool val = GetBool(s); shellOption = new BoolOption(uiOption.Name, val, val, canOverride) { DisplayName = uiOption.DisplayText, Description = uiOption.DisplayText, Category = shellSubCategory == null ? null : shellSubCategory.Parent, SubCategory = shellSubCategory }; break; } case OptionDataTypeEnum.Integer: { int val = GetInt(s); shellOption = new IntegerOption(uiOption.Name, val, val, canOverride) { DisplayName = uiOption.DisplayText, Description = uiOption.DisplayText, Category = shellSubCategory == null ? null : shellSubCategory.Parent, SubCategory = shellSubCategory }; break; } case OptionDataTypeEnum.String: { if (uiOption.Encrypted) { shellOption = new EncryptionOption(uiOption.Name, s, s, canOverride) { DisplayName = uiOption.DisplayText, Description = uiOption.DisplayText, Category = shellSubCategory == null ? null : shellSubCategory.Parent, SubCategory = shellSubCategory }; } else { shellOption = new StringOption(uiOption.Name, s, s, canOverride) { DisplayName = uiOption.DisplayText, Description = uiOption.DisplayText, Category = shellSubCategory == null ? null : shellSubCategory.Parent, SubCategory = shellSubCategory, IsPrimaryKey = uiOption.IsPrimaryKey }; } break; } case OptionDataTypeEnum.Color: { var val = GetColor(s); shellOption = new ColorOption(uiOption.Name, val, val, canOverride) { DisplayName = uiOption.DisplayText, Description = uiOption.DisplayText, Category = shellSubCategory == null ? null : shellSubCategory.Parent, SubCategory = shellSubCategory }; break; } case OptionDataTypeEnum.KeyValueRange: { int val = GetInt(s); shellOption = new EnumOption(uiOption.Name, val, val, canOverride, GetEnumValues(uiOption)) { DisplayName = uiOption.DisplayText, Description = uiOption.DisplayText, Category = shellSubCategory == null ? null : shellSubCategory.Parent, SubCategory = shellSubCategory }; break; } case OptionDataTypeEnum.Format: case OptionDataTypeEnum.Range: default: { // do nothing. these need to be converted #if DEBUG throw new NotImplementedException(); #else break; #endif } } return shellOption; }