Equals() public method

public Equals ( object obj ) : bool
obj object
return bool
コード例 #1
0
 public static void DrawText(System.Drawing.Graphics graphics, string text, System.Drawing.Font font, System.Drawing.Color foreColor, System.Drawing.Color backColor, System.Drawing.Rectangle bounds, Skybound.Windows.Forms.TextFormatFlags formatFlags)
 {
     if ((text == null) || (text.Length == 0) || (graphics == null) || (font == null) || bounds.Size == System.Drawing.Size.Empty || foreColor.Equals(System.Drawing.Color.Empty) || foreColor.Equals(System.Drawing.Color.Transparent))
     {
         return;
     }
     System.IntPtr intPtr1 = graphics.GetHdc();
     try
     {
         System.IntPtr intPtr2 = Skybound.Windows.Forms.TextRenderer.GetCachedFont(font);
         System.IntPtr intPtr3 = Skybound.Windows.Forms.TextRenderer.SelectObject(intPtr1, intPtr2);
         if (backColor.Equals(System.Drawing.Color.Empty) || backColor.Equals(System.Drawing.Color.Transparent))
         {
             Skybound.Windows.Forms.TextRenderer.SetBkMode(intPtr1, 1);
         }
         else
         {
             Skybound.Windows.Forms.TextRenderer.SetBkMode(intPtr1, 2);
             Skybound.Windows.Forms.TextRenderer.SetBkColor(intPtr1, System.Drawing.ColorTranslator.ToWin32(backColor));
         }
         int i = Skybound.Windows.Forms.TextRenderer.GetTextColor(intPtr1);
         Skybound.Windows.Forms.TextRenderer.SetTextColor(intPtr1, System.Drawing.ColorTranslator.ToWin32(foreColor));
         Skybound.Windows.Forms.TextRenderer.RECT rect = new Skybound.Windows.Forms.TextRenderer.RECT(bounds);
         Skybound.Windows.Forms.TextRenderer.DrawText(intPtr1, text, text.Length, ref rect, (int)formatFlags);
         Skybound.Windows.Forms.TextRenderer.SetTextColor(intPtr1, i);
         Skybound.Windows.Forms.TextRenderer.SelectObject(intPtr1, intPtr3);
     }
     finally
     {
         graphics.ReleaseHdc(intPtr1);
     }
 }
コード例 #2
0
ファイル: LogoMarkerSymbol.cs プロジェクト: secondii/Yutai
        bool ESRI.ArcGIS.esriSystem.IClone.IsEqual(IClone other)
        {
            bool angle = false;
            ILogoMarkerSymbol logoMarkerSymbol  = null;
            ILogoMarkerSymbol logoMarkerSymbol1 = null;
            IMarkerSymbol     markerSymbol      = null;
            IMarkerSymbol     markerSymbol1     = null;
            ISymbol           symbol            = null;
            ISymbol           symbol1           = null;
            IDisplayName      displayName       = null;
            IDisplayName      displayName1      = null;
            ISymbolRotation   symbolRotation    = null;
            ISymbolRotation   symbolRotation1   = null;
            IMapLevel         mapLevel          = null;
            IMapLevel         mapLevel1         = null;

            if (other != null)
            {
                if (other is ILogoMarkerSymbol)
                {
                    logoMarkerSymbol  = other as ILogoMarkerSymbol;
                    logoMarkerSymbol1 = this;
                    System.Drawing.Color color =
                        ColorTranslator.FromOle(Convert.ToInt32(logoMarkerSymbol1.ColorBorder.RGB));
                    angle = angle &
                            color.Equals(ColorTranslator.FromOle(Convert.ToInt32(logoMarkerSymbol.ColorBorder.RGB)));
                    color = ColorTranslator.FromOle(Convert.ToInt32(logoMarkerSymbol1.ColorLeft.RGB));
                    angle = angle &
                            color.Equals(ColorTranslator.FromOle(Convert.ToInt32(logoMarkerSymbol.ColorLeft.RGB)));
                    color = ColorTranslator.FromOle(Convert.ToInt32(logoMarkerSymbol1.ColorRight.RGB));
                    angle = angle &
                            color.Equals(ColorTranslator.FromOle(Convert.ToInt32(logoMarkerSymbol.ColorRight.RGB)));
                    color = ColorTranslator.FromOle(Convert.ToInt32(logoMarkerSymbol1.ColorTop.RGB));
                    angle = angle &
                            color.Equals(ColorTranslator.FromOle(Convert.ToInt32(logoMarkerSymbol.ColorTop.RGB)));
                    markerSymbol    = other as IMarkerSymbol;
                    markerSymbol1   = this;
                    angle           = angle & markerSymbol1.Angle == markerSymbol.Angle;
                    color           = ColorTranslator.FromOle(Convert.ToInt32(markerSymbol1.Color.RGB));
                    angle           = angle & color.Equals(ColorTranslator.FromOle(Convert.ToInt32(markerSymbol.Color.RGB)));
                    angle           = angle & markerSymbol1.Size == markerSymbol.Size;
                    angle           = angle & markerSymbol1.XOffset == markerSymbol.XOffset;
                    angle           = angle & markerSymbol1.YOffset == markerSymbol.YOffset;
                    symbol          = other as ISymbol;
                    symbol1         = this;
                    angle           = angle & symbol1.ROP2 == symbol.ROP2;
                    displayName     = other as IDisplayName;
                    displayName1    = this;
                    angle           = angle & (displayName1.NameString == displayName.NameString);
                    symbolRotation  = other as ISymbolRotation;
                    symbolRotation1 = this;
                    angle           = angle & symbolRotation1.RotateWithTransform == symbolRotation.RotateWithTransform;
                    mapLevel        = other as IMapLevel;
                    mapLevel1       = this;
                    angle           = angle & mapLevel1.MapLevel == mapLevel.MapLevel;
                }
            }
            return(angle);
        }
コード例 #3
0
ファイル: ColorUtils.cs プロジェクト: benjy3gg/PoeHud
        /// <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");
        }
コード例 #4
0
 internal System.Drawing.Color MakeSolidColor(System.Drawing.Color color)
 {
     if (color.Equals(System.Drawing.Color.Empty) || (color.A == 255))
     {
         return(color);
     }
     return(System.Drawing.Color.FromArgb(255, color));
 }
コード例 #5
0
        public static void ReturnColor(Color c)
        {
            if (c.Equals(Color.Black))
                return;

            lock (_colors)
            {
                _colors.Insert(0, c);
            }
        }
コード例 #6
0
 public bool Equals(ColorInfo other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(ScreenInfo, other.ScreenInfo) && Color.Equals(other.Color));
 }
コード例 #7
0
 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;
 }
コード例 #8
0
ファイル: FastBitmap.cs プロジェクト: gavinramm/Afterglow
        /// <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;
        }
コード例 #9
0
        private void FindColor()
        {
            _valueChanging = true;
            string name = "";

            _colorListBox.SelectedIndex = -1;
            _valueChanging = false;

            if (comboBoxList.SelectedIndex < 0)
            {
                return;
            }

            if (comboBoxList.SelectedIndex == 0)
            {
                foreach (string s in _colorListBox.Items)
                {
                    System.Drawing.Color c = System.Drawing.Color.FromName(s);

                    c = System.Drawing.Color.FromArgb(c.A, c.R, c.G, c.B);

                    if (c.Equals(_color) | (c.R == _color.R && c.G == _color.G && c.B == _color.B && c.A == _color.A))
                    {
                        name = s;
                        break;
                    }
                }
            }
            else
            {
                name = string.Format("#{0:X2}{1:X2}{2:X2}", _color.R, _color.G, _color.B);
            }

            int i = _colorListBox.FindString(name);

            _valueChanging = true;
            if (i >= 0 & name != "")
            {
                _colorListBox.SelectedIndex = i;
            }
            else
            {
                _colorListBox.SelectedIndex = -1;
            }
            _valueChanging = false;
        }
コード例 #10
0
ファイル: LabelSymbol.cs プロジェクト: secondii/Yutai
        bool ESRI.ArcGIS.esriSystem.IClone.IsEqual(IClone other)
        {
            bool            width           = false;
            LabelSymbol     labelSymbol     = null;
            LabelSymbol     labelSymbol1    = null;
            ILineSymbol     lineSymbol      = null;
            ILineSymbol     lineSymbol1     = null;
            ISymbol         symbol          = null;
            ISymbol         symbol1         = null;
            IDisplayName    displayName     = null;
            IDisplayName    displayName1    = null;
            ISymbolRotation symbolRotation  = null;
            ISymbolRotation symbolRotation1 = null;
            IMapLevel       mapLevel        = null;
            IMapLevel       mapLevel1       = null;

            if (other != null)
            {
                if (other is LabelSymbol)
                {
                    labelSymbol  = other as LabelSymbol;
                    labelSymbol1 = this;
                    lineSymbol   = other as ILineSymbol;
                    lineSymbol1  = this;
                    System.Drawing.Color color = ColorTranslator.FromOle(Convert.ToInt32(lineSymbol1.Color.RGB));
                    width           = width & color.Equals(ColorTranslator.FromOle(Convert.ToInt32(lineSymbol.Color.RGB)));
                    width           = width & lineSymbol1.Width == lineSymbol.Width;
                    symbol          = other as ISymbol;
                    symbol1         = this;
                    width           = width & symbol1.ROP2 == symbol.ROP2;
                    displayName     = other as IDisplayName;
                    displayName1    = this;
                    width           = width & (displayName1.NameString == displayName.NameString);
                    symbolRotation  = other as ISymbolRotation;
                    symbolRotation1 = this;
                    width           = width & symbolRotation1.RotateWithTransform == symbolRotation.RotateWithTransform;
                    mapLevel        = other as IMapLevel;
                    mapLevel1       = this;
                    width           = width & mapLevel1.MapLevel == mapLevel.MapLevel;
                }
            }
            return(width);
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: TheBritz/Sprite-Analyzer
        /// <summary>
        /// Extracts the individual parts of a color argument
        /// </summary>
        /// <param name="arg">The argument</param>
        /// <param name="name">The name of the analysis data</param>
        /// <param name="color">The color source of this analysis</param>
        /// <param name="analyzerDLL">The name of the analyzer component</param>
        private static void GetColorArgParts(string arg, out string name,
                                             out DRAW.Color color, out string analyzerDLL, out string analyzerID)
        {
            string colorStr = string.Empty;

            name        = string.Empty;
            analyzerDLL = string.Empty;
            analyzerID  = string.Empty;
            if (arg.ElementAt(0) == '-' && arg.Contains("=") && arg.Contains("|"))
            {
                //This argument contains a name for this color, get both
                string[] thisArgElements = arg.Split
                                               ("-=|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                name        = thisArgElements[0];
                colorStr    = thisArgElements[1];
                analyzerDLL = thisArgElements[2];
                analyzerID  = thisArgElements[3];
            }
            else
            {
                colorStr = arg;
            }

            //Try to instantiate the color from the raw color string in case
            //it's a name
            color = DRAW.Color.FromName(colorStr);

            //Instantiate a color converter
            DRAW.ColorConverter colConverter = new DRAW.ColorConverter();

            //Check if this is a valid color
            if (color.Equals(DRAW.Color.FromName("Invalid")))
            {
                //Sanitize color string
                if (colorStr.ElementAt(0) != '#')
                {
                    colorStr = "#" + colorStr;
                }

                color = (DRAW.Color)colConverter.ConvertFromString(colorStr);
            }
        }
コード例 #12
0
        private void SendColorToPeripheral(System.Drawing.Color color, bool forced = false)
        {
            if ((!previous_peripheral_Color.Equals(color) || forced) && mouse != null)
            {
                if (Global.Configuration.allow_peripheral_devices)
                {
                    mouse.SetAll(color);

                    previous_peripheral_Color = color;
                    peripheral_updated        = true;
                }
                else
                {
                    if (peripheral_updated)
                    {
                        peripheral_updated = false;
                    }
                }
            }
        }
コード例 #13
0
 private HexCellBiome fromColorToBiome(Color color)
 {
     if (color.Equals(Color.FromArgb(255, 55, 136, 48)))
     {
         return(HexCellBiome.FOREST);
     }
     else if (color.Equals(Color.FromArgb(255, 139, 183, 128)))
     {
         return(HexCellBiome.SCRUB);
     }
     else if (color.Equals(Color.FromArgb(255, 89, 220, 65)))
     {
         return(HexCellBiome.GRASS);
     }
     else if (color.Equals(Color.FromArgb(255, 96, 173, 195)))
     {
         return(HexCellBiome.WATER);
     }
     else if (color.Equals(Color.FromArgb(255, 189, 137, 97)))
     {
         return(HexCellBiome.CROP);
     }
     else if (color.Equals(Color.FromArgb(255, 48, 48, 48)))
     {
         return(HexCellBiome.CITY);
     }
     else if (color.Equals(Color.FromArgb(255, 255, 76, 77)))
     {
         return(HexCellBiome.BUILDINGS);
     }
     else if (color.Equals(Color.FromArgb(255, 107, 107, 107)))
     {
         return(HexCellBiome.ROCK);
     }
     return(HexCellBiome.WATER);
 }
コード例 #14
0
        public static string GetColourDescription(Color c, bool orig)
        {
            if (c.Equals(Color.Transparent))
            {
                return "Transparent";
            }

            //get matching
            var bc = Beads.AllBeadColours.Where(s => ColorExtras.Equals(s.Value, c)).ToList();
            if (!bc.Any())
                return c.ToString();
            var bcf = bc.First();
            return bcf.Key + " " + bcf.Value;
        }
コード例 #15
0
        /////////////////
        //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
            }
        }
コード例 #16
0
ファイル: ImageList.cs プロジェクト: mind0n/hive
 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");
     }
 }
コード例 #17
0
        public void setServerData(int index, string column, string text, Color backgroundColor)
        {
            var a = new Action(() =>
            {
                serverGridView.Rows[index].Cells[column].Value = text;
                serverGridView.Rows[index].Cells[column].Style.BackColor = backgroundColor;
                string nodeName = serverGridView.Rows[index].Cells["Node"].Value.ToString();

                string state = "";
                if (!(nodeStates.TryGetValue(new Tuple<string, string>(nodeName, column), out state)))
                {
                    state = "None";
                }

                if (backgroundColor.Equals(ActionRunner.getColorForActionStatus(ActionStatus.Failure)) && state != "Red")
                {
                    nodeStates[new Tuple<string, string>(nodeName, column)] = "Red";
                }
                else if (backgroundColor.Equals(ActionRunner.getColorForActionStatus(ActionStatus.Success)) && state != "Green")
                {
                    nodeStates[new Tuple<string, string>(nodeName, column)] = "Green";
                }

                string newState = "";
                if (!(nodeStates.TryGetValue(new Tuple<string, string>(nodeName, column), out newState)))
                {
                    newState = "None";
                }

                if (state != "None" && state != newState)
                {
                    addToNodeStateChangeLog(nodeName + " - " + column + " changed from " + state + " to " + newState);
                }
            });
            condInvoke(a);
        }
コード例 #18
0
ファイル: RendererBase.cs プロジェクト: wxll1120/c585b99f
        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,
                            itemRect.Top + TabControl.TabContentSpacing,
                            image.Width, image.Height);

                        format.Alignment = StringAlignment.Center;

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

                            gfx.DrawString(tabPageText, TabControl.TabItemFont, brush, rect, format);
                        }
                    }
                    else if (TabControl.TextImageRelation.Equals(TextImageRelation.Overlay))
                    {
                        gfx.DrawImage(image, itemRect.Left + itemRect.Width / 2 - image.Width / 2,
                            itemRect.Top + itemRect.Height / 2 - image.Height / 2,
                            image.Width, image.Height);

                        format.Alignment = StringAlignment.Center;

                        using (Brush brush = new SolidBrush(foreColor))
                        {
                            gfx.DrawString(tabPageText, TabControl.TabItemFont, brush, itemRect, format);
                        }
                    }
                }

                //绘制边框
                if (!borderColor.Equals(Color.Empty) && borderWidth > 0)
                {
                    itemRect.Width -= borderWidth;
                    itemRect.Height -= borderWidth;

                    using (Pen pen = new Pen(borderColor, borderWidth))
                    {
                        gfx.DrawRectangle(pen, itemRect);
                    }
                }
            }
        }
コード例 #19
0
ファイル: Tile.svc.cs プロジェクト: XiBeichuan/hydronumerics
 /// <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));
 }
コード例 #20
0
ファイル: Tile.svc.cs プロジェクト: XiBeichuan/hydronumerics
        /// <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);
                            }
                        }
                    }
                }
            }
        }
コード例 #21
0
        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;
        }
コード例 #22
0
        public MRMPrim(MRMPrimFactory factory, string name, Vector3 position, Color colour = default(Color), Vector3 scale = default(Vector3), PrimType shape = PrimType.Unknown, Quaternion rotation = default(Quaternion))
        {
            _exists = true;
            _editable = true;
            _factory = factory;
            _name = name;
            _obj = factory.RegisterPrim(this, name, position);
            _id = _obj.GlobalID;
            _child = !ID.Equals(_obj.Root.GlobalID);

            Glow = 0d;
            Name = _name;
            Colour = !colour.Equals(default(Color)) ? colour : Color.White;
            Shape = !shape.Equals(PrimType.Unknown) ? shape : PrimType.Box;
            Rotation = !rotation.Equals(default(Quaternion)) ? rotation : Quaternion.Identity;
            Scale = !scale.Equals(default(Vector3)) ? scale : new Vector3(.5f, .5f, .5f);

            _updateListener = Update;
            factory.Update += _updateListener;
        }
コード例 #23
0
        /// <summary>
        /// Does the provided color exist in the definition.
        /// </summary>
        /// <param name="color">Color to find.</param>
        /// <returns>True if found; otherwise false.</returns>
        public bool ContainsColor(Color color)
        {
            if ((_colors != null) && (color != null))
            {
                foreach (Color[] column in _colors)
                    foreach (Color row in column)
                        if (color.Equals(row))
                            return true;
            }

            return false;
        }
コード例 #24
0
		private void AddColoursToList(ListBox in_listBox, Type in_colourSource, Color in_selectMe)
		{
			PropertyInfo [] pic;
			ColourAndNameListItem canli;			
			int i;

			pic = in_colourSource.GetProperties();

			foreach (PropertyInfo pi in pic)
			{
				if (pi.PropertyType == typeof(Color))
				{
					canli = new ColourAndNameListItem();
					canli.Colour = (Color)pi.GetValue(null, null);
					canli.Name = pi.Name;

					i = in_listBox.Items.Add(canli);

					if (in_selectMe.Equals(canli.Colour))
						in_listBox.SelectedIndex = i;
				}
			}																							
		}
コード例 #25
0
ファイル: settingsUI.cs プロジェクト: willie68/SkypeLight
        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;
        }
コード例 #26
0
ファイル: MainForm.cs プロジェクト: Knaster/LitePlacer-ver2
        // 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 { }
        }
 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)))
     {
         if (cacheCheckImage != null)
         {
             cacheCheckImage.Dispose();
             cacheCheckImage = null;
         }
         System.Windows.Forms.NativeMethods.RECT rect = System.Windows.Forms.NativeMethods.RECT.FromXYWH(0, 0, fullSize.Width, fullSize.Height);
         Bitmap image = new Bitmap(fullSize.Width, fullSize.Height);
         Graphics wrapper = Graphics.FromImage(image);
         wrapper.Clear(Color.Transparent);
         IntPtr hdc = wrapper.GetHdc();
         try
         {
             System.Windows.Forms.SafeNativeMethods.DrawFrameControl(new HandleRef(wrapper, hdc), ref rect, 2, 1);
         }
         finally
         {
             wrapper.ReleaseHdcInternal(hdc);
             wrapper.Dispose();
         }
         image.MakeTransparent();
         cacheCheckImage = image;
         cacheCheckColor = checkColor;
     }
     return cacheCheckImage;
 }
コード例 #28
0
ファイル: FillColor.cs プロジェクト: yarden/sbml2tikz
 public static string AlphaValTex(Color linecolor)
 {
     if (!linecolor.Equals(Color.Empty))
     {
         return "!" + (linecolor.A * 100 / 255).ToString();
     }
     return "";
 }
コード例 #29
0
ファイル: VisioImporter.cs プロジェクト: ChrisMoreton/Test3
		/// <summary>
		/// Converts Visio's arrow type into Flowchart.NET EArrowHead enum
		/// </summary>
		/// <param name="ArrowType">String arrow style</param>
		/// <param name="lpCR">Color object reference to be returned</param>
		/// <returns>EArrowHead enumeration value</returns>
		private ArrowHead  String2ArrowType( string ArrowType, ref Color lpCR )
		{
			long lArrowType = 0;
			ArrowHead ahReturn = ArrowHead.None;

			if (( ArrowType == null ) || ( ArrowType == "") )
				return ahReturn;

			try
			{
				lArrowType = System.Convert.ToInt16(ArrowType);
			
				ahReturn = ArrowHead.Arrow;
				switch ( lArrowType)
				{
					case 0:
						ahReturn = ArrowHead.None;
						break;
					case 2:
					case 4:
					case 5:
					case 6:
					case 8:
					case 13:
					case 14:
					case 15:
					case 16:
					case 17:
					case 18:
					case 19:
					case 39:
					case 40:
					case 44:
						ahReturn = ArrowHead.Triangle;
						break;
					case 20:
					case 29:
					case 30:
					case 31:
					case 32:
					case 33:
					case 34:
					case 41:
					case 42:
						ahReturn = ArrowHead.Circle;
						break;
					case 11:
					case 21:
						ahReturn = ArrowHead.Tetragon;
						break;
					case 22:
					case 38:
						ahReturn = ArrowHead.Rhombus;
						break;
					case 23:
						ahReturn = ArrowHead.BackSlash;
						break;
					case 9:
						ahReturn = ArrowHead.Slash;
						break;
					case 43:
					case 45:
						ahReturn = ArrowHead.DoubleArrow;
						break;
	
				}

				if ((lpCR.Equals(null)) && ( lArrowType>=15))
					lpCR = Color.FromArgb(255,255,255);
			}
			catch (Exception ex)
			{
				ahReturn = ArrowHead.None;
				Trace.WriteLine(String.Format("{0} error {1}\n","String2ArrowType",ex.Message));
			}
			return ahReturn;
		}
コード例 #30
0
ファイル: ComboBoxBase.cs プロジェクト: bmadarasz/ndihelpdesk
        internal void DrawComboBoxBorder(Graphics g, Color color)
        {
            // Keep track of what we painted last
              if (color.Equals(ColorUtil.VSNetBorderColor))
              {
            highlighted = true;
              }
              else
              {
            highlighted = false;
              }

              Pen pen = new Pen(new SolidBrush(color), 1);
              g.DrawRectangle(pen, ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - 1,
                      ClientRectangle.Height - 1);

              // We need to draw an extra "inner" border to erase the ugly 3D look of  the combobox
              //PATCH: Pens.White <- new Pen(new SolidBrush(BackColor))
              g.DrawRectangle(new Pen(new SolidBrush(BackColor)), ClientRectangle.Left + 1, ClientRectangle.Top + 1,
                      ClientRectangle.Width - SystemInformation.VerticalScrollBarWidth, ClientRectangle.Height - 3);
        }
コード例 #31
0
        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);
                    }
                }
            }
        }
コード例 #32
0
ファイル: Tile.svc.cs プロジェクト: XiBeichuan/hydronumerics
        /// <summary>
        /// RenderMultiLinestring
        ///     Render a MultiLinestring 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 stroke color style</param>
        private void RenderMultiLinestring(SqlGeography geo, string table, Graphics g, int id, Color valueFill)
        {

            if (geo.STNumGeometries() > 0)
            {
                totalPoints += (int)geo.STNumPoints();

                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)
                            {
                                Point[] ptArray = new Point[(int)geo.STNumPoints()];
                                double lon1 = 0.0;
                                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 linePath = new GraphicsPath();
                                linePath.AddLines(ptArray);
                                Pen myPen = new Pen(valueFill);
                                myPen.Width = 2;
                                g.DrawPath(myPen, linePath);
                            }
                        }
                    }
                }

            }

        }
コード例 #33
0
ファイル: Utils.cs プロジェクト: PabloCorso/BattleNotifier
 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;
 }
コード例 #34
0
        /// <summary>
        /// Business logic to place the Project Premonition trap in a
        /// relevant location to attract mosquitos.  (Note that this
        /// is not the real business logic used by Project Premonition
        /// research team; this is intended as an example/demo of using
        /// the AI for Earth land cover APIs.)
        /// </summary>
        /// <param name="x"></param>
        private void FindBestPlacement(Bitmap img)
        {
            /*
             *  var pixels = new List<System.Windows.Point>()
             *  {
             *      //Test data
             *      new System.Windows.Point(70, 30),
             *      new System.Windows.Point(80, 140),
             *      new System.Windows.Point(235, 180),
             *  };
             */

            var pixels        = new List <System.Windows.Point>();
            var possibilities = new List <System.Windows.Point>();

            // Colors of classification
            System.Drawing.Color noData     = System.Drawing.Color.FromArgb(0, 0, 0);
            System.Drawing.Color water      = System.Drawing.Color.FromArgb(0, 0, 255);
            System.Drawing.Color trees      = System.Drawing.Color.FromArgb(0, 127, 0);
            System.Drawing.Color herbaceous = System.Drawing.Color.FromArgb(127, 255, 127);
            System.Drawing.Color barren     = System.Drawing.Color.FromArgb(127, 95, 95);

            // We are not storing off "no data" or "barren" points because mosquitos
            // are unlikely to be found there.
            List <System.Windows.Point> waterPoints      = new List <System.Windows.Point>();
            List <System.Windows.Point> treePoints       = new List <System.Windows.Point>();
            List <System.Windows.Point> herbaceousPoints = new List <System.Windows.Point>();

            // Find points where water and trees meet
            for (int i = 1; i < img.Width - 1; i++)
            {
                for (int j = 1; j < img.Height - 1; j++)
                {
                    System.Drawing.Color pixelColor = img.GetPixel(i, j);
                    if (pixelColor.Equals(trees))
                    {
                        treePoints.Add(new System.Windows.Point(i, j));

                        // Check for presence of water next to it
                        if (img.GetPixel(i - 1, j - 1).Equals(water))
                        {
                            waterPoints.Add(new System.Windows.Point(i - 1, j - 1));
                            possibilities.Add(new System.Windows.Point(i, j));
                        }
                        else if (img.GetPixel(i - 1, j).Equals(water))
                        {
                            waterPoints.Add(new System.Windows.Point(i - 1, j));
                            possibilities.Add(new System.Windows.Point(i, j));
                        }
                        else if (img.GetPixel(i - 1, j + 1).Equals(water))
                        {
                            waterPoints.Add(new System.Windows.Point(i - 1, j + 1));
                            possibilities.Add(new System.Windows.Point(i, j));
                        }
                        else if (img.GetPixel(i, j - 1).Equals(water))
                        {
                            waterPoints.Add(new System.Windows.Point(i, j - 1));
                            possibilities.Add(new System.Windows.Point(i, j));
                        }
                        else if (img.GetPixel(i, j + 1).Equals(water))
                        {
                            waterPoints.Add(new System.Windows.Point(i, j + 1));
                            possibilities.Add(new System.Windows.Point(i, j));
                        }
                        else if (img.GetPixel(i + 1, j - 1).Equals(water))
                        {
                            waterPoints.Add(new System.Windows.Point(i + 1, j - 1));
                            possibilities.Add(new System.Windows.Point(i, j));
                        }
                        else if (img.GetPixel(i + 1, j).Equals(water))
                        {
                            waterPoints.Add(new System.Windows.Point(i + 1, j));
                            possibilities.Add(new System.Windows.Point(i, j));
                        }
                        else if (img.GetPixel(i + 1, j + 1).Equals(water))
                        {
                            waterPoints.Add(new System.Windows.Point(i + 1, j + 1));
                            possibilities.Add(new System.Windows.Point(i, j));
                        }
                    }
                    else if (pixelColor.Equals(water))
                    {
                        waterPoints.Add(new System.Windows.Point(i, j));
                    }
                    else if (pixelColor.Equals(herbaceous))
                    {
                        herbaceousPoints.Add(new System.Windows.Point(i, j));
                    }
                }
            }

            Random rand = new Random(100);

            // If there is water next to trees, use that location first
            if (possibilities.Count > 0)
            {
                int r = rand.Next(possibilities.Count);
                pixels.Add(possibilities[r]);
            }

            // Otherwise find place in trees.  (Choose a random value in treePoints)
            else if (treePoints.Count > 0)
            {
                int r = rand.Next(treePoints.Count);
                pixels.Add(treePoints[r]);
            }

            // Otherwise field (can't place trap in water or in buildings/on roads)
            else if (herbaceousPoints.Count > 0)
            {
                int r = rand.Next(herbaceousPoints.Count);
                pixels.Add(herbaceousPoints[r]);
            }

            // Adjust pixels for scale factor
            var scaledPixels = new List <System.Windows.Point>();

            for (int i = 0; i < pixels.Count; i++)
            {
                System.Windows.Point p = new System.Windows.Point(pixels[i].X * 256 / img.Width, pixels[i].Y * 256 / img.Height);
                scaledPixels.Add(p);
            }

            //Display the traps on the map. Pass in the pixel of the image.
            ShowTrapsOnMap(scaledPixels);
        }
コード例 #35
0
        private static void AddNewEdge(Pixel p1, Pixel p2, Color cA, Color cB, UndirectedGraph<Pixel, TaggedUndirectedEdge<Pixel, EdgeTag>> graph)
        {
            TaggedUndirectedEdge<Pixel, EdgeTag> e;
            TaggedUndirectedEdge<Pixel, EdgeTag> e1;
            TaggedUndirectedEdge<Pixel, EdgeTag> e2;
            bool b = !cA.Equals(cB);

            graph.TryGetEdge(p1, p2, out e1);
            graph.TryGetEdge(p2, p1, out e2);
            p1.color = cA;
            p1.colorB = cB;
            p2.color = cA;
            p2.colorB = cB;

            if (e1 == null && e2 == null && b) // adicionado o "b" para adicionar apenas arestas visiveis ao grafo
            {
                e = new TaggedUndirectedEdge<Pixel, EdgeTag>(p1, p2, new EdgeTag(cA, cB, b));
                graph.AddEdge(e);
                if (b) //conta valencia apenas se for visivel
                {
                    p1.valence++;
                    p2.valence++;
                }
            }
        }
コード例 #36
0
ファイル: main.cs プロジェクト: 1995hnagamin/Pidet
 int IndexByColor(Color e)
 {
     for (int i = 0; i < 20; i++)
     {
         if (e.Equals(ColorByIndex(i))) return i;
     }
     return pColor.White;
 }
コード例 #37
0
ファイル: Converter.cs プロジェクト: RocDeanGit/PicToAscii
 /// <summary>
 /// 写入html的Body部分
 /// </summary>
 /// <param name="sw">输出流</param>
 private void writeHtmlBody(StreamWriter sw)
 {
     if (sw != null)
     {
         int stepW = Precision;
         int stepH = 2 * stepW;
         sw.WriteLine("<pre>");
         for (int i = 1; i + stepH < Bmp.Height; i += stepH)
         {
             for (int j = 1; j + stepW < Bmp.Width; j += stepW)
             {
                 conCol = getColor(Bmp,j, i, stepW, stepH);
                 int index = (int)((characters.Length - 1) * conCol.GetBrightness());
                 if (i * j == 1)
                 {
                     sw.Write("<c style=\"color:" + ColorTranslator.ToHtml(conCol) + "\">"
                                                + characters.ElementAt(index));
                 }
                 else
                 {
                     if (conCol.Equals(tmpCol))
                     {
                         sw.Write(characters.ElementAt(index));
                     }
                     else
                     {
                         sw.Write("</c><c style=\"color:" + ColorTranslator.ToHtml(conCol) + "\">"
                             + characters.ElementAt(index));
                     }
                     tmpCol = conCol;
                 }
             }
             sw.WriteLine();
         }
         sw.WriteLine("</c></pre>");
     }
 }
コード例 #38
0
        /// <summary>
        /// Adds a vignette image effect to the current image.
        /// </summary>
        /// <param name="color">
        /// The <see cref="T:System.Drawing.Color"/> to tint the image with. Defaults to black.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory Vignette(Color? color = null)
        {
            if (this.ShouldProcess)
            {
                Vignette vignette = new Vignette
                {
                    DynamicParameter = color.HasValue && !color.Equals(Color.Transparent)
                                        ? color.Value
                                        : Color.Black
                };

                this.CurrentImageFormat.ApplyProcessor(vignette.ProcessImage, this);
            }

            return this;
        }
コード例 #39
0
ファイル: MainForm.cs プロジェクト: jkuusama/LitePlacer-ver2
 // TinyG communication monitor textbox  
 public void DisplayText(string txt, Color color) {
     if (!IsShown) 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 {
     }
 }
コード例 #40
0
ファイル: Colors.cs プロジェクト: Grifs99/ShareX
 public static bool IsVisible(Color c)
 {
     return c != null && !c.Equals(Color.Empty) && !c.Equals(Color.Transparent) && c.A > 0;
 }
コード例 #41
0
 public override bool Equals(object obj)
 {
     return((obj is SolidBrush sb) && color.Equals(sb.Color));
 }