Exemplo n.º 1
0
        public PointF ToPointF(ObjectPoint op)
        {
            FormulaChart backChart = this.Manager.Canvas.BackChart;

            if (backChart != null)
            {
                return(backChart.GetPointAt(this.AreaName, op.X, null, op.Y));
            }
            return(PointF.Empty);
        }
Exemplo n.º 2
0
        public void RestoreWay()
        {
            var startPoint = new ObjectPoint(0, 0, ObjectType.StartPoint);
            var endPoint   = new ObjectPoint(2, 2, ObjectType.EndPoint);

            //   0      1     2      3      |
            //------------------------------+---
            //  (a)0  (-)1   (-)2   (x)'    | 0
            //  (-)1  (x)'   (-)3   (-)4    | 1
            //  (-)2  (x)'   (b)4   (x)'    | 2
            WaveObject[,] area = new WaveObject[3, 4]
            {
                { new WaveObject(value: 0, type: ObjectType.StartPoint),        // -- 0,0
                  new WaveObject(value: 1, type: ObjectType.None),              //    0,1
                  new WaveObject(value: 2, type: ObjectType.None),              //    0,2
                  new WaveObject(value: null, type: ObjectType.Block) },        //    0,3
                { new WaveObject(value: 1, type: ObjectType.None),              // -- 1,0
                  new WaveObject(value: null, type: ObjectType.Block),          //    1,1
                  new WaveObject(value: 3, type: ObjectType.None),              //    1,2
                  new WaveObject(value: 4, type: ObjectType.None) },            //    1,3
                { new WaveObject(value: 2, type: ObjectType.None),              // -- 2,0
                  new WaveObject(value: null, type: ObjectType.Block),          //    2,1
                  new WaveObject(value: 4, type: ObjectType.EndPoint),          //    2,2
                  new WaveObject(value: null, type: ObjectType.Block) }         //    2,3
            };
            // x,y
            // 0,0 -> 0,1 -> 0,2 -> 1,2 -> 2,2
            List <ObjectPoint> expectedResult = new List <ObjectPoint>()
            {
                new ObjectPoint {
                    X = 0, Y = 1, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 0, Y = 2, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 1, Y = 2, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 2, Y = 2, Obj = ObjectType.EndPoint
                }
            };

            List <ObjectPoint> path = WaveAlgLee.RestoreWay(area, startPoint, endPoint);

            if (path.Count == 0)
            {
                Assert.Fail("Result path list count 0 elements");
            }
            for (int i = 0; i < path.Count; i++)
            {
                Assert.AreEqual(expectedResult[i], path[i]);
            }
        }
Exemplo n.º 3
0
 public ObjectManager(IObjectCanvas Canvas, PropertyGrid propertyGrid, ObjectToolPanel ToolPanel)
 {
     this.StartPoint = ObjectPoint.Empty;
     this.EndPoint   = ObjectPoint.Empty;
     this.objects    = new ObjectCollection();
     LoadSettings(ToolPanel);
     this.SetHandler(Canvas, propertyGrid, ToolPanel);
     if (ToolPanel != null)
     {
         ToolPanel.LoadObjectTool();
     }
 }
Exemplo n.º 4
0
        private void DesignerControl_MouseDown(object sender, MouseEventArgs e)
        {
            FormulaArea fa = null;
            BaseObject  objectAt;

            this.StartPoint = this.GetValueFromPos((float)e.X, (float)e.Y, ref fa);
            this.SaveChartControlSetting();
            if (this.ObjectType == null)
            {
                this.SelectedObject = null;
                if (e.Button == MouseButtons.Left)
                {
                    int controlPointIndex = this.GetPointIndex(e.X, e.Y, out objectAt);
                    if (objectAt == null)
                    {
                        objectAt = this.GetObjectAt(e.X, e.Y);
                    }
                    if (objectAt != null)
                    {
                        this.SelectedObject = objectAt;
                        this.DragObject     = new ObjectDragging(new PointF((float)e.X, (float)e.Y), controlPointIndex, objectAt);
                        this.Designer.Invalidate(objectAt.GetRegion());
                        objectAt.InMove = true;
                    }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                this.objects.Remove(this.DragObject.Object);
                this.DragObjectFinished();
            }
            else if (this.ObjectSteps == 0)
            {
                objectAt          = this.ObjectType.Invoke();
                objectAt.AreaName = fa.Name;
                objectAt.Area     = fa;
                objectAt.InSetup  = true;
                objectAt.InMove   = true;
                if (this.AfterCreateStart != null)
                {
                    this.AfterCreateStart(this, objectAt);
                }
                objectAt.SetObjectManager(this);
                for (int i = 0; i < objectAt.ControlPointNum; i++)
                {
                    objectAt.ControlPoints[i] = this.StartPoint;
                }
                this.objects.Add(objectAt);
                this.SelectedObject = objectAt;
                this.DragObject     = new ObjectDragging(new PointF((float)e.X, (float)e.Y), ((this.ObjectSteps + objectAt.InitNum) > 1) ? 1 : 0, objectAt);
            }
            this.DragMemBmp = null;
        }
Exemplo n.º 5
0
        public void MakeWayTest_ExceptionGeneration_IncorrectEndPointArgument()
        {
            string[,] area = new string[3, 3] {
                // 0   1   2
                { "a", "", "" },    // 0
                { "", "", "" },     // 1
                { "", "", "b" }     // 2
            };
            var startPoint     = new ObjectPoint(0, 0, ObjectType.StartPoint);
            var incorrectPoint = new ObjectPoint(2, 2, ObjectType.Block);

            WaveAlgLee.MakeWay(ref area, startPoint, incorrectPoint);
        }
Exemplo n.º 6
0
        public ExtSymbolic(ExtStaticData extStaticData, WCFSymbolic wcfSymbolic)
        {
            WCFSymbolic = wcfSymbolic;

            ObjectPoint = extStaticData.ObjectPoint.Where(p => p.WCFObjectPoint.Symbolic == WCFSymbolic.Name);
            ObjectPoint = ObjectPoint.OrderBy(p => p.WCFObjectPoint.Sort).ToList();

            Points = new PointCollection(this.ObjectPoint.Select(p => new Point(p.GamePoint.X, p.GamePoint.Y)));

            Opacity    = 0.66;
            Background = _DefaultBackground;

            ClientInfo.ClientGameChanging += ClientInfo_ClientGameChanging;
        }
Exemplo n.º 7
0
        public ExtTerrain(ExtStaticData extStaticData, WCFTerrain wcfTerrain)
        {
            WCFTerrain     = wcfTerrain;
            JoinTerrainCol = new List <ExtTerrain>();

            ObjectPoint = extStaticData.ObjectPoint.Where(p => p.WCFObjectPoint.Terrain == WCFTerrain.Name);
            ObjectPoint = ObjectPoint.OrderBy(p => p.WCFObjectPoint.Sort).ToList();

            Points = new PointCollection(this.ObjectPoint.Select(p => new Point(p.GamePoint.X, p.GamePoint.Y)));

            ExtTokenPoint = extStaticData.TokenPoint.Where(p => p.WCFTokenPoint.Terrain == WCFTerrain.Name).ToList();
            Name          = App.GetResources("terrain_" + WCFTerrain.Name);

            ClientInfo.ClientGameChanging += ClientInfo_ClientGameChanging;
        }
Exemplo n.º 8
0
        public override void CalcPoint()
        {
            base.SetSnapPrice(this.snap);
            PointF tf   = base.ToPointF(base.ControlPoints[0]);
            PointF tf2  = base.ToPointF(base.ControlPoints[1]);
            double y    = base.ControlPoints[0].Y;
            double num2 = base.ControlPoints[1].Y;

            base.pfStart = new PointF[this.split.Length];
            base.pfEnd   = new PointF[this.split.Length];
            ObjectPoint op = new ObjectPoint(base.ControlPoints[0].X, 0.0);

            for (int i = 0; i < this.split.Length; i++)
            {
                op.Y = ((num2 - y) * this.split[i]) + y;
                PointF tf3 = base.ToPointF(op);
                base.pfStart[i] = new PointF(tf.X, tf3.Y);
                base.pfEnd[i]   = new PointF(tf2.X, tf3.Y);
            }
        }
Exemplo n.º 9
0
        public void MakeWayTest_Common_usage()
        {
            string[,] area = new string[3, 3] {
                // 0   1   2
                { "a", "", "" },     // 0
                { "", "x", "" },     // 1
                { "", "x", "b" }     // 2
            };

            var startPoint = new ObjectPoint(0, 0, ObjectType.StartPoint);
            var endPoint   = new ObjectPoint(2, 2, ObjectType.EndPoint);

            List <ObjectPoint> expectedResult = new List <ObjectPoint>()
            {
                new ObjectPoint {
                    X = 0, Y = 1, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 0, Y = 2, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 1, Y = 2, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 2, Y = 2, Obj = ObjectType.EndPoint
                }
            };

            var result = WaveAlgLee.MakeWay(ref area, startPoint, endPoint);

            if (result.Count == 0)
            {
                Assert.Fail("Result path list count 0 elements");
            }
            for (int i = 0; i < result.Count; i++)
            {
                Assert.AreEqual(expectedResult[i], result[i]);
            }
        }
Exemplo n.º 10
0
        private List<ObjectPoint> SelectObjectCenters(int [,,] neigbourmap, int width, int height)
        {
            //Set the threshold to the maximal neigbours a point can possibly have
            int maxThreshold = SettingsManager.RecognitionSet.ObjectMaximalRadius*SettingsManager.RecognitionSet.ObjectMaximalRadius;
            int minThreshold = SettingsManager.RecognitionSet.ObjectMinimalRadius*SettingsManager.RecognitionSet.ObjectMinimalRadius;

            int threshold = maxThreshold;

            List<ObjectPoint> pointlist = new List<ObjectPoint>();

            while (threshold > minThreshold)
            {
                int currentMaxThreshold = 0;

                //Check whether there are any points matching this threshold
                for (int x = 0; x<width; x++)
                {
                    for (int y = 0; y<height; y++)
                    {
                        //Check whether this is a maximum threshold (for later use)
                        if (neigbourmap[x, y, 0] > currentMaxThreshold)
                            currentMaxThreshold = neigbourmap[x, y, 0];

                        //Check whether the pixel reach the current Threshold
                        if (neigbourmap[x, y, 0] >= threshold)
                        {
                            //Add this point to the list
                            ObjectPoint p = new ObjectPoint(x, y, neigbourmap[x, y, 0], neigbourmap[x, y, 1]);
                            pointlist.Add(p);

                            //Set the neigbours of the points within this point's Rectangle to 0, as they are part of the same object
                            //(so they aren't recognized anymore)
                            SetPointsToZero(ref neigbourmap, width, height, p);
                        }
                    }
                }

                //now decrease the threshold by 1 for the next run
                threshold--;
                //if the threshold was never reached, set it to the maximum threshold that occured in the neigbourmap
                if (threshold > currentMaxThreshold)
                    threshold = currentMaxThreshold;
            }

            return pointlist;
        }
Exemplo n.º 11
0
 public virtual void Add(ObjectPoint op1, ObjectPoint op2)
 {
     this.Add(new ObjectSegment(op1, op2));
 }
Exemplo n.º 12
0
        public void WavePropagation()
        {
            var startPoint = new ObjectPoint(0, 0, ObjectType.StartPoint);
            var endPoint   = new ObjectPoint(2, 2, ObjectType.EndPoint);

            //  0   1   2   3   |
            //------------------+---
            //  a   '   '   x   | 0
            //  '   x   '   '   | 1
            //  '   x   b   x   | 2
            WaveObject[,] area = new WaveObject[3, 4]
            {
                { new WaveObject(value: 0, type: ObjectType.StartPoint),            // -- 0,0
                  new WaveObject(value: null, type: ObjectType.None),               //    0,1
                  new WaveObject(value: null, type: ObjectType.None),               //    0,2
                  new WaveObject(value: null, type: ObjectType.Block) },            //    0,3
                { new WaveObject(value: null, type: ObjectType.None),               // -- 1,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,1
                  new WaveObject(value: null, type: ObjectType.None),               //    1,2
                  new WaveObject(value: null, type: ObjectType.None) },             //    1,3
                { new WaveObject(value: null, type: ObjectType.None),               // -- 2,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,1
                  new WaveObject(value: null, type: ObjectType.EndPoint),           //    2,2
                  new WaveObject(value: null, type: ObjectType.Block) }             //    2,3
            };

            WaveAlgLee.WavePropagation(ref area, startPoint, endPoint, true);

            //   0      1     2      3      |
            //------------------------------+---
            //  (a)0  (-)1   (-)2   (x)'    | 0
            //  (-)1  (x)'   (-)3   (-)4    | 1
            //  (-)2  (x)'   (b)4   (x)'    | 2
            WaveObject[,] expectedArea = new WaveObject[3, 4]
            {
                { new WaveObject(value: 0, type: ObjectType.StartPoint),        // -- 0,0
                  new WaveObject(value: 1, type: ObjectType.None),              //    0,1
                  new WaveObject(value: 2, type: ObjectType.None),              //    0,2
                  new WaveObject(value: null, type: ObjectType.Block) },        //    0,3
                { new WaveObject(value: 1, type: ObjectType.None),              // -- 1,0
                  new WaveObject(value: null, type: ObjectType.Block),          //    1,1
                  new WaveObject(value: 3, type: ObjectType.None),              //    1,2
                  new WaveObject(value: 4, type: ObjectType.None) },            //    1,3
                { new WaveObject(value: 2, type: ObjectType.None),              // -- 2,0
                  new WaveObject(value: null, type: ObjectType.Block),          //    2,1
                  new WaveObject(value: 4, type: ObjectType.EndPoint),          //    2,2
                  new WaveObject(value: null, type: ObjectType.Block) }         //    2,3
            };

            int arrayHeight = area.GetUpperBound(1) + 1;

            if (arrayHeight > 0 && area.Length > 0)
            {
                int arrayWidth = area.Length / arrayHeight;
                for (int x = 0; x < arrayWidth; x++)
                {
                    for (int y = 0; y < arrayHeight; y++)
                    {
                        Assert.AreEqual(expectedArea[x, y], area[x, y]);
                    }
                }
            }
            else
            {
                Assert.Fail("Array length or height was 0");
            }
        }
Exemplo n.º 13
0
        public override void CalcPoint()
        {
            float num3;

            this.fd = base.Area.FormulaDataArray[0];
            double[] dd    = base.Manager.Canvas.BackChart.DataProvider["DATE"];
            int      index = 0;
            int      num2  = 1;

            if (base.ControlPoints[0].X > base.ControlPoints[1].X)
            {
                index = 1;
                num2  = 0;
            }
            this.Bar1 = FormulaChart.FindIndex(dd, base.ControlPoints[index].X);
            this.Bar2 = FormulaChart.FindIndex(dd, base.ControlPoints[num2].X);
            if (this.regressionType != RegressionType.UpDownTrend)
            {
                FormulaBase.CalcLinearRegression(this.fd, this.Bar2, this.Bar2 - this.Bar1, out this.A, out this.B);
            }
            else
            {
                this.A = base.ControlPoints[index].Y;
                this.B = (base.ControlPoints[num2].Y - base.ControlPoints[index].Y) / ((double)(this.Bar2 - this.Bar1));
            }
            ObjectPoint point  = base.ControlPoints[index];
            ObjectPoint point2 = base.ControlPoints[num2];

            point.Y  = this.A;
            point2.Y = this.A + (this.B * (this.Bar2 - this.Bar1));
            this.scLines.Clear();
            if (this.centerLine)
            {
                this.scLines.Add(point, point2);
            }
            if (((this.regressionType == RegressionType.Channel) || (this.regressionType == RegressionType.AsynChannel)) || (this.regressionType == RegressionType.UpDownTrend))
            {
                float num4 = base.CalcDelta(this.fd, this.A, this.B, this.Bar1, this.Bar2, "H", true);
                float num5 = base.CalcDelta(this.fd, this.A, this.B, this.Bar1, this.Bar2, "L", false);
                if (this.regressionType == RegressionType.Channel)
                {
                    num3 = Math.Max(Math.Abs(num4), Math.Abs(num5));
                }
                else
                {
                    num3 = -num4;
                }
                if (this.upLine)
                {
                    this.AddLine(point, point2, num3);
                }
                if (this.regressionType != RegressionType.Channel)
                {
                    num3 = num5;
                }
                if (this.downLine)
                {
                    this.AddLine(point, point2, -num3);
                }
            }
            else if ((this.regressionType == RegressionType.StdChannel) || (this.regressionType == RegressionType.StdErrorChannel))
            {
                num3 = this.Std(this.regressionType == RegressionType.StdErrorChannel);
                this.AddLine(point, point2, num3);
                this.AddLine(point, point2, -num3);
            }
            base.pfStart = new PointF[this.scLines.Count];
            base.pfEnd   = new PointF[this.scLines.Count];
            for (int i = 0; i < this.scLines.Count; i++)
            {
                ObjectSegment segment = this.scLines[i];
                if (!double.IsNaN(segment.op1.Y) && !double.IsNaN(segment.op2.Y))
                {
                    base.pfStart[i] = base.ToPointF(segment.op1);
                    base.pfEnd[i]   = base.ToPointF(segment.op2);
                    if (this.openStart)
                    {
                        base.ExpandLine(ref base.pfEnd[i], ref base.pfStart[i]);
                    }
                    if (this.openEnd)
                    {
                        base.ExpandLine(ref base.pfStart[i], ref base.pfEnd[i]);
                    }
                }
                else
                {
                    base.pfStart[i] = PointF.Empty;
                    base.pfEnd[i]   = PointF.Empty;
                }
            }
        }
Exemplo n.º 14
0
 private void AddLine(ObjectPoint op1, ObjectPoint op2, float Delta)
 {
     op1.Y -= Delta * this.percentage;
     op2.Y -= Delta * this.percentage;
     this.scLines.Add(op1, op2);
 }
Exemplo n.º 15
0
        public void RestoreWay_WxH_10x5()
        {
            //  0   1   2   3   4   5   6   7   8   9   |
            //------------------------------------------+---
            //  a   '   '   x   '   '   '   '   '   '   | 0
            //  '   x   '   '   x   x   '   '   x   '   | 1
            //  '   x   x   x   '   '   '   x   x   '   | 2
            //  '   '   '   '   '   '   '   x   '   '   | 3
            //  '   x   '   x   '   '   x   '   b   x   | 4
            //------------------------------------------+---
            //  0   1   2   3   4   5   6   7   8   9   |
            //------------------------------------------+---
            //  a0  1   2   x   14  13  12  13  14  15  | 0
            //  1   x   3   4   x   x   11  12  x   16  | 1
            //  2   x   x   x   8   9   10  x   x   17  | 2
            //  3   4   5   6   7   8   9   x   19  18  | 3
            //  4   x   6   x   8   9   x   '   b20 x   | 4
            //------------------------------------------+---
            //  0   1   2   3   4   5   6   7   8   9   |
            WaveObject[,] area = new WaveObject[10, 5]
            {
                { new WaveObject(value: 0, type: ObjectType.StartPoint),            // -- 0,0
                  new WaveObject(value: 1, type: ObjectType.None),                  //    0,1
                  new WaveObject(value: 2, type: ObjectType.None),                  //    0,2
                  new WaveObject(value: 3, type: ObjectType.None),                  //    0,3
                  new WaveObject(value: 4, type: ObjectType.None) },                //    0,4
                { new WaveObject(value: 1, type: ObjectType.StartPoint),            // -- 1,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,1
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,2
                  new WaveObject(value: 4, type: ObjectType.None),                  //    1,3
                  new WaveObject(value: null, type: ObjectType.Block) },            //    2,4
                { new WaveObject(value: 2, type: ObjectType.None),                  // -- 2,0
                  new WaveObject(value: 3, type: ObjectType.None),                  //    2,1
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,2
                  new WaveObject(value: 5, type: ObjectType.None),                  //    2,3
                  new WaveObject(value: 6, type: ObjectType.None) },                //    2,4
                { new WaveObject(value: null, type: ObjectType.Block),              // -- 3,0
                  new WaveObject(value: 4, type: ObjectType.None),                  //    3,1
                  new WaveObject(value: null, type: ObjectType.Block),              //    3,2
                  new WaveObject(value: 6, type: ObjectType.None),                  //    3,3
                  new WaveObject(value: null, type: ObjectType.Block) },            //    3,4
                { new WaveObject(value: 14, type: ObjectType.None),                 // -- 4,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    4,1
                  new WaveObject(value: 8, type: ObjectType.None),                  //    4,2
                  new WaveObject(value: 7, type: ObjectType.None),                  //    4,3
                  new WaveObject(value: 8, type: ObjectType.None) },                //    4,4
                { new WaveObject(value: 13, type: ObjectType.None),                 // -- 5,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    5,1
                  new WaveObject(value: 9, type: ObjectType.None),                  //    5,2
                  new WaveObject(value: 8, type: ObjectType.None),                  //    5,3
                  new WaveObject(value: 9, type: ObjectType.None) },                //    5,4
                { new WaveObject(value: 12, type: ObjectType.None),                 // -- 6,0
                  new WaveObject(value: 11, type: ObjectType.None),                 //    6,1
                  new WaveObject(value: 10, type: ObjectType.None),                 //    6,2
                  new WaveObject(value: 9, type: ObjectType.None),                  //    6,3
                  new WaveObject(value: null, type: ObjectType.Block) },            //    6,4
                { new WaveObject(value: 13, type: ObjectType.None),                 // -- 7,0
                  new WaveObject(value: 12, type: ObjectType.None),                 //    7,1
                  new WaveObject(value: null, type: ObjectType.Block),              //    7,2
                  new WaveObject(value: null, type: ObjectType.Block),              //    7,3
                  new WaveObject(value: null, type: ObjectType.None) },             //    7,4
                { new WaveObject(value: 14, type: ObjectType.None),                 // -- 8,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    8,1
                  new WaveObject(value: null, type: ObjectType.Block),              //    8,2
                  new WaveObject(value: 19, type: ObjectType.None),                 //    8,3
                  new WaveObject(value: 20, type: ObjectType.EndPoint) },           //    8,4
                { new WaveObject(value: 15, type: ObjectType.None),                 // -- 9,0
                  new WaveObject(value: 16, type: ObjectType.None),                 //    9,1
                  new WaveObject(value: 17, type: ObjectType.None),                 //    9,2
                  new WaveObject(value: 18, type: ObjectType.None),                 //    9,3
                  new WaveObject(value: null, type: ObjectType.Block) }             //    9,4
            };
            //  0   1   2   3   4   5   6   7   8   9   |
            //------------------------------------------+---
            //  a0  1   2   x   14  13  12  13  14  15  | 0
            //  1   x   3   4   x   x   11  12  x   16  | 1
            //  2   x   x   x   8   9   10  x   x   17  | 2
            //  3   4   5   6   7   8   9   x   19  18  | 3
            //  4   x   6   x   8   9   x   '   b20 x   | 4
            //------------------------------------------+---
            //  0   1   2   3   4   5   6   7   8   9   |

            var startPoint = new ObjectPoint(0, 0, ObjectType.StartPoint);
            var endPoint   = new ObjectPoint(8, 4, ObjectType.EndPoint);

            // x,y
            // 1,0 -> 2,0 -> 3,0 -> 3,1 -> 3,2 -> 3,3 -> 3,4 -> 3,5
            List <ObjectPoint> expectedResult = new List <ObjectPoint>()
            {
                new ObjectPoint {
                    X = 0, Y = 1, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 0, Y = 2, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 0, Y = 3, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 1, Y = 3, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 2, Y = 3, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 3, Y = 3, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 4, Y = 3, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 5, Y = 3, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 6, Y = 3, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 6, Y = 2, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 6, Y = 1, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 7, Y = 1, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 7, Y = 0, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 8, Y = 0, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 9, Y = 0, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 9, Y = 1, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 9, Y = 2, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 9, Y = 3, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 8, Y = 3, Obj = ObjectType.None
                },
                new ObjectPoint {
                    X = 8, Y = 4, Obj = ObjectType.EndPoint
                }
            };

            List <ObjectPoint> path = WaveAlgLee.RestoreWay(area, startPoint, endPoint);

            if (path.Count == 0)
            {
                Assert.Fail("Result path list count 0 elements");
            }
            for (int i = 0; i < path.Count; i++)
            {
                Assert.AreEqual(expectedResult[i], path[i]);
            }
        }
Exemplo n.º 16
0
        public string ReplaceTag(ObjectPoint op, string s)
        {
            int num;

Label_0005:
            num = s.IndexOf('{');
            int index = s.IndexOf('}');

            if (index <= num)
            {
                return(s);
            }
            string str    = s.Substring(num + 1, (index - num) - 1);
            int    length = str.IndexOf(':');
            string format = "";
            string strA   = str;

            if (length > 0)
            {
                strA   = str.Substring(0, length);
                format = str.Substring(length + 1);
            }
            double[] dd   = this.Manager.Canvas.BackChart.DataProvider["DATE"];
            int      num4 = FormulaChart.FindIndex(dd, op.X);

            if (num4 >= dd.Length)
            {
                return(s);
            }
            if (string.Compare(strA, "D") == 0)
            {
                if (format == "")
                {
                    format = "yyyy-MM-dd";
                }
                strA = DateTime.FromOADate(dd[num4]).ToString(format);
                goto Label_01BA;
            }
            FormulaData objA = null;

            try
            {
                length = int.Parse(strA);
                if (length < this.Area.FormulaDataArray.Count)
                {
                    dd = this.Area.FormulaDataArray[length].Data;
                }
            }
            catch
            {
                objA = this.Area.FormulaDataArray[strA];
                if (object.Equals(objA, null))
                {
                    foreach (FormulaData data2 in this.Area.FormulaDataArray)
                    {
                        dd = data2[strA];
                        if (dd != null)
                        {
                            goto Label_018F;
                        }
                    }
                }
                else
                {
                    dd = objA.Data;
                }
            }
Label_018F:
            if (dd != null)
            {
                if (format == "")
                {
                    format = "f2";
                }
                strA = dd[num4].ToString(format);
            }
Label_01BA:
            s = s.Substring(0, num) + strA + s.Substring(index + 1);
            goto Label_0005;
        }
Exemplo n.º 17
0
 public bool InLineSegment(int X, int Y, ObjectPoint p1, ObjectPoint p2, int PenWidth)
 {
     return(this.InLineSegment(X, Y, this.ToPointF(p1), this.ToPointF(p2), PenWidth));
 }
Exemplo n.º 18
0
        /// <summary>
        /// Sets all neigbourvalues around a given point (in "his" rectangle) to zero
        /// </summary>
        /// <param name="neigbourmap"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="point"></param>
        private void SetPointsToZero(ref int[,,] neigbourmap, int width, int height, ObjectPoint point)
        {
            //Create Rectangle for point
            TRectangle workrectancle = new TRectangle(point.X, point.Y, point.RectSize, true,
                                                      new TRectangle(0, 0, width-1, height-1));

            //Set every neigbourvalue to 0
            for (int x = workrectancle.X; x <= workrectancle.X2; x++)
            {
                for (int y = workrectancle.Y; y <= workrectancle.Y2; y++)
                {
                    neigbourmap[x, y, 0] = 0;
                }
            }
        }
Exemplo n.º 19
0
        public void WavePropagation_WxH_5x10()
        {
            //  0   1   2   3   4   5   6   7   8   9   |
            //------------------------------------------+---
            //  a   '   '   x   '   '   '   '   '   '   | 0
            //  '   x   '   '   x   x   '   '   x   '   | 1
            //  '   x   x   x   '   '   '   x   x   '   | 2
            //  '   '   '   '   '   '   '   x   '   '   | 3
            //  '   x   '   x   '   '   x   '   b   x   | 4
            //------------------------------------------+---
            //  0   1   2   3   4   5   6   7   8   9   |
            WaveObject[,] area = new WaveObject[5, 10]
            {
                { new WaveObject(value: 0, type: ObjectType.StartPoint),            // -- 0,0
                  new WaveObject(value: null, type: ObjectType.None),               //    0,1
                  new WaveObject(value: null, type: ObjectType.None),               //    0,2
                  new WaveObject(value: null, type: ObjectType.Block),              //    0,3
                  new WaveObject(value: null, type: ObjectType.None),               //    0,4
                  new WaveObject(value: null, type: ObjectType.None),               //    0,5
                  new WaveObject(value: null, type: ObjectType.None),               //    0,6
                  new WaveObject(value: null, type: ObjectType.None),               //    0,7
                  new WaveObject(value: null, type: ObjectType.None),               //    0,8
                  new WaveObject(value: null, type: ObjectType.None) },             //    0,9
                { new WaveObject(value: null, type: ObjectType.None),               // -- 1,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,1
                  new WaveObject(value: null, type: ObjectType.None),               //    1,2
                  new WaveObject(value: null, type: ObjectType.None),               //    1,3
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,4
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,5
                  new WaveObject(value: null, type: ObjectType.None),               //    1,6
                  new WaveObject(value: null, type: ObjectType.None),               //    1,7
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,8
                  new WaveObject(value: null, type: ObjectType.None) },             //    1,9
                { new WaveObject(value: null, type: ObjectType.None),               // -- 2,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,1
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,2
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,3
                  new WaveObject(value: null, type: ObjectType.None),               //    2,4
                  new WaveObject(value: null, type: ObjectType.None),               //    2,5
                  new WaveObject(value: null, type: ObjectType.None),               //    2,6
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,7
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,8
                  new WaveObject(value: null, type: ObjectType.None) },             //    2,9
                { new WaveObject(value: null, type: ObjectType.None),               // -- 3,0
                  new WaveObject(value: null, type: ObjectType.None),               //    3,1
                  new WaveObject(value: null, type: ObjectType.None),               //    3,2
                  new WaveObject(value: null, type: ObjectType.None),               //    3,3
                  new WaveObject(value: null, type: ObjectType.None),               //    3,4
                  new WaveObject(value: null, type: ObjectType.None),               //    3,5
                  new WaveObject(value: null, type: ObjectType.None),               //    3,6
                  new WaveObject(value: null, type: ObjectType.Block),              //    3,7
                  new WaveObject(value: null, type: ObjectType.None),               //    3,8
                  new WaveObject(value: null, type: ObjectType.None) },             //    3,9
                { new WaveObject(value: null, type: ObjectType.None),               // -- 4,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    4,1
                  new WaveObject(value: null, type: ObjectType.None),               //    4,2
                  new WaveObject(value: null, type: ObjectType.Block),              //    4,3
                  new WaveObject(value: null, type: ObjectType.None),               //    4,4
                  new WaveObject(value: null, type: ObjectType.None),               //    4,5
                  new WaveObject(value: null, type: ObjectType.Block),              //    4,6
                  new WaveObject(value: null, type: ObjectType.None),               //    4,7
                  new WaveObject(value: null, type: ObjectType.EndPoint),           //    4,8
                  new WaveObject(value: null, type: ObjectType.Block) }             //    4,9
            };
            //  0   1   2   3   4   5   6   7   8   9   |
            //------------------------------------------+---
            //  a   '   '   x   '   '   '   '   '   '   | 0
            //  '   x   '   '   x   x   '   '   x   '   | 1
            //  '   x   x   x   '   '   '   x   x   '   | 2
            //  '   '   '   '   '   '   '   x   '   '   | 3
            //  '   x   '   x   '   '   x   '   b   x   | 4
            //------------------------------------------+---
            //  0   1   2   3   4   5   6   7   8   9   |

            var startPoint = new ObjectPoint(0, 0, ObjectType.StartPoint);
            var endPoint   = new ObjectPoint(4, 8, ObjectType.EndPoint);

            WaveAlgLee.WavePropagation(ref area, startPoint, endPoint, true);

            //  0   1   2   3   4   5   6   7   8   9   |
            //------------------------------------------+---
            //  a0  1   2   x   14  13  12  13  14  15  | 0
            //  1   x   3   4   x   x   11  12  x   16  | 1
            //  2   x   x   x   8   9   10  x   x   17  | 2
            //  3   4   5   6   7   8   9   x   19  18  | 3
            //  4   x   6   x   8   9   x   '   b20 x   | 4
            //------------------------------------------+---
            //  0   1   2   3   4   5   6   7   8   9   |
            WaveObject[,] expectedArea = new WaveObject[5, 10]
            {
                { new WaveObject(value: 0, type: ObjectType.StartPoint),            // -- 0,0
                  new WaveObject(value: 1, type: ObjectType.None),                  //    0,1
                  new WaveObject(value: 2, type: ObjectType.None),                  //    0,2
                  new WaveObject(value: null, type: ObjectType.Block),              //    0,3
                  new WaveObject(value: 14, type: ObjectType.None),                 //    0,4
                  new WaveObject(value: 13, type: ObjectType.None),                 //    0,5
                  new WaveObject(value: 12, type: ObjectType.None),                 //    0,6
                  new WaveObject(value: 13, type: ObjectType.None),                 //    0,7
                  new WaveObject(value: 14, type: ObjectType.None),                 //    0,8
                  new WaveObject(value: 15, type: ObjectType.None) },               //    0,9
                { new WaveObject(value: 1, type: ObjectType.None),                  // -- 1,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,1
                  new WaveObject(value: 3, type: ObjectType.None),                  //    1,2
                  new WaveObject(value: 4, type: ObjectType.None),                  //    1,3
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,4
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,5
                  new WaveObject(value: 11, type: ObjectType.None),                 //    1,6
                  new WaveObject(value: 12, type: ObjectType.None),                 //    1,7
                  new WaveObject(value: null, type: ObjectType.Block),              //    1,8
                  new WaveObject(value: 16, type: ObjectType.None) },               //    1,9
                { new WaveObject(value: 2, type: ObjectType.None),                  // -- 2,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,1
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,2
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,3
                  new WaveObject(value: 8, type: ObjectType.None),                  //    2,4
                  new WaveObject(value: 9, type: ObjectType.None),                  //    2,5
                  new WaveObject(value: 10, type: ObjectType.None),                 //    2,6
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,7
                  new WaveObject(value: null, type: ObjectType.Block),              //    2,8
                  new WaveObject(value: 17, type: ObjectType.None) },               //    2,9
                { new WaveObject(value: 3, type: ObjectType.None),                  // -- 3,0
                  new WaveObject(value: 4, type: ObjectType.None),                  //    3,1
                  new WaveObject(value: 5, type: ObjectType.None),                  //    3,2
                  new WaveObject(value: 6, type: ObjectType.None),                  //    3,3
                  new WaveObject(value: 7, type: ObjectType.None),                  //    3,4
                  new WaveObject(value: 8, type: ObjectType.None),                  //    3,5
                  new WaveObject(value: 9, type: ObjectType.None),                  //    3,6
                  new WaveObject(value: null, type: ObjectType.Block),              //    3,7
                  new WaveObject(value: 19, type: ObjectType.None),                 //    3,8
                  new WaveObject(value: 18, type: ObjectType.None) },               //    3,9
                { new WaveObject(value: 4, type: ObjectType.None),                  // -- 4,0
                  new WaveObject(value: null, type: ObjectType.Block),              //    4,1
                  new WaveObject(value: 6, type: ObjectType.None),                  //    4,2
                  new WaveObject(value: null, type: ObjectType.Block),              //    4,3
                  new WaveObject(value: 8, type: ObjectType.None),                  //    4,4
                  new WaveObject(value: 9, type: ObjectType.None),                  //    4,5
                  new WaveObject(value: null, type: ObjectType.Block),              //    4,6
                  new WaveObject(value: null, type: ObjectType.None),               //    4,7
                  new WaveObject(value: 20, type: ObjectType.EndPoint),             //    4,8
                  new WaveObject(value: null, type: ObjectType.Block) }             //    4,9
            };
            //  0   1   2   3   4   5   6   7   8   9   | Y/X
            //------------------------------------------+---
            //  a0  1   2   x   14  13  12  13  14  15  | 0 (X)
            //  1   x   3   4   x   x   11  12  x   16  | 1
            //  2   x   x   x   8   9   10  x   x   17  | 2
            //  3   4   5   6   7   8   9   x   19  18  | 3
            //  4   x   6   x   8   9   x   '   b20 x   | 4
            //------------------------------------------+---
            //  0   1   2   3   4   5   6   7   8   9   | Y/X

            int arrayHeight = area.GetUpperBound(1) + 1;

            if (arrayHeight > 0 && area.Length > 0)
            {
                int arrayWidth = area.Length / arrayHeight;
                for (int x = 0; x < arrayWidth; x++)
                {
                    for (int y = 0; y < arrayHeight; y++)
                    {
                        Assert.AreEqual(expectedArea[x, y], area[x, y]);
                    }
                }
            }
            else
            {
                Assert.Fail("Array length or height was 0");
            }
        }
Exemplo n.º 20
0
 public ObjectSegment(ObjectPoint op1, ObjectPoint op2)
 {
     this.op1 = op1;
     this.op2 = op2;
 }