private static Color ColorFromString(string val) { string[] part = val.Split("|".ToCharArray()); float r = 0f; float g = 0f; float b = 0f; float a = 0f; if (float.TryParse(part[0], NumberStyles.Any, CultureInfo.InvariantCulture, out r)) { if (float.TryParse(part[1], NumberStyles.Any, CultureInfo.InvariantCulture, out g)) { if (float.TryParse(part[2], NumberStyles.Any, CultureInfo.InvariantCulture, out b)) { if (part.Length == 4) { float.TryParse(part[3], NumberStyles.Any, CultureInfo.InvariantCulture, out a); } } } } return(ColorExtension.ColorFromVector(new Vector4(r, g, b, a))); }
private static void UnityExtensions() { BehaviourExtension.Example(); CameraExtension.Example(); ColorExtension.Example(); QFramework.GameObjectExtension.Example(); GraphicExtension.Example(); ImageExtension.Example(); ObjectExtension.Example(); UnityActionExtension.Example(); #region RectTransform #endregion #region Selectable #endregion #region Toggle #endregion }
private void ConfigureHalfCircularProgress() { var frame = new CGRect(0, 301, View.Frame.Width, View.Frame.Height / 2); halfCircularProgress = new iOS.CircularProgress(frame, true); var center = new CGPoint(160, 200); var bezier = new UIBezierPath(); bezier.AddArc(center, halfCircularProgress.Frame.Width / 3, (nfloat)Math.PI, (nfloat)0.0, true); halfCircularProgress.Path = bezier; halfCircularProgress.Colors = new [] { ColorExtension.RgbaColor(0xA6E39DAA).CGColor, ColorExtension.RgbaColor(0xAEC1E3AA).CGColor, ColorExtension.RgbaColor(0xAEC1E3AA).CGColor, ColorExtension.RgbaColor(0xF3C0ABAA).CGColor }; halfCircularProgress.LineWidth = 8.0; halfCircularProgress.ProgressGuideColor = new UIColor((nfloat)0.1, (nfloat)0.1, (nfloat)0.1, (nfloat)0.7); textLabel = new UILabel(new CGRect(halfCircularProgress.Frame.X + 120.0, 170.0, 80, 32)); textLabel.TextAlignment = UITextAlignment.Center; textLabel.TextColor = UIColor.Green; textLabel.Font = UIFont.FromName("HelveticaNeue-UltraLight", 20f); textLabel.Alpha = (System.nfloat) 0.5; textLabel.Text = ""; halfCircularProgress.AddSubview(textLabel); halfCircularProgress.ProgressUpdated += (sender, e) => { BeginInvokeOnMainThread(() => textLabel.Text = string.Format("{0}%", (int)(e.Progress * 100))); }; View.AddSubview(halfCircularProgress); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var windowActivated = (bool)value; if (windowActivated) { if (_color1 == null) { _color1 = ColorExtension.GetChromeColor(); } if (_color1 != null) { var color = _color1.Value; var average = (color.R + color.G + color.B) / 3f; return(average >= 128 ? new SolidColorBrush(Color.FromRgb(0, 0, 0)) : new SolidColorBrush(Color.FromRgb(255, 255, 255))); } return(new SolidColorBrush(Color.FromRgb(255, 255, 255))); } return(new SolidColorBrush(Color.FromRgb(0, 0, 0))); }
public void SetupHueGradient(float saturation = 1.0f, float brightness = 1.0f, int accuracy = 256) { ColorBlend blend = new ColorBlend(); blend.Colors = new Color[] { ColorExtension.ColorFromHSV(0.0f, saturation, brightness), ColorExtension.ColorFromHSV(1.0f / 6.0f, saturation, brightness), ColorExtension.ColorFromHSV(2.0f / 6.0f, saturation, brightness), ColorExtension.ColorFromHSV(3.0f / 6.0f, saturation, brightness), ColorExtension.ColorFromHSV(4.0f / 6.0f, saturation, brightness), ColorExtension.ColorFromHSV(5.0f / 6.0f, saturation, brightness), ColorExtension.ColorFromHSV(1.0f, saturation, brightness) }; blend.Positions = new float[] { 0.0f, 1.0f / 6.0f, 2.0f / 6.0f, 3.0f / 6.0f, 4.0f / 6.0f, 5.0f / 6.0f, 1.0f }; this.SetupGradient(blend, accuracy); }
protected override int ExecInternal() { if (ArgNum < 5) { throw new EventErrorException(this, "Lineコマンドの引数の数が違います"); } var x1 = (GetArgAsLong(2) + Event.BaseX); var y1 = (GetArgAsLong(3) + Event.BaseY); var x2 = (GetArgAsLong(4) + Event.BaseX); var y2 = (GetArgAsLong(5) + Event.BaseY); GUI.SaveScreen(); var dtype = ""; var clr = Event.ObjColor; for (var i = 6; i <= ArgNum; i++) { var opt = GetArgAsString(i); if (Strings.Asc(opt) == 35) // # { if (!ColorExtension.TryFromHexString(opt, out clr)) { throw new EventErrorException(this, "色指定が不正です"); } } else { if (opt != "B" && opt != "BF") { throw new EventErrorException(this, "Lineコマンドに不正なオプション「" + opt + "」が使われています"); } dtype = opt; } } var drawOpt = new ScreanDrawOption(Event, clr); switch (dtype ?? "") { case "B": // Box SRC.GUIScrean.BoxCmd(drawOpt, x1, y1, x2, y2); break; case "BF": // Box Fill drawOpt.FillStyle = FillStyle.VbFSSolid; drawOpt.FillColor = drawOpt.ForeColor; SRC.GUIScrean.BoxCmd(drawOpt, x1, y1, x2, y2); break; default: // Line SRC.GUIScrean.LineCmd(drawOpt, x1, y1, x2, y2); break; } return(EventData.NextID); }
public void SetData(UTileViewItemRoomHeroSkin item) { if (SkinIconImage == null || SelectFrame == null || SkinProssesText == null || SkinGradeText == null || SkinNameText == null || SkinBuyObj == null) { return; } if (item.eRoomState == Stage_ManagerDef.EMatchRoomState.MatchRoomState_Wait) { SkinMaskObj.SetActive(false); } else { if (item.eRoomState == Stage_ManagerDef.EMatchRoomState.MatchRoomState_SelectHero) { SkinMaskObj.SetActive(!item.bIsHaveSkin); } } SkinIconImage.sprite = USpriteManager.Instance.GetSprite(USpriteManager.ESpriteType.EST_HeadPortrait, WndID.WND_ID_GAMEWAITINGROOMVIEW, item.nSkinIconId, 6, item.nHeroID); SkinIconImage.gameObject.SetActive(SkinIconImage.sprite); string[] szWord = new string[] { "经典", "传说", "史诗", "终极" }; int nSkinGrade = item.nSkinType; if (nSkinGrade >= 0 && nSkinGrade < szWord.Length) { SkinGradeText.text = szWord[nSkinGrade]; } SkinNameText.text = item.szSkinName; string szProssesText = ""; Color prossesColor = Color.white; if (item.bIsHaveSkin) { if (item.dwSkinLimitTime > 0) { DateTime calcTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Unspecified).AddSeconds(item.dwSkinLimitTime); calcTime = calcTime.ToLocalTime(); TimeSpan ts = calcTime.Subtract(DateTime.Now).Duration(); if (ts.Days > 0) { szProssesText = ts.Days.ToString() + "天";//+ ts.Hours.ToString() + "小时"; } else if (ts.Hours > 0) { szProssesText = ts.Hours.ToString() + "小时"; //+ ts.Minutes.ToString() + "分钟"; } else { szProssesText = ts.Minutes.ToString() + "分钟"; } prossesColor = Color.red; SkinBuyObj.SetActive(false); } else { szProssesText = "已拥有"; prossesColor = Color.white; SkinBuyObj.SetActive(false); } } else { szProssesText = "未拥有"; prossesColor = Color.red; SkinBuyObj.SetActive(true); } SkinProssesText.text = szProssesText; SkinProssesText.color = prossesColor; string[] colorList = new string[4] { "FFFFFFFF", "F11DF9", "F9BF1D", "20C53B" }; if (nSkinGrade >= 0 && nSkinGrade < szWord.Length) { Color32 colorItem = ColorExtension.FromHex(colorList[nSkinGrade]); SkinGradeText.color = colorItem; SkinNameText.color = colorItem; } if (item.bSelect) { SetSelectDownShotEffect(); RoomList.SelectHeroItem = this; } else { DestorySelectDownShotEffect(); } SelectFrame.gameObject.SetActive(item.bSelect); ItemData = item; //SkinTypeImage.sprite = }
public override ScanLine DoTask(ScanLine source) { try { //Debug.WriteLine("\nBegin outlier data detection using k-means clustering demo\n"); //Debug.WriteLine("Loading all (height-weight) data into memory"); string[] attributes = new string[] { "X", "Y", "Z" }; Vector3d[] rawData = new Vector3d[source.Count]; // in most cases data will be in a text file or SQl table for (int i = 0; i < rawData.Length; i++) { rawData[i] = new Vector3d(source[i].Position.X, source[i].Position.Y, source[i].Position.Z); } //Debug.WriteLine("\nRaw data:\n"); //ShowMatrix(rawData, rawData.Length, true); int numAttributes = attributes.Length; // 2 in this demo (height,weight) int numClusters = NumClusters; // vary this to experiment (must be between 2 and number data tuples) int maxCount = 30; // trial and error //Debug.WriteLine("\nBegin clustering data with k = " + numClusters + " and maxCount = " + maxCount); int[] clustering = Cluster(rawData, numClusters, numAttributes, maxCount); //Debug.WriteLine("\nClustering complete"); //Debug.WriteLine("\nClustering in internal format: \n"); //ShowVector(clustering, true); // true -> newline after display //Debug.WriteLine("\nClustered data:"); //ShowClustering(rawData, numClusters, clustering, true); double maxDist = Distance(source.Max, source.Min) / (50); List <int> outlier = Outlier(rawData, clustering, maxDist); //Debug.WriteLine("Outlier for cluster 0 is:"); //ShowVector(outlier, true); //Debug.WriteLine("\nEnd demo\n"); List <int> count = new List <int>(numClusters); for (int i = 0; i < numClusters; i++) { count.Add(0); } for (int i = 0; i < clustering.Length; i++) { count[clustering[i]]++; } int pointCount = source.Count; List <bool> clusterOk = new List <bool>(numClusters); for (int i = 0; i < numClusters; i++) { double pct = (100f * count[i]) / pointCount; clusterOk.Add(pct >= this.RejectPercent); } ScanLine ret = new ScanLine(source.LaserID, source.Count); for (int i = 0; i < source.Count; i++) { Point3D sp = source[i]; int clusterIndex = clustering[i]; Color col = sp.Color; #if DEBUG if (ColoriseOnly) { float clamp = (float)((1.0f * clusterIndex) / (numClusters - 1)); col = ColorExtension.ColorFromVector(new Vector4(clamp, clamp, clamp, clamp)); if (!clusterOk[clusterIndex]) { col = Color.Green; } else if (outlier.Contains(i)) { col = Color.Red; } ret.Add(new Point3D(sp.Position, sp.Normal, col)); } else if (clusterOk[clusterIndex] && !outlier.Contains(i)) #endif ret.Add(new Point3D(sp.Position, sp.Normal, col)); } return(ret); } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(source); } // Main
protected override int ExecInternal() { var fontOption = new DrawFontOption { FontFamily = GUI.CurrentPaintFont.Name, Bold = GUI.CurrentPaintFont.Bold, Italic = GUI.CurrentPaintFont.Italic, Size = GUI.CurrentPaintFont.Size, Color = GUI.CurrentPaintColor, }; // デフォルトの設定 if (ArgNum == 1) { GUI.ResetDrawString(); GUI.PermanentStringMode = false; GUI.KeepStringMode = false; } else { for (var i = 2; i <= ArgNum; i++) { var opt = GetArgAsString(i); switch (opt ?? "") { case "P明朝": { fontOption.FontFamily = "MS P明朝"; break; } case "Pゴシック": { fontOption.FontFamily = "MS Pゴシック"; break; } case "明朝": { fontOption.FontFamily = "MS 明朝"; break; } case "ゴシック": { fontOption.FontFamily = "MS ゴシック"; break; } case "Bold": fontOption.Bold = true; break; case "Italic": fontOption.Italic = true; break; case "Regular": fontOption.Bold = true; fontOption.Italic = true; break; case "通常": { GUI.PermanentStringMode = false; GUI.KeepStringMode = false; break; } case "背景": { GUI.PermanentStringMode = true; break; } case "保持": { GUI.KeepStringMode = true; break; } // 無視 case " ": case var @case when @case == "": { break; } default: { if (Strings.Right(opt, 2) == "pt") { // 文字サイズ opt = Strings.Left(opt, Strings.Len(opt) - 2); fontOption.Size = (float)Conversions.ToDouble(opt); } else if (Strings.Asc(opt) == 35 && Strings.Len(opt) == 7) { // 文字色 Color color; if (ColorExtension.TryFromHexString(opt, out color)) { fontOption.Color = color; } } else { // その他のフォント fontOption.FontFamily = opt; } break; } } } } GUI.SetDrawFont(fontOption); return(EventData.NextID); }
public void SetData(cmd_update_support_vote_person data, int nPlayerCount) { if (data.uPDBIU <= 0) { return; } // 初始化标签轮盘 WarLabelSelectItem labelItem = VoteButton.GetComponent <WarLabelSelectItem>(); if (labelItem != null && labelItem.gameObject.activeSelf) { labelItem.Init(data.nVoteID, data.uPDBIU); } m_PDBIU = data.uPDBIU; // 计算玩家本次的点赞总数 int nSupportNum = LogicDataCenter.labelDataManager.getPlayerSupportNum(m_PDBIU); if (parentsView) { VotePointImage.sprite = parentsView.GetSupportNumSprite(nSupportNum); } cmd_war_add_label lastLabel; int nLabelCount; // 当前玩家是否最新被点赞的玩家 bool isLastPlayer = LogicDataCenter.labelDataManager.getLastPlayerLabel(m_PDBIU, out lastLabel, out nLabelCount); if (isLastPlayer) { // 播放标签特效 loadLabelEffect(lastLabel, nLabelCount); } VotePointImage.SetNativeSize(); VotePointImage.gameObject.SetActive(VotePointImage.sprite); SSchemeWarSupportPlayerConfig config = WarSupportPlayerConfigPage.Instance.GetWarSupportPlayerConfig(data.nVoteID); if (config != null) { VoteDescText.text = config.sVoteDesc; TitleImage.sprite = parentsView.GetSupportTitleSprite(config.nVoteIconID); TitleImage.gameObject.SetActive(TitleImage.sprite); } else { Debug.LogError(String.Format("GetWarSupportPlayerConfig failed. nVoteID={0},pdbid={1}", data.nVoteID, data.uPDBIU)); } DataCenter.WarRecordTableDataManager.WarPersonInfo info = LogicDataCenter.recordTableDataManager.getWarPersonInfoByPDBID(data.uPDBIU); if (info == null) { return; } PlayerNameText.text = info.playerName; bool bSameCamp = info.nCamp == EntityFactory.MainHeroView.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_CAMP); string szColor = bSameCamp ? "7BDBEDFF" : "FF3434FF"; string szEffectColor = bSameCamp ? "0072FF99" : "92000099"; Color32 color = ColorExtension.FromHex(szColor); Color32 effectcolor = ColorExtension.FromHex(szEffectColor); PlayerNameText.color = color; PlayerNameText.gameObject.GetComponent <Outline>().effectColor = effectcolor; SSchemeWarSupportPositionConfig positionConfig = WarSupportPlayerConfigPage.Instance.GetWarSupportPositionConfig(data.nSortID, nPlayerCount); if (positionConfig == null) { return; } Vector3 oldAnchoredPosition = this.GetComponent <RectTransform>().anchoredPosition; this.GetComponent <RectTransform>().anchoredPosition = new Vector3(positionConfig.fUIPositionOffsetX, oldAnchoredPosition.y, oldAnchoredPosition.z); // 播放光效 if (isLastPlayer) { DoEffect(m_PDBIU, bSameCamp, nSupportNum, data.nSortID); } // 播放音效 if (isLastPlayer) { DoSound(nSupportNum); } }
protected override int ExecInternal() { if (ArgNum < 2) { throw new EventErrorException(this, "ColorFilterコマンドの引数の数が違います"); } var late_refresh = false; Map.MapDrawIsMapOnly = false; var trans_par = 0.5d; for (var i = 3; i <= ArgNum; i++) { var buf = GetArgAsString(i); switch (buf ?? "") { case "非同期": { late_refresh = true; break; } case "マップ限定": { Map.MapDrawIsMapOnly = true; break; } default: { if (Strings.Right(buf, 1) == "%" && Information.IsNumeric(Strings.Left(buf, Strings.Len(buf) - 1))) { trans_par = GeneralLib.MaxDbl( 0d, GeneralLib.MinDbl(1d, Conversions.ToDouble(Strings.Left(buf, Strings.Len(buf) - 1)) / 100d)); } else { throw new EventErrorException(this, "ColorFilterコマンドに不正なオプション「" + buf + "」が使われています"); } break; } } } Color filter_color; { var buf = GetArgAsString(2); if (!ColorExtension.TryFromHexString(buf, out filter_color)) { throw new EventErrorException(this, "ColorFilterコマンドのカラー指定が不正です"); } } // マウスカーソルを砂時計に GUI.ChangeStatus(GuiStatus.WaitCursor); GUI.SetupBackground("フィルタ", "非同期", filter_color, trans_par); GUI.RedrawScreen(late_refresh); // マウスカーソルを元に戻す GUI.ChangeStatus(GuiStatus.Default); return(EventData.NextID); }
protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; //g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.SystemDefault; if (isRectBorder) { g.Clear(SkinManager.ColorScheme.PrimaryColor); } else { g.Clear(Parent.BackColor); using (var backgroundPath = DrawHelper.CreateRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1, 1f)) { g.FillPath(Primary ? SkinManager.ColorScheme.PrimaryBrush : SkinManager.GetRaisedButtonBackgroundBrush(), backgroundPath); } } //Hover Color c = SkinManager.GetFlatButtonHoverBackgroundColor(); using (Brush b = new SolidBrush(Color.FromArgb((int)(hoverAnimationManager.GetProgress() * c.A), ColorExtension.RemoveAlpha(c)))) g.FillRectangle(b, ClientRectangle); if (animationManager.IsAnimating()) { for (int i = 0; i < animationManager.GetAnimationCount(); i++) { var animationValue = animationManager.GetProgress(i); var animationSource = animationManager.GetSource(i); var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.White)); var rippleSize = (int)(animationValue * Width * 2); g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); } } //Icon Rectangle iconRect = new Rectangle(8, 6, 24, 24); if (string.IsNullOrEmpty(Text)) { // Center Icon iconRect.X += 2; } if (Icon != null) { g.DrawImage(Icon, iconRect); } //Text Rectangle textRect = ClientRectangle; if (Icon != null) { // // Resize and move Text container // // First 8: left padding // 24: icon width // Second 4: space between Icon and Text // Third 8: right padding textRect.Width -= 8 + 24 + 4 + 8; // First 8: left padding // 24: icon width // Second 4: space between Icon and Text textRect.X += 8 + 24 + 4; } g.DrawString( Text.ToUpper(), SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetRaisedButtonTextBrush(Primary), textRect, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); }
private void OnDisable() { _manager = null; _warningInfos = null; }
internal static IExcelColor ReadColor(XElement node, ExcelDrawingColorSettings drawingColorSettings) { if (node.Name.LocalName == "schemeClr") { string str = node.GetAttributeValueOrDefaultOfStringType("val", null).ToUpperInvariant(); foreach (XElement element in node.Elements()) { if (element.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "hue") { drawingColorSettings.Hue = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "hueOff") { drawingColorSettings.HueOff = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "hueMod") { drawingColorSettings.HueMod = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "sat") { drawingColorSettings.Sat = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "satOff") { drawingColorSettings.SatOff = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "satMod") { drawingColorSettings.SatMod = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "lum") { drawingColorSettings.Lum = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "lumOff") { drawingColorSettings.LumOff = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element.Name.LocalName == "lumMod") { drawingColorSettings.LumMod = new double?((double)element.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } if (!string.IsNullOrWhiteSpace(str)) { return(new ExcelColor(ExcelColorType.Theme, (uint)str.ToColorSchmeIndex(), 0.0)); } } else { if (node.Name.LocalName == "hslClr") { int num = node.GetAttributeValueOrDefaultOfInt32Type("hue", 0); int num2 = node.GetAttributeValueOrDefaultOfInt32Type("sat", 0); int num3 = node.GetAttributeValueOrDefaultOfInt32Type("lum", 0); foreach (XElement element2 in node.Elements()) { if (element2.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element2.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element2.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element2.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element2.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element2.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } return(new ExcelColor(ExcelColorType.RGB, ColorExtension.ConvertHLSToRGB((double)num, (double)num3, (double)num2).ToArgb(), 0.0)); } if (node.Name.LocalName == "prstClr") { string str2 = node.GetAttributeValueOrDefaultOfStringType("val", null); foreach (XElement element3 in node.Elements()) { if (element3.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element3.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element3.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element3.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element3.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element3.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } if (!string.IsNullOrWhiteSpace(str2)) { return(new ExcelColor(ExcelColorType.RGB, ColorExtension.FromPresetColorVal(str2).ToArgb(), 0.0)); } } else { if (node.Name.LocalName == "scrgbClr") { float val = node.GetAttributeValueOrDefaultOfFloatType("r", 0f); float num5 = node.GetAttributeValueOrDefaultOfFloatType("g", 0f); float num6 = node.GetAttributeValueOrDefaultOfFloatType("b", 0f); foreach (XElement element4 in node.Elements()) { if (element4.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element4.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element4.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element4.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element4.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element4.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } return(new ExcelColor(ExcelColorType.RGB, GcColor.FromArgb(0xff, ColorExtension.ScRgbTosRgb(val), ColorExtension.ScRgbTosRgb(num5), ColorExtension.ScRgbTosRgb(num6)).ToArgb(), 0.0)); } if (node.Name.LocalName == "srgbClr") { string str3 = node.GetAttributeValueOrDefaultOfStringType("val", null); foreach (XElement element5 in node.Elements()) { if (element5.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element5.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element5.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element5.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element5.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element5.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } if (!string.IsNullOrEmpty(str3)) { uint num7 = 0; if (uint.TryParse(str3, (NumberStyles)NumberStyles.HexNumber, (IFormatProvider)CultureInfo.InvariantCulture, out num7)) { return(new ExcelColor(ExcelColorType.RGB, num7, 0.0)); } } } else if (node.Name.LocalName == "sysClr") { GcColor color = new GcColor(); bool flag = ExcelSystemColor.TryGetSystemColor(node.GetAttributeValueOrDefaultOfStringType("val", null), out color); foreach (XElement element6 in node.Elements()) { if (element6.Name.LocalName == "alpha") { drawingColorSettings.Alpha = new double?((double)element6.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element6.Name.LocalName == "shade") { drawingColorSettings.Shade = new double?((double)element6.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element6.Name.LocalName == "tint") { drawingColorSettings.Tint = new double?((double)element6.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } else if (element6.Name.LocalName == "lumMode") { drawingColorSettings.LumMod = new double?((double)element6.GetAttributeValueOrDefaultOfInt32Type("val", 0)); } } if (flag) { return(new ExcelColor(ExcelColorType.RGB, color.ToArgb(), 0.0)); } } } } return(null); }
protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; //g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.SystemDefault; g.Clear(Parent.BackColor); if (isDrawBorder) { g.DrawRectangle(SkinManager.ColorScheme.PrimaryPen, ClientRectangle); } //Hover Color c = SkinManager.GetFlatButtonHoverBackgroundColor(); using (Brush b = new SolidBrush(Color.FromArgb((int)(hoverAnimationManager.GetProgress() * c.A), ColorExtension.RemoveAlpha(c)))) g.FillRectangle(b, ClientRectangle); //Ripple if (animationManager.IsAnimating()) { g.SmoothingMode = SmoothingMode.AntiAlias; for (int i = 0; i < animationManager.GetAnimationCount(); i++) { var animationValue = animationManager.GetProgress(i); var animationSource = animationManager.GetSource(i); using (Brush rippleBrush = new SolidBrush(Color.FromArgb((int)(101 - (animationValue * 100)), Color.Black))) { var rippleSize = (int)(animationValue * Width * 2); g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); } } g.SmoothingMode = SmoothingMode.None; } StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; //Icon Rectangle iconRect = new Rectangle(8, 1, 24, 24); if (String.IsNullOrEmpty(Text)) { // Center Icon iconRect.X += 2; } if (Icon != null) { g.DrawImage(Icon, iconRect); g.DrawString(IconTxt, SkinManager.ROBOTO_MEDIUM_10, Brushes.White, iconRect, sf); } //Text Rectangle textRect = ClientRectangle; if (Icon != null) { // // Resize and move Text container // // First 8: left padding // 24: icon width // Second 4: space between Icon and Text // Third 8: right padding textRect.Width -= (4 + 24 + 4 + 8); // First 8: left padding // 24: icon width // Second 4: space between Icon and Text //textRect.X += 8 + 24 + 4; textRect.X += 4 + 24 + 4; } g.DrawString( Text.ToUpper(), SkinManager.ROBOTO_MEDIUM_10, Enabled ? (Primary ? SkinManager.ColorScheme.PrimaryBrush : SkinManager.GetPrimaryTextBrush()) : SkinManager.GetFlatButtonDisabledTextBrush(), textRect, sf); }
public void setFillColor(string strClr) { Color32 color = ColorExtension.FromHex(strClr); fillImage.color = color; }
internal void WindowSwitchControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (MajorGrid == null || ButtonPanel == null) { return; } MajorGrid.Children.Clear(); ButtonPanel.Children.Clear(); switch (SelectionBox.SelectedIndex) { case 0: #region Add major ColorPicker color = new ColorPicker() { Color = this.WireColor }; MajorGrid.Children.Add(color); #endregion #region Add Button ButtonPanel.Children.Add(CreateARespondIconButton(PackIconKind.Refresh, System.Drawing.Color.DarkRed, (x, y) => { this.SetWireColor(ColorExtension.ConvertToMediaColor(this._wireColor)); this._proxy.Owner.ExpireSolution(true); }, LanguagableComponent.GetTransLation(new string[] { "Reset", "重置" }))); ButtonPanel.Children.Add(CreateARespondIconButton(PackIconKind.Refresh, System.Drawing.Color.DimGray, (x, y) => { this.SetWireColor(color); this._proxy.Owner.ExpireSolution(true); }, LanguagableComponent.GetTransLation(new string[] { "Refresh", "刷新" }))); SelectionBox.SelectionChanged += (x, y) => { this.SetWireColor(color); }; OKButton.Click += (x, y) => { this.SetWireColor(color); }; #endregion break; case 1: #region Add major MajorGrid.Children.Add(CreateDataGrid(true)); #endregion #region Add Button IOControlButton(true); #endregion break; case 2: #region Add major MajorGrid.Children.Add(CreateDataGrid(false)); #endregion #region Add Button IOControlButton(false); #endregion break; default: throw new ArgumentOutOfRangeException("selectedindex", "index is out of range."); } }
public static string ColorPad(string value, Color color) { return("<color=#" + ColorExtension.colorToHex(color) + ">" + value + "</color>"); }
/// <summary> /// Calculate a color based on 3 color (average) /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="c"></param> /// <returns></returns> public static Color CalculateColor(Color c1, Color c2, Color c3) { var c = (c1.ToVector() + c2.ToVector() + c3.ToVector()) / 3f; return ColorExtension.ColorFromVector(c); }
protected override int ExecInternal() { if (ArgNum < 4) { throw new EventErrorException(this, "PaintPictureコマンドの引数の数が違います"); } var buf = ""; var options = ""; var tcolor = Color.White; var i = 5; var opt_n = 4; while (i <= ArgNum) { buf = GetArgAsString(i); switch (buf ?? "") { case "透過": case "背景": case "白黒": case "セピア": case "明": case "暗": case "上下反転": case "左右反転": case "上半分": case "下半分": case "右半分": case "左半分": case "右上": case "左上": case "右下": case "左下": case "ネガポジ反転": case "シルエット": case "夕焼け": case "水中": case "保持": case "フィルタ": { options = options + buf + " "; break; } case "右回転": { i = (i + 1); options = options + "右回転 " + GetArgAsString(i) + " "; break; } case "左回転": { i = (i + 1); options = options + "左回転 " + GetArgAsString(i) + " "; break; } case "-": { // スキップ // スキップ opt_n = i; break; } case var @case when @case == "": { break; } default: { if (Strings.Asc(buf) == 35 && Strings.Len(buf) == 7) { Color filterColor = ColorExtension.FromHexString(buf); if (!filterColor.IsEmpty) { if (GetArgAsString((i - 1)) == "フィルタ") { options = options + filterColor.ToHexString() + " "; } } } else if (Information.IsNumeric(buf)) { // スキップ opt_n = i; } else if (Strings.InStr(buf, " ") > 0) { options = options + buf + " "; } else if (Strings.Right(buf, 1) == "%" && Information.IsNumeric(Strings.Left(buf, Strings.Len(buf) - 1))) { options = options + buf + " "; } else { throw new EventErrorException(this, "PaintPictureコマンドの" + i + "番目のパラメータ「" + buf + "」が不正です"); } break; } } i = (i + 1); } var fname = GetArgAsString(2); switch (Strings.Right(Strings.LCase(fname), 4) ?? "") { // 正しい画像ファイル名 case ".bmp": case ".jpg": case ".gif": case ".png": break; default: if (SRC.PDList.IsDefined(fname)) { fname = @"Pilot\" + SRC.PDList.Item(fname).Bitmap; } else if (SRC.NPDList.IsDefined(fname)) { fname = @"Pilot\" + SRC.NPDList.Item(fname).Bitmap; } else if (SRC.UDList.IsDefined(fname)) { fname = @"Unit\" + SRC.UDList.Item(fname).Bitmap; } else { throw new EventErrorException(this, "不正な画像ファイル名「" + fname + "」が指定されています"); } break; } // 描画先の画像 int dx, dy, dw, dh; buf = GetArgAsString(3); if (buf == "-") { dx = Constants.DEFAULT_LEVEL; } else { dx = GeneralLib.StrToLng(buf) + Event.BaseX; } buf = GetArgAsString(4); if (buf == "-") { dy = Constants.DEFAULT_LEVEL; } else { dy = GeneralLib.StrToLng(buf) + Event.BaseY; } // 描画サイズ if (opt_n >= 6) { buf = GetArgAsString(5); if (buf == "-") { dw = Constants.DEFAULT_LEVEL; } else { dw = GeneralLib.StrToLng(buf); if (dw <= 0) { return(EventData.NextID); } } buf = GetArgAsString(6); if (buf == "-") { dh = Constants.DEFAULT_LEVEL; } else { dh = GeneralLib.StrToLng(buf); if (dh <= 0) { return(EventData.NextID); } } } else { dw = Constants.DEFAULT_LEVEL; dh = Constants.DEFAULT_LEVEL; } // 原画像における転送元座標&サイズ int sx, sy, sw, sh; if (opt_n == 10) { buf = GetArgAsString(7); if (buf == "-") { sx = Constants.DEFAULT_LEVEL; } else { sx = GeneralLib.StrToLng(buf); } buf = GetArgAsString(8); if (buf == "-") { sy = Constants.DEFAULT_LEVEL; } else { sy = GeneralLib.StrToLng(buf); } sw = GetArgAsLong(9); sh = GetArgAsLong(10); } else { sx = 0; sy = 0; sw = 0; sh = 0; } GUI.DrawPicture(fname, dx, dy, dw, dh, sx, sy, sw, sh, options); SRC.LogTrace($"DrawPicture({fname}, {dx}, {dy}, {dw}, {dh}, {sx}, {sy}, {sw}, {sh}, {options})"); return(EventData.NextID); }
public InspectorNoteAttribute(string header, string message, string hexColor) { this.header = header; this.message = message; this.color = ColorExtension.hexToColor(hexColor); }