Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

System.Drawing.Drawing2D.DashStyle

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

    System.Drawing.Drawing2D.DashStyle

    I have starting working with the Draw.Line() function.

    What I have had trouble doing is getting the DashStyle.Solid to be recognized. Although most of your technology now uses the "System.Windows.Media", this particular parameter still comes from the older NT7 namespace "System.Drawing.Drawing2D.DashStyle". If I add this USING directive it cause some ambiguous reference that need to be fixed. I will add the explicate reference "System.Drawing.Drawing2D.DashStyle.Solid" for now.

    Is there a reason you need to mix this technology with the newer approach? This seems to stick out like a soar thumb. I understand if this was a short-cut for now, but will likely cause a code break later if you want to roll it under the Windows.Media.

    #2
    It sticks out even in the Draw.Line implementation itself:
    Code:
    		// line overloads
    		private static Line Line(NinjaScriptBase owner, bool isAutoScale, string tag,
    								int startBarsAgo, DateTime startTime, double startY, int endBarsAgo, DateTime endTime, double endY,
    								Brush brush, System.Drawing.Drawing2D.DashStyle dashStyle, int width)
    		{
    			return DrawLineTypeCore<Line>(owner, isAutoScale, tag, startBarsAgo, startTime, startY, endBarsAgo, endTime, endY, brush, dashStyle, width, false, null);
    		}
    What was wrong with DashStyles in Media namespace that it is not used?

    Comment


      #3
      Yup,

      Strange all the Drawing tools use the 2d version.

      Comment


        #4
        Thanks guys. I will have the team run some analysis and will get back to you.

        Comment


          #5
          You are right. We will remove/replace those references. #8190

          Note: this will break existing NT8B1 code.

          Thanks for reporting.

          Comment


            #6
            There is at least one more conflict: in the Draw.Text, System.Drawing.StringAlignment is being used.
            With the change to System.Windows.Media it should use TextAlignment instead
            Code:
            public static Text Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, DateTime time, double y, int yPixelOffset,
            			Brush textBrush, Gui.Tools.SimpleFont font, System.Drawing.StringAlignment alignment,
            			Brush outlineBrush, Brush areaBrush, int areaOpacity)
            {
            	return TextCore(owner, tag, false, text, int.MinValue, time, y, yPixelOffset, textBrush, alignment, font, outlineBrush, areaBrush, areaOpacity, false, null);
            }
            Last edited by gregid; 05-09-2015, 09:10 AM.

            Comment


              #7
              Thanks. We'll look into.

              Comment


                #8
                Update: already fixed with most recent changes on removing 'System.Drawing' references...

                Comment


                  #9
                  Another conflict

                  Pen for DashStyle uses System.Windows.Media.DashStyles
                  Stroke for DashStyle uses NinjaTrader.Gui.DashStyleHelper

                  Also there is no property grid editor for System.Windows.Media.DashStyles it simply displays "System.Windows.Media.DashStyles":
                  Code:
                  [NinjaScriptProperty]
                  [Display(Name = "Detail Dash Style1", Order = 0, GroupName = "Visual")]
                  public DashStyle DetailDashStyle1
                  { get; set; }
                  versus DashStyleHelper which displays correctly (it is enum after all)
                  Code:
                  [NinjaScriptProperty]
                  [Display(Name = "Detail Dash Style2", Order = 1, GroupName = "Visual")]
                  public DashStyleHelper DetailDashStyle2
                  { get; set; }
                  My understanding is that Pen should also use DashStyleHelper
                  Last edited by gregid; 05-10-2015, 07:32 AM. Reason: typo correction: DashStyles -> DashStyle

                  Comment


                    #10
                    Thanks for the report, we're reviewing DashStyleHelper for Strokes and Pens as well...

                    Regarding the property, I can reproduce and reported to development - NTEIGHT-8201
                    MatthewNinjaTrader Product Management

                    Comment


                      #11
                      Originally posted by NinjaTrader_Matthew View Post
                      Thanks for the report, we're reviewing DashStyleHelper for Strokes and Pens as well...

                      Regarding the property, I can reproduce and reported to development - NTEIGHT-8201
                      Can you already tell me which one is going to be used more likely for both Stroke and Pen: DashStyleHelper or DashStyle - I have plenty of properties like this and would like to make changes accordingly.

                      Comment


                        #12
                        I will be sure to update once our devs have finalized on this decision.
                        MatthewNinjaTrader Product Management

                        Comment


                          #13
                          While we are at Stroke and Pen there is one minor issue I would like resolved - when adding plot with a Stroke:
                          Code:
                          AddPlot(new Stroke(Brushes.Orange, DashStyleHelper.Dash, 2.0f, PlotStyle.Line));
                          I can add in one line all the information I use for plots in 99% of cases, but if I want to change the way it plots I can't use Stroke (ie: there is no Plot.Stroke) so I can't do something like:
                          Code:
                          Plots[0].Stroke = new Stroke(Brushes.Red, DashStyleHelper.Dot, 1.0f, PlotStyle.Line)
                          I can achieve this using Plot.Pen:
                          Code:
                          Pen newPen = new Pen(Brushes.Red, 1.0f);
                          newPen.DashStyle = DashStyles.Dot;
                          Plots[0].Pen = newPen;
                          but as you can see it requires 3 lines instead of the initial 1 line. Obviously, the DashStyle conflict you are looking now to resolve also complicates things but this is temporary I believe. It also adds to confusion since I created a plot with a Stroke and now edit Pen instead.
                          So what I would like to see is either access to Plot.Stroke (just as it is with Plot.Pen at the moment) or adding one more overload to Pen:
                          Code:
                          Pen(Brush brush, DashStyle dashStyle, double thickness)
                          (whichever DashStyle it is going to use in the end)
                          Last edited by gregid; 05-11-2015, 03:49 PM.

                          Comment


                            #14
                            Originally posted by gregid View Post
                            Can you already tell me which one is going to be used more likely for both Stroke and Pen: DashStyleHelper or DashStyle - I have plenty of properties like this and would like to make changes accordingly.
                            DashStyleHelper will be used as parameter for all methods and objects.

                            For your last question, Plot class is inherited from Stroke, so you can directly access any of the stroke properties from the Plots[arrayIdx]

                            I believe the below solves your problem(?)

                            Code:
                            AddPlot(new Stroke(Brushes.Orange, DashStyleHelper.Dash, 2.0f), PlotStyle.Line, "MyPlot");
                            Plots[0].Brush = Brushes.Pink;
                            Plots[0].DashStyleHelper = DashStyleHelper.Dot;
                            MatthewNinjaTrader Product Management

                            Comment


                              #15
                              Originally posted by NinjaTrader_Matthew View Post
                              DashStyleHelper will be used as parameter for all methods and objects.

                              For your last question, Plot class is inherited from Stroke, so you can directly access any of the stroke properties from the Plots[arrayIdx]

                              I believe the below solves your problem(?)

                              Code:
                              AddPlot(new Stroke(Brushes.Orange, DashStyleHelper.Dash, 2.0f), PlotStyle.Line, "MyPlot");
                              Plots[0].Brush = Brushes.Pink;
                              Plots[0].DashStyleHelper = DashStyleHelper.Dot;
                              Surprisingly it does - my problem was due to Plot.Pen being read only and the confusion associated with it. Changing Plot properties directly makes more sense than adding Stroke then editing Pen

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by FrazMann, Today, 11:21 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post FrazMann  
                              Started by geddyisodin, Yesterday, 05:20 AM
                              8 responses
                              52 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              10 responses
                              37 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by DayTradingDEMON, Today, 09:28 AM
                              4 responses
                              24 views
                              0 likes
                              Last Post DayTradingDEMON  
                              Started by George21, Today, 10:07 AM
                              1 response
                              21 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Working...
                              X