void loadLUT(string fname) { dgvLUT.Columns.Clear(); dgvLUT.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader; using (FileStream fs = new FileStream(fname, FileMode.Open, FileAccess.Read)) { using (StreamReader sr = new StreamReader(fs)) { string line = sr.ReadLine(); string[] ln = line.Split(';'); dgvLUT.Columns.Add(ln[0], ln[0]); // Start Index for colors dgvLUT.Columns.Add(ln[1], ln[1]); // Color dgvLUT.Columns.Add(ln[2], ln[2]); // Category int i = 0; while (!sr.EndOfStream) { dgvLUT.Rows.Add(); line = sr.ReadLine(); ln = line.Split(';'); dgvLUT.Rows[i].Cells[0].Value = ln[0]; Int32 c = Convert.ToInt32(ln[1]); Color col = ColorTranslator.FromWin32(c); dgvLUT.Rows[i].Cells[2].Value = ln[2]; dgvLUT.Rows[i].Cells[1].Style.BackColor = col; i += 1; } } } }
public SchGraphicalObject() { Color = ColorTranslator.FromWin32(0); AreaColor = ColorTranslator.FromWin32(0); IsNotAccesible = true; EnableDraw = true; }
/// <sumary> /// Draws the board background /// </sumary> /// <param name="g"> /// Graphics object used to do the drawing /// </param> /// <param name="marginX"> /// Board's horizontal margin /// </param> /// <param name="marginY"> /// Board's vertical margin /// </param> /// <param name="incValue"> /// Increment factor between board houses /// </param> private void drawBoard(Graphics g, int marginX, int marginY, int incValue) { int pos; Brush cellColor; Color whiteCell = ColorTranslator.FromWin32(Checkers.wR + Checkers.wG * 256 + Checkers.wB * 65536); Color blackCell = ColorTranslator.FromWin32(Checkers.bR + Checkers.bG * 256 + Checkers.bB * 65536); for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { if ((x + y) % 2 == 0) { cellColor = new SolidBrush(whiteCell); } else { pos = y * 4 + (x + ((y % 2 == 0) ? -1 : 0)) / 2; if (selected.has(pos)) { cellColor = new SolidBrush(Color.LightGreen); } else { cellColor = new SolidBrush(blackCell); } } g.FillRectangle(cellColor, marginX + x * incValue, marginY + y * incValue, incValue - 1, incValue - 1); } } }
/// <summary> /// 给单元格赋值4 /// </summary> /// <param name="x">列号</param> /// <param name="y">行号</param> /// <param name="text">值</param> /// <param name="font">字符格式</param> /// <param name="color">颜色</param> /// <param name="align">对齐(CENTER、LEFT、RIGHT)</param> public void SetValue(int x, int y, string text, System.Drawing.Font font, int color, string align) { this.SetValue(x, y, text); Range range = sheet.get_Range(this.GetAix(x, y), miss); range.Font.Size = font.Size; range.Font.Bold = font.Bold; //这里是int型的颜色 range.Font.Color = ColorTranslator.ToOle(ColorTranslator.FromWin32(color)); range.Font.Name = font.Name; range.Font.Italic = font.Italic; range.Font.Underline = font.Underline; if (align.ToUpper() == "CENTER") { range.HorizontalAlignment = XlHAlign.xlHAlignCenter; } if (align.ToUpper() == "LEFT") { range.HorizontalAlignment = XlHAlign.xlHAlignLeft; } if (align.ToUpper() == "RIGHT") { range.HorizontalAlignment = XlHAlign.xlHAlignRight; } }
private Color GetColor(int which) { IntPtr ptr = ConstPointer(); int abgr = UnsafeNativeMethods.CDisplayPipelineMaterial_GetColor(ptr, which); return(ColorTranslator.FromWin32(StripAlpha(abgr))); }
public SchRectangle() : base() { Corner = new CoordPoint(Utils.DxpFracToCoord(50, 0), Utils.DxpFracToCoord(50, 0)); Color = ColorTranslator.FromWin32(128); AreaColor = ColorTranslator.FromWin32(11599871); IsSolid = true; }
private Color GetPixelColorAt(IntPtr dc, int x, int y) { var pixel = GetPixel(dc, x, y); var color = ColorTranslator.FromWin32(pixel); return(Color.FromArgb(color.A, color.R, color.G, color.B)); }
//public virtual void SaveToXML(XmlElement Node) { } public override void LoadFromXML(XmlElement Node) { base.LoadFromXML(Node); try { Points.Add(new PointF(iOrgX1, iOrgY1)); Points.Add(new PointF(iOrgX2, iOrgY2)); XmlElement TextNode = (XmlElement)(Node.SelectSingleNode("Appearance")); //绘制背景 Background = Convert.ToBoolean(TextNode.GetAttribute("Transparent")); TextW = Convert.ToSingle(TextNode.GetAttribute("Width")); TextH = Convert.ToSingle(TextNode.GetAttribute("Height")); String strFontName = TextNode.GetAttribute("FontName"); float fSize = Convert.ToSingle(TextNode.GetAttribute("FontSize")); FontStyle fStyle = (FontStyle)Enum.Parse(typeof(FontStyle), TextNode.GetAttribute("FontStyle")); DrawFont = new System.Drawing.Font(strFontName, fSize, fStyle); String strTemp = TextNode.GetAttribute("FontColor"); FontBrush.Color = ColorTranslator.FromWin32(Int32.Parse(strTemp)); int ExpType = int.Parse(TextNode.GetAttribute("ViewStyle")); FExpression.ExpressType = (LCExpressType)ExpType; FExpression.Exipression = TextNode.GetAttribute("ShowVar"); FExpression.IsShowUnit = Convert.ToBoolean(TextNode.GetAttribute("IsShowUnit")); FExpression.GetDeviceVar(); if (TextNode.HasAttribute("TextOut_horizontal")) { HorizonAlign = (StringAlignment)Enum.Parse(typeof(StringAlignment), TextNode.GetAttribute("TextOut_horizontal")); } if (TextNode.HasAttribute("TextOut_Vertical")) { VerticalAlign = (StringAlignment)Enum.Parse(typeof(StringAlignment), TextNode.GetAttribute("TextOut_Vertical")); } Text = TextNode.GetAttribute("Text"); FExpression.sText = Text; FExpression.GetDeviceVar(); IsBorder = Convert.ToBoolean(TextNode.GetAttribute("IsBorder")); DrawPen.Color = ColorTranslator.FromWin32(Int32.Parse(TextNode.GetAttribute("BorderColor"))); DrawPen.Width = Int32.Parse(TextNode.GetAttribute("BorderWidth")); DrawPen.DashStyle = DashStyle.Solid; FillOptions.BrushType = LCBrushType.Solid; m_SolidBrush.Color = ColorTranslator.FromWin32(Int32.Parse(TextNode.GetAttribute("FillColor"))); strIfName = TextNode.GetAttribute("strIfName"); bCloseWin = Convert.ToBoolean(TextNode.GetAttribute("bCloseWin")); strSta = TextNode.GetAttribute("strSta"); TextNode = (XmlElement)(Node.SelectSingleNode("Behavior")); IsExecProgram = Convert.ToBoolean(TextNode.GetAttribute("IsExecProgram")); Program = TextNode.GetAttribute("Program"); } catch (Exception e) { } }
/// <summary> /// ロードイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_Load(object sender, EventArgs e) { ContainerBase.parent = this; if (_ControlsInit() != ResultCodes.Success) { QFormError.OpenErrorMessage("初期化異常です。アプリケーションを終了します。", QFormError.ERROR_CLEAN_UP_TYPE.SHATDOWN); } // フォームの色をコンフィグの色に変更 string path = Application.StartupPath + @"\option.conf"; if (!File.Exists(path)) { using (StreamWriter sw = File.CreateText(path)) { // 初期背景色を設定 sw.WriteLine("color=15790320"); } this.BackColor = ColorTranslator.FromWin32(15790320); } else { using (StreamReader sr = File.OpenText(path)) { this.BackColor = ColorTranslator.FromWin32(int.Parse(sr.ReadLine().Replace("color=", ""))); } } checkedListBox1.ItemCheck += CheckedListBox1_ItemCheck; checkedListBox1.SetItemChecked(lastCheckedIndex, true); }
public void LoadColorsFromRegistry() { RegistryKey categoryKey; bool success = TryGetCategoryKey(out categoryKey); if (!success) { return; } var backgroundColorEntry = (int)categoryKey.GetValue("SelectedText Background"); var foregroundColorEntry = (int)categoryKey.GetValue("SelectedText Foreground"); System.Drawing.Color backgroundDrawingColor = ColorTranslator.FromWin32(backgroundColorEntry); System.Drawing.Color foregroundDrawingColor = ColorTranslator.FromWin32(foregroundColorEntry); BackgroundColor = Color.FromArgb(backgroundDrawingColor.A, backgroundDrawingColor.R, backgroundDrawingColor.G, backgroundDrawingColor.B); ForegroundColor = Color.FromArgb(foregroundDrawingColor.A, foregroundDrawingColor.R, foregroundDrawingColor.G, foregroundDrawingColor.B); }
public SchArc() : base() { LineWidth = LineWidth.Small; Radius = Utils.DxpFracToCoord(10, 0); EndAngle = 360.0; Color = ColorTranslator.FromWin32(16711680); }
public static void OpenImage(AxPXV_Control axPXV_Control1, out Bitmap btm, string imgPath) { btm = null; try { IIXC_Inst inst = (IIXC_Inst)axPXV_Control1.Inst.GetExtension("IXC"); //Create new instance IIXC_Image img_for_open = inst.CreateEmptyImage(); //Crete new empty image for open file img_for_open.Load(imgPath); //Load image from it path IIXC_Page page_ixc = img_for_open.GetPage(0); //Create new page from image page_ixc.ConvertToFormat(IXC_PageFormat.PageFormat_8Indexed); btm = new Bitmap((int)page_ixc.Width, (int)page_ixc.Height); //Converting by pixels page to C# bitmap for (int i = 0; i < page_ixc.Width; i++) { for (int j = 0; j < page_ixc.Height; j++) { int color = (int)page_ixc.GetPixel(i, j); Color clr = ColorTranslator.FromWin32(color); btm.SetPixel(i, j, clr); } } } catch { } }
void loadCP(string fname) // load color palette and lookup table { dgvCP.Columns.Clear(); using (FileStream fs = new FileStream(fname, FileMode.Open, FileAccess.Read)) { using (StreamReader sr = new StreamReader(fs)) { DataGridViewRow dgvr = new DataGridViewRow(); string line = sr.ReadLine(); string[] ln = line.Split(';'); dgvCP.Columns.Add(ln[0], ln[0]); // Index column dgvCP.Columns[ln[0]].ReadOnly = true; dgvCP.Columns.Add("Red", "Red"); // Red column dgvCP.Columns.Add("Green", "Green"); // Green column dgvCP.Columns.Add("Blue", "Blue"); // Blue column dgvCP.Columns.Add("Alfa", "Alfa"); // Alfa column dgvCP.Columns.Add("Color", "Color"); // Color column for (int i = 0; i < 256; i++) { dgvCP.Rows.Add(); line = sr.ReadLine(); ln = line.Split(';'); dgvCP.Rows[i].Cells[0].Value = ln[0]; Int32 c = Convert.ToInt32(ln[1]); Color col = ColorTranslator.FromWin32(c); dgvCP.Rows[i].Cells[1].Value = col.R; //r; dgvCP.Rows[i].Cells[2].Value = col.G; //g; dgvCP.Rows[i].Cells[3].Value = col.B; // b; dgvCP.Rows[i].Cells[4].Value = col.A; // a; dgvCP.Rows[i].Cells[5].Style.BackColor = col; // Color.FromArgb(a, r, g, b ); } } } }
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { double value = Convert.ToInt64(e.ProgressPercentage); label1.Text = value.ToString(); if (value < 1024) { double lightness = (value / 1024) * 240; BackColor = ColorTranslator.FromWin32(ColorHLSToRGB( 0, Convert.ToInt32(lightness), 20)); SetBrightness(Convert.ToInt32((lightness / 240) * 255)); if (lightness >= 120) { label1.ForeColor = Color.Black; } else { label1.ForeColor = Color.White; } } else { BackColor = Color.White; label1.ForeColor = Color.Black; SetBrightness(255); } }
public string chooseColor(ScriptScopeContext scope, string defaultColor) => scope.DoWindow(w => { var cc = new ChooseColor(); cc.lStructSize = Marshal.SizeOf(cc); var lpCustColors = Marshal.AllocCoTaskMem(16 * sizeof(int)); try { Marshal.Copy(customColors, 0, lpCustColors, 16); cc.hwndOwner = w; cc.lpCustColors = lpCustColors; cc.Flags = ChooseColorFlags.FullOpen | ChooseColorFlags.RgbInit; var c = ColorTranslator.FromHtml(defaultColor); cc.rgbResult = ColorTranslator.ToWin32(c); if (!ChooseColor(ref cc)) { return((string)null); } c = ColorTranslator.FromWin32(cc.rgbResult); return(ColorTranslator.ToHtml(c)); } finally { Marshal.FreeCoTaskMem(lpCustColors); } });
public Color GetNearestColor(Color color) { HandleRef hdc = new HandleRef(null, dc.Hdc); int colorResult = IntUnsafeNativeMethods.GetNearestColor(hdc, ColorTranslator.ToWin32(color)); return(ColorTranslator.FromWin32(colorResult)); }
private void button1_Click(object sender, EventArgs e) { using (Graphics g = Graphics.FromImage(bmp)) { if (x + width > bmp.Width) // if drawing the next block would exceed the bmp width... { g.DrawImage(bmp, new Point(-width, 0)); // draw ourself shifted to the left x = x - width; } // draw the new block int val; Color color; val = ColorHLSToRGB(h, 128, 240); color = ColorTranslator.FromWin32(val); using (SolidBrush sb = new SolidBrush(color)) { g.FillRectangle(sb, x, 0, width, height); } } x = x + width; h = h + width; if (h >= 240) { h = 0; } panel1.Invalidate(); // force panel1 to redraw itself }
/// <summary> /// Returns a standard VS color or a system color, if the VS colors service is not available /// </summary> /// <param name="visualStudioColor">Color enum</param> /// <returns>The color itself</returns> internal static Color GetVsColor(Vs2010Color visualStudioColor) { uint win32Color = 0; IVsUIShell2 vsuiShell2 = WixPackage.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell2; if (vsuiShell2 != null && vsuiShell2.GetVSSysColorEx((Int32)visualStudioColor, out win32Color) == VSConstants.S_OK) { Color color = ColorTranslator.FromWin32((int)win32Color); return(color); } // We need to fall back to some reasonable colors when we're not running in VS // to keep the forms/property pages editable in the designers switch (visualStudioColor) { case Vs2010Color.VSCOLOR_BUTTONFACE: return(SystemColors.ButtonFace); case Vs2010Color.VSCOLOR_BUTTONTEXT: return(SystemColors.ControlText); case Vs2010Color.VSCOLOR_WINDOW: return(SystemColors.Window); default: return(Color.Red); } }
public TrayImageListStreamer(SerializationInfo i, StreamingContext c) { string name = c0bbbfa1d3eac60244be07cb7c7058941.c47c07faa149539febe2a8e1f978fa8dd(1); object obj4 = i.GetValue(name, typeof(int)); int num = (int)obj4; Color color2 = ColorTranslator.FromWin32(num); this.tClr = color2; this.lstImages = new ArrayList(); string text7 = c0bbbfa1d3eac60244be07cb7c7058941.c47c07faa149539febe2a8e1f978fa8dd(12); int num2 = i.GetInt32(text7); for (int j = 0; j < num2; j++) { string text8 = c0bbbfa1d3eac60244be07cb7c7058941.c47c07faa149539febe2a8e1f978fa8dd(0x21); string text9 = j.ToString(); string text10 = text8 + text9; Type type = typeof(byte[]); object obj2 = i.GetValue(text10, type); this.lstImages.Add(obj2); } Label_0098: switch (4) { case 0: goto Label_0098; } if (1 == 0) { } }
private void Timer1_Tick(object sender, EventArgs e) { //this is to ensure that EyeDropper tool feature doesn't //affect Color Dialog tool feature if (_timerCounter < TIMER_COUNTER_THRESHOLD) { _timerCounter++; return; } _timerCounter++; System.Drawing.Point mousePos = Control.MousePosition; IntPtr deviceContext = Native.GetDC(IntPtr.Zero); if (currMode == MODE.NONE) { dataSource.SelectedColor = ColorTranslator.FromWin32(Native.GetPixel(deviceContext, mousePos.X, mousePos.Y)); ColorSelectedShapesWithColor(panel1.BackColor); } else { _pickedColor = ColorTranslator.FromWin32(Native.GetPixel(deviceContext, mousePos.X, mousePos.Y)); ColorSelectedShapesWithColor(_pickedColor); } }
/// <summary> /// 获取颜色 /// </summary> /// <param name="color">整型颜色</param> /// <returns>Gdi颜色</returns> public Color GetColor(double dwPenColor) { if (MCommon.Instance.m_colors.ContainsKey(dwPenColor)) { return(MCommon.Instance.m_colors[dwPenColor]); } else { Color gdiColor = Color.Empty; if (dwPenColor >= 0) { gdiColor = ColorTranslator.FromWin32((int)dwPenColor); } else { double absDwPenColor = Math.Abs(dwPenColor); gdiColor = ColorTranslator.FromWin32((int)absDwPenColor); int alpha = (int)(absDwPenColor * 1000 % (int)(absDwPenColor)); if (alpha < 255) { gdiColor = Color.FromArgb(alpha, gdiColor); } } MCommon.Instance.m_colors[dwPenColor] = gdiColor; return(gdiColor); } }
public SchCircle() : base() { Radius = 10; Color = ColorTranslator.FromWin32(16711680); AreaColor = ColorTranslator.FromWin32(12632256); IsSolid = true; }
public void RegisterGetProcessHighlightingColorHandler(GeneralGetHighlightingColorDelegate handler) { if (handler == null) { throw new InvalidOperationException("Delegate handler can not be null."); } CallbackRegistration registration = new CallbackRegistration( NativeApi.PhGetGeneralCallback(PhGeneralCallback.GetProcessHighlightingColor), (parameter, context) => { PhPluginGetHighlightingColor *pargs = (PhPluginGetHighlightingColor *)parameter; GeneralGetHighlightingColorArgs args; args.Parameter = (IntPtr)pargs->Parameter; args.BackColor = ColorTranslator.FromWin32(pargs->BackColor); args.Handled = pargs->Handled; args.Cache = pargs->Cache; handler(this, ref args); pargs->BackColor = ColorTranslator.ToWin32(args.BackColor); pargs->Handled = args.Handled; pargs->Cache = args.Cache; } ); _registrations.Add(registration); }
private static Color FetchColor(IServiceProvider serviceProvider, object colorToFetch) { if (_cachedColors.ContainsKey((int)colorToFetch)) { return(_cachedColors[(int)colorToFetch]); } if (serviceProvider != null) { var vsUIShell = serviceProvider.GetService(typeof(IVsUIShell)) as IVsUIShell2; if (vsUIShell != null) { uint vscolor; NativeMethods.ThrowOnFailure(vsUIShell.GetVSSysColorEx((int)colorToFetch, out vscolor)); var vsColor = ColorTranslator.FromWin32((int)vscolor); _cachedColors.Add((int)colorToFetch, vsColor); return(vsColor); } else { Debug.Fail("Failed to get the IVsUIShell2 service"); return(Color.Empty); } } else { Debug.Fail("incorrectly constructed color service"); return(Color.Empty); } }
// Color Dialog button ( Color dialog custom colors added to UI buttons' back color ): public void showColorDialog_Click(object sender, EventArgs e) { using (ColorDialog colorDialog1 = new ColorDialog()) { colorDialog1.FullOpen = true; colorDialog1.CustomColors = ccColors; if (colorDialog1.ShowDialog() == DialogResult.OK) { for (int i = 0; i < ccColors.Length; i++) { ccColors[i] = colorDialog1.CustomColors[i]; ccButtons[i].BackColor = ColorTranslator.FromWin32(ccColors[i]); } if (radioCw1.Checked) { paintingColor1 = colorDialog1.Color; } if (radioCw2.Checked) { paintingColor2 = colorDialog1.Color; } ColorApplying(); } } }
public DialogResult ShowDialog() { var cc = new ChooseColor(); cc.structSize = Marshal.SizeOf(cc); //Does not seem to work unless custom colors are initialized. var lpCustColors = Marshal.AllocCoTaskMem(16 * sizeof(int)); cc.custColors = lpCustColors; cc.flags = ChooseColorFlags.RgbInit; try { Marshal.Copy(customColors, 0, lpCustColors, 16); if (Win32Dialogs.ChooseColor(cc)) { Color = ColorTranslator.FromWin32(cc.rgbResult); return(DialogResult.OK); } else { return(DialogResult.Cancel); } } finally { Marshal.FreeCoTaskMem(lpCustColors); } }
public static Color GetDarkenedColor(string color, string subColor = "1f1f1f") { int clr = Convert.ToInt32(color.Replace("#", ""), 16); int sub = Convert.ToInt32(subColor, 16); return(ColorTranslator.FromWin32(clr - sub)); }
public void MostrarBellman(Graphics gr) { Color clr = Color.Aqua; int ancho_linea = 2; if (estado == Estados.OPTIMO) { Random r = new Random(); clr = ColorTranslator.FromWin32(r.Next()); ancho_linea = 6; } Pen Flecha = new Pen(clr, ancho_linea); GraphicsPath capPath = new GraphicsPath(); capPath.AddLine(-4, -14, 0, -6); capPath.AddLine(4, -14, 0, -6); Flecha.CustomEndCap = new System.Drawing.Drawing2D.CustomLineCap(null, capPath); gr.DrawLine(Flecha, origen.X + origen.Radio, origen.Y + origen.Radio, destino.X + destino.Radio, destino.Y + destino.Radio); origen.Mostrar(gr); destino.Mostrar(gr); int xh = origen.X + (destino.X - origen.X) / 2; int yh = origen.Y + (destino.Y - origen.Y) / 2; gr.DrawString(peso.ToString(), new Font(new FontFamily("Arial"), 10, FontStyle.Bold), Brushes.Blue, xh, yh); }
protected virtual void OnDrawTicks(IntPtr hdc) { Graphics graphics = Graphics.FromHdc(hdc); if (((this.OwnerDrawParts & TrackBarOwnerDrawParts.Ticks) == TrackBarOwnerDrawParts.Ticks) && !this.DesignMode) { Rectangle bounds; Rectangle rectangle2; if (this.Orientation == Orientation.Horizontal) { rectangle2 = new Rectangle(this.ChannelBounds.Left + (this.ThumbBounds.Width / 2), this.ThumbBounds.Top - 6, this.ChannelBounds.Width - this.ThumbBounds.Width, this.ThumbBounds.Height + 10); bounds = rectangle2; } else { rectangle2 = new Rectangle(this.ThumbBounds.Left - (this.ThumbBounds.Height / 2), this.ChannelBounds.Top + 6, this.ThumbBounds.Width + 10, this.ChannelBounds.Height - this.ThumbBounds.Height); bounds = rectangle2; } TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, bounds, (TrackBarItemState)this.ThumbState); if (this.DrawTicks != null) { this.DrawTicks(this, e); } } else { if (this.TickStyle == TickStyle.None) { return; } if (this.ThumbBounds.Equals(Rectangle.Empty)) { return; } Color black = Color.Black; if (VisualStylesEnabled) { IntPtr hTheme = NativeMethods.OpenThemeData(this.Handle, "TRACKBAR"); if (!hTheme.Equals(IntPtr.Zero)) { int pColor = 0; if (NativeMethods.GetThemeColor(hTheme, 9, this.ThumbState, 0xcc, ref pColor) == 0) { black = ColorTranslator.FromWin32(pColor); } NativeMethods.CloseThemeData(hTheme); } } if (this.Orientation == Orientation.Horizontal) { this.DrawHorizontalTicks(graphics, black); } else { this.DrawVerticalTicks(graphics, black); } } graphics.Dispose(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Converts a BGR color (as used in FW props, for example) to a .Net Color object. /// </summary> /// <param name="bgrColor"></param> /// <returns>An instance of the <see>Color</see>class representing the given BGR value /// </returns> /// ------------------------------------------------------------------------------------ static public Color ConvertBGRtoColor(uint bgrColor) { if (bgrColor == 0xC0000000) { return(Color.FromKnownColor(KnownColor.Transparent)); } return(ColorTranslator.FromWin32((int)bgrColor)); }