Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

loop search for horizontal hand drawn lines by color --- what am I doing wrong ??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    loop search for horizontal hand drawn lines by color --- what am I doing wrong ??

    Hello,

    The code below finds the hand drawn horizontal lines, and the correct price...but it is not matching on the brush color!!! (black or cyan)

    Anyone?


    foreach (DrawingTool draw in DrawObjects.ToList())
    {
    // select User Drawn Horizontal or Ray Lines
    if (draw.IsUserDrawn)
    {

    if (draw is DrawingTools.HorizontalLine)
    {
    DrawingTools.HorizontalLine thisLine = draw as DrawingTools.HorizontalLine;

    Print ("Horizontal Line Found " + thisLine.StartAnchor.Price.ToString() + " ..... " + thisLine.Stroke.Brush.ToString() + " ..... " + Brushes.Cyan.ToString() + " ..... " + Brushes.Black.ToString());

    if (thisLine.Stroke.Brush == Brushes.Black)
    Print ("Matches BLACK");
    if (thisLine.Stroke.Brush == Brushes.Cyan)
    Print ("Matches CYAN");
    )
    )
    )​

    #2
    well, it is not pretty, but changing the Brush to a string and then comparing them works


    private string thisColor;
    private string myBlack = Brushes.Black.ToString();
    private string myCyan = Brushes.Cyan.ToString();



    DrawingTools.HorizontalLine thisLine = draw as DrawingTools.HorizontalLine;

    thisColor = thisLine.Stroke.Brush.ToString();

    if (thisColor == myBlack)
    Print ("Matches BLACK");

    if (thisColor == myCyan())
    Print ("Matches CYAN");

    if (thisColor == myBlack || thisColor == myCyan)


    I really don't believe it has to be this convoluted...isn't there a more elegant way to compare two brushes/color?
    .
    (it works so unless I get a better answer will leave it that way)

    Comment


      #3
      Hello llanqui,

      What you have done is correct, brushes cannot be compared by using == you would have to get the brushes name and compare that instead which you are doing.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      646 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      367 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X