Equals() public method

public Equals ( Color color ) : bool
color Color
return bool
Beispiel #1
0
 private static bool IsBothNullOrEqual(Color a, Color b)
 {
     return (a == null && b == null) ||
            (a != null && b != null && a.Equals(b));
 }
        /// <summary>
        /// SeachColorCombo
        /// </summary>
        /// <param name="inpColor"></param>
        /// <returns></returns>
        private ComboBoxItem SeachColorCombo(ComboBox comboBox, Color inpColor)
        {
            try
            {
                ComboBoxItem outpitem = null;
                foreach (ComboBoxItem cmbitem in comboBox.Items)
                {
                    SolidColorBrush brush = cmbitem.Background as SolidColorBrush;

                    if (brush != null)
                    {
                        if (inpColor.Equals(brush.Color))
                        {
                            outpitem = cmbitem;
                            break;
                        }
                    }

                }
                return outpitem;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private bool WasFlipped(Color old_color, Color new_color)
 {
     return (old_color.Equals(Colors.Black) && new_color.Equals(Colors.White)) ||
         (old_color.Equals(Colors.White) && new_color.Equals(Colors.Black));
 }
        public Checker(int x, int y, Color color, Color bg)
        {
            el1 = new Ellipse();
            el2 = new Ellipse();
            crown = new Image();
            BitmapImage bi = new BitmapImage();
            bi.UriSource = new Uri("crown.png", UriKind.Relative);
            crown.Source = bi;
            crown.Visibility = Visibility.Collapsed;
            crown.MouseLeftButtonUp += ellipse_MouseUp;

            this.x = x;
            this.y = y;
            this.width = 55;
            this.lit = false;
            this.color = color;
            this.col = (color.Equals(GamePage.DarkGrey) ? false : true);
            this.bg = bg;
            this.high = !col ? GamePage.HighlightGrey : GamePage.HighlightRed;

            el1.Width = width;
            el1.MinWidth = width;
            el1.Height = width;
            el1.MinHeight = width;
            el1.Fill = new SolidColorBrush(color);

            el2.Width = width;
            el2.MinWidth = width;
            el2.Height = width;
            el2.MinHeight = width;
            el2.Fill = new SolidColorBrush(bg);
            el1.MouseLeftButtonUp += ellipse_MouseUp;
            el2.MouseLeftButtonUp += ellipse_MouseUp;
        }
 public bool HasColor(Color color)
 {
     return color.Equals(_primary) || color.Equals(_secondary);
 }
 private static void AdjustHighlightingColour(HighlightingColor current, Color desired)
 {
     if (!desired.Equals(current.Foreground.GetColor(_colourContext)))
     {
         current.Foreground = new CustomHighlightingBrush(desired);
     }
 }
        private void FloodFillImage_GetMousePosition(object sender, MouseButtonEventArgs e)
        {
            Point mousePoint = e.GetPosition((Image)sender);

            int index = GetPixelPosition((int)mousePoint.X, (int)mousePoint.Y);

            Color clickPointColor = new Color();
            clickPointColor.B = enhPixelData[index];
            clickPointColor.G = enhPixelData[index + 1];
            clickPointColor.R = enhPixelData[index + 2];
            //tempColor.A = enhPixelData[index + 3];

            if (!clickPointColor.Equals(highLightColor))
            {

                if (!isFirstCilck)
                {
                    //恢复前一个点选区域的颜色
                    int newIndex = GetPixelPosition((int)lastMousePoint.X, (int)lastMousePoint.Y);
                    Color newColorOfLastPoint = new Color();
                    newColorOfLastPoint.B = enhPixelData[newIndex];
                    newColorOfLastPoint.G = enhPixelData[newIndex + 1];
                    newColorOfLastPoint.R = enhPixelData[newIndex + 2];

                    //
                    if (newColorOfLastPoint.Equals(highLightColor) || !newColorOfLastPoint.Equals(lastClickColor))
                    {
                        //恢复前一个点选区域的颜色
                        FillGray(lastMousePoint, lastColor);
                    }

                }
                //高亮目前区域颜色
                FillGray(mousePoint, highLightColor);

                lastMousePoint = mousePoint;
                lastColor = clickPointColor;
                isFirstCilck = false;
            }
            else
            {
                //nothing
            }
        }
Beispiel #8
0
        private bool CheckEdge(Point temp, Color color)
        {
            if ((temp.X < 0) || (temp.X >= ImageWidth) || (temp.Y < 0) || (temp.Y >= ImageHeight))
                return false;
            int index = GetPixelPosition((int)temp.X, (int)temp.Y);

            Color tempColor = new Color();
            tempColor.B = enhPixelData[index];
            tempColor.G = enhPixelData[index + 1];
            tempColor.R = enhPixelData[index + 2];
            tempColor.A = enhPixelData[index + 3];

            //if (tempColor.Equals(old))
            //{
            //    return false;
            //}
            //else
            if (!tempColor.Equals(borderColor))
            {
                return true;
            }
            else
                return false;
        }
Beispiel #9
0
 //与背景色 以及其余可选色相同 即可填充
 //与边框相同即不可填充 返回false
 private bool canFillArea(Color current, Color old)
 {
     if (current.Equals(old))
     {
         return false;
     }
     else if (!current.Equals(borderColor))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
        /// <summary>
        /// Create an XPath query that retrieves the ink level from a standard bidi response.
        /// </summary>
        /// <param name="color"></param>
        /// <returns></returns>
        private static string CreateInkXPathQuery(Color color)
        {
            string colorName = null;

            if (color.Equals(Colors.Black))
            {
                colorName = "Black";
            }
            else if (color.Equals(Colors.Red))
            {
                colorName = "Red";
            }
            else if (color.Equals(Colors.Green))
            {
                colorName = "Green";
            }
            else if (color.Equals(Colors.Blue))
            {
                colorName = "Blue";
            }
            else if (color.Equals(Colors.Cyan))
            {
                colorName = "Cyan";
            }
            else if (color.Equals(Colors.Magenta))
            {
                colorName = "Magenta";
            }
            else if (color.Equals(Colors.Yellow))
            {
                colorName = "Yellow";
            }
            else
            {
                throw new ArgumentException("Unsupported color");
            }

            return "/bidi:Get/Query/Schema[@name='\\Printer.Consumables." + colorName + "Ink" + ":Level']/BIDI_INT";
        }
Beispiel #11
0
        private string GetColorName(Color color)
        {
            if (color.Equals(Colors.Yellow))
                return "yellow";
            if (color.Equals(Colors.Red))
                return "red";
            if (color.Equals(Colors.Blue))
                return "blue";
            if (color.Equals(Colors.Green))
                return "green";

            return "";
        }