当前位置: 首页>>代码示例>>C#>>正文


C# Color.Equals方法代码示例

本文整理汇总了C#中System.Drawing.Color.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Color.Equals方法的具体用法?C# Color.Equals怎么用?C# Color.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Color的用法示例。


在下文中一共展示了Color.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrimaryColorValue

        /// <summary>
        /// Returns the value for the requested primary color from the Color object.
        /// </summary>
        /// <param name="primaryColor">The primary color to return a value for.  Must be one of: Color.Red, Color.Green, Color.Blue.</param>
        /// <returns>Color value between 0 and 255</returns>
        public static int PrimaryColorValue(this Color _color, Color primaryColor)
        {
            if (primaryColor.Equals(Color.Red))
                return _color.R;
            if (primaryColor.Equals(Color.Green))
                return _color.G;
            if (primaryColor.Equals(Color.Blue))
                return _color.B;

            throw new ArgumentOutOfRangeException("Supplied color is not one of the valid colors");
        }
开发者ID:benjy3gg,项目名称:PoeHud,代码行数:16,代码来源:ColorUtils.cs

示例2: ReturnColor

        public static void ReturnColor(Color c)
        {
            if (c.Equals(Color.Black))
                return;

            lock (_colors)
            {
                _colors.Insert(0, c);
            }
        }
开发者ID:ilMagnifico,项目名称:asymmetric-threat-tracker,代码行数:10,代码来源:ColorPalette.cs

示例3: getFaceColorByColor

 public static CubeFaceColor getFaceColorByColor(Color color)
 {
     if (color.Equals(Color.Blue))
     {
         return CubeFaceColor.B;
     }
     else if (color.Equals(Color.Red))
     {
         return CubeFaceColor.R;
     }
     else if (color.Equals(Color.White))
     {
         return CubeFaceColor.W;
     }
     else if (color.Equals(Color.Orange))
     {
         return CubeFaceColor.O;
     }
     else if (color.Equals(Color.Yellow))
     {
         return CubeFaceColor.Y;
     }
     else if (color.Equals(Color.Green))
     {
         return CubeFaceColor.G;
     }
     return CubeFaceColor.B;
 }
开发者ID:petcomputacaoufrgs,项目名称:roborubik,代码行数:28,代码来源:ColorTranslate.cs

示例4: PixelIsSimilar

        /// <summary>
        /// Determines if two pixels match
        /// </summary>
        /// <param name="c1">Color structure representing pixel A</param>
        /// <param name="c2">Color structure representing pixel B</param>
        /// <param name="threshold">The maximum deviation between the two values</param>
        /// <returns>True if the two pixels are within the threshold</returns>
        /// <remarks>
        /// The threshold represents the average difference between the individual color components.
        /// (Abs(R1-R2)+Abs(G1-G2)+Abs(B1-B2))/3 = deviation
        /// </remarks>
        public static bool PixelIsSimilar(Color c1, Color c2, int threshold)
        {
            if (threshold == 0)
            {
                return c1.Equals(c2);
            }

            // c1 to c2 diff
            Color c1VSc2 = Color.FromArgb(
                Math.Abs(c1.R - c2.R),
                Math.Abs(c1.G - c2.G),
                Math.Abs(c1.B - c2.B)
                );

            int c1VSc2Avg = ColorVariationAverage(c1VSc2.R, c1VSc2.G, c1VSc2.B);
            return c1VSc2Avg <= threshold;
        }
开发者ID:gavinramm,项目名称:Afterglow,代码行数:28,代码来源:FastBitmap.cs

示例5: ColorCheck

        /////////////////
        //Color Checker//
        /////////////////

        public static int ColorCheck(Color color)
        {
            if (color.Equals(Color.FromArgb(0, 0, 0)))
            {
                return 1; // Checks for Black
            }
            else if (color.Equals(Color.FromArgb(0, 0, 255)))
            {
                return 2; // Checks for Blue
            }
            else if (color.Equals(Color.FromArgb(0, 255, 255)))
            {
                return 3; // Checks for Cyan
            }
            else if (color.Equals(Color.FromArgb(0, 0, 128)))
            {
                return 4; // Checks for DarkBlue
            }
            else if (color.Equals(Color.FromArgb(0, 128, 128)))
            {
                return 5; // Checks for DarkCyan
            }
            else if (color.Equals(Color.FromArgb(128, 128, 128)))
            {
                return 6; // Checks for DarkGrey
            }
            else if (color.Equals(Color.FromArgb(0, 128, 0)))
            {
                return 7; // Checks for DarkGreen
            }
            else if (color.Equals(Color.FromArgb(128, 0, 128)))
            {
                return 8; // Checks for DarkMagenta
            }
            else if (color.Equals(Color.FromArgb(128, 0, 0)))
            {
                return 9; // Checks for DarkRed
            }
            else if (color.Equals(Color.FromArgb(128, 128, 0)))
            {
                return 10; // Checks for DarkYellow
            }
            else if (color.Equals(Color.FromArgb(192, 192, 192)))
            {
                return 11; // Checks for Gray
            }
            else if (color.Equals(Color.FromArgb(0, 255, 0)))
            {
                return 12; // Checks for Green
            }
            else if (color.Equals(Color.FromArgb(255, 0, 255)))
            {
                return 13; // Checks for Magenta
            }
            else if (color.Equals(Color.FromArgb(255, 0, 0)))
            {
                return 14; // Checks for Red
            }
            else if (color.Equals(Color.FromArgb(255, 255, 255)))
            {
                return 15; // Checks for White
            }
            else if (color.Equals(Color.FromArgb(255, 255, 0)))
            {
                return 16; // Checks for Yellow
            }
            else
            {
                return 0; // Returns the default for none
            }
        }
开发者ID:PressmanMatthew,项目名称:Console-Based-Roguelike-Game,代码行数:75,代码来源:Pixel.cs

示例6: GetCheckBoxImage

        private static Bitmap GetCheckBoxImage(Color checkColor, Rectangle fullSize, ref Color cacheCheckColor, ref Bitmap cacheCheckImage)
        {
            if (cacheCheckImage != null &&
                cacheCheckColor.Equals(checkColor) &&
                cacheCheckImage.Width == fullSize.Width &&
                cacheCheckImage.Height == fullSize.Height) {
                return cacheCheckImage;
            }

            if (cacheCheckImage != null)
            {
                cacheCheckImage.Dispose();
                cacheCheckImage = null;
            }

            // We draw the checkmark slightly off center to eliminate 3-D border artifacts,
            // and compensate below
            NativeMethods.RECT rcCheck = NativeMethods.RECT.FromXYWH(0, 0, fullSize.Width, fullSize.Height);
            Bitmap bitmap = new Bitmap(fullSize.Width, fullSize.Height);
            Graphics offscreen = Graphics.FromImage(bitmap);
            offscreen.Clear(Color.Transparent);
            IntPtr dc = offscreen.GetHdc();
            try {
                SafeNativeMethods.DrawFrameControl(new HandleRef(offscreen, dc), ref rcCheck,
                                         NativeMethods.DFC_MENU, NativeMethods.DFCS_MENUCHECK);
            } finally {
                offscreen.ReleaseHdcInternal(dc);
                offscreen.Dispose();
            }

            bitmap.MakeTransparent();
            cacheCheckImage = bitmap;
            cacheCheckColor = checkColor;

            return cacheCheckImage;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:36,代码来源:CheckBoxBaseAdapter.cs

示例7: ChangeColor

 private static Bitmap ChangeColor(Bitmap scrBitmap, Color from, Color to)
 {
     Color actualColor = new Color();
     Bitmap newBitmap = new Bitmap(scrBitmap.Width, scrBitmap.Height);
     for (int i = 0; i < scrBitmap.Width; i++)
     {
         for (int j = 0; j < scrBitmap.Height; j++)
         {
             actualColor = scrBitmap.GetPixel(i, j);
             if (actualColor.Equals(from))
                 newBitmap.SetPixel(i, j, to);
             else
                 newBitmap.SetPixel(i, j, actualColor);
         }
     }
     return newBitmap;
 }
开发者ID:PabloCorso,项目名称:BattleNotifier,代码行数:17,代码来源:Utils.cs

示例8: UpdateRecentColors

        private void UpdateRecentColors(Color color)
        {
            // Do we need to update the recent colors collection?
            if (AutoRecentColors)
            {
                // We do not add to recent colors if it is inside another color columns
                foreach (KryptonContextMenuItemBase item in _kryptonContextMenu.Items)
                {
                    // Only interested in the non-recent colors color columns
                    if ((item is KryptonContextMenuColorColumns) && (item != _colorsRecent))
                    {
                        // Cast to correct type
                        KryptonContextMenuColorColumns colors = (KryptonContextMenuColorColumns)item;

                        // We do not change the theme or standard entries if they are not to be used
                        if (((item == _colorsTheme) && !VisibleThemes) ||
                            ((item == _colorsStandard) && !VisibleStandard))
                            continue;

                        // If matching color found, do not add to recent colors
                        if (colors.ContainsColor(color))
                            return;
                    }
                }

                // If this color valid and so possible to become a recent color
                if ((color != null) && !color.Equals(Color.Empty))
                {
                    bool found = false;
                    foreach (Color recentColor in _recentColors)
                        if (recentColor.Equals(color))
                        {
                            found = true;
                            break;
                        }

                    // If the color is not already part of the recent colors
                    if (!found)
                    {
                        // Add to start of the list
                        _recentColors.Insert(0, color);

                        // Enforce the maximum number of recent colors
                        if (_recentColors.Count > MaxRecentColors)
                            _recentColors.RemoveRange(MaxRecentColors, _recentColors.Count - MaxRecentColors);
                    }
                }
            }
        }
开发者ID:ComponentFactory,项目名称:Krypton,代码行数:49,代码来源:KryptonColorButton.cs

示例9: sendColor

        private void sendColor(Color color)
        {
            bool blink = cbBlink.Checked;
            arduinoCom.setColorBlink(blink);
            lastColor = color;
            Icon icon;
            String title = "SkypeLight: ";
            arduinoCom.sendColor(color);
            if (color.Equals(Color.Black))
            {
                icon = Icon.FromHandle(((Bitmap)imageList1.Images[0]).GetHicon());
                title = title + "Aus";
            }
            else if (color.Equals(Color.Blue))
            {
                icon = Icon.FromHandle(((Bitmap)imageList1.Images[0]).GetHicon());
                title = title + "Blau";
            }
            else if (color.Equals(Color.Green))
            {
                icon = Icon.FromHandle(((Bitmap)imageList1.Images[2]).GetHicon());
                title = title + "Grün";
            }
            else if (color.Equals(Color.Red))
            {
                icon = Icon.FromHandle(((Bitmap)imageList1.Images[0]).GetHicon());
                title = title + "Rot";
            }
            else if (color.Equals(Color.Yellow))
            {
                icon = Icon.FromHandle(((Bitmap)imageList1.Images[1]).GetHicon());
                title = title + "Gelb";
            }
            else if (color.Equals(Color.White))
            {
                icon = Icon.FromHandle(((Bitmap)imageList1.Images[0]).GetHicon());
                title = title + "Weiß";
            }
            else
            {
                // kein connect
                icon = Icon.FromHandle(((Bitmap)imageList1.Images[0]).GetHicon());
                title = title + "?";
                blink = true;
            }

            notifyIcon1.Icon = icon;
            this.Icon = icon;
            notifyIcon1.Text = title;
            lastSendet = DateTime.Now;
        }
开发者ID:willie68,项目名称:SkypeLight,代码行数:51,代码来源:settingsUI.cs

示例10: RenderPoint

 /// <summary>
 /// RenderPoint
 ///     Render a point to Graphics
 /// </summary>
 /// <param name="geo">SqlGeography geo</param>
 /// <param name="table">string layer table</param>
 /// <param name="g">Graphics used to draw to</param>
 /// <param name="valueFill">Color the fill color style</param>
 private void RenderPoint(SqlGeography geo, string table, Graphics g, Color valueFill)
 {
     totalPoints++;
     double lat = (double)geo.Lat;
     double lon = (double)geo.Long;
     LatLongToPixelXY(lat, lon, lvl, out pixelX, out pixelY);
     Point cp = new Point(pixelX - nwX, pixelY - nwY);
     if (valueFill.Equals(Color.White)) valueFill = ColorFromInt(LayerStyle[table].fill);
     SolidBrush myBrush = new SolidBrush(valueFill);
     int r = LayerStyle[table].pointRadius;
     g.FillEllipse(myBrush, new Rectangle(cp.X - r / 2, cp.Y - r / 2, r, r));
 }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:20,代码来源:Tile.svc.cs

示例11: RenderGeometryCollection

        /// <summary>
        /// RenderGeometryCollection
        ///     Render a GeometryCollection to Graphics
        /// </summary>
        /// <param name="geo">SqlGeography geo</param>
        /// <param name="table">string layer table</param>
        /// <param name="g">Graphics used to draw to</param>
        /// <param name="id">int record id</param>
        /// <param name="valueFill">Color the fill color style</param>
        private void RenderGeometryCollection(SqlGeography geo, string table, Graphics g, int id, Color valueFill)
        {
            int numGeom = (int)geo.STNumGeometries();
            if (geo.STNumGeometries() > 0)
            {
                for (int j = 1; j <= geo.STNumGeometries(); j++)
                {
                    if (geo.STGeometryN(j).NumRings() > 0)
                    {
                        for (int k = 1; k <= geo.STGeometryN(j).NumRings(); k++)
                        {
                            if (geo.STGeometryN(j).RingN(k).STNumPoints() > 1)
                            {
                                double lon1 = 0.0;
                                Point[] ptArray = new Point[(int)geo.STGeometryN(j).RingN(k).STNumPoints()];
                                for (int m = 1; m <= geo.STGeometryN(j).RingN(k).STNumPoints(); m++)
                                {
                                    double lat = (double)geo.STGeometryN(j).RingN(k).STPointN(m).Lat;
                                    double lon = (double)geo.STGeometryN(j).RingN(k).STPointN(m).Long;

                                    if (m > 1)
                                    {
                                        lon = HemisphereCorrection(lon, lon1, id);
                                    }

                                    LatLongToPixelXY(lat, lon, lvl, out pixelX, out pixelY);
                                    ptArray[m - 1] = new Point(pixelX - nwX, pixelY - nwY);
                                    lon1 = lon;
                                }
                                if (valueFill.Equals(Color.White)) valueFill = ColorFromInt(LayerStyle[table].fill);
                                GraphicsPath extRingRegion = new GraphicsPath();
                                extRingRegion.AddPolygon(ptArray);
                                Region region = new Region(extRingRegion);
                                g.FillRegion(new SolidBrush(valueFill), region);
                                Pen myPen = new Pen(ColorFromInt(LayerStyle[table].stroke));
                                myPen.Width = 1;
                                g.DrawPolygon(myPen, ptArray);
                            }
                        }
                    }
                }
            }
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:52,代码来源:Tile.svc.cs

示例12: Original

 internal Original(object image, OriginalOptions options, Color customTransparentColor) {
     Debug.Assert(image != null, "image is null");
     if (!(image is Icon) && !(image is Image)) {
         throw new InvalidOperationException(SR.GetString(SR.ImageListEntryType));
     }
     this.image = image;
     this.options = options;
     this.customTransparentColor = customTransparentColor;
     if ((options & OriginalOptions.CustomTransparentColor) == 0) {
         Debug.Assert(customTransparentColor.Equals(Color.Transparent),
                      "Specified a custom transparent color then told us to ignore it");
     }
 }
开发者ID:mind0n,项目名称:hive,代码行数:13,代码来源:ImageList.cs

示例13: AlphaValTex

 public static string AlphaValTex(Color linecolor)
 {
     if (!linecolor.Equals(Color.Empty))
     {
         return "!" + (linecolor.A * 100 / 255).ToString();
     }
     return "";
 }
开发者ID:yarden,项目名称:sbml2tikz,代码行数:8,代码来源:FillColor.cs

示例14: DisplayText

        // TinyG communication monitor textbox  
        public void DisplayText(string txt, Color color) {
            if (!IsShown || !checkBoxShowDebugInfo.Checked) return;
            // XXX need to add robust mechanism to only show desired debugging messages
            if (!showTinyGComms_checkbox.Checked && (color.Equals(Color.Gray) || color.Equals(Color.Green))) return;
            try {
                if (InvokeRequired) { Invoke(new Action<string, Color>(DisplayText), txt, color); return; }
                txt = txt.Replace("\n", "");
                // TinyG sends \n, textbox needs \r\n. (TinyG could be set to send \n\r, which does not work with textbox.)
                // Adding end of line here saves typing elsewhere
                txt = txt + "\r\n";
                if (SerialMonitor_richTextBox.Text.Length > 1000000) {
                    SerialMonitor_richTextBox.Text = SerialMonitor_richTextBox.Text.Substring(SerialMonitor_richTextBox.Text.Length - 10000);
                }
                SerialMonitor_richTextBox.AppendText(txt, color);
                SerialMonitor_richTextBox.ScrollToCaret();
            } catch {
            }

           // int lines = SerialMonitor_richTextBox.GetFirstCharIndexFromLine(1);

            try
            {
                if (checkBoxLimitDebugLines.Checked && (int.Parse(textBoxLimitDebugLines.Text) < ((int)SerialMonitor_richTextBox.Lines.Length)))
                {
                    do
                    {
                        SerialMonitor_richTextBox.Select(0, SerialMonitor_richTextBox.GetFirstCharIndexFromLine(1));
                        SerialMonitor_richTextBox.SelectedText = "";
                    } while (int.Parse(textBoxLimitDebugLines.Text) < ((int)SerialMonitor_richTextBox.Lines.Length));
                }
            }
            catch { }
        }
开发者ID:Knaster,项目名称:LitePlacer-ver2,代码行数:34,代码来源:MainForm.cs

示例15: DrawTabItem

        private void DrawTabItem(Graphics gfx, Rectangle itemRect, string tabPageText, Color backColor,
            Color borderColor, int borderWidth, Color foreColor, Image image, StringFormat format1)
        {
            using (StringFormat format = new StringFormat(StringFormatFlags.LineLimit))
            {
                format.LineAlignment = StringAlignment.Center;
                format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;

                //绘制选项卡背景色
                if (!backColor.Equals(Color.Empty))
                {
                    using (Brush brush = new SolidBrush(backColor))
                    {
                        gfx.FillRectangle(brush, itemRect);
                    }
                }

                //绘制图标及文字
                if (TabControl.TabItemStyle.Equals(TabItemStyle.Image))
                {
                    //gfx.DrawImage(image, itemRect.Left + TabControl.TabContentSpacing,
                    //    itemRect.Top + TabControl.TabContentSpacing, image.Width, image.Height);
                    gfx.DrawImage(image, itemRect.Left + itemRect.Width / 2 - image.Width / 2,
                            itemRect.Top + itemRect.Height / 2 - image.Height / 2,
                            image.Width, image.Height);
                }
                else if (TabControl.TabItemStyle.Equals(TabItemStyle.Text) && !string.IsNullOrEmpty(tabPageText))
                {
                    format.Alignment = StringAlignment.Center;

                    using (Brush brush = new SolidBrush(foreColor))
                    {
                        gfx.DrawString(tabPageText, TabControl.TabItemFont, brush,
                            itemRect, format);
                    }
                }
                else if (TabControl.TabItemStyle.Equals(TabItemStyle.TextAndImage))
                {
                    if (TabControl.TextImageRelation.Equals(TextImageRelation.ImageBeforeText))
                    {
                        gfx.DrawImage(image, itemRect.Left + TabControl.TabContentSpacing,
                            itemRect.Top + itemRect.Height / 2 - image.Height / 2, image.Width, image.Height);

                        format.LineAlignment = StringAlignment.Center;

                        using (Brush brush = new SolidBrush(foreColor))
                        {
                            Rectangle rect = new Rectangle(itemRect.Left + TabControl.TabContentSpacing + image.Width,
                                itemRect.Y,
                                itemRect.Width - TabControl.TabContentSpacing - image.Width,
                                itemRect.Height);

                            //gfx.DrawString(tabPageText, TabControl.TabItemFont, brush,
                            //    itemRect.Left + TabControl.TabContentSpacing * 2 + image.Width,
                            //    itemRect.Top + TabControl.TabContentSpacing,sf);

                            gfx.DrawString(tabPageText, TabControl.TabItemFont, brush, rect, format);
                        }
                    }
                    else if (TabControl.TextImageRelation.Equals(TextImageRelation.TextBeforeImage))
                    {
                        format.LineAlignment = StringAlignment.Center;

                        using (Brush brush = new SolidBrush(foreColor))
                        {
                            Rectangle rect = new Rectangle(itemRect.Left,
                                itemRect.Y,
                                itemRect.Width - TabControl.TabContentSpacing - image.Width,
                                itemRect.Height);

                            //gfx.DrawString(tabPageText, TabControl.TabItemFont, brush,
                            //    itemRect.Left + TabControl.TabContentSpacing,
                            //    itemRect.Top + TabControl.TabContentSpacing);

                            gfx.DrawString(tabPageText, TabControl.TabItemFont, brush, rect, format);
                        }

                        gfx.DrawImage(image, itemRect.Right - TabControl.TabContentSpacing - image.Width,
                            itemRect.Top + itemRect.Height / 2 - image.Height / 2, image.Width, image.Height);
                    }
                    else if (TabControl.TextImageRelation.Equals(TextImageRelation.TextAboveImage))
                    {
                        format.Alignment = StringAlignment.Center;

                        using (Brush brush = new SolidBrush(foreColor))
                        {
                            Rectangle rect = new Rectangle(itemRect.Left, itemRect.Top,
                                itemRect.Width,
                                itemRect.Height - TabControl.TabContentSpacing - image.Height);

                            gfx.DrawString(tabPageText, TabControl.TabItemFont, brush, rect, format);
                        }

                        gfx.DrawImage(image, itemRect.Left + itemRect.Width / 2 - image.Width / 2,
                            itemRect.Bottom - TabControl.TabContentSpacing - image.Height,
                            image.Width, image.Height);
                    }
                    else if (TabControl.TextImageRelation.Equals(TextImageRelation.ImageAboveText))
                    {
                        gfx.DrawImage(image, itemRect.Left + itemRect.Width / 2 - image.Width / 2,
//.........这里部分代码省略.........
开发者ID:wxll1120,项目名称:c585b99f,代码行数:101,代码来源:RendererBase.cs


注:本文中的System.Drawing.Color.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。