public void HasChanged() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); long changeNum = 0; Assert.IsTrue(changeNum < eventDB.ChangeNum); changeNum = eventDB.ChangeNum; undomgr.BeginCommand(61, "Command1"); ControlPoint ctl1 = new ControlPoint(ControlPointKind.Start, null, new PointF(5, 0)); ctl1.symbolIds[1] = "2.8"; ctl1.symbolIds[2] = "8.5"; eventDB.AddControlPoint(ctl1); undomgr.EndCommand(61); Assert.IsTrue(changeNum < eventDB.ChangeNum); changeNum = eventDB.ChangeNum; eventDB = new EventDB(undomgr); Assert.IsTrue(changeNum != eventDB.ChangeNum); changeNum = eventDB.ChangeNum; eventDB = new EventDB(undomgr); Assert.IsTrue(changeNum != eventDB.ChangeNum); changeNum = eventDB.ChangeNum; }
public void RoundTripLeg() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); Leg leg1, leg2, leg3, leg4, leg5, leg6; ControlPoint ctl1, ctl2; Id <ControlPoint> ctlId1, ctlId2; undomgr.BeginCommand(81, "Command1"); ctl1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(10, 10)); ctl1.symbolIds[0] = "0.3"; ctl1.symbolIds[1] = "2.4"; ctl1.columnFText = "2m"; ctlId1 = eventDB.AddControlPoint(ctl1); ctl2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(20, -10.5F)); ctl2.symbolIds[1] = "3.7"; ctl2.symbolIds[5] = "12.1"; ctl2.gaps = new Dictionary <int, CircleGap[]>(); ctl2.gaps.Add(15000, CircleGap.ComputeCircleGaps(0xFFFFFFDF)); ctl2.gaps.Add(10000, CircleGap.ComputeCircleGaps(0xFF00FFFF)); ctl2.descriptionText = "very marshy spot"; ctlId2 = eventDB.AddControlPoint(ctl2); leg1 = new Leg(ctlId1, ctlId2); eventDB.AddLeg(leg1); leg2 = new Leg(ctlId1, ctlId2); leg2.flagging = FlaggingKind.All; eventDB.AddLeg(leg2); leg3 = new Leg(ctlId1, ctlId2); leg3.flagging = FlaggingKind.Begin; leg3.flagStartStop = new PointF(5, -7.5F); leg3.bends = new PointF[2] { leg3.flagStartStop, new PointF(17, 6) }; eventDB.AddLeg(leg3); leg4 = new Leg(ctlId1, ctlId2); leg4.flagging = FlaggingKind.End; leg4.flagStartStop = new PointF(5, -7.5F); leg4.bends = new PointF[1] { leg4.flagStartStop }; leg4.gaps = new LegGap[2] { new LegGap(2, 0.3F), new LegGap(3.4F, 0.4F) }; eventDB.AddLeg(leg4); leg5 = new Leg(ctlId1, ctlId2); leg5.gaps = new LegGap[3] { new LegGap(0.9F, 0.3F), new LegGap(3.4F, 0.4F), new LegGap(4.5F, 1.1F) }; eventDB.AddLeg(leg5); leg6 = new Leg(ctlId1, ctlId2); leg6.flagging = FlaggingKind.IssuePointMiddle; leg6.flagStartStop = new PointF(5, -7.5F); leg6.bends = new PointF[1] { leg6.flagStartStop }; eventDB.AddLeg(leg6); undomgr.EndCommand(81); eventDB.Validate(); eventDB.Save(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml")); undomgr.Clear(); eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml")); eventDB.Validate(); TestUtil.TestEnumerableAnyOrder(eventDB.AllLegPairs, new KeyValuePair <Id <Leg>, Leg>[] { new KeyValuePair <Id <Leg>, Leg>(LegId(1), leg1), new KeyValuePair <Id <Leg>, Leg>(LegId(2), leg2), new KeyValuePair <Id <Leg>, Leg>(LegId(3), leg3), new KeyValuePair <Id <Leg>, Leg>(LegId(4), leg4), new KeyValuePair <Id <Leg>, Leg>(LegId(5), leg5), new KeyValuePair <Id <Leg>, Leg>(LegId(6), leg6) } ); }
public void RoundTripControlPoints() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); ControlPoint ctl1, ctl2, ctl3, ctl4, ctl5, ctl6, ctl7, ctl8, ctl9, ctl10, ctl11; undomgr.BeginCommand(61, "Command1"); ctl1 = new ControlPoint(ControlPointKind.Start, null, new PointF(5, 0)); ctl1.symbolIds[1] = "2.8"; ctl1.symbolIds[2] = "8.5"; eventDB.AddControlPoint(ctl1); ctl2 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(10, 10)); ctl2.symbolIds[0] = "0.3"; ctl2.symbolIds[1] = "2.4"; ctl2.columnFText = "2m"; ctl2.customCodeLocation = true; ctl2.codeLocationAngle = 97F; eventDB.AddControlPoint(ctl2); ctl3 = new ControlPoint(ControlPointKind.CrossingPoint, null, new PointF(13, -7.8F)); ctl3.symbolIds[0] = "13.2"; ctl3.orientation = 94.5F; eventDB.AddControlPoint(ctl3); ctl4 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(20, -10.5F)); ctl4.symbolIds[1] = "3.7"; ctl4.symbolIds[5] = "12.1"; ctl4.gaps = new Dictionary <int, CircleGap[]>(); ctl4.gaps.Add(15000, CircleGap.ComputeCircleGaps(0xFFFFFFDF)); ctl4.gaps.Add(10000, CircleGap.ComputeCircleGaps(0xFF00FFFF)); ctl4.descriptionText = "very marshy spot"; ctl4.punches = new PunchPattern(); ctl4.punches.size = 9; ctl4.punches.dots = new bool[ctl4.punches.size, ctl4.punches.size]; ctl4.punches.dots[0, 0] = true; ctl4.punches.dots[4, 4] = true; ctl4.punches.dots[8, 8] = true; ctl4.punches.dots[8, 0] = true; eventDB.AddControlPoint(ctl4); ctl5 = new ControlPoint(ControlPointKind.Normal, "GO", new PointF(35.4F, -22.5F)); ctl5.symbolIds[0] = "0.1N"; ctl5.symbolIds[1] = "5.5"; ctl5.symbolIds[2] = "5.2"; ctl5.symbolIds[3] = "10.1"; ctl5.symbolIds[4] = "11.1N"; ctl5.symbolIds[5] = "12.3"; eventDB.AddControlPoint(ctl5); ctl6 = new ControlPoint(ControlPointKind.Finish, null, new PointF(30.3F, -27.11F)); ctl6.symbolIds[0] = "14.2"; eventDB.AddControlPoint(ctl6); ctl7 = new ControlPoint(ControlPointKind.Normal, "QX", new PointF(43, 7.1F)); ctl7.symbolIds[1] = "3.6"; ctl7.descTextBefore = "hi there"; ctl7.descTextAfter = "bye there"; eventDB.AddControlPoint(ctl7); ctl8 = new ControlPoint(ControlPointKind.MapExchange, null, new PointF(133, 7.8F)); ctl8.symbolIds[0] = "13.5"; eventDB.AddControlPoint(ctl8); ctl9 = new ControlPoint(ControlPointKind.MapIssue, null, new PointF(40.3F, -7.11F)); ctl9.symbolIds[0] = "13.6"; ctl9.mapIssueKind = MapIssueKind.Beginning; eventDB.AddControlPoint(ctl9); ctl10 = new ControlPoint(ControlPointKind.MapIssue, null, new PointF(-17.2F, 7.01F)); ctl10.symbolIds[0] = "13.6"; ctl10.mapIssueKind = MapIssueKind.Middle; eventDB.AddControlPoint(ctl10); ctl11 = new ControlPoint(ControlPointKind.MapIssue, null, new PointF(1.3F, 14.5F)); ctl11.symbolIds[0] = "13.6"; ctl11.mapIssueKind = MapIssueKind.End; eventDB.AddControlPoint(ctl11); undomgr.EndCommand(61); eventDB.Save(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml")); undomgr.Clear(); eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml")); TestUtil.TestEnumerableAnyOrder(eventDB.AllControlPointPairs, new KeyValuePair <Id <ControlPoint>, ControlPoint>[] { new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(1), ctl1), new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(2), ctl2), new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(3), ctl3), new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(4), ctl4), new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(5), ctl5), new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(6), ctl6), new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(7), ctl7), new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(8), ctl8), new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(9), ctl9), new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(10), ctl10), new KeyValuePair <Id <ControlPoint>, ControlPoint>(ControlId(11), ctl11) } ); }
public void ComputeLegLengthBends() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); ControlPoint control1, control2; Leg leg1; Event ev = new Event(); control1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(4.5F, -10.1F)); control2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(-6.8F, 14.1F)); undomgr.BeginCommand(123, "Add controls"); Id<ControlPoint> id1 = eventDB.AddControlPoint(control1); Id<ControlPoint> id2 = eventDB.AddControlPoint(control2); leg1 = new Leg(id1, id2); leg1.bends = new PointF[] { new PointF(7, 8), new PointF(10, 14) }; Id<Leg> legId = eventDB.AddLeg(leg1); ev.mapScale = 15000; eventDB.ChangeEvent(ev); undomgr.EndCommand(123); float length = QueryEvent.ComputeLegLength(eventDB, id1, id2, legId); Assert.AreEqual(626.7, length, 0.01); SymPath path = QueryEvent.GetLegPath(eventDB, id1, id2); Assert.AreEqual(new SymPath(new PointF[] { new PointF(4.5F, -10.1F), new PointF(7, 8), new PointF(10, 14), new PointF(-6.8F, 14.1F) }), path); }
public void ComputeStraightLineControlDistance() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); ControlPoint control1, control2, control3; Leg leg1; Event ev = new Event(); control1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(4.5F, -10.1F)); control2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(-6.8F, 14.1F)); control3 = new ControlPoint(ControlPointKind.Normal, "33", new PointF(-12.8F, 32.9F)); undomgr.BeginCommand(123, "Add controls"); Id<ControlPoint> id1 = eventDB.AddControlPoint(control1); Id<ControlPoint> id2 = eventDB.AddControlPoint(control2); Id<ControlPoint> id3 = eventDB.AddControlPoint(control3); leg1 = new Leg(id1, id2); leg1.bends = new PointF[] { new PointF(7, 8), new PointF(10, 14) }; Id<Leg> legId = eventDB.AddLeg(leg1); ev.mapScale = 15000; eventDB.ChangeEvent(ev); undomgr.EndCommand(123); float length = QueryEvent.ComputeStraightLineControlDistance(eventDB, id1, id2); Assert.AreEqual(400.62F, length, 0.01F); // Doesn't take bend in leg into account! length = QueryEvent.ComputeStraightLineControlDistance(eventDB, id3, id2); Assert.AreEqual(296.01F, length, 0.01F); }
public void FindLeg() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); ControlPoint control1, control2, control3, control4; Leg leg1, leg2; Id<Leg> legId1, legId2; Event ev = new Event(); control1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(4.5F, -10.1F)); control2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(-6.8F, 14.1F)); control3 = new ControlPoint(ControlPointKind.Normal, "33", new PointF(5F, 19F)); control4 = new ControlPoint(ControlPointKind.Normal, "34", new PointF(18F, 1F)); undomgr.BeginCommand(124, "Add controls"); Id<ControlPoint> id1 = eventDB.AddControlPoint(control1); Id<ControlPoint> id2 = eventDB.AddControlPoint(control2); Id<ControlPoint> id3 = eventDB.AddControlPoint(control3); Id<ControlPoint> id4 = eventDB.AddControlPoint(control4); leg1 = new Leg(id1, id2); legId1 = eventDB.AddLeg(leg1); leg2 = new Leg(id4, id2); legId2 = eventDB.AddLeg(leg2); undomgr.EndCommand(124); Id<Leg> result = QueryEvent.FindLeg(eventDB, id1, id3); Assert.IsTrue(result.IsNone); result = QueryEvent.FindLeg(eventDB, id2, id1); Assert.IsTrue(result.IsNone); result = QueryEvent.FindLeg(eventDB, id3, id2); Assert.IsTrue(result.IsNone); result = QueryEvent.FindLeg(eventDB, id1, id2); Assert.IsTrue(result == legId1); result = QueryEvent.FindLeg(eventDB, id4, id2); Assert.IsTrue(result == legId2); }
public void ComputeFlaggedLegLength() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); ControlPoint control1, control2; Leg leg1; Event ev = new Event(); control1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(4F, -10F)); control2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(-3F, 14F)); undomgr.BeginCommand(123, "Add controls"); Id<ControlPoint> id1 = eventDB.AddControlPoint(control1); Id<ControlPoint> id2 = eventDB.AddControlPoint(control2); leg1 = new Leg(id1, id2); leg1.bends = new PointF[] { new PointF(6, 3), new PointF(7, 8), new PointF(10, 14) }; Id<Leg> legId = eventDB.AddLeg(leg1); // distances. 13.153, 5.099, 6.708, 13.00 * 15000 ev.mapScale = 15000; eventDB.ChangeEvent(ev); undomgr.EndCommand(123); float length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId); Assert.AreEqual(569.4, length, 0.01); undomgr.BeginCommand(123, "Change leg"); leg1.flagging = FlaggingKind.All; eventDB.ReplaceLeg(legId, leg1); undomgr.EndCommand(123); length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId); Assert.AreEqual(569.4, length, 0.01); undomgr.BeginCommand(123, "Change leg"); leg1.flagging = FlaggingKind.Begin; leg1.flagStartStop = new PointF(7, 8); eventDB.ReplaceLeg(legId, leg1); undomgr.EndCommand(123); length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId); Assert.AreEqual(273.78, length, 0.01); undomgr.BeginCommand(123, "Change leg"); leg1.flagging = FlaggingKind.End; eventDB.ReplaceLeg(legId, leg1); undomgr.EndCommand(123); length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId); Assert.AreEqual(295.62, length, 0.01); }
public void RoundTripLeg() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); Leg leg1, leg2, leg3, leg4, leg5; ControlPoint ctl1, ctl2; Id<ControlPoint> ctlId1, ctlId2; undomgr.BeginCommand(81, "Command1"); ctl1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(10, 10)); ctl1.symbolIds[0] = "0.3"; ctl1.symbolIds[1] = "2.4"; ctl1.columnFText = "2m"; ctlId1 = eventDB.AddControlPoint(ctl1); ctl2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(20, -10.5F)); ctl2.symbolIds[1] = "3.7"; ctl2.symbolIds[5] = "12.1"; ctl2.gaps = new Dictionary<int, CircleGap[]>(); ctl2.gaps.Add(15000, CircleGap.ComputeCircleGaps(0xFFFFFFDF)); ctl2.gaps.Add(10000, CircleGap.ComputeCircleGaps(0xFF00FFFF)); ctl2.descriptionText = "very marshy spot"; ctlId2 = eventDB.AddControlPoint(ctl2); leg1 = new Leg(ctlId1, ctlId2); eventDB.AddLeg(leg1); leg2 = new Leg(ctlId1, ctlId2); leg2.flagging = FlaggingKind.All; eventDB.AddLeg(leg2); leg3 = new Leg(ctlId1, ctlId2); leg3.flagging = FlaggingKind.Begin; leg3.flagStartStop = new PointF(5, -7.5F); leg3.bends = new PointF[2] { leg3.flagStartStop, new PointF(17, 6) }; eventDB.AddLeg(leg3); leg4 = new Leg(ctlId1, ctlId2); leg4.flagging = FlaggingKind.End; leg4.flagStartStop = new PointF(5, -7.5F); leg4.bends = new PointF[1] { leg4.flagStartStop }; leg4.gaps = new LegGap[2] { new LegGap(2, 0.3F), new LegGap(3.4F, 0.4F)}; eventDB.AddLeg(leg4); leg5 = new Leg(ctlId1, ctlId2); leg5.gaps = new LegGap[3] { new LegGap(0.9F, 0.3F), new LegGap(3.4F, 0.4F), new LegGap(4.5F, 1.1F) }; eventDB.AddLeg(leg5); undomgr.EndCommand(81); eventDB.Validate(); eventDB.Save(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml")); undomgr.Clear(); eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml")); eventDB.Validate(); TestUtil.TestEnumerableAnyOrder(eventDB.AllLegPairs, new KeyValuePair<Id<Leg>, Leg>[] { new KeyValuePair<Id<Leg>,Leg>(LegId(1), leg1), new KeyValuePair<Id<Leg>,Leg>(LegId(2), leg2), new KeyValuePair<Id<Leg>,Leg>(LegId(3), leg3), new KeyValuePair<Id<Leg>,Leg>(LegId(4), leg4), new KeyValuePair<Id<Leg>,Leg>(LegId(5), leg5) } ); }
public void RoundTripControlPoints() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); ControlPoint ctl1, ctl2, ctl3, ctl4, ctl5, ctl6, ctl7, ctl8; undomgr.BeginCommand(61, "Command1"); ctl1 = new ControlPoint(ControlPointKind.Start, null, new PointF(5, 0)); ctl1.symbolIds[1] = "2.8"; ctl1.symbolIds[2] = "8.5"; eventDB.AddControlPoint(ctl1); ctl2 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(10, 10)); ctl2.symbolIds[0] = "0.3"; ctl2.symbolIds[1] = "2.4"; ctl2.columnFText = "2m"; ctl2.customCodeLocation = true; ctl2.codeLocationAngle = 97F; eventDB.AddControlPoint(ctl2); ctl3 = new ControlPoint(ControlPointKind.CrossingPoint, null, new PointF(13, -7.8F)); ctl3.symbolIds[0] = "13.2"; ctl3.orientation = 94.5F; eventDB.AddControlPoint(ctl3); ctl4 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(20, -10.5F)); ctl4.symbolIds[1] = "3.7"; ctl4.symbolIds[5] = "12.1"; ctl4.gaps = new Dictionary<int,CircleGap[]>(); ctl4.gaps.Add(15000, CircleGap.ComputeCircleGaps(0xFFFFFFDF)); ctl4.gaps.Add(10000, CircleGap.ComputeCircleGaps(0xFF00FFFF)); ctl4.descriptionText = "very marshy spot"; ctl4.punches = new PunchPattern(); ctl4.punches.size = 9; ctl4.punches.dots = new bool[ctl4.punches.size, ctl4.punches.size]; ctl4.punches.dots[0, 0] = true; ctl4.punches.dots[4, 4] = true; ctl4.punches.dots[8, 8] = true; ctl4.punches.dots[8, 0] = true; eventDB.AddControlPoint(ctl4); ctl5 = new ControlPoint(ControlPointKind.Normal, "GO", new PointF(35.4F, -22.5F)); ctl5.symbolIds[0] = "0.1N"; ctl5.symbolIds[1] = "5.5"; ctl5.symbolIds[2] = "5.2"; ctl5.symbolIds[3] = "10.1"; ctl5.symbolIds[4] = "11.1N"; ctl5.symbolIds[5] = "12.3"; eventDB.AddControlPoint(ctl5); ctl6 = new ControlPoint(ControlPointKind.Finish, null, new PointF(30.3F, -27.11F)); ctl6.symbolIds[0] = "14.2"; eventDB.AddControlPoint(ctl6); ctl7 = new ControlPoint(ControlPointKind.Normal, "QX", new PointF(43, 7.1F)); ctl7.symbolIds[1] = "3.6"; ctl7.descTextBefore = "hi there"; ctl7.descTextAfter = "bye there"; eventDB.AddControlPoint(ctl7); ctl8 = new ControlPoint(ControlPointKind.MapExchange, null, new PointF(133, 7.8F)); ctl8.symbolIds[0] = "13.5"; eventDB.AddControlPoint(ctl8); undomgr.EndCommand(61); eventDB.Save(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml")); undomgr.Clear(); eventDB = new EventDB(undomgr); eventDB.Load(TestUtil.GetTestFile("eventdb\\testoutput_temp.xml")); TestUtil.TestEnumerableAnyOrder(eventDB.AllControlPointPairs, new KeyValuePair<Id<ControlPoint>, ControlPoint>[] { new KeyValuePair<Id<ControlPoint>,ControlPoint>(ControlId(1), ctl1), new KeyValuePair<Id<ControlPoint>,ControlPoint>(ControlId(2), ctl2), new KeyValuePair<Id<ControlPoint>,ControlPoint>(ControlId(3), ctl3), new KeyValuePair<Id<ControlPoint>,ControlPoint>(ControlId(4), ctl4), new KeyValuePair<Id<ControlPoint>,ControlPoint>(ControlId(5), ctl5), new KeyValuePair<Id<ControlPoint>,ControlPoint>(ControlId(6), ctl6), new KeyValuePair<Id<ControlPoint>,ControlPoint>(ControlId(7), ctl7), new KeyValuePair<Id<ControlPoint>,ControlPoint>(ControlId(8), ctl8) } ); }
public void AutoRenumber2() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); Event ev = new Event(); Id<ControlPoint>[] ids = new Id<ControlPoint>[10]; undomgr.BeginCommand(123, "Add controls"); ids[0] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "64", new PointF())); //64 ids[1] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "69", new PointF())); //69 ids[2] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "67", new PointF())); //67 ids[3] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "71", new PointF())); //71 ids[4] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "73", new PointF())); //65 ids[5] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "61", new PointF())); //62 ids[6] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "66", new PointF())); //63 ids[7] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "60", new PointF())); //60 ids[8] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "70", new PointF())); //70 ev.mapScale = 15000; ev.firstControlCode = 60; ev.disallowInvertibleCodes = true; eventDB.ChangeEvent(ev); ChangeEvent.AutoRenumberControls(eventDB); undomgr.EndCommand(123); Assert.AreEqual("64", eventDB.GetControl(ids[0]).code); Assert.AreEqual("69", eventDB.GetControl(ids[1]).code); Assert.AreEqual("67", eventDB.GetControl(ids[2]).code); Assert.AreEqual("71", eventDB.GetControl(ids[3]).code); Assert.AreEqual("65", eventDB.GetControl(ids[4]).code); Assert.AreEqual("62", eventDB.GetControl(ids[5]).code); Assert.AreEqual("63", eventDB.GetControl(ids[6]).code); Assert.AreEqual("60", eventDB.GetControl(ids[7]).code); Assert.AreEqual("70", eventDB.GetControl(ids[8]).code); }
public void AutoRenumber() { UndoMgr undomgr = new UndoMgr(5); EventDB eventDB = new EventDB(undomgr); Event ev = new Event(); Id<ControlPoint>[] ids = new Id<ControlPoint>[10]; undomgr.BeginCommand(123, "Add controls"); ids[0] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "36", new PointF())); //36 ids[1] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "33", new PointF())); //33 ids[2] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "AB", new PointF())); //40 ids[3] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "34", new PointF())); //34 ids[4] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "31", new PointF())); //35 ids[5] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "51", new PointF())); //39 ids[6] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "37", new PointF())); //37 ids[7] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "38", new PointF())); //38 ids[8] = eventDB.AddControlPoint(new ControlPoint(ControlPointKind.Normal, "FA", new PointF())); //41 ev.mapScale = 15000; ev.firstControlCode = 33; ev.disallowInvertibleCodes = false; eventDB.ChangeEvent(ev); ChangeEvent.AutoRenumberControls(eventDB); undomgr.EndCommand(123); Assert.AreEqual("36", eventDB.GetControl(ids[0]).code); Assert.AreEqual("33", eventDB.GetControl(ids[1]).code); Assert.AreEqual("40", eventDB.GetControl(ids[2]).code); Assert.AreEqual("34", eventDB.GetControl(ids[3]).code); Assert.AreEqual("35", eventDB.GetControl(ids[4]).code); Assert.AreEqual("39", eventDB.GetControl(ids[5]).code); Assert.AreEqual("37", eventDB.GetControl(ids[6]).code); Assert.AreEqual("38", eventDB.GetControl(ids[7]).code); Assert.AreEqual("41", eventDB.GetControl(ids[8]).code); }