Inheritance: MonoBehaviour
コード例 #1
0
ファイル: X.cs プロジェクト: bjornebjornson/LottoEf4
 public static int eval(this Game o, Draw d, GameType gt, PrizeCategory pc)
 {
     if(gt == GameType.Undefined || pc == PrizeCategory.Undefined)
         return 0;
     o.notNull(); d.notNull();
     return o.Playslips.Sum(playslip => eval((Playslip)playslip, d, gt, pc));
 }
コード例 #2
0
    IEnumerator DrawTimer(byte id, Draw canvas)
    {
        float time = drawTime;

        while (time > 0f)
        {
            time -= Time.deltaTime;
            countDownText.text = ((int)time).ToString();
            yield return null;

            if (Input.GetKeyDown(KeyCode.Space))
                break;
        }

        countDownText.text = "";
        activeGUI = true;

        switch (id)
        {
            case 0:
                faceStore.LiegeFace = canvas.EndDraw(); break;
            case 1:
                faceStore.BlueVassalFace = canvas.EndDraw(); break;
            case 2:
                faceStore.RedVassalFace = canvas.EndDraw(); break;
        }
        Destroy(canvas.gameObject);

        transfer.Transfer();
    }
コード例 #3
0
ファイル: YuvPacked.cs プロジェクト: imintsystems/Kean
		public override float Distance(Draw.Image other)
		{
			float result = 0;
			if (other.IsNull())
				result = float.MaxValue;
			else if (!(other is YuvPacked))
				using (YuvPacked o = other.Convert<YuvPacked>())
					result = this.Distance(o);
			else if (this.Size != other.Size)
				using (YuvPacked o = other.ResizeTo(this.Size) as YuvPacked)
					result = this.Distance(o);
			else
			{
				for (int y = 0; y < this.Size.Height; y++)
					for (int x = 0; x < this.Size.Width; x++)
					{
						Color.Yuv c = this[x, y];
						Color.Yuv o = (other as YuvPacked)[x, y];
						if (c.Distance(o) > 0)
						{
							Color.Yuv maximum = o;
							Color.Yuv minimum = o;
							for (int otherY = Integer.Maximum(0, y - this.DistanceRadius); otherY < Integer.Minimum(y + 1 + this.DistanceRadius, this.Size.Height); otherY++)
								for (int otherX = Integer.Maximum(0, x - this.DistanceRadius); otherX < Integer.Minimum(x + 1 + this.DistanceRadius, this.Size.Width); otherX++)
									if (otherX != x || otherY != y)
									{
										Color.Yuv pixel = (other as YuvPacked)[otherX, otherY];
										if (maximum.Y < pixel.Y)
											maximum.Y = pixel.Y;
										else if (minimum.Y > pixel.Y)
											minimum.Y = pixel.Y;
										if (maximum.U < pixel.U)
											maximum.U = pixel.U;
										else if (minimum.U > pixel.U)
											minimum.U = pixel.U;
										if (maximum.V < pixel.V)
											maximum.V = pixel.V;
										else if (minimum.V > pixel.V)
											minimum.V = pixel.V;
									}
							float distance = 0;
							if (c.Y < minimum.Y)
								distance += Single.Squared(minimum.Y - c.Y);
							else if (c.Y > maximum.Y)
								distance += Single.Squared(c.Y - maximum.Y);
							if (c.U < minimum.U)
								distance += Single.Squared(minimum.U - c.U);
							else if (c.U > maximum.U)
								distance += Single.Squared(c.U - maximum.U);
							if (c.V < minimum.V)
								distance += Single.Squared(minimum.V - c.V);
							else if (c.V > maximum.V)
								distance += Single.Squared(c.V - maximum.V);
							result += Single.SquareRoot(distance) / 3;
						}
					}
				result /= this.Size.Length;
			}
			return result;
		}
コード例 #4
0
        public Intersect()
        {
            InitializeComponent();

            MyMap.Layers.LayersInitialized += Layers_LayersInitialized;

            MyMap.MinimumResolution = double.Epsilon;

            MyDrawObject = new Draw(MyMap)
            {
                DrawMode = DrawMode.Polygon,
                IsEnabled = false,
                FillSymbol = LayoutRoot.Resources["CyanFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol
            };
            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;

            parcelGraphicsLayer = MyMap.Layers["ParcelsGraphicsLayer"] as GraphicsLayer;
            intersectGraphicsLayer = MyMap.Layers["IntersectGraphicsLayer"] as GraphicsLayer;

            geometryService =
              new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

            geometryService.SimplifyCompleted += GeometryService_SimplifyCompleted;
            geometryService.IntersectCompleted += GeometryService_IntersectCompleted;
            geometryService.Failed += GeometryService_Failed;

            random = new Random();
        }
コード例 #5
0
ファイル: Image.cs プロジェクト: imintsystems/Kean
		public Image(Map map, Draw.Image image, Geometry2D.Single.Box source, Geometry2D.Single.Box destination)
		{
			this.Map = map;
			this.Data = image;
			this.Source = source;
			this.Destination = destination;
		}
コード例 #6
0
        public AreasAndLengths()
        {
            InitializeComponent();

            ESRI.ArcGIS.Client.Geometry.Envelope initialExtent =
                    new ESRI.ArcGIS.Client.Geometry.Envelope(
                mercator.FromGeographic(
                    new ESRI.ArcGIS.Client.Geometry.MapPoint(-130, 20)) as MapPoint,
                mercator.FromGeographic(
                    new ESRI.ArcGIS.Client.Geometry.MapPoint(-65, 55)) as MapPoint);

            initialExtent.SpatialReference = new SpatialReference(102100);

            MyMap.Extent = initialExtent;

            MyDrawObject = new Draw(MyMap)
            {
                DrawMode = DrawMode.Polygon,
                IsEnabled = true,
                FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol
            };
            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
            MyDrawObject.DrawBegin += MyDrawObject_DrawBegin;

            calculationTypeCombo.ItemsSource = Enum.GetValues(typeof(CalculationType));
            calculationTypeCombo.SelectedIndex = 0;
        }
コード例 #7
0
        private IEnumerable<List<int>> GetSets(Draw draw, int s)
        {
            List<int> balls = draw.BallSorted;

            for (int a = 0; a < 6; a++)
            {
                for (int b = a+1; b < 6; b++)
                {
                    for (int c = b+1; c < 6; c++)
                    {
                        for (int d = c+1; d < 6; d++)
                        {
                            for (int e = d+1; e < 6; e++)
                            {
                                for (int f = e+1; f < 6; f++)
                                {
                                    if (s == 6)
                                        yield return new List<int>() { balls[a], balls[b], balls[c], balls[d], balls[e], balls[f] };
                                }
                                if (s == 5)
                                    yield return new List<int>() { balls[a], balls[b], balls[c], balls[d], balls[e] };
                            }
                            if (s == 4)
                                yield return new List<int>() { balls[a], balls[b], balls[c], balls[d] };
                        }
                        if (s == 3)
                            yield return new List<int>() { balls[a], balls[b], balls[c] };
                    }
                    if (s == 2)
                        yield return new List<int>() { balls[a], balls[b] };
                }
                if (s == 1)
                    yield return new List<int>() { balls[a] };
            }
        }
コード例 #8
0
ファイル: MainPage.xaml.cs プロジェクト: csergent45/Hybrid
        public MainPage()
        {
            InitializeComponent();

            activateIdentify = true;

            MyDrawObject = new Draw(myMap)
            {
                FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol,
                DrawMode = DrawMode.Rectangle

            };

            MyDrawObject.DrawComplete += myDrawObject_DrawComplete;
            MyDrawObject.IsEnabled = false;
            _toolMode = "";
            _previousExtentImage = btnPrevExtent.Content as Image;
            _nextExtentImage = btnNextExtent.Content as Image;

            // Initializes the graphics layer
            graphicsLayer = myMap.Layers["myGraphicsLayer"] as GraphicsLayer;

            myMeasureObject = new Draw(myMap)
            {
                // Sets the initial drawing of the line and polygon
                FillSymbol = LayoutRoot.Resources["RedFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol,
                LineSymbol = LayoutRoot.Resources["RedLineSymbol"] as ESRI.ArcGIS.Client.Symbols.CartographicLineSymbol
            };

            // Runs the measure draw complete method
            myMeasureObject.DrawComplete += myMeasureObject_DrawComplete;
            // Disables the measure drawing once a graphic is drawn - in other words, I don't want to draw multiple graphics
            myMeasureObject.IsEnabled = false;
        }
コード例 #9
0
        public AreaAndLengths()
        {
            InitializeComponent();
            ESRI.ArcGIS.Client.Geometry.Envelope initialExtent =
                new ESRI.ArcGIS.Client.Geometry.Envelope(
            ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(
                new ESRI.ArcGIS.Client.Geometry.MapPoint(-130, 20)),
            ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(
                new ESRI.ArcGIS.Client.Geometry.MapPoint(-65, 55)));

            initialExtent.SpatialReference = new SpatialReference(102100);

            MyMap.Extent = initialExtent;

            MyDrawObject = new Draw(MyMap)
            {
                DrawMode = DrawMode.Polygon,
                IsEnabled = false,
                FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol
            };
            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
            MyDrawObject.DrawBegin += MyDrawObject_DrawBegin;

            List<CalculationType> enumVals = new List<CalculationType>();
            foreach (var val in typeof(CalculationType).GetFields())
            {
                if (val.IsLiteral)
                    enumVals.Add((CalculationType)val.GetValue(typeof(CalculationType)));
            }
            CalcTypeListBox.ItemsSource = enumVals;
            CalcTypeListBox.SelectedIndex = 0;
        }
コード例 #10
0
 public FiledPlayslipDto(Playslip playslip, Draw draw)
 {
     playslip.notNull();
     RefId = playslip.RefId;
     IsInvalidOrEmpty = playslip.invalid() || !playslip.valid();
     IsWin = playslip.valid() && null != draw && playslip.win(draw);
 }
コード例 #11
0
ファイル: IcnRecode.cs プロジェクト: gabrielgio/Vivacity
 public IcnRecode(Project project, double width, double heigth, Draw draw)
 {
     DrawLine = draw;
     _width = width;
     _heigth = heigth;
     _project = project;
 }
コード例 #12
0
        public DriveTimes()
        {
            InitializeComponent();

            graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            bufferSymbols = new List<FillSymbol>(
                    new FillSymbol[] { LayoutRoot.Resources["FillSymbol1"] as FillSymbol,
                        LayoutRoot.Resources["FillSymbol2"] as FillSymbol,
                        LayoutRoot.Resources["FillSymbol3"] as FillSymbol });

            _geoprocessorTask = new Geoprocessor("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/GPServer/Generate%20Service%20Areas");
            _geoprocessorTask.JobCompleted += GeoprocessorTask_JobCompleted;
            _geoprocessorTask.StatusUpdated += GeoprocessorTask_StatusUpdated;
            _geoprocessorTask.GetResultDataCompleted += GeoprocessorTask_GetResultDataCompleted;
            _geoprocessorTask.Failed += GeoprocessorTask_Failed;

            MyDrawObject = new Draw(MyMap)
            {
                IsEnabled = true,
                DrawMode = DrawMode.Point
            };

            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
        }
コード例 #13
0
ファイル: BankDemo.cs プロジェクト: aloneplayer/BenProjects
        //普通实现方法
        public static void Demo2()
        {
            IService s1 = new Saving();
            IService s2 = new Draw();
            IService s3 = new Fund();

            //要办理业务的三个客户队列
            List<IService> list = new List<IService>();
            list.Add(s1);
            list.Add(s2);
            list.Add(s3);

            foreach (IService item in list)
            {
                if (item is Saving)
                {
                    Console.WriteLine("存款");

                }
                else if (item is Draw)
                {
                    Console.WriteLine("取款");
                }
                else if (item is Fund)
                {
                    Console.WriteLine("基金");
                }
            }
        }
コード例 #14
0
ファイル: X.cs プロジェクト: bjornebjornson/LottoEf4
 public static int eval(this Board o, Draw d, PrizeCategory pc)
 {
     if(pc == PrizeCategory.Undefined)
         return 0;
     o.notNull();
     d.notNull();
     var intersect = o.AsArray.Intersect(d.Lotto).Count();
     return EvalUtil.hits(intersect, o.AsArray.Contains(d.Zz), o.Playslip.Sz == d.Sz, pc, o.Combo);
 }
コード例 #15
0
ファイル: DrawDto.cs プロジェクト: bjornebjornson/LottoEf4
 public DrawDto(Draw draw)
 {
     draw.notNull();
     Super6 = draw.S6String;
     Spiel77 = draw.S77String;
     Lotto = draw.LString;
     Superzahl = draw.Sz.ToString();
     Zusatzzahl = draw.Zz.ToString();
 }
コード例 #16
0
 public EvaluationDto(Game game, Draw draw)
 {
     this.game = game.notNull();
     this.draw = draw.notNull();
     IsWin = game.win(draw);
     IsWin_L649 = game.Playslips.Any(x => x.win(draw, GameType.Lotto649));
     IsWin_S77 = game.Playslips.Any(x => x.win(draw, GameType.Spiel77));
     IsWin_S6 = game.Playslips.Any(x => x.win(draw, GameType.Super6));
 }
コード例 #17
0
ファイル: BoardDto.cs プロジェクト: bjornebjornson/LottoEf4
 public BoardDto(Board board, Draw draw)
 {
     board.notNull();
     Combo = board.Combo;
     IsInvalid = board.invalid();
     Position = board.Position.ToString();
     Numbers = new List<byte>(board.AsArray);
     IsWin = board.valid() && null != draw && board.win(draw);
 }
コード例 #18
0
 public TemplateDto(Playslip playslip, Draw draw)
 {
     playslip.notNull();
     IsInvalid = playslip.invalid();
     RefId = playslip.RefId;
     Nr = playslip.Nr.AsString;
     HasSpiel77 = playslip.IsS77;
     HasSuper6 = playslip.IsS6;
     Boards = new List<BoardDto>(playslip.Select(board => new BoardDto(board, draw)));
 }
コード例 #19
0
        public BufferPoint()
        {
            InitializeComponent();
            myDrawObject = new Draw(MyMap)
            {
                DrawMode = DrawMode.Point,
                IsEnabled = false
            };

            myDrawObject.DrawComplete += myDrawObject_DrawComplete;
        }
コード例 #20
0
        public Routing()
        {
            InitializeComponent();
            MyDrawObject = new Draw(MyMap)
            {
                IsEnabled = true,
                DrawMode = DrawMode.Point
            };

            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
        }
コード例 #21
0
ファイル: BankDemo.cs プロジェクト: aloneplayer/BenProjects
        public static void Demo(String[] args)
        {
            IService s1 = new Saving();
            IService s2 = new Draw();
            IService s3 = new Fund();

            Visitor visitor = new Visitor();

            s1.Accept(visitor);
            s2.Accept(visitor);
            s3.Accept(visitor);
        }
コード例 #22
0
        public MessageInABottle()
        {
            InitializeComponent();

            MyDrawObject = new Draw(MyMap)
            {
                IsEnabled = false,
                DrawMode = DrawMode.Point
            };

            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
        }
コード例 #23
0
 public Densify()
 {
     InitializeComponent();
     MyDrawObject = new Draw(MyMap)
         {
             DrawMode = DrawMode.Polygon,
             IsEnabled = true,
             FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol
         };
     MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
     MyDrawObject.DrawBegin += MyDrawObject_DrawBegin;
 }
コード例 #24
0
        public DrawGraphics()
        {
            InitializeComponent();

            MyDrawObject = new Draw(MyMap)
            {
                LineSymbol = LayoutRoot.Resources["DrawLineSymbol"] as LineSymbol,
                FillSymbol = LayoutRoot.Resources["DrawFillSymbol"] as FillSymbol
            };

            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
        }
コード例 #25
0
ファイル: CreateNewDrawing.cs プロジェクト: Rirols/Draw
    void Start()
    {
        _events = GetComponent<Events>();
        _draw = GetComponent<Draw>();
        _createNewTexture = GetComponent<CreateNewTexture>();
        _childrenContainer = GetComponent<ChildrenContainer>();
        _clones = GameObject.FindGameObjectWithTag("GameManager").GetComponent<Clones>();

        _rect = new Rect(0, 0, Screen.width, (int)(Screen.height * transform.localScale.y / (Camera.main.orthographicSize * 2)));

        _events.MouseUp += MouseUp;
    }
コード例 #26
0
 public Lengths()
 {
     InitializeComponent();
     MyDrawObject = new Draw(MyMap)
     {
         DrawMode = DrawMode.Polyline,
         LineSymbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.LineSymbol,
         IsEnabled = false
     };
     MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
     MyDrawObject.DrawBegin += MyDrawObject_DrawBegin;
 }
コード例 #27
0
        public Identify()
        {
            InitializeComponent();

            MyDrawObject = new Draw(MyMap)
            {
                IsEnabled = false,
                DrawMode = DrawMode.Point
            };

            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;
            MyMap.Layers.LayersInitialized += Layers_LayersInitialized;
        }
コード例 #28
0
        public SpatialQuery()
        {
            InitializeComponent();

            selectionGraphicsLayer = MyMap.Layers["MySelectionGraphicsLayer"] as GraphicsLayer;

            MyDrawObject = new Draw(MyMap)
            {
                LineSymbol = LayoutRoot.Resources["DefaultLineSymbol"] as SimpleLineSymbol,
                FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as FillSymbol
            };
            MyDrawObject.DrawComplete += MyDrawSurface_DrawComplete;
        }
コード例 #29
0
        public QueryImageService()
        {
            InitializeComponent();

            myDrawObject = new Draw(MyMap)
            {
                DrawMode = DrawMode.Rectangle,
                FillSymbol = LayoutRoot.Resources["DrawFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol,
                IsEnabled = true
            };

            myDrawObject.DrawComplete += MyDrawObject_DrawComplete;
            footprintsGraphicsLayer = MyMap.Layers["FootprintsGraphicsLayer"] as GraphicsLayer;
        }
コード例 #30
0
        public ConvexHull()
        {
            InitializeComponent();

            MyDrawObject = new Draw(MyMap)
            {
                DrawMode = DrawMode.Point,
                IsEnabled = false
            };
            MyDrawObject.DrawComplete += MyDrawObject_DrawComplete;

            outputGraphicsLayer = MyMap.Layers["ConvexHullGraphicsLayer"] as GraphicsLayer;
            inputGraphicsLayer = MyMap.Layers["InputGraphicsLayer"] as GraphicsLayer;
        }
コード例 #31
0
ファイル: Canvas.cs プロジェクト: McoreD/ShareX
 protected void OnDraw(Graphics g)
 {
     Draw?.Invoke(g);
 }
コード例 #32
0
 /// <summary>Clears this clock's date based on the last rendered date.</summary>
 private void ClearDate()
 {
     Draw.Row(BG, RenderedDate.Length, LeftPos, TopPos + ClockFont.Height + 2);
 }
コード例 #33
0
        private void FlatUIPaint(PaintEventArgs e)
        {
            B            = new Bitmap(Width, Height);
            G            = Graphics.FromImage(B);
            flatUIWidth  = Width - 1;
            flatUIHeight = Height - 1;

            GraphicsPath GP   = new GraphicsPath();
            Rectangle    Base = new Rectangle(0, 0, flatUIWidth, flatUIHeight);


            //G.SmoothingMode = SmoothingMode.HighQuality;
            //G.PixelOffsetMode = PixelOffsetMode.HighQuality;
            //G.TextRenderingHint = TextRendering;
            G.Clear(Parent.BackColor);


            StringFormat CenterSF = new StringFormat
            {
                Alignment     = StringAlignment.Center,
                LineAlignment = StringAlignment.Center
            };

            switch (State)
            {
            case MouseState.None:
                if (FlatUIRounded)
                {
                    //-- Base
                    GP = Draw.RoundRec(Base, 6);
                    G.FillPath(new SolidBrush(_BaseColor), GP);

                    //-- Text
                    //G.DrawString(Text, Font, new SolidBrush(ForeColor), Base, CenterSF);
                }
                else
                {
                    //-- Base
                    G.FillRectangle(new SolidBrush(_BaseColor), Base);

                    //-- Text
                    //G.DrawString(Text, Font, new SolidBrush(ForeColor), Base, CenterSF);
                }
                break;

            case MouseState.Over:
                if (FlatUIRounded)
                {
                    //-- Base
                    GP = Draw.RoundRec(Base, 6);
                    G.FillPath(new SolidBrush(_BaseColor), GP);
                    G.FillPath(new SolidBrush(Color.FromArgb(20, Color.White)), GP);

                    //-- Text
                    //G.DrawString(Text, Font, new SolidBrush(ForeColor), Base, CenterSF);
                }
                else
                {
                    //-- Base
                    G.FillRectangle(new SolidBrush(_BaseColor), Base);
                    G.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.White)), Base);

                    //-- Text
                    //G.DrawString(Text, Font, new SolidBrush(ForeColor), Base, CenterSF);
                }
                break;

            case MouseState.Down:
                if (FlatUIRounded)
                {
                    //-- Base
                    GP = Draw.RoundRec(Base, 6);
                    G.FillPath(new SolidBrush(_BaseColor), GP);
                    G.FillPath(new SolidBrush(Color.FromArgb(20, Color.Black)), GP);

                    //-- Text
                    //G.DrawString(Text, Font, new SolidBrush(ForeColor), Base, CenterSF);
                }
                else
                {
                    //-- Base
                    G.FillRectangle(new SolidBrush(_BaseColor), Base);
                    G.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.Black)), Base);

                    //-- Text
                    //G.DrawString(Text, Font, new SolidBrush(ForeColor), Base, CenterSF);
                }
                break;
            }


            e.Graphics.InterpolationMode = (InterpolationMode)7;
            e.Graphics.DrawImageUnscaled(B, 0, 0);
            //B.Dispose();
            //G.Dispose();
        }
コード例 #34
0
        private static TopoInfo GetRoomEx()
        {
            roomCount++;

            int              pCout = 0;
            List <Point3d>   ps    = new List <Point3d>();
            List <PointInfo> pis   = new List <PointInfo>();
            double           pMinX = double.MaxValue;
            double           pMinY = double.MaxValue;
            double           pMaxX = double.MinValue;
            double           pMaxY = double.MinValue;

            int     ibegin    = 0;
            Point3d lineBegin = new Point3d();

            while (true)
            {
                pCout++;
                var p1 = Interaction.GetPoint("房间坐标" + pCout);
                if (double.IsNaN(p1.X))
                {
                    if (pis.Count >= 2)
                    {
                        break; //出口
                    }
                    else
                    {
                        continue;
                    }
                }
                ps.Add(p1);
                PointInfo pi1 = GetPointInfo(p1);

                if (ibegin == 0)
                {
                    lineBegin = p1;
                    ibegin    = 1;
                }
                else
                {
                    var leftLine = Draw.Line(lineBegin, p1);
                    lineBegin = p1;
                    // leftLine.SetLayer("aaa");

                    leftLine.QOpenForWrite <Entity>(line => line.ColorIndex = 3);
                    var arrow = Modify.Group(new[] { leftLine });
                }

                pis.Add(pi1);

                if (p1.X < pMinX)
                {
                    pMinX = p1.X;
                }
                if (p1.Y < pMinY)
                {
                    pMinY = p1.Y;
                }

                if (p1.Y > pMaxY)
                {
                    pMaxY = p1.Y;
                }
                if (p1.X > pMaxX)
                {
                    pMaxX = p1.X;
                }
            }

            Point3d pMin = Point3d.Origin;
            Point3d pMax = Point3d.Origin;

            if (pis.Count == 2)
            {
                pMin = ps[0];
                pMax = ps[1];
            }
            else
            {
                pMin = new Point3d(pMinX, pMinY, 0);
                pMax = new Point3d(pMaxX, pMaxY, 0);
            }

            string room = GetText(pMin, pMax);

            if (string.IsNullOrEmpty(room))
            {
                room = Interaction.GetString("输入房间名称");
                if (string.IsNullOrEmpty(room))
                {
                    room = "房间_" + roomCount;
                }
            }

            TopoInfo topoInfo = GetTopoInfo(room, AreaTypes.机房, pis);

            Interaction.WriteLine(string.Format("{0} {1} {2}", pis.First(), pis.Last(), room));
            Interaction.WriteLine("");

            //string xml = XmlSerializeHelper.GetXmlText(topoInfo);
            //Gui.TextReport("房间:" + txt, xml, 700, 500);

            return(topoInfo);
        }
コード例 #35
0
 public override void Render()
 {
     this.DrawCogs(Vector2.UnitY, new Color?(Color.Black));
     this.DrawCogs(Vector2.Zero, null);
     Draw.Rect(new Rectangle((int)(this.ZipMover.X - 1f), (int)(this.ZipMover.Y - 1f), (int)this.ZipMover.Width + 2, (int)this.ZipMover.Height + 2), Color.Black);
 }
コード例 #36
0
ファイル: Test.cs プロジェクト: evstmax/CopyCtrl
        public void TestWipe()
        {
            var id = Interaction.GetEntity("\nEntity");

            Draw.Wipeout(id);
        }
コード例 #37
0
    override public void OnInspectorGUI()
    {
        Draw script = (Draw)target;

        GUILayout.Space(5);

        GUILayout.Label("Draw Method", EditorStyles.boldLabel);

        script.drawStyle = (Draw.DrawStyle)EditorGUILayout.EnumPopup("Draw Style", script.drawStyle);

        // Style Specific Options
        switch (script.drawStyle)
        {
        case Draw.DrawStyle.Continuous:
            script.samplingRate = EditorGUILayout.FloatField("Sample Rate", script.samplingRate);
            break;

        case Draw.DrawStyle.ContinuousClosingDistance:
            script.samplingRate    = EditorGUILayout.FloatField("Sample Rate", script.samplingRate);
            script.closingDistance = EditorGUILayout.FloatField("Closing Distance", script.closingDistance);
            break;

        case Draw.DrawStyle.PointMaxVertex:
            script.maxVertices = EditorGUILayout.IntField("Max Allowed Vertices", script.maxVertices);
            break;

        case Draw.DrawStyle.PointClosingDistance:
            script.closingDistance = EditorGUILayout.FloatField("Closing Distance", script.closingDistance);
            break;
        }

        script.inputCamera = (Camera)EditorGUILayout.ObjectField(new GUIContent("Input Camera", "The camera that listens for mouse input.  Must be orthographic."), script.inputCamera, typeof(Camera), true);

        GUILayout.Space(5);

        showDrawSettings = EditorGUILayout.Foldout(showDrawSettings, "Drawing Settings");
        if (showDrawSettings)
        {
            script.showPointMarkers = EditorGUILayout.BeginToggleGroup("Show Vertex Markers", script.showPointMarkers);
            script.pointMarker      = (GameObject)EditorGUILayout.ObjectField("Point Marker", script.pointMarker, typeof(GameObject), true);
            EditorGUILayout.EndToggleGroup();

            script.drawMeshInProgress = EditorGUILayout.Toggle("Draw Preview Mesh", script.drawMeshInProgress);

            script.drawLineRenderer = EditorGUILayout.BeginToggleGroup("Draw Line Renderer", script.drawLineRenderer);
            script.lineRenderer     = (LineRenderer)EditorGUILayout.ObjectField(new GUIContent("Trail Renderer", "If left null, a default trail renderer will be applied automatically."), script.lineRenderer, typeof(LineRenderer), true);
            if (script.lineRenderer == null)
            {
                script.lineWidth = EditorGUILayout.FloatField("Trail Renderer Width", script.lineWidth);
            }
            EditorGUILayout.EndToggleGroup();

            script.drawSettings.requireMinimumArea = EditorGUILayout.BeginToggleGroup(new GUIContent("Require Minimum Area to Draw Object", "If true, the drawn polygon must have an area greater than this value in order to be generated.  Perfect for use with Drawing Style Continuous."), script.drawSettings.requireMinimumArea);
            script.drawSettings.minimumAreaToDraw  = EditorGUILayout.FloatField("Minimum Area", script.drawSettings.minimumAreaToDraw);
            EditorGUILayout.EndToggleGroup();

            script.useDistanceCheck = EditorGUILayout.BeginToggleGroup(new GUIContent("Use Distance Check", "If final user set point is greater than `x` distance from origin point, polygon will not be drawn"), script.useDistanceCheck);
            script.maxDistance      = EditorGUILayout.FloatField("Max Distance from Origin", script.maxDistance);
            EditorGUILayout.EndToggleGroup();
        }

        showMeshSettings = EditorGUILayout.Foldout(showMeshSettings, "Mesh Settings");
        if (showMeshSettings)
        {
            script.drawSettings.meshName = EditorGUILayout.TextField("Mesh Name", script.drawSettings.meshName);

            script.drawSettings.frontMaterial = (Material)EditorGUILayout.ObjectField("Material", script.drawSettings.frontMaterial, typeof(Material), false);

            script.drawSettings.anchor = (Draw.Anchor)EditorGUILayout.EnumPopup("Mesh Anchor", script.drawSettings.anchor);

            script.drawSettings.zPosition = EditorGUILayout.FloatField("Z Origin", script.drawSettings.zPosition);

            script.drawSettings.faceOffset = EditorGUILayout.FloatField(new GUIContent("Z Offset", "Allows for custom offsets.  See docs for details."), script.drawSettings.faceOffset);

            script.drawSettings.generateSide = EditorGUILayout.BeginToggleGroup("Generate Sides", script.drawSettings.generateSide);

            script.drawSettings.sideLength   = EditorGUILayout.FloatField("Side Length", script.drawSettings.sideLength);
            script.drawSettings.sideMaterial = (Material)EditorGUILayout.ObjectField("Side Material", script.drawSettings.sideMaterial, typeof(Material), false);

            EditorGUILayout.EndToggleGroup();

            script.drawSettings.drawEdgePlanes = EditorGUILayout.BeginToggleGroup("Draw Edge Planes", script.drawSettings.drawEdgePlanes);

            script.drawSettings.edgeMaterial       = (Material)EditorGUILayout.ObjectField("Edge Material", script.drawSettings.edgeMaterial, typeof(Material), false);
            script.drawSettings.edgeLengthModifier = EditorGUILayout.FloatField(new GUIContent("Edge Length Modifier", "Multiply the length of the plane by this amount.  1 = no change, 1.3 = 33% longer."), script.drawSettings.edgeLengthModifier);
            script.drawSettings.edgeHeight         = EditorGUILayout.FloatField(new GUIContent("Edge Height", "Absolute value; how tall to make edge planes."), script.drawSettings.edgeHeight);
            script.drawSettings.minLengthToDraw    = EditorGUILayout.FloatField(new GUIContent("Minimum Edge Length", "Edges with a length less than this amount will not be drawn."), script.drawSettings.minLengthToDraw);
            script.drawSettings.edgeOffset         = EditorGUILayout.FloatField(new GUIContent("Edge Z Offset", "Value to scoot mesh + or - from Z Position."), script.drawSettings.edgeOffset);
            script.drawSettings.maxAngle           = EditorGUILayout.FloatField(new GUIContent("Maximum Slope", "Edge Z rotation must be less than this amount to be drawn.  Set to 180 to draw a complete loop, or leave at 45 to only draw up facing planes."), script.drawSettings.maxAngle);
            script.drawSettings.areaRelativeHeight = EditorGUILayout.Toggle(new GUIContent("Area Relative Height", "If true, the height of each plane will be modified by how large the finalized mesh is."), script.drawSettings.areaRelativeHeight);
            if (script.drawSettings.areaRelativeHeight)
            {
                script.drawSettings.minEdgeHeight = EditorGUILayout.FloatField("Minimum Edge Height", script.drawSettings.minEdgeHeight);
                script.drawSettings.maxEdgeHeight = EditorGUILayout.FloatField("Maximum Edge Height", script.drawSettings.maxEdgeHeight);
            }

            EditorGUILayout.EndToggleGroup();

            script.drawSettings.uvScale = EditorGUILayout.Vector2Field("UV Scale", script.drawSettings.uvScale);
        }

        showGameObjectSettings = EditorGUILayout.Foldout(showGameObjectSettings, "GameObject Settings");
        if (showGameObjectSettings)
        {
            script.drawSettings.useTag = EditorGUILayout.BeginToggleGroup(new GUIContent("Apply Tag", "Tag must exist prior to assignment."), script.drawSettings.useTag);
            script.drawSettings.tagVal = EditorGUILayout.TextField("Tag", script.drawSettings.tagVal);
            EditorGUILayout.EndToggleGroup();

            script.maxAllowedObjects = EditorGUILayout.IntField("Max Drawn Objects Allowed", script.maxAllowedObjects);
        }

        showCollisionSettings = EditorGUILayout.Foldout(showCollisionSettings, "Physics Settings");
        if (showCollisionSettings)
        {
            script.drawSettings.colliderType = (Draw.ColliderType)EditorGUILayout.EnumPopup(new GUIContent("Collison", "If set to mesh, a Mesh Collider will be applied.  If set to Box, a series of thin box colliders will be generated bordering the edges, allowing for concave interactions.  None means no collider will be applied."), script.drawSettings.colliderType);

            if (script.drawSettings.colliderType == Draw.ColliderType.BoxCollider)
            {
                if (!script.drawSettings.manualColliderDepth)
                {
                    script.drawSettings.colDepth = script.drawSettings.sideLength;
                }

                script.drawSettings.manualColliderDepth = EditorGUILayout.BeginToggleGroup(new GUIContent("Manual Collider Depth", "If false, the side length will be used as the depth value."), script.drawSettings.manualColliderDepth);

                script.drawSettings.colDepth = EditorGUILayout.FloatField("Collider Depth", script.drawSettings.colDepth);

                EditorGUILayout.EndToggleGroup();
            }

            switch (script.drawSettings.colliderType)
            {
            case Draw.ColliderType.BoxCollider:
                break;

            case Draw.ColliderType.MeshCollider:
                script.drawSettings.forceConvex = EditorGUILayout.Toggle("Force Convex", script.drawSettings.forceConvex);
                break;

            case Draw.ColliderType.None:
                break;
            }

            script.drawSettings.applyRigidbody = EditorGUILayout.BeginToggleGroup("Apply Rigidbody", script.drawSettings.applyRigidbody);

            script.drawSettings.useGravity = EditorGUILayout.Toggle("Use Gravity", script.drawSettings.useGravity);

            script.drawSettings.isKinematic = EditorGUILayout.Toggle("Is Kinematic", script.drawSettings.isKinematic);

            script.drawSettings.areaRelativeMass = EditorGUILayout.Toggle("Area Relative Mass", script.drawSettings.areaRelativeMass);
            if (script.drawSettings.areaRelativeMass)
            {
                script.drawSettings.massModifier = EditorGUILayout.FloatField("Mass Modifier", script.drawSettings.massModifier);
            }
            else
            {
                script.drawSettings.mass = EditorGUILayout.FloatField("Mass", script.drawSettings.mass);
            }
            EditorGUILayout.EndToggleGroup();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(script);
        }
    }
コード例 #38
0
ファイル: Test.cs プロジェクト: evstmax/CopyCtrl
        public void TestHatch3()
        {
            var seed = Interaction.GetPoint("\nPick one point");

            Draw.Hatch("SOLID", seed);
        }
コード例 #39
0
ファイル: Test.cs プロジェクト: evstmax/CopyCtrl
 public void TestBlock()
 {
     var bId = Draw.Block(QuickSelection.SelectAll(), "test");
     // TODO: complete this test.
 }
コード例 #40
0
ファイル: Test.cs プロジェクト: evstmax/CopyCtrl
        public void TestBoundary()
        {
            var point = Interaction.GetPoint("\nPick one point");

            Draw.Boundary(point, BoundaryType.Polyline);
        }
コード例 #41
0
        protected override void OnBarUpdate()
        {
            // Limit Historical processing in case a chart uses too many bars for calculation (I.E. EURUSD Renko charts)
            if (State == State.Historical && LimitHistory && CurrentBar < Bars.Count - LimitHistoricalLookback)
            {
                return;
            }

            //DETERMINE LOCATION OF LAST UP/DOWN TREND LINES
            signal[0]       = 0;
            trendStarted[0] = 0;
            int upTrendOccurence = 1; int upTrendStartBarsAgo = 0; int upTrendEndBarsAgo = 0;
            int downTrendOccurence = 1; int downTrendStartBarsAgo = 0; int downTrendEndBarsAgo = 0;

            // Only calculate new autotrend line if ray hasent been put into manual mode by unlocking current ray
            if (((DrawObjects["UpTrendRay" + unique] == null) || (DrawObjects["UpTrendRay" + unique].IsLocked)) && ((DrawObjects["DownTrendRay" + unique] == null) || (DrawObjects["DownTrendRay" + unique].IsLocked)))
            {
                //Only do the following if existing ray is in auto mode
                // Calculate up trend line
                upTrendOccurence = 1;
                while (Low[upTrendEndBarsAgo] <= Low[upTrendStartBarsAgo])
                {
                    upTrendStartBarsAgo = Swing(Strength).SwingLowBar(0, upTrendOccurence + 1, CurrentBar);
                    upTrendEndBarsAgo   = Swing(Strength).SwingLowBar(0, upTrendOccurence, CurrentBar);
                    if (upTrendStartBarsAgo < 0 || upTrendEndBarsAgo < 0)
                    {
                        break;
                    }
                    upTrendOccurence++;
                }
                // Calculate down trend line
                downTrendOccurence = 1;
                while (High[downTrendEndBarsAgo] >= High[downTrendStartBarsAgo])
                {
                    downTrendStartBarsAgo = Swing(Strength).SwingHighBar(0, downTrendOccurence + 1, CurrentBar);
                    downTrendEndBarsAgo   = Swing(Strength).SwingHighBar(0, downTrendOccurence, CurrentBar);
                    if (downTrendStartBarsAgo < 0 || downTrendEndBarsAgo < 0)
                    {
                        break;
                    }
                    downTrendOccurence++;
                }
            }

            // Clear out arrows that mark trend line breaks unless ShowHistory flag is true
            if (!ShowHistory)
            {
                RemoveDrawObject("DownTrendBreak" + unique);
            }
            if (!ShowHistory)
            {
                RemoveDrawObject("UpTrendBreak" + unique);
            }

            //PROCESS UPTREND LINE IF CURRENT
            if (upTrendStartBarsAgo > 0 && upTrendEndBarsAgo > 0 && upTrendStartBarsAgo < downTrendStartBarsAgo)
            {
                RemoveDrawObject("DownTrendRay" + unique);
                double startBarPrice = Low[upTrendStartBarsAgo];
                double endBarPrice   = Low[upTrendEndBarsAgo];
                changePerBar[0] = (endBarPrice - startBarPrice) / (Math.Abs(upTrendEndBarsAgo - upTrendStartBarsAgo));
                //Test to see if this is a new trendline and increment lineCounter if so.
                if (startBarPrice != startBarPriceOld)
                {
                    direction = 1;  //Signal that we have a new uptrend and put dot on trendline where new trend detected
                    if (ShowHistory)
                    {
                        Draw.Dot(this, CurrentBar.ToString(), true, 0, startBarPrice + (upTrendStartBarsAgo * changePerBar[0]), UpTrendColor);
                        trendStarted[0] = 1;
                    }
                    lineCount       = lineCount + 1;
                    triggerBarIndex = 0;
                    //ResetAlert("Alert");
                }
                startBarPriceOld = startBarPrice;
                //
                // Draw the up trend line
                // If user has unlocked the ray use manual rays position instead of auto generated positions to track ray position
                if ((DrawObjects["UpTrendRay" + unique] != null) && (!DrawObjects["UpTrendRay" + unique].IsLocked))
                {
                    Ray upTrendRay = (Ray)DrawObjects["UpTrendRay" + unique];
                    startBarPrice       = upTrendRay.StartAnchor.Price;
                    endBarPrice         = upTrendRay.EndAnchor.Price;
                    upTrendStartBarsAgo = upTrendRay.StartAnchor.BarsAgo;
                    upTrendEndBarsAgo   = upTrendRay.EndAnchor.BarsAgo;
                    changePerBar[0]     = (endBarPrice - startBarPrice) / (Math.Abs(upTrendRay.EndAnchor.BarsAgo - upTrendRay.StartAnchor.BarsAgo));
                }
                else
                {
                    Draw.Ray(this, "UpTrendRay" + unique, false, upTrendStartBarsAgo, startBarPrice, upTrendEndBarsAgo, endBarPrice, UpTrendColor, DashStyleHelper.Solid, lineWidth);
                }

                //Draw the history line that will stay persistent on chart using lineCounter to establish a unique name
                if (ShowHistory)
                {
                    Draw.Line(this, "HistoryLine" + unique + lineCount.ToString(), false, upTrendStartBarsAgo, startBarPrice, 0, startBarPrice + (upTrendStartBarsAgo * changePerBar[0]), UpHistColor, DashStyleHelper.Solid, lineWidth);
                }
                //SET RETURN VALUES FOR INDICATOR
                // Check for an uptrend line break
                trendPrice = (startBarPrice + (upTrendStartBarsAgo * changePerBar[0]));
                for (int barsAgo = upTrendEndBarsAgo - 1; barsAgo >= 0; barsAgo--)
                {
                    if (Close[barsAgo] < endBarPrice + (Math.Abs(upTrendEndBarsAgo - barsAgo) * changePerBar[0]))
                    {
                        if (ShowHistory)
                        {
                            Draw.ArrowDown(this, "UpTrendBreak" + unique + lineCount.ToString(), true, barsAgo, High[barsAgo] + TickSize, DownTrendColor);
                        }
                        else
                        {
                            Draw.ArrowDown(this, "UpTrendBreak" + unique, true, barsAgo, High[barsAgo] + TickSize, DownTrendColor);
                        }
                        // Set the break signal only if the break is on the right most bar
                        //if (barsAgo == 0)
                        signal[barsAgo] = -1;
                        // Alert will only trigger in real-time
                        if (AlertOnBreak && triggerBarIndex == 0)
                        {
                            triggerBarIndex = CurrentBar - upTrendEndBarsAgo;
                            Alert("Alert" + unique, Priority.High, "Up trend line broken", "Alert2.wav", 100000, Brushes.Black, Brushes.Red);
                        }
                        break;
                    }
                }
            }

            else
            //DETECT AND PROCESS DOWNTREND LINE	IF CURRENT
            if (downTrendStartBarsAgo > 0 && downTrendEndBarsAgo > 0 && upTrendStartBarsAgo > downTrendStartBarsAgo)
            {
                RemoveDrawObject("UpTrendRay" + unique);
                double startBarPrice = High[downTrendStartBarsAgo];
                double endBarPrice   = High[downTrendEndBarsAgo];
                changePerBar[0] = (endBarPrice - startBarPrice) / (Math.Abs(downTrendEndBarsAgo - downTrendStartBarsAgo));
                //Test to see if this is a new trendline and increment lineCount if so.
                if (startBarPrice != startBarPriceOld)
                {
                    direction = -1;     //signl that we have a new downtrend
                    if (ShowHistory)
                    {
                        Draw.Dot(this, CurrentBar.ToString(), true, 0, startBarPrice + (downTrendStartBarsAgo * changePerBar[0]), DownTrendColor);
                        trendStarted[0] = -1;
                    }
                    lineCount       = lineCount + 1;
                    triggerBarIndex = 0;
                }
                startBarPriceOld = startBarPrice;
                //
                // Draw the down trend line
                // If user has unlocked the ray use manual rays position instead
                if ((DrawObjects["DownTrendRay" + unique] != null) && (!DrawObjects["DownTrendRay" + unique].IsLocked))
                {
                    Ray downTrendRay = (Ray)DrawObjects["DownTrendRay" + unique];
                    startBarPrice         = downTrendRay.StartAnchor.Price;
                    endBarPrice           = downTrendRay.EndAnchor.Price;
                    downTrendStartBarsAgo = downTrendRay.StartAnchor.BarsAgo;
                    downTrendEndBarsAgo   = downTrendRay.EndAnchor.BarsAgo;
                    changePerBar[0]       = (endBarPrice - startBarPrice) / (Math.Abs(downTrendRay.EndAnchor.BarsAgo - downTrendRay.StartAnchor.BarsAgo));
                }
                else
                {
                    Draw.Ray(this, "DownTrendRay" + unique, false, downTrendStartBarsAgo, startBarPrice, downTrendEndBarsAgo, endBarPrice, DownTrendColor, DashStyleHelper.Solid, lineWidth);
                }
                if (ShowHistory)
                {
                    Draw.Line(this, "HistoryLine" + unique + lineCount.ToString(), false, downTrendStartBarsAgo, startBarPrice, 0, startBarPrice + (downTrendStartBarsAgo * changePerBar[0]), DownHistColor, DashStyleHelper.Solid, lineWidth);
                }
                //SET RETURN VALUES FOR INDICATOR
                // Check for a down trend line break
                trendPrice = (startBarPrice + (downTrendStartBarsAgo * changePerBar[0]));
                for (int barsAgo = downTrendEndBarsAgo - 1; barsAgo >= 0; barsAgo--)
                {
                    //	direction=-1;
                    if (Close[barsAgo] > endBarPrice + (Math.Abs(downTrendEndBarsAgo - barsAgo) * changePerBar[0]))
                    {
                        if (ShowHistory)
                        {
                            Draw.ArrowUp(this, "DownTrendBreak" + unique + lineCount.ToString(), true, barsAgo, Low[barsAgo] - TickSize, UpTrendColor);
                        }
                        else
                        {
                            Draw.ArrowUp(this, "DownTrendBreak" + unique, true, barsAgo, Low[barsAgo] - TickSize, UpTrendColor);
                        }
                        // Set the break signal only if the break is on the right most bar
                        //if (barsAgo == 0)
                        signal[barsAgo] = 1;
                        // Alert will only trigger in real-time
                        if (AlertOnBreak && triggerBarIndex == 0)
                        {
                            triggerBarIndex = CurrentBar - downTrendEndBarsAgo;
                            Alert("Alert" + unique, Priority.High, "Down trend line broken", "Alert2.wav", 100000, Brushes.Black, Brushes.Green);
                        }
                        break;
                    }
                }
            }
        }
コード例 #42
0
        public void Start(int barsAgo, bool justCurrentCandleSignal)
        {
            if (starting)
            {
                low  = pb.Input[0];
                high = pb.Input[0];

                isFirstLowValue  = true;
                isFirstHighValue = true;

                currentLowTagNamePb  = "0";
                currentHighTagNamePb = "1";

                starting = false;
            }

            if (pb.IsFirstTickOfBar)
            {
                pb.RemoveDrawObject(@"Arrow down");
                pb.RemoveDrawObject(@"Arrow up");
                pb.RemoveDrawObject(@"Fall Dot");
                pb.RemoveDrawObject(@"Rise Dot");
            }

            //Calculation
            isFalling = pb.Close[barsAgo] < pb.Close[barsAgo + 1];
            isRising  = pb.Close[barsAgo] > pb.Close[barsAgo + 1];

            isOverLowPipDiff  = pb.Close[barsAgo] <= (high - (pb.PipDiff * (pb.TickSize * 10)));
            isOverHighPipDiff = pb.Close[barsAgo] >= (low + (pb.PipDiff * (pb.TickSize * 10)));

            // Add low
            if (isFirstLowValue && isFalling && isOverLowPipDiff)
            {
                low       = pb.Close[barsAgo];
                lastPrice = low;
                lastTop   = high;

                // Show fibo signals
                if (fiboCalc(high, lastBottom, lastPrice, -1) < pb.MaxFiboPercent &&
                    fiboCalc(high, lastBottom, lastPrice, -1) > pb.MinFiboPercent)
                {
                    pb.Value[barsAgo] = 1;
                    if (!justCurrentCandleSignal)
                    {
                        currentLowTagNamePb = @"Arrow up " + pb.Time[barsAgo].ToString();
                        Draw.ArrowUp(pb, currentLowTagNamePb, false, barsAgo, pb.Close[barsAgo] - (pipSpace * (pb.TickSize * 10)), pb.Arrow_DotUpColor);
                    }
                    else
                    {
                        Draw.ArrowUp(pb, @"Arrow up", false, barsAgo, pb.Close[barsAgo] - (pipSpace * (pb.TickSize * 10)), pb.Arrow_DotUpColor);
                    }
                }

                // Show zigzag points
                if (pb.ShowTopBottomPoints)
                {
                    if (!justCurrentCandleSignal)
                    {
                        currentLowTagNameZz = @"Fall Dot " + pb.Time[barsAgo].ToString();
                        Draw.Dot(pb, currentLowTagNameZz, false, barsAgo, pb.Close[barsAgo], pb.Arrow_DotDownColor);
                    }
                    else
                    {
                        Draw.Dot(pb, @"Fall Dot", false, barsAgo, pb.Close[barsAgo], pb.Arrow_DotDownColor);
                    }
                }

                isFirstLowValue  = false;
                isFirstHighValue = true;
                return;
            }
            // Add high
            else if (isFirstHighValue && isRising && isOverHighPipDiff)
            {
                high       = pb.Close[barsAgo];
                lastPrice  = high;
                lastBottom = low;

                // Show fibo signals
                if (fiboCalc(lastTop, low, lastPrice, 1) < pb.MaxFiboPercent &&
                    fiboCalc(lastTop, low, lastPrice, 1) > pb.MinFiboPercent)
                {
                    pb.Value[barsAgo] = -1;
                    if (!justCurrentCandleSignal)
                    {
                        currentHighTagNamePb = @"Arrow down " + pb.Time[barsAgo].ToString();
                        Draw.ArrowDown(pb, currentHighTagNamePb, false, barsAgo, pb.Close[barsAgo] + (pipSpace * (pb.TickSize * 10)), pb.Arrow_DotDownColor);
                    }
                    else
                    {
                        Draw.ArrowDown(pb, @"Arrow down", false, barsAgo, pb.Close[barsAgo] + (pipSpace * (pb.TickSize * 10)), pb.Arrow_DotDownColor);
                    }
                }

                // Show zigzag points
                if (pb.ShowTopBottomPoints)
                {
                    if (!justCurrentCandleSignal)
                    {
                        currentHighTagNameZz = @"Rise Dot " + pb.Time[barsAgo].ToString();
                        Draw.Dot(pb, currentHighTagNameZz, false, barsAgo, pb.Close[barsAgo], pb.Arrow_DotUpColor);
                    }
                    else
                    {
                        Draw.Dot(pb, @"Rise Dot", false, barsAgo, pb.Close[barsAgo], pb.Arrow_DotUpColor);
                    }
                }

                isFirstHighValue = false;
                isFirstLowValue  = true;
                return;
            }
            // Update low
            if (!isFirstLowValue && isFalling && isOverLowPipDiff && pb.Close[barsAgo] < lastPrice)
            {
                low       = pb.Close[barsAgo];
                lastPrice = low;

                // Show fibo signals
                if (fiboCalc(high, lastBottom, lastPrice, -1) < pb.MaxFiboPercent &&
                    fiboCalc(high, lastBottom, lastPrice, -1) > pb.MinFiboPercent)
                {
                    pb.Value[barsAgo] = 1;
                    if (!justCurrentCandleSignal)
                    {
                        Draw.ArrowUp(pb, currentLowTagNamePb, false, barsAgo, pb.Close[barsAgo] - (pipSpace * (pb.TickSize * 10)), pb.Arrow_DotUpColor);
                    }
                    else
                    {
                        Draw.ArrowUp(pb, @"Arrow up", false, barsAgo, pb.Close[barsAgo] - (pipSpace * (pb.TickSize * 10)), pb.Arrow_DotUpColor);
                    }
                }

                // Show zigzag points
                if (pb.ShowTopBottomPoints)
                {
                    if (!justCurrentCandleSignal)
                    {
                        Draw.Dot(pb, currentLowTagNameZz, false, barsAgo, pb.Close[barsAgo], pb.Arrow_DotDownColor);
                    }
                    else
                    {
                        Draw.Dot(pb, @"Fall Dot", false, barsAgo, pb.Close[barsAgo], pb.Arrow_DotDownColor);
                    }
                }
            }
            // Update high
            else if (!isFirstHighValue && isRising && isOverHighPipDiff && pb.Close[barsAgo] > lastPrice)
            {
                high      = pb.Close[barsAgo];
                lastPrice = high;

                // Show fibo signals
                if (fiboCalc(lastTop, low, lastPrice, 1) < pb.MaxFiboPercent &&
                    fiboCalc(lastTop, low, lastPrice, 1) > pb.MinFiboPercent)
                {
                    pb.Value[barsAgo] = -1;
                    if (!justCurrentCandleSignal)
                    {
                        Draw.ArrowDown(pb, currentHighTagNamePb, false, barsAgo, pb.Close[barsAgo] + (pipSpace * (pb.TickSize * 10)), pb.Arrow_DotDownColor);
                    }
                    else
                    {
                        Draw.ArrowDown(pb, @"Arrow down", false, barsAgo, pb.Close[barsAgo] + (pipSpace * (pb.TickSize * 10)), pb.Arrow_DotDownColor);
                    }
                }

                // Show zigzag points
                if (pb.ShowTopBottomPoints)
                {
                    if (!justCurrentCandleSignal)
                    {
                        Draw.Dot(pb, currentHighTagNameZz, false, barsAgo, pb.Close[barsAgo], pb.Arrow_DotUpColor);
                    }
                    else
                    {
                        Draw.Dot(pb, @"Rise Dot", false, barsAgo, pb.Close[barsAgo], pb.Arrow_DotUpColor);
                    }
                }
            }
        }
コード例 #43
0
ファイル: ZigZag.cs プロジェクト: Techbreakers/SATbot
        protected override void OnRender(Gui.Chart.ChartControl chartControl, Gui.Chart.ChartScale chartScale)
        {
            if (Bars == null || chartControl == null || startIndex == int.MinValue)
            {
                return;
            }

            IsValidDataPointAt(Bars.Count - 1 - (Calculate == NinjaTrader.NinjaScript.Calculate.OnBarClose ? 1 : 0));             // Make sure indicator is calculated until last (existing) bar
            int preDiff = 1;

            for (int i = ChartBars.FromIndex - 1; i >= 0; i--)
            {
                if (i - Displacement < startIndex || i - Displacement > Bars.Count - 1 - (Calculate == NinjaTrader.NinjaScript.Calculate.OnBarClose ? 1 : 0))
                {
                    break;
                }

                bool isHigh = zigZagHighZigZags.IsValidDataPointAt(i - Displacement);
                bool isLow  = zigZagLowZigZags.IsValidDataPointAt(i - Displacement);

                if (isHigh || isLow)
                {
                    break;
                }

                preDiff++;
            }

            preDiff -= (Displacement < 0 ? Displacement : 0 - Displacement);

            int postDiff = 0;

            for (int i = ChartBars.ToIndex; i <= zigZagHighZigZags.Count; i++)
            {
                if (i - Displacement < startIndex || i - Displacement > Bars.Count - 1 - (Calculate == NinjaTrader.NinjaScript.Calculate.OnBarClose ? 1 : 0))
                {
                    break;
                }

                bool isHigh = zigZagHighZigZags.IsValidDataPointAt(i - Displacement);
                bool isLow  = zigZagLowZigZags.IsValidDataPointAt(i - Displacement);

                if (isHigh || isLow)
                {
                    break;
                }

                postDiff++;
            }

            postDiff += (Displacement < 0 ? 0 - Displacement : Displacement);

            int    lastIdx   = -1;
            double lastValue = -1;

            SharpDX.Direct2D1.PathGeometry g    = null;
            SharpDX.Direct2D1.GeometrySink sink = null;

            for (int idx = ChartBars.FromIndex - preDiff; idx <= ChartBars.ToIndex + postDiff; idx++)
            {
                if (idx < startIndex || idx > Bars.Count - (Calculate == NinjaTrader.NinjaScript.Calculate.OnBarClose ? 2 : 1) || idx < Math.Max(BarsRequiredToPlot - Displacement, Displacement))
                {
                    continue;
                }

                bool isHigh = zigZagHighZigZags.IsValidDataPointAt(idx);
                bool isLow  = zigZagLowZigZags.IsValidDataPointAt(idx);

                if (!isHigh && !isLow)
                {
                    continue;
                }

                double value = isHigh ? zigZagHighZigZags.GetValueAt(idx) : zigZagLowZigZags.GetValueAt(idx);

                if (lastIdx >= startIndex)
                {
                    float x1 = (chartControl.BarSpacingType == BarSpacingType.TimeBased || chartControl.BarSpacingType == BarSpacingType.EquidistantMulti && idx + Displacement >= ChartBars.Count
                                                ? chartControl.GetXByTime(ChartBars.GetTimeByBarIdx(chartControl, idx + Displacement))
                                                : chartControl.GetXByBarIndex(ChartBars, idx + Displacement));
                    float y1 = chartScale.GetYByValue(value);

                    if (sink == null)
                    {
                        float x0 = (chartControl.BarSpacingType == BarSpacingType.TimeBased || chartControl.BarSpacingType == BarSpacingType.EquidistantMulti && lastIdx + Displacement >= ChartBars.Count
                                                ? chartControl.GetXByTime(ChartBars.GetTimeByBarIdx(chartControl, lastIdx + Displacement))
                                                : chartControl.GetXByBarIndex(ChartBars, lastIdx + Displacement));
                        float y0 = chartScale.GetYByValue(lastValue);
                        g    = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFactory);
                        sink = g.Open();
                        sink.BeginFigure(new SharpDX.Vector2(x0, y0), SharpDX.Direct2D1.FigureBegin.Hollow);
                    }
                    sink.AddLine(new SharpDX.Vector2(x1, y1));
                }

                // Save as previous point
                lastIdx   = idx;
                lastValue = value;
            }

            if (sink != null)
            {
                sink.EndFigure(SharpDX.Direct2D1.FigureEnd.Open);
                sink.Close();
            }

            if (g != null)
            {
                var oldAntiAliasMode = RenderTarget.AntialiasMode;
                RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive;
                RenderTarget.DrawGeometry(g, Plots[0].BrushDX, Plots[0].Width, Plots[0].StrokeStyle);
                RenderTarget.AntialiasMode = oldAntiAliasMode;
                g.Dispose();
                RemoveDrawObject("NinjaScriptInfo");
            }
            else
            {
                Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.ZigZagDeviationValueError, TextPosition.BottomRight);
            }
        }
コード例 #44
0
ファイル: Test.cs プロジェクト: evstmax/CopyCtrl
        public void TestSetLayer()
        {
            var lineId = Draw.Line(Point3d.Origin, Point3d.Origin + Vector3d.XAxis);

            lineId.SetLayer("aaa");
        }
コード例 #45
0
        private void calcVolumeSwings()
        {
            swingVol  = LT_Swing_Trend1.SwingVolume[0];
            swingSize = LT_Swing_Trend1.SwingSize[0];
            if (swingVol > 0 && swingSize > 0)
            {
                if (upSwing)
                {
                    RemoveDrawObject("up" + lastObservation);
                }
                if (swingVol > lastSwingVolDn)
                {
                    trendMessage = "Bullish";
                    LineNowColor = UpColor;
                    swingTrend   = 1;
                }
                else
                {
                    trendMessage = "Bearish";
                    LineNowColor = DnColor;
                    swingTrend   = -1;
                }

                if (deBug)
                {
                    string messages = swingVol.ToString() + "\n" + lastSwingVolDn.ToString() + "\n" + trendMessage;
                    Draw.Text(this, "up" + CurrentBar, messages, 0, Low[0] - 2 * TickSize, Brushes.White);
                }
                upSwing         = true;
                lastObservation = CurrentBar;
                lastSwingVolUp  = swingVol;
            }
            else if (swingVol > 0 && swingSize < 0)
            {
                //Print("\t" + Time[0].ToString() + " \nDn \t " +  swingVol+ " \t Size: " + swingSize);
                if (!upSwing)
                {
                    RemoveDrawObject("dn" + lastObservation);
                }
                if (swingVol < lastSwingVolUp)
                {
                    trendMessage = "Bullish";
                    LineNowColor = UpColor;
                    swingTrend   = 1;
                }
                else
                {
                    trendMessage = "Bearish";
                    LineNowColor = DnColor;
                    swingTrend   = -1;
                }

                if (deBug)
                {
                    string messages = swingVol.ToString() + "\n" + lastSwingVolUp.ToString() + "\n" + trendMessage;
                    Draw.Text(this, "dn" + CurrentBar, messages, 0, High[0] + 2 * TickSize, Brushes.White);
                }
                upSwing         = false;
                lastObservation = CurrentBar;
                lastSwingVolDn  = swingVol;
            }
            PlotBrushes[0][0] = LineNowColor;
            TrendDir[0]       = MIN(Low, 120)[0];
        }
コード例 #46
0
ファイル: Test.cs プロジェクト: evstmax/CopyCtrl
 public void TestHatch()
 {
     Draw.Hatch(new[] { new Point3d(0, 0, 0), new Point3d(100, 0, 0), new Point3d(0, 100, 0) });
 }
コード例 #47
0
        protected override void OnBarUpdate()
        {
            if (BarsInProgress == 0)
            {
                if (currentDate != sessionIterator.GetTradingDay(Time[0]))
                {
                    opening      = Open[0];
                    openingHigh  = High[0];
                    openingLow   = Low[0];
                    currentAUp   = openingHigh + (setACValues ? aSeries[0] : (TickSize * this.ATicks));
                    currentADown = openingLow - (setACValues ? aSeries[0] : (TickSize * this.ATicks));
                    currentCUp   = openingHigh + (setACValues ? cSeries[0] : (TickSize * this.CTicks));
                    currentCDown = openingLow - (setACValues ? cSeries[0] : (TickSize * this.CTicks));

                    MyOpen[0]   = opening;
                    OpenHigh[0] = openingHigh;
                    OpenLow[0]  = openingLow;
                    AUp[0]      = currentAUp;
                    ADown[0]    = currentADown;
                    CUp[0]      = currentCUp;
                    CDown[0]    = currentCDown;

                    currentDate      = sessionIterator.GetTradingDay(Time[0]);
                    aUpBreachedBar   = 0;
                    aUpSuccessBar    = 0;
                    aDownBreachedBar = 0;
                    aDownSuccessBar  = 0;
                    cUpBreachedBar   = 0;
                    cUpSuccessBar    = 0;
                    cDownBreachedBar = 0;
                    cDownSuccessBar  = 0;

                    MyOpen[0] = Open[0];

                    #region Pivot
                    priorDayHigh  = currentHigh;
                    priorDayLow   = currentLow;
                    priorDayClose = currentClose;

                    double pivotPrice         = (priorDayHigh + priorDayLow + priorDayClose) / 3;
                    double pivotHighLowMiddle = (priorDayHigh + priorDayLow) / 2;
                    double pivotDifferential  = Math.Abs(pivotPrice - pivotHighLowMiddle);
                    pivotUpperBound = pivotPrice + pivotDifferential;
                    pivotLowerBound = pivotPrice - pivotDifferential;
                    PivotHigh[0]    = pivotUpperBound;
                    PivotLow[0]     = pivotLowerBound;

                    // Initilize the current day settings to the new days data
                    currentHigh  = High[0];
                    currentLow   = Low[0];
                    currentClose = Close[0];
                    #endregion

                    #region NumberLine
                    if (CurrentBars[2] > 36)
                    {
                        String numberLineText = String.Format("Outlook: {8}{1}NL: {0}{1}Days: {2}, {3}, {4}{1}Trend: {5}, {6}, {7}{1}Drop: {9}",
                                                              numberLineSeries[0].ToString("+#;-#;0"),
                                                              Environment.NewLine,
                                                              dayNumberLineSeries[2].ToString("+#;-#;0"),
                                                              dayNumberLineSeries[1].ToString("+#;-#;0"),
                                                              dayNumberLineSeries[0].ToString("+#;-#;0"),
                                                              numberLineSeries[2].ToString("+#;-#;0"),
                                                              numberLineSeries[1].ToString("+#;-#;0"),
                                                              numberLineSeries[0].ToString("+#;-#;0"),
                                                              Close[1] > PivotHigh[0] ? "Plus" : Close[1] < PivotLow[0] ? "Minus" : "Neutral",
                                                              numberLineDropOffScore.ToString("+#;-#;0"));

                        Draw.Text(this, String.Format("NumberLine_{0}", currentDate.ToShortDateString()), false, numberLineText, 5,
                                  priorDayLow, 10,
                                  textColor, textFont, TextAlignment.Justify, Brushes.Transparent, Brushes.Transparent, 0);
                    }
                    #endregion
                }
                else
                {
                    MyOpen[0]   = opening;
                    OpenHigh[0] = openingHigh;
                    OpenLow[0]  = openingLow;
                    AUp[0]      = currentAUp;
                    ADown[0]    = currentADown;
                    CUp[0]      = currentCUp;
                    CDown[0]    = currentCDown;

                    #region Pivot
                    currentHigh  = Math.Max(currentHigh, High[0]);
                    currentLow   = Math.Min(currentLow, Low[0]);
                    currentClose = Close[0];

                    DateTime projectTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, this.ProjectHour, this.ProjectMinute, 0);

                    if (Time[0] >= projectTime)
                    {
                        double pivotPrice         = (currentHigh + currentLow + currentClose) / 3;
                        double pivotHighLowMiddle = (currentHigh + currentLow) / 2;
                        double pivotDifferential  = Math.Abs(pivotPrice - pivotHighLowMiddle);
                        PivotHigh[0] = pivotPrice + pivotDifferential;
                        PivotLow[0]  = pivotPrice - pivotDifferential;
                    }
                    else
                    {
                        PivotHigh[0] = pivotUpperBound;
                        PivotLow[0]  = pivotLowerBound;
                    }
                    #endregion

                    #region NumberLine
                    AddNumberLineEvents(currentNumberLineEvents,
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.AUpBreached, aUpBreachedBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.AUpSuccess, aUpSuccessBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.ADownBreached, aDownBreachedBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.ADownSuccess, aDownSuccessBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.CUpBreached, cUpBreachedBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.CUpSuccess, cUpSuccessBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.CDownBreached, cDownBreachedBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.CDownSuccess, cDownSuccessBar > 0));

                    currentOpeningRangeClose = GetOpeningRangeClose(Close[0]);

                    if (CurrentBars[2] > 36)
                    {
                        double tempNumberLineScore = ScoreNumberLineMaster();

                        //PrintValues(numberLineSeries[0], tempNumberLineSum, tempNumberLineScore);

                        String numberLineText = String.Format("Drop: {1}{0}Add: {2}{0}Proj: {3}{0}OR: {4}{0}",
                                                              Environment.NewLine,
                                                              numberLineDropOffScore.ToString("+#;-#;0"),
                                                              tempNumberLineScore.ToString("+#;-#;0"),
                                                              (numberLineMinusOneSum + tempNumberLineScore).ToString("+#;-#;0"),
                                                              (Math.Abs(openingHigh - openingLow).ToString("C")));

                        Draw.TextFixed(this, "numberLineToday", numberLineText, textPosition: TextPosition.BottomRight);
                    }
                    #endregion
                }

                RollingPivotHigh[0] = rollingPivotUpperBound;
                RollingPivotLow[0]  = rollingPivotLowerBound;

                if (!String.IsNullOrEmpty(redrawTag) && !String.IsNullOrEmpty(redrawText))
                {
                    bool isUp = redrawTag.StartsWith("Up_");

                    Draw.Text(this, redrawTag, false, redrawText, 0,
                              isUp ? Math.Max(High[0], High[1]) : Math.Min(Low[0], Low[1]),
                              isUp ? 20 : -10,
                              textColor, textFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);

                    redrawTag  = String.Empty;
                    redrawText = String.Empty;
                }
            }
            else if (BarsInProgress == 1)
            {
                fastPivotPriceSeries[0] = (High[0] + Low[0] + Close[0]) / 3;

                if (fastCurrentDate != sessionIterator.GetTradingDay(Time[0]))
                {
                    fastCurrentDate = sessionIterator.GetTradingDay(Time[0]);
                    fastCurrentBar  = 1;
                }
                else
                {
                    fastCurrentBar += 1;
                }

                if (fastCurrentBar >= openingBars)
                {
                    #region A Up
                    if (aUpBreachedBar == 0 && aDownSuccessBar == 0 && fastPivotPriceSeries[0] > currentAUp)
                    {
                        aUpBreachedBar = CurrentBar;
                    }

                    if (aUpBreachedBar > 0 &&
                        aUpSuccessBar == 0 &&
                        aDownSuccessBar == 0 &&
                        (CurrentBar - aUpBreachedBar) >= halfTimeFrameBars &&
                        CountIf(() => fastPivotPriceSeries[0] > currentAUp, halfTimeFrameBars) >= halfTimeFrameBars)
                    {
                        aUpSuccessBar = CurrentBar;

                        redrawTag  = "Up_" + currentDate.ToShortDateString();
                        redrawText = " A Up ";

                        Draw.Text(this, redrawTag, false, redrawText, 0, Highs[0][0], 50, textColor,
                                  textFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                    }
                    #endregion

                    #region A Down
                    if (aDownBreachedBar == 0 && aUpSuccessBar == 0 && fastPivotPriceSeries[0] < currentADown)
                    {
                        aDownBreachedBar = CurrentBars[0];
                    }

                    if (aDownBreachedBar > 0 &&
                        aUpSuccessBar == 0 &&
                        aDownSuccessBar == 0 &&
                        (CurrentBar - aDownBreachedBar) >= halfTimeFrameBars &&
                        CountIf(() => fastPivotPriceSeries[0] < currentADown, halfTimeFrameBars) >= halfTimeFrameBars)
                    {
                        aDownSuccessBar = CurrentBars[0];

                        redrawTag  = "Down_" + currentDate.ToShortDateString();
                        redrawText = " A Down ";

                        Draw.Text(this, redrawTag, false, redrawText, 0, Lows[0][0], -50, textColor,
                                  textFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                    }
                    #endregion

                    #region C Up
                    if (aDownSuccessBar > 0 && cUpBreachedBar == 0 && cDownSuccessBar == 0 && fastPivotPriceSeries[0] > currentCUp)
                    {
                        cUpBreachedBar = CurrentBar;
                    }

                    if (cUpBreachedBar > 0 &&
                        cUpSuccessBar == 0 &&
                        cDownSuccessBar == 0 &&
                        (CurrentBar - cUpBreachedBar) >= halfTimeFrameBars &&
                        CountIf(() => fastPivotPriceSeries[0] > currentCUp, halfTimeFrameBars) >= halfTimeFrameBars)
                    {
                        cUpSuccessBar = CurrentBar;

                        redrawTag  = "Up_" + currentDate.ToShortDateString();
                        redrawText = " C Up ";

                        Draw.Text(this, redrawTag, false, redrawText, 0, Highs[0][0], 50, textColor,
                                  textFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                    }
                    #endregion

                    #region C Down
                    if (aUpSuccessBar > 0 && cDownBreachedBar == 0 && cUpSuccessBar == 0 && fastPivotPriceSeries[0] < currentCDown)
                    {
                        cDownBreachedBar = CurrentBar;
                    }

                    if (cDownBreachedBar > 0 &&
                        cDownSuccessBar == 0 &&
                        cUpSuccessBar == 0 &&
                        (CurrentBar - cDownBreachedBar) >= halfTimeFrameBars &&
                        CountIf(() => fastPivotPriceSeries[0] < currentCDown, halfTimeFrameBars) >= halfTimeFrameBars)
                    {
                        cDownSuccessBar = CurrentBar;

                        redrawTag  = "Down_" + currentDate.ToShortDateString();
                        redrawText = " C Down ";

                        Draw.Text(this, redrawTag, false, redrawText, 0, Lows[0][0], -50, textColor,
                                  textFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                    }
                    #endregion
                }
            }
            else if (BarsInProgress == 2 && CurrentBar > 3)
            {
                double high = MAX(High, 3)[0];
                double low  = MAX(High, 3)[0];

                double pivotPrice         = (high + low + Close[0]) / 3;
                double pivotHighLowMiddle = (high + low) / 2;
                double pivotDifferential  = Math.Abs(pivotPrice - pivotHighLowMiddle);
                rollingPivotUpperBound = pivotPrice + pivotDifferential;
                rollingPivotLowerBound = pivotPrice - pivotDifferential;

                trueRangeSeries[0] = (new List <double>()
                {
                    High[0] - Low[0], Math.Abs(High[0] - Close[0]), Math.Abs(Low[0] - Close[0])
                }).Max();

                if (CurrentBar > 35)
                {
                    List <double> trueRangeFactors = new List <double>();
                    for (int i = 10; i <= 30; i++)
                    {
                        trueRangeFactors.Add(SUM(trueRangeSeries, i)[0] / i);
                    }

                    double firstValue = trueRangeFactors.Average();
                    aSeries[0]  = this.Instrument.MasterInstrument.RoundToTickSize(.1 * (firstValue / 2));
                    cSeries[0]  = this.Instrument.MasterInstrument.RoundToTickSize(.15 * (firstValue / 2));
                    setACValues = true;
                }

                currentOpeningRangeClose = GetOpeningRangeClose(Close[0]);
                dayNumberLineSeries[0]   = ScoreNumberLineMaster();
                numberLineSeries[0]      = SUM(dayNumberLineSeries, 30)[0];
                numberLineMinusOneSum    = SUM(dayNumberLineSeries, 29)[0];

                try
                {
                    numberLineDropOffScore = dayNumberLineSeries[29];
                }
                catch { }

                currentNumberLineEvents  = new List <NumberLineEvents>();
                currentOpeningRangeClose = OpeningRangeCloses.None;

                //RollingPivotHigh[0] = rollingPivotUpperBound;
                //RollingPivotLow[0] = rollingPivotLowerBound;
                //Draw.TextFixed(this, "tag1", String.Format("Text to draw{0}Yo", Environment.NewLine), textPosition: TextPosition.BottomRight);
            }
        }
コード例 #48
0
ファイル: Test.cs プロジェクト: evstmax/CopyCtrl
        public void TestHatch2()
        {
            var ids = Interaction.GetSelection("\nSelect entities");

            Draw.Hatch(ids);
        }
コード例 #49
0
        public override void Render()
        {
            Vector2 position = this.Position;

            this.Position += base.Shake;
            Draw.Rect(base.X, base.Y, base.Width, base.Height, Color.Black);
            int   num   = 1;
            float num2  = 0f;
            int   count = this.innerCogs.Count;
            int   num3  = 4;

            while ((float)num3 <= base.Height - 4f)
            {
                int num4 = num;
                int num5 = 4;
                while ((float)num5 <= base.Width - 4f)
                {
                    int       index     = (int)(this.mod((num2 + (float)num * this.percent * 3.14159274f * 4f) / 1.57079637f, 1f) * (float)count);
                    MTexture  mtexture  = this.innerCogs[index];
                    Rectangle rectangle = new Rectangle(0, 0, mtexture.Width, mtexture.Height);
                    Vector2   zero      = Vector2.Zero;
                    bool      flag      = num5 <= 4;
                    if (flag)
                    {
                        zero.X           = 2f;
                        rectangle.X      = 2;
                        rectangle.Width -= 2;
                    }
                    else
                    {
                        bool flag2 = (float)num5 >= base.Width - 4f;
                        if (flag2)
                        {
                            zero.X           = -2f;
                            rectangle.Width -= 2;
                        }
                    }
                    bool flag3 = num3 <= 4;
                    if (flag3)
                    {
                        zero.Y            = 2f;
                        rectangle.Y       = 2;
                        rectangle.Height -= 2;
                    }
                    else
                    {
                        bool flag4 = (float)num3 >= base.Height - 4f;
                        if (flag4)
                        {
                            zero.Y            = -2f;
                            rectangle.Height -= 2;
                        }
                    }
                    mtexture = mtexture.GetSubtexture(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, this.temp);
                    mtexture.DrawCentered(this.Position + new Vector2((float)num5, (float)num3) + zero, Color.White * ((num < 0) ? 0.5f : 1f));
                    num   = -num;
                    num2 += 1.04719758f;
                    num5 += 8;
                }
                bool flag5 = num4 == num;
                if (flag5)
                {
                    num = -num;
                }
                num3 += 8;
            }
            int num6 = 0;

            while ((float)num6 < base.Width / 8f)
            {
                int num7 = 0;
                while ((float)num7 < base.Height / 8f)
                {
                    int  num8  = (num6 == 0) ? 0 : (((float)num6 == base.Width / 8f - 1f) ? 2 : 1);
                    int  num9  = (num7 == 0) ? 0 : (((float)num7 == base.Height / 8f - 1f) ? 2 : 1);
                    bool flag6 = num8 != 1 || num9 != 1;
                    if (flag6)
                    {
                        this.edges[num8, num9].Draw(new Vector2(base.X + (float)(num6 * 8), base.Y + (float)(num7 * 8)));
                    }
                    num7++;
                }
                num6++;
            }
            base.Render();
            this.Position = position;
        }
コード例 #50
0
ファイル: Test.cs プロジェクト: evstmax/CopyCtrl
 public void TestText()
 {
     Modify.TextStyle("Tahoma", 100, 5 * Math.PI / 180, 0.8);
     Draw.Text("FontAbc", 100, Point3d.Origin, 0, true);
 }
コード例 #51
0
 /// <summary>Clears this clock based on the last rendered time.</summary>
 private void ClearClock()
 {
     Draw.Box(BG, Width, Height, LeftPos, TopPos);
 }
コード例 #52
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            TransparentInPaint(e.Graphics);
            //Bitmap B = new Bitmap(Width, Height);
            Graphics  G = e.Graphics;
            Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1);

            G.SmoothingMode     = smoothing;
            G.InterpolationMode = InterpolationMode.HighQualityBicubic;
            G.Clear(BackColor);

            Rectangle imageRec = new Rectangle(0, 0, Width, Height);

            PointF ipt = ImageLocation(GetStringFormat(ImageAlign), Size, ImageSize);



            Font drawFont = new Font("Tahoma", 8, FontStyle.Bold);

            Rectangle           R1     = new Rectangle(0, 0, Width - 125, 35 / 2);
            Rectangle           R2     = new Rectangle(5, Height - 10, Width - 11, 5);
            Rectangle           R3     = new Rectangle(6, Height - 9, Width - 13, 3);
            Rectangle           R4     = new Rectangle(1, 1, Width - 3, Height - 3);
            Rectangle           R5     = new Rectangle(1, 0, Width - 1, Height - 1);
            Rectangle           R6     = new Rectangle(0, -1, Width - 1, Height - 1);
            LinearGradientBrush lgb    = new LinearGradientBrush(ClientRectangle, lgb1, lgb2, angle);
            LinearGradientBrush botbar = new LinearGradientBrush(R2, botbar1, botbar2, angle);
            LinearGradientBrush fill   = new LinearGradientBrush(R3, fill1, fill2, angle);
            LinearGradientBrush gloss  = null;
            Pen          o             = new Pen(path1, 1);
            StringFormat format        = new StringFormat()
            {
                Alignment = textAlign, LineAlignment = textAlign
            };

            if (State == MouseState.Over)
            {
                gloss = new LinearGradientBrush(R1, glossOver1, glossOver2, angle);
            }
            else if (State == MouseState.Down)
            {
                gloss = new LinearGradientBrush(R1, glossDown1, glossDown2, angle);
            }
            else
            {
                gloss = new LinearGradientBrush(R1, glossDefault1, glossDefault2, angle);
            }

            G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 2));
            G.FillPath(gloss, Draw.RoundRect(ClientRectangle, 2));
            G.FillPath(botbar, Draw.RoundRect(R2, 1));
            G.FillPath(fill, Draw.RoundRect(R3, 1));
            G.DrawPath(o, Draw.RoundRect(ClientRectangle, 2));
            G.DrawPath(new Pen(path2, borderWidth), Draw.RoundRect(R4, 2));
            G.DrawString(Text, drawFont, new SolidBrush(textColor1), R5, format);
            G.DrawString(Text, drawFont, new SolidBrush(textColor2), R6, format);

            if ((Image == null))                                                                    ///
            {                                                                                       ///
                //G.DrawString(Text, Font, new SolidBrush(ForeColor), imageRec, new StringFormat           ///
                //{                                                                               ///
                //    Alignment = _TextAlignment,                                                 ///
                //    LineAlignment = StringAlignment.Center                                      ///
                //});                                                                             ///
            }                                                                                      ///
            else                                                                                   ///
            {                                                                                      ///
                G.DrawImage(_Image, ipt.X, ipt.Y, ImageSize.Width, ImageSize.Height);              ///
                //G.DrawString(Text, Font, new SolidBrush(ForeColor), imageRec, new StringFormat          ///
                //{                                                                               ///
                //    Alignment = _TextAlignment,                                                 ///
                //    LineAlignment = StringAlignment.Center                                      ///
                //});                                                                             ///
            }

            //e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
            //G.Dispose();
            //B.Dispose();
            base.OnPaint(e);
        }
コード例 #53
0
ファイル: Pivots.cs プロジェクト: Techbreakers/SATbot
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description        = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionPivots;
                Name               = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNamePivots;
                Calculate          = Calculate.OnBarClose;
                DisplayInDataBox   = true;
                DrawOnPricePanel   = false;
                IsAutoScale        = false;
                IsOverlay          = true;
                PaintPriceMarkers  = true;
                ScaleJustification = ScaleJustification.Right;

                AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.PivotsPP);
                AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.PivotsR1);
                AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.PivotsR2);
                AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.PivotsR3);
                AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.PivotsS1);
                AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.PivotsS2);
                AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.PivotsS3);
            }
            else if (State == State.Configure)
            {
                if (priorDayHlc == HLCCalculationMode.DailyBars)
                {
                    AddDataSeries(BarsPeriodType.Day, 1);
                }
            }
            else if (State == State.DataLoaded)
            {
                storedSession = new SessionIterator(Bars);
            }
            else if (State == State.Historical)
            {
                if (priorDayHlc == HLCCalculationMode.DailyBars && BarsArray[1].DayCount <= 0)
                {
                    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.PiviotsDailyDataError, TextPosition.BottomRight);
                    Log(NinjaTrader.Custom.Resource.PiviotsDailyDataError, LogLevel.Error);
                    return;
                }

                if (!Bars.BarsType.IsIntraday && BarsPeriod.BarsPeriodType != BarsPeriodType.Day && (BarsPeriod.BarsPeriodType != BarsPeriodType.HeikenAshi && BarsPeriod.BarsPeriodType != BarsPeriodType.Volumetric || BarsPeriod.BaseBarsPeriodType != BarsPeriodType.Day))
                {
                    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.PiviotsDailyBarsError, TextPosition.BottomRight);
                    Log(NinjaTrader.Custom.Resource.PiviotsDailyBarsError, LogLevel.Error);
                }
                if ((BarsPeriod.BarsPeriodType == BarsPeriodType.Day || ((BarsPeriod.BarsPeriodType == BarsPeriodType.HeikenAshi || BarsPeriod.BarsPeriodType == BarsPeriodType.Volumetric) && BarsPeriod.BaseBarsPeriodType == BarsPeriodType.Day)) && pivotRangeType == PivotRange.Daily)
                {
                    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.PiviotsWeeklyBarsError, TextPosition.BottomRight);
                    Log(NinjaTrader.Custom.Resource.PiviotsWeeklyBarsError, LogLevel.Error);
                }
                if ((BarsPeriod.BarsPeriodType == BarsPeriodType.Day || ((BarsPeriod.BarsPeriodType == BarsPeriodType.HeikenAshi || BarsPeriod.BarsPeriodType == BarsPeriodType.Volumetric) && BarsPeriod.BaseBarsPeriodType == BarsPeriodType.Day)) && BarsPeriod.Value > 1)
                {
                    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.PiviotsPeriodTypeError, TextPosition.BottomRight);
                    Log(NinjaTrader.Custom.Resource.PiviotsPeriodTypeError, LogLevel.Error);
                }
                if ((priorDayHlc == HLCCalculationMode.DailyBars &&
                     (pivotRangeType == PivotRange.Monthly && BarsArray[1].GetTime(0).Date >= BarsArray[1].GetTime(BarsArray[1].Count - 1).Date.AddMonths(-1) ||
                      pivotRangeType == PivotRange.Weekly && BarsArray[1].GetTime(0).Date >= BarsArray[1].GetTime(BarsArray[1].Count - 1).Date.AddDays(-7) ||
                      pivotRangeType == PivotRange.Daily && BarsArray[1].GetTime(0).Date >= BarsArray[1].GetTime(BarsArray[1].Count - 1).Date.AddDays(-1))) ||
                    pivotRangeType == PivotRange.Monthly && BarsArray[0].GetTime(0).Date >= BarsArray[0].GetTime(BarsArray[0].Count - 1).Date.AddMonths(-1) ||
                    pivotRangeType == PivotRange.Weekly && BarsArray[0].GetTime(0).Date >= BarsArray[0].GetTime(BarsArray[0].Count - 1).Date.AddDays(-7) ||
                    pivotRangeType == PivotRange.Daily && BarsArray[0].GetTime(0).Date >= BarsArray[0].GetTime(BarsArray[0].Count - 1).Date.AddDays(-1)
                    )
                {
                    Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.PiviotsInsufficentDataError, TextPosition.BottomRight);
                    Log(NinjaTrader.Custom.Resource.PiviotsInsufficentDataError, LogLevel.Error);
                }
            }
        }
コード例 #54
0
        private static void DrawBox(Graphics g, DrawingNode drNode)
        {
            NodeAttr nodeAttr = drNode.Attr;
            var      settings = drNode.UserData as NodeDisplaySettings;

            // Create the shape.
            var width   = (float)drNode.Width;
            var height  = (float)drNode.Height;
            var xRadius = (float)nodeAttr.XRadius;
            var yRadius = (float)nodeAttr.YRadius;
            var path    = new GraphicsPath();

            FillTheGraphicsPath(drNode, width, height, ref xRadius, ref yRadius, path);

            // Select line width.
            var lineWidth = (float)drNode.Attr.LineWidth;

            if (settings.HasErrors)
            {
                lineWidth += 2;
            }

            if (settings.IsHighlighted)
            {
                lineWidth += 2;
            }

            // Set up line pen.
            Color lineColor;

            if (settings.HasErrors)
            {
                lineColor = Color.Red;
            }
            else if (settings.IsHighlighted)
            {
                lineColor = Color.Blue;
            }
            else
            {
                lineColor = Draw.MsaglColorToDrawingColor(drNode.Attr.Color);
            }

            if (settings.IsFadedOut)
            {
                lineColor = Color.FromArgb(128, lineColor.R, lineColor.G, lineColor.B);
            }

            var pen = new Pen(lineColor, lineWidth);

            // Set up fill brush.
            Brush brush;
            Color fillColor = Draw.MsaglColorToDrawingColor(nodeAttr.FillColor);

            if (settings.IsFadedOut)
            {
                fillColor = Color.FromArgb(128, fillColor.R, fillColor.G, fillColor.B);
            }

            if (settings.HasUnsavedChanges)
            {
                var hashColor = Color.FromArgb((int)(fillColor.R * 0.9f + 128 * 0.1f),
                                               (int)(fillColor.G * 0.9f + 128 * 0.1f),
                                               (int)(fillColor.B * 0.9f + 128 * 0.1f));
                brush = new HatchBrush(HatchStyle.WideUpwardDiagonal, hashColor, fillColor);
            }
            else
            {
                brush = new SolidBrush(fillColor);
            }

            // Paint.
            g.FillPath(brush, path);
            g.DrawPath(pen, path);
        }
コード例 #55
0
        /// <summary>
        /// Draw click effect
        /// </summary>
        /// <param name="e"></param>
        private void DrawClick(PaintEventArgs e)
        {
            // Control's graphics object
            Graphics g = e.Graphics;

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // ClickEffect
            if (_clickEffect != ClickEffect.None)
            {
                // Color of ClickEffect
                Color color;
                Color fill = (_fullColored) ? _tint : _sourceTheme.CONTROL_FILL.Normal.ToColor();

                if (_sourceTheme.DARK_BASED == true)
                {
                    // Dark based themes
                    color = Color.FromArgb(_alpha, MColor.AddRGB(150, fill));
                }
                else
                {
                    // Light based themes
                    color = Color.FromArgb(_alpha, MColor.AddRGB(-150, fill));
                }

                // Draws ClickEffect
                // Set up antialiasing
                g.SmoothingMode = SmoothingMode.AntiAlias;

                // Ink
                if (_clickEffect == ClickEffect.Ink)
                {
                    // Ink's brush and grapics path
                    SolidBrush   brush = new SolidBrush(color);
                    GraphicsPath ink   = Draw.GetEllipsePath(_mouse, (int)_radius);

                    // Draws ink ClickEffect
                    g.FillPath(brush, ink);
                }

                // Square
                if (_clickEffect == ClickEffect.Square || _clickEffect == ClickEffect.SquareRotate)
                {
                    // Square's brush and grapics path
                    SolidBrush   brush  = new SolidBrush(color);
                    GraphicsPath square = Draw.GetSquarePath(_mouse, (int)_radius);

                    // Rotates square
                    if (_clickEffect == ClickEffect.SquareRotate)
                    {
                        Matrix matrix = new Matrix();
                        matrix.RotateAt(_rotation, _mouse);
                        square.Transform(matrix);
                    }

                    // Draws square ClickEffect
                    g.FillPath(brush, square);
                }

                // Remove antialiasing
                g.SmoothingMode = SmoothingMode.Default;
            }
        }
コード例 #56
0
 /// <summary>Draws this box</summary>
 public override void DrawElement()
 {
     Draw.Box(Color, Length, Height, Parent.LeftPos + LeftPos, Parent.TopPos + TopPos);
 }
コード例 #57
0
ファイル: PayView.cs プロジェクト: JeongInHye/OrderByKiosk
 public PayView(Form parentForm)
 {
     this.parentForm = parentForm;
     draw            = new Draw();
     getView();
 }
コード例 #58
0
 internal static void Internal_Draw()
 {
     Draw?.Invoke();
 }
コード例 #59
0
 public void Setup()
 {
     _drawRepositoryMock = new Mock <IDrawRepository>();
     _service            = new DrawService(_drawRepositoryMock.Object);
     _previousDraw       = null;
 }
コード例 #60
0
 private static void Game_OnStart(EventArgs args)
 {
     Draw.Item("连杀人数").SetValue(new Slider(0, 0, 8));
 }