Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ambiguous Reference NinjaScript Generated Code

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

    Ambiguous Reference NinjaScript Generated Code

    I am getting the following error within #region NinjaScript generated code:

    'Brush' is an ambiguous reference between 'System.Windows.Media.Brush' and 'SharpDX.Direct2D1.Brush'.

    How would I resolve this, particularly as the code is autogenerated?

    #2
    What is the object you are creating in your properties being used for?

    That's where the auto-gen stuff is getting its info from. Maybe need to have full object namespace for it

    Comment


      #3
      You have probably referenced a Brush in your code and imported an alternative namespace (eg; a using statement). Just remove the alternative namespace and prefix your variable declaration with the full namespace.

      codeowl.

      Comment


        #4
        Hello FatCanary,

        Have you been able to resolve the issue?

        If not can you provide further information?

        Comment


          #5
          Sorry Calonious, I'm not sure what you mean.

          Comment


            #6
            Hi codeowl

            I'm using:
            System.Windows.Media;
            and
            using SharpDX.DirectWrite;
            using SharpDX;
            using SharpDX.Direct2D1;

            As an example I have:
            private Brush panelBrush = Brushes.White;

            and then:
            SharpDX.Direct2D1.Brush panelBrushDx = panelBrush.ToDxBrush(RenderTarget);

            Comment


              #7
              Hi Paul

              Working on it...

              Will let you know.

              Yes, now resolved.
              Last edited by FatCanary; 05-10-2016, 03:24 PM.

              Comment


                #8
                So from your example, you have a SharpDX brush and a System.Windows.Media.Brush

                Two different brushes that the auto gen isn't getting.

                You just defined Brush but the system doesn't know which brush you are using here from the using statements, hence the compile error

                Take out the SharpDX using statements and just use the full name for them, or you need to have
                private System.Windows.Media.Brush panelBrush = System.Windows.Meida.Brushes.White;

                using SharpDX.DirectWrite;
                using SharpDX;
                using SharpDX.Direct2D1;

                Comment


                  #9
                  That is what I suspected.

                  Where I have:
                  private Brush panelBrush = Brushes.White;

                  is there no way to set panelBrush as a SharpDX object straight away rather than having to use:
                  SharpDX.Direct2D1.Brush panelBrushDx = panelBrush.ToDxBrush(RenderTarget);

                  Seems long winded to me. I have 8 different brushes.So would need to use the SharpDX full name for each one, every time I used it.

                  Comment


                    #10
                    Yeah, welcome to DirectX programming!

                    Since, you're going the path of wanting to have the end user change the color so that the SharpDX changes based on that, you would need to go this route since you're converting a Windows.Media.Brush to a SharpDX.Direct2D1.Brush; there is some extra code involved.

                    Also, I don't think the PropertyGrid handles SharpDX brush objects either...So that would be another reason why you need the Windows.Media.Brush as the intermeidary to the SharDX object.

                    Comment


                      #11
                      Oh great
                      Thanks for the clarification.

                      Before I go head long down this route, can I just check that there is no other way to draw, say, a rectangle or text on a chart panel, exactly where I want it, without using DirectX?
                      I take it DirectX has now replaced 'graphics.' that was used in NT7?

                      Comment


                        #12
                        Not without hindering performance using WPF objects. Not worth it IMO

                        P.S.

                        As a side note you can create Using objects based on a name for a certain object in that code
                        Code:
                        using Brush = System.Windows.Media.Brush;
                        using DxBrush = SharpDX.Direct2D1.Brush;
                        Then you can just use those names for reference in the code.

                        Code:
                        DxBrush dxBrush = panelBrush.ToDxBrush(RenderTarget);
                        Last edited by Calonious; 05-10-2016, 03:25 PM.

                        Comment


                          #13
                          Much thanks.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          599 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          344 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          103 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          558 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          557 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X