internal static ShapeCollection CreateForSlide(SlidePart slidePart, SCSlide slide) { var phService = new PlaceholderService(slidePart.SlideLayoutPart); var transformFactory = new LocationParser(phService); var geometryFactory = new GeometryFactory(phService); var shapeContextBuilder = new ShapeContext.Builder(slidePart); var chartGrFrameHandler = new ChartGraphicFrameHandler(); var tableGrFrameHandler = new TableGraphicFrameHandler(shapeContextBuilder, transformFactory); var oleGrFrameHandler = new OleGraphicFrameHandler(shapeContextBuilder, transformFactory); var pShapeHandler = new AutoShapeCreator(shapeContextBuilder, transformFactory); var pictureHandler = new PictureHandler(shapeContextBuilder, transformFactory, geometryFactory); var sdkGroupShapeHandler = new PGroupShapeHandler(shapeContextBuilder, transformFactory, geometryFactory, slidePart); pShapeHandler.Successor = sdkGroupShapeHandler; sdkGroupShapeHandler.Successor = oleGrFrameHandler; oleGrFrameHandler.Successor = pictureHandler; pictureHandler.Successor = chartGrFrameHandler; chartGrFrameHandler.Successor = tableGrFrameHandler; P.ShapeTree shapeTree = slidePart.Slide.CommonSlideData.ShapeTree; var shapes = new List <IShape>(shapeTree.Count()); foreach (OpenXmlCompositeElement compositeElement in shapeTree.OfType <OpenXmlCompositeElement>()) { IShape shape = pShapeHandler.Create(compositeElement, slide); if (shape != null) { shapes.Add(shape); } } return(new ShapeCollection(shapes)); }
public PictureHandler(ShapeContext.Builder shapeContextBuilder, LocationParser transformFactory, IGeometryFactory geometryFactory, SlidePart sdkSldPart) : this(shapeContextBuilder, transformFactory, geometryFactory, sdkSldPart, new ShapeEx.Builder()) { }
public frmLocationEditor(List <Location> Locations, MapParser MapParser, LocationParser LocParser) { this.Locations = Locations; this.MapParser = MapParser; this.LocParser = LocParser; InitializeComponent(); }
public void CanParseAStartingLocation(string startingLocation) { var locationParser = new LocationParser(); RobotVector location = locationParser.Parse(startingLocation); Assert.That(location.ToString(), Is.EqualTo(startingLocation)); }
public OleGraphicFrameHandler(ShapeContext.Builder shapeContextBuilder, LocationParser transformFactory, IShapeBuilder shapeBuilder) { _shapeContextBuilder = shapeContextBuilder ?? throw new ArgumentNullException(nameof(shapeContextBuilder));; _transformFactory = transformFactory ?? throw new ArgumentNullException(nameof(transformFactory)); _shapeBuilder = shapeBuilder ?? throw new ArgumentNullException(nameof(shapeBuilder)); }
public void TestFunctions(string input, Function function) { var target = new LocationParser(); var result = target.Parse(input, out var message); Assert.IsNull(message); Assert.AreEqual(function, result.Functions[0]); }
public void TestRemarks(string input, string remarks) { var target = new LocationParser(); var result = target.Parse(input, out var message); Assert.IsNull(message); Assert.AreEqual(remarks, result.Remarks); }
public void TestChangeDetails(string input, ChangeDetails changeDetails) { var target = new LocationParser(); var result = target.Parse(input, out var message); Assert.IsNull(message); Assert.AreEqual(changeDetails, result.ChangeDetails[0]); }
//TODO: inject interface instead public SdkShapeHandler(ShapeContext.Builder shapeContextBuilder, LocationParser transformFactory, IGeometryFactory geometryFactory, IShapeBuilder shapeBuilder) { _shapeContextBuilder = shapeContextBuilder ?? throw new ArgumentNullException(nameof(shapeContextBuilder)); _transformFactory = transformFactory ?? throw new ArgumentNullException(nameof(transformFactory)); _geometryFactory = geometryFactory ?? throw new ArgumentNullException(nameof(geometryFactory)); _shapeBuilder = shapeBuilder ?? throw new ArgumentNullException(nameof(shapeBuilder)); }
public void TestChangeReason(string input, ChangeReason changeReason) { var target = new LocationParser(); var result = target.Parse(input, out var message); Assert.IsNull(message); Assert.AreEqual(changeReason, result.ChangeReason); Assert.IsTrue(result.ChangeDetails.Length == 0); }
public void TestInvalidChangeReason() { const string input = "\"P\",\"AE\",\"HAT\",\"Hatta\",\"Hatta\",\"DU\",\"--3-----\",\"RL\",\"1707\",,\"2447N 05607E\","; var target = new LocationParser(); var result = target.Parse(input, out var message); Assert.AreEqual(ChangeReason.None, result.ChangeReason); Assert.AreEqual("Invalid change reason: P", message); }
public frmEditLocation(Location Loc, MapParser MapParser, LocationParser LocParser, bool NewLoc) { this.NewLoc = NewLoc; this.MapParser = MapParser; this.LocParser = LocParser; this.Loc = Loc; if (Loc != null) { LoadedPid = Loc.Pid; } InitializeComponent(); toolTip = new ToolTip(); toolTip.SetToolTip(lblName, "Internal name, used to generate define (for _maps.fos)"); toolTip.SetToolTip(lblWmName, "Worldmap name, shown in-game on the worldmap."); }
/// <summary> /// Create a new instance of <see cref="UnlocLoader"/>. /// </summary> public UnlocLoader() { var locationParser = new LocationParser(); _countryLoader = new CountryLoader(); _locationLoader = new LocationLoader(locationParser); _fileDownloader = new FileDownloader(); _countryLoader.OnInfo += (sender, s) => OnInfo?.Invoke(sender, s); _countryLoader.OnWarn += (sender, s) => OnWarn?.Invoke(sender, s); _countryLoader.OnTrace += (sender, s) => OnTrace?.Invoke(sender, s); _locationLoader.OnInfo += (sender, s) => OnInfo?.Invoke(sender, s); _locationLoader.OnWarn += (sender, s) => OnWarn?.Invoke(sender, s); _locationLoader.OnTrace += (sender, s) => OnTrace?.Invoke(sender, s); }
public void TestCombinedChangeDetails() { const string input = ",\"AE\",\"HAT\",\"Hatta\",\"Hatta\",\"DU\",\"--3-----\",\"RL\",\"1707\",,\"2447N 05607E\",\"@Coo@Fun@Nam\""; var target = new LocationParser(); var result = target.Parse(input, out var message); Assert.IsNull(message); Assert.IsTrue(result.ChangeDetails.Length == 3); Assert.IsTrue(result.ChangeDetails.Any(d => d == ChangeDetails.Coordinates)); Assert.IsTrue(result.ChangeDetails.Any(d => d == ChangeDetails.Function)); Assert.IsTrue(result.ChangeDetails.Any(d => d == ChangeDetails.LocationName)); Assert.IsTrue(result.ChangeDetails.All(d => d != ChangeDetails.SpellingName)); Assert.IsTrue(result.ChangeDetails.All(d => d != ChangeDetails.SubdivisionCode)); Assert.IsTrue(result.ChangeDetails.All(d => d != ChangeDetails.Status)); }
public void TestCombinedFunctions() { const string input = ",\"AE\",\"HAT\",\"Hatta\",\"Hatta\",\"DU\",\"1-3-5-7-\",\"RL\",\"1707\",,\"2447N 05607E\",\"@Coo@Fun@Nam\""; var target = new LocationParser(); var result = target.Parse(input, out var message); Assert.IsNull(message); Assert.IsTrue(result.ChangeDetails.Length == 3); Assert.IsTrue(result.Functions.Any(d => d == Function.Port)); Assert.IsTrue(result.Functions.Any(d => d == Function.RoadTerminal)); Assert.IsTrue(result.Functions.Any(d => d == Function.PostalExchangeOffice)); Assert.IsTrue(result.Functions.Any(d => d == Function.FixedTransportFunction)); Assert.IsTrue(result.Functions.All(d => d != Function.RailTerminal)); Assert.IsTrue(result.Functions.All(d => d != Function.Airport)); Assert.IsTrue(result.Functions.All(d => d != Function.MultimodalFunction)); Assert.IsTrue(result.Functions.All(d => d != Function.BorderCrossing)); }
public void TestNormalLocation(string input, string name, string spellingName) { var target = new LocationParser(); var result = target.Parse(input, out var message); Assert.IsNotNull(result); Assert.IsNull(message); Assert.AreEqual(ChangeReason.None, result.ChangeReason); Assert.IsTrue(result.ChangeDetails.Length == 0); Assert.AreEqual("AD", result.CountryId); Assert.AreEqual("ADALV", result.UNLOC); Assert.AreEqual(name, result.Name); Assert.AreEqual(spellingName, result.SpellingName); Assert.AreEqual(42.5, result.Position.Lat, 0.00001); Assert.AreEqual(1.516667, result.Position.Lng, 0.00001); Assert.IsTrue(result.Functions.Any(f => f == Function.Airport)); Assert.IsTrue(result.Functions.Any(f => f == Function.RoadTerminal)); Assert.IsTrue(result.Functions.Any(f => f == Function.MultimodalFunction)); }
public IList <ShapeEx> FromSldPart(SlidePart sdkSldPart) { var sldPhFontService = new PlaceholderFontService(sdkSldPart); //TODO: make DI var phService = new PlaceholderService(sdkSldPart.SlideLayoutPart); var transformFactory = new LocationParser(phService); var geometryFactory = new GeometryFactory(phService); var shapeContextBuilder = new ShapeContext.Builder(_preSettings, sldPhFontService, sdkSldPart); var chartGrFrameHandler = new ChartGraphicFrameHandler(shapeContextBuilder, transformFactory); var tableGrFrameHandler = new TableGraphicFrameHandler(shapeContextBuilder, transformFactory); var oleGrFrameHandler = new OleGraphicFrameHandler(shapeContextBuilder, transformFactory); var sdkShapeHandler = new SdkShapeHandler(shapeContextBuilder, transformFactory, geometryFactory); var pictureHandler = new PictureHandler(shapeContextBuilder, transformFactory, geometryFactory, sdkSldPart); var sdkGroupShapeHandler = new SdkGroupShapeHandler(shapeContextBuilder, transformFactory, geometryFactory, sdkSldPart); sdkShapeHandler.Successor = sdkGroupShapeHandler; sdkGroupShapeHandler.Successor = oleGrFrameHandler; // OLE objects handler must be before pictures handler, cause OLE container can contain p:pic elements, // thereby defining OLE as a picture oleGrFrameHandler.Successor = pictureHandler; pictureHandler.Successor = chartGrFrameHandler; chartGrFrameHandler.Successor = tableGrFrameHandler; var sdkShapeTree = sdkSldPart.Slide.CommonSlideData.ShapeTree; var shapes = new List <ShapeEx>(sdkShapeTree.Count()); foreach (var openXmlElement in sdkShapeTree) { var shape = sdkShapeHandler.Create(openXmlElement); if (shape != null) { shapes.Add(shape); } } return(shapes); }
public static Ship Create(string spec) { var locParser = new LocationParser(1, 'A', Game.MaxSize); return(new ShipFactory(locParser).Create(spec)); }
public OleGraphicFrameHandler(ShapeContext.Builder shapeContextBuilder, LocationParser transformFactory) : this(shapeContextBuilder, transformFactory, new ShapeEx.Builder()) { }
public void Login() { IsLoggingIn = true; // Report crashes only once and not on relogs/reconnects LastExecStatus execStatus = instance.GetLastExecStatus(); if (!instance.AnotherInstanceRunning() && execStatus != LastExecStatus.Normal && (!instance.ReportedCrash)) { instance.ReportedCrash = true; loginOptions.LastExecEvent = execStatus; Logger.Log("Reporting crash of the last application run to the grid login service", Helpers.LogLevel.Warning); } else { loginOptions.LastExecEvent = LastExecStatus.Normal; Logger.Log("Reporting normal shutdown of the last application run to the grid login service", Helpers.LogLevel.Info); } instance.MarkStartExecution(); OverrideEventArgs ea = new OverrideEventArgs(); OnClientLoggingIn(ea); if (ea.Cancel) { IsLoggingIn = false; return; } if (string.IsNullOrEmpty(loginOptions.FirstName) || string.IsNullOrEmpty(loginOptions.LastName) || string.IsNullOrEmpty(loginOptions.Password)) { OnClientLoginStatus( new LoginProgressEventArgs(LoginStatus.Failed, "One or more fields are blank.", string.Empty)); } string startLocation = string.Empty; string loginLocation = string.Empty; switch (loginOptions.StartLocation) { case StartLocationType.Home: startLocation = "home"; break; case StartLocationType.Last: startLocation = "last"; break; case StartLocationType.Custom: var parser = new LocationParser(loginOptions.StartLocationCustom.Trim()); startLocation = parser.GetStartLocationUri(); break; } string password; if (LoginOptions.IsPasswordMD5(loginOptions.Password)) { password = loginOptions.Password; } else { password = Utils.MD5(loginOptions.Password.Length > 16 ? loginOptions.Password.Substring(0, 16) : loginOptions.Password); } LoginParams loginParams = client.Network.DefaultLoginParams( loginOptions.FirstName, loginOptions.LastName, password, loginOptions.Channel, loginOptions.Version); Grid = loginOptions.Grid; loginParams.Start = startLocation; loginParams.LoginLocation = loginLocation; loginParams.AgreeToTos = AgreeToTos; loginParams.URI = Grid.LoginURI; loginParams.LastExecEvent = loginOptions.LastExecEvent; loginParams.MfaEnabled = true; loginParams.MfaHash = loginOptions.MfaHash; loginParams.Token = loginOptions.MfaToken; client.Network.BeginLogin(loginParams); }
public SdkShapeHandler(ShapeContext.Builder shapeContextBuilder, LocationParser transformFactory, IGeometryFactory geometryFactory) : this(shapeContextBuilder, transformFactory, geometryFactory, new ShapeEx.Builder()) { }
/// <summary> /// Generates cost matrix from every location to every other. /// </summary> /// <remarks> /// Overrides <see cref="TourTemplate{T}.GenerateCostMatrix">TourTemplate.GenerateCostMatrix</see> /// </remarks> /// /// <returns>Cost matrix</returns> protected override int[,] GenerateCostMatrix() { this._graph = new Graph <ILocationParser>(); // All found managed manually bool allFound = false; // Initialize matrix int[,] costMatrix = new int[this._items.Count, this._items.Count]; for (int i = 0; i < this._items.Count; i++) { for (int j = 0; j < this._items.Count; j++) { if (i == j) { costMatrix[i, j] = -1; } else { costMatrix[i, j] = int.MaxValue; } } } // Queue for breadth-first search // To, From, Cost Queue <Tuple <ILocationParser, ILocationParser, int> > queue = new Queue <Tuple <ILocationParser, ILocationParser, int> >(); IList <string> visited = new List <string>(); // Add current location queue.Enqueue(new Tuple <ILocationParser, ILocationParser, int>(this._items[0], null, 0)); // Find all locations needed while (!allFound && queue.Count > 0) { // Pop an item Tuple <ILocationParser, ILocationParser, int> current = queue.Dequeue(); ILocationParser to = current.Item1; ILocationParser from = current.Item2; int cost = current.Item3; // If visited continue if (visited.Contains(to.GetName())) { continue; } else { this._graph.AddNode(to.GetName(), to); visited.Add(to.GetName()); } int index = this._items.IndexOf(to); int fromIndex = this._items.IndexOf(from); if (index == -1) { // Not on our list, add connections IList <Warp> connections = to.GetWarps(); foreach (Warp connection in connections) { this._graph.AddEdge(connection.TargetName, to.GetName()); ILocationParser locationParser = new LocationParser(connection.TargetName); queue.Enqueue(new Tuple <ILocationParser, ILocationParser, int>(locationParser, from, cost + 1)); } } else { if (fromIndex != -1) { // Add all values from parent + 1 for (int i = 0; i < this._items.Count(); i++) { if (i != index) { if (i == fromIndex) { costMatrix[i, index] = cost; costMatrix[index, i] = cost; } else if (costMatrix[i, fromIndex] != int.MaxValue) { costMatrix[i, index] = costMatrix[i, fromIndex] + cost; costMatrix[index, i] = costMatrix[i, fromIndex] + cost; } } } } // Enqueue all connections IList <Warp> connections = to.GetWarps(); foreach (Warp connection in connections) { this._graph.AddEdge(connection.TargetName, to.GetName()); ILocationParser locationParser = new LocationParser(connection.TargetName); queue.Enqueue(new Tuple <ILocationParser, ILocationParser, int>(locationParser, to, 1)); } allFound = true; foreach (int distance in costMatrix) { if (distance == int.MaxValue) { allFound = false; break; } } } } return(costMatrix); }
public void Parse() { var location1 = LocationParser.Parse("6F1AFAA99234CB31770000140774365500000000".ToByteArray(), "YB3 03.6.10"); var location2 = LocationParser.Parse("6F56C4297C6B095931E0002C10DC745400000000".ToByteArray(), "TS 01.06.09"); var location3 = LocationParser.Parse("2640E58A7BCA3300546573740000000000000000".ToByteArray(), "YB3 03.6.10"); }