public static Color GetColor(int collisionRecency) { // Return a color switch (SelectedPalette) { case Palette.Complex: // If called right after initialisation of Skaters, return a random color from the palette. if (collisionRecency == -1) { return(PaletteColors[Shared.GetRandom.Next(PaletteColors.Count())]); } // If we do have a recent collision, we return red. else if (collisionRecency > 0) { return(Color.Red); } // Return white if no collision. else { return(Color.White); } case Palette.Gradual: // White as base color, colors indicate collision recency. if (collisionRecency > 0) { // Cannot rely on default rounding of ints, so we have to cast twice. // -> We want 10 / (10 / 5) = 4 (because that is the highest index in PaletteColors if Count == 5) // -> Substracting 1 is not a solution, because then 1 / (10 / 5) - 1 = -1. // -> Substracting 0.5 causes perfect behaviour, but only if initial division result is already a double. return(PaletteColors[(int)(collisionRecency / (CollisionFadeSpeed / (double)PaletteColors.Count) - 0.5)]); } else { return(Color.White); } case Palette.Simple: // White as base color, red indicates recent collision. if (collisionRecency > 0) { return(PaletteColors[1]); } else { return(PaletteColors[0]); } case Palette.White: // Returns white, always. return(PaletteColors[0]); case Palette.Black: // Returns white, always. return(PaletteColors[0]); } return(Color.White); }
private void PaletteColorSelectedMessageReceived(PaletteColorSelectedMessage message) { if (SelectedColor != null && SelectedColor.Id != message.Id) { SelectedColor.Unselect(); } SelectedColor = PaletteColors.First(x => x.Id == message.Id); }
/// <summary> /// 속성들을 Xml Attribute로 생성합니다. /// </summary> /// <param name="writer">Attribute를 쓸 Writer</param> public override void GenerateXmlAttributes(System.Xml.XmlWriter writer) { base.GenerateXmlAttributes(writer); if (PaletteColors.IsNotWhiteSpace()) { writer.WriteAttributeString("paletteColors", PaletteColors); } if (ShowPlotBorder.HasValue) { writer.WriteAttributeString("showPlotBorder", ShowPlotBorder.GetHashCode().ToString()); } if (PlotBorderColor.HasValue) { writer.WriteAttributeString("plotBorderColor", PlotBorderColor.Value.ToHexString()); } if (PlotBorderThickness.HasValue) { writer.WriteAttributeString("plotBorderThickness", PlotBorderThickness.ToString()); } if (PlotBorderAlpha.HasValue) { writer.WriteAttributeString("plotBorderAlpha", PlotBorderAlpha.ToString()); } if (PlotFillAlpha.HasValue) { writer.WriteAttributeString("plotFillAlpha", PlotFillAlpha.ToString()); } if (PlotFillColor.HasValue) { writer.WriteAttributeString("plotFillColor", PlotFillColor.Value.ToHexString()); } if (PieRadius.HasValue) { writer.WriteAttributeString("pieRadius", PieRadius.ToString()); } if (PieFillAlpha.HasValue) { writer.WriteAttributeString("PieFillAlpha", PieFillAlpha.ToString()); } if (PieBorderThickness.HasValue) { writer.WriteAttributeString("PieBorderThickness", PieBorderThickness.ToString()); } if (HoverFillColor.HasValue) { writer.WriteAttributeString("HoverFillColor", HoverFillColor.Value.ToHexString()); } if (PieBorderColor.HasValue) { writer.WriteAttributeString("PieBorderColor", PieBorderColor.Value.ToHexString()); } if (UseHoverColor.HasValue) { writer.WriteAttributeString("useHoverColor", UseHoverColor.GetHashCode().ToString()); } }
public override void WriteInitializationScript(TextWriter writer) { var options = new Dictionary <string, object>(Events); if (Palette == ColorPickerPalette.Basic) { options["palette"] = "basic"; } else if (Palette == ColorPickerPalette.WebSafe) { options["palette"] = "websafe"; } else if (PaletteColors != null && PaletteColors.Any()) { options["palette"] = PaletteColors; } if (Opacity) { options["opacity"] = true; } if (!Buttons) { options["buttons"] = false; } if (!string.IsNullOrEmpty(ToolIcon)) { options["toolIcon"] = ToolIcon; } if (!string.IsNullOrEmpty(Value)) { options["value"] = Value; } if (TileSize != null) { var tileSize = TileSize as ColorPaletteTileSize; if (tileSize != null) { options["tileSize"] = new { width = tileSize.Width, height = tileSize.Height }; } else { options["tileSize"] = (int)TileSize; } } writer.Write(Initializer.Initialize(Selector, "ColorPicker", options)); base.WriteInitializationScript(writer); }
public Color this[PaletteColors color] { get { if ((int)color >= colors.Count) { return(System.Windows.Media.Colors.Black); } return(colors[(int)color]); } set { if ((int)color >= colors.Count) { return; } colors[(int)color] = value; } }
public override void WriteInitializationScript(TextWriter writer) { var options = new Dictionary <string, object>(Events); if (Palette == ColorPickerPalette.Basic) { options["palette"] = "basic"; } else if (Palette == ColorPickerPalette.WebSafe) { options["palette"] = "websafe"; } else if (PaletteColors != null && PaletteColors.Any()) { options["palette"] = PaletteColors; } if (Columns != ColumnsDefault) { options["columns"] = Columns; } if (TileSize != null) { var tileSize = TileSize as ColorPaletteTileSize; if (tileSize != null) { options["tileSize"] = new { width = tileSize.Width, height = tileSize.Height }; } else { options["tileSize"] = (int)TileSize; } } writer.Write(Initializer.Initialize(Selector, "ColorPalette", options)); base.WriteInitializationScript(writer); }
public void SetSelectedColor(Texture texture) { SelectedColor?.Unselect(); SelectedColor = PaletteColors.First(x => x.Texture == texture); SelectedColor.Select(); }
public Color GetCurrentColor(PaletteColors color) { switch (color) { case PaletteColors.YELLOW: return C_YELLOW; case PaletteColors.GREEN: return C_GREEN; case PaletteColors.BLUE: return C_BLUE; case PaletteColors.PURPLE: return C_PURPLE; case PaletteColors.RED: return C_RED; case PaletteColors.BROWN: return C_BROWN; case PaletteColors.WHITE: return C_WHITE; case PaletteColors.BLACK: return C_BLACK; default: return C_BLACK; } }
/// <summary> /// 속성 중 Attribute Node로 표현해야 한다. /// </summary> /// <param name="writer"></param> public override void GenerateXmlAttributes(XmlWriter writer) { base.GenerateXmlAttributes(writer); // NOTE: 자동으로 속성을 XmlAttribute로 생성합니다 (개발 중) // ChartExtensions.WriteChartAttribute((FusionChartBase)this, writer); if (Animation.HasValue) { writer.WriteAttributeString("Animation", Animation.Value.GetHashCode().ToString()); } if (PaletteColors.IsNotWhiteSpace()) { writer.WriteAttributeString("PaletteColors", PaletteColors); } if (LabelDisplay.HasValue) { writer.WriteAttributeString("LabelDisplay", LabelDisplay.Value.ToString()); } if (RotateLabels.HasValue) { writer.WriteAttributeString("RotateLabels", RotateLabels.GetHashCode().ToString()); } if (SlantLabels.HasValue) { writer.WriteAttributeString("SlantLabels", SlantLabels.GetHashCode().ToString()); } if (LabelStep.HasValue) { writer.WriteAttributeString("LabelStep", LabelStep.ToString()); } if (StaggerLines.HasValue) { writer.WriteAttributeString("StaggerLines", StaggerLines.ToString()); } if (PlaceValuesInside.HasValue) { writer.WriteAttributeString("PlaceValuesInside", PlaceValuesInside.GetHashCode().ToString()); } if (ShowLimits.HasValue) { writer.WriteAttributeString("ShowLimits", ShowLimits.GetHashCode().ToString()); } if (ShowDivLineValues.HasValue) { writer.WriteAttributeString("ShowDivLineValues", ShowDivLineValues.GetHashCode().ToString()); } if (ShowPercentValues.HasValue) { writer.WriteAttributeString("showPercentValues", ShowPercentValues.GetHashCode().ToString()); } if (AdjustDiv.HasValue) { writer.WriteAttributeString("AdjustDiv", AdjustDiv.GetHashCode().ToString()); } if (MaxColWidth.HasValue) { writer.WriteAttributeString("MaxColWidth", MaxColWidth.ToString()); } if (Use3DLighting.HasValue) { writer.WriteAttributeString("Use3DLighting", Use3DLighting.GetHashCode().ToString()); } if (SetAdaptiveYMin.HasValue) { writer.WriteAttributeString("SetAdaptiveYMin", SetAdaptiveYMin.GetHashCode().ToString()); } if (Is2D.HasValue) { writer.WriteAttributeString("is2D", Is2D.GetHashCode().ToString()); } if (ChartOnTop.HasValue) { writer.WriteAttributeString("chartOnTop", ChartOnTop.GetHashCode().ToString()); } if (XLabelGap.HasValue) { writer.WriteAttributeString("xLabelGap", XLabelGap.ToString()); } if (YLabelGap.HasValue) { writer.WriteAttributeString("yLabelGap", YLabelGap.ToString()); } if (NumVisiblePlot.HasValue) { writer.WriteAttributeString("numVisiblePlot", NumVisiblePlot.ToString()); } if (ScrollToEnd.HasValue) { writer.WriteAttributeString("scrollToEnd", ScrollToEnd.GetHashCode().ToString()); } if (_anchor != null) { _anchor.GenerateXmlAttributes(writer); } if (NumDivLines.HasValue) { writer.WriteAttributeString("numDivLines", NumDivLines.ToString()); } if (_divLine != null) { _divLine.GenerateXmlAttributes(writer); } if (_zeroPlane != null) { _zeroPlane.GenerateXmlAttributes(writer); } if (NumVDivLines.HasValue) { writer.WriteAttributeString("numVDivLines", NumVDivLines.ToString()); } if (_vDivLine != null) { _vDivLine.GenerateXmlAttributes(writer); } if (_alternateHGrid != null) { _alternateHGrid.GenerateXmlAttributes(writer); } if (_alternateVGrid != null) { _alternateVGrid.GenerateXmlAttributes(writer); } if (DivLineEffect.HasValue) { writer.WriteAttributeString("divLineEffect", DivLineEffect.ToString().ToUpper()); } if (_outCnvBaseFontAttr != null) { _outCnvBaseFontAttr.GenerateXmlAttributes(writer); } if (_dataPlotAttr != null) { _dataPlotAttr.GenerateXmlAttributes(writer); } if (_xAxisAttr != null) { _xAxisAttr.GenerateXmlAttributes(writer); } if (_yAxisAttr != null) { _yAxisAttr.GenerateXmlAttributes(writer); } }
public static Material LoadMaterial(PaletteColors _color, PaletteTone _tone, PaletteType _type = PaletteType.diffuse_saturated) { return(LoadMaterial(string.Format("{0}_{1}", _color.ToString(), _tone.ToString()), _type)); }