public bool AttemptPlace() { PlayerCharacter character = Main.LocalPlayer.GetModPlayer <PlayerCharacter>(); if (CanPlaceItem(Main.mouseItem)) { foreach (ProceduralMinion minion in character.minions.Where(minion => minion.source == character.selectedAbility && minion.projectile.modProjectile is ProceduralMinion)) { foreach (ProceduralSpellProj psp in minion.circlingProtection) { psp.projectile.Kill(); } minion.circlingProtection.Clear(); if (minion.smallProt != null) { minion.smallProt.projectile.Kill(); } minion.projectile.Kill(); } Item prevItem = Glyph; Glyph = Main.mouseItem; Main.mouseItem = prevItem; Main.PlaySound(Terraria.ID.SoundID.Item4, Main.screenPosition + Bounds.Center()); return(true); } else { return(false); } }
// Configures and adds primary label view private void LayoutPrimaryLabel() { if (_primaryLabel == null) { _primaryLabel = new UILabel(); AddSubview(_primaryLabel); } _primaryLabel.Font = PrimaryTextFont != null ? PrimaryTextFont : UIFont.BoldSystemFontOfSize(PrimaryTextSize); _primaryLabel.TextColor = PrimaryTextColor; _primaryLabel.TextAlignment = PrimaryTextAlignment; _primaryLabel.Lines = 0; _primaryLabel.LineBreakMode = UILineBreakMode.WordWrap; _primaryLabel.Text = PrimaryText; _primaryLabel.SizeToFit(); var height = _primaryLabel.Frame.Height; var width = _primaryLabel.Frame.Width; var maxWidth = Frame.Width - (MaterialShowcase.LABEL_MARGIN * 2); if (width > maxWidth) { width = maxWidth; } _primaryLabel.Frame = new CGRect(x: (Bounds.Width - width) * 0.5, y: Bounds.Center().Y - height, width: width, height: height); _primaryLabel.SizeToFitHeight(); _primaryLabel.UserInteractionEnabled = false; }
public Bezier(BezierType type, ICollection<float> pointData, IList<PointF> pixels, Angle angle = default(Angle)) : this() { Bounds = InitializeBezier(type, pointData, pixels, out points, angle); Option = type; Angle = angle.AssignCenter(Bounds.Center()); ID = Factory.NewID(Name); }
internal virtual void PerformClick() { if (!Enabled) { WhiteLogger.Instance.WarnFormat("Clicked on disabled item: {0}", ToString()); } mouse.Click(Bounds.Center(), actionListener); }
// Return the position of the ship's nose. public PointF NosePosition() { PointF center = Bounds.Center(); double radians = Heading * Math.PI / 180; double x = center.X + ShipRadius * Math.Cos(radians); double y = center.Y + ShipRadius * Math.Sin(radians); return(new PointF((int)x, (int)y)); }
/// <summary> /// Creates a kmlLookAt from a Bounds object. /// </summary> /// <param name="ge">the plug-in</param> /// <param name="bounds">the bounds object to create the view of</param> /// <param name="aspectRatio">Optional aspect ratio</param> /// <param name="defaultRange">Optional default range</param> /// <param name="scaleRange">Optional scale range</param> /// <returns>A KmlLookAt based on the <paramref name="bounds"/> (or null)</returns> public static dynamic CreateBoundsView( dynamic ge, Bounds bounds, double aspectRatio = 1.0, double defaultRange = 1000, double scaleRange = 1.5) { Coordinate center = bounds.Center(); Coordinate boundsSpan = bounds.Span(); double lookAtRange = defaultRange; dynamic lookat = null; if (Convert.ToBoolean(boundsSpan.Latitude) || Convert.ToBoolean(boundsSpan.Longitude)) { // Distance - using law of cosines for speed... double distEW = new Coordinate(center.Latitude, bounds.East) .Distance(new Coordinate(center.Latitude, bounds.West)); double distNS = new Coordinate(bounds.North, center.Longitude) .Distance(new Coordinate(bounds.South, center.Longitude)); aspectRatio = Math.Min(Math.Max(aspectRatio, distEW / distNS), 1.0); // Create a LookAt using the experimentally derived distance formula. double alpha = Maths.ConvertDegreesToRadians(45.0 / (aspectRatio + 0.4) - 2.0); double expandToDistance = Math.Max(distNS, distEW); double beta = Math.Min( Maths.ConvertDegreesToRadians(90), alpha + expandToDistance / (2 * Maths.EarthMeanRadiusKilometres)); lookAtRange = scaleRange * Maths.EarthMeanRadiusKilometres * (Math.Sin(beta) * Math.Sqrt(1 + 1 / Math.Pow(Math.Tan(alpha), 2)) - 1); } try { lookat = ge.createLookAt(string.Empty); lookat.set(center.Latitude, center.Longitude, bounds.Top, bounds.Northeast.AltitudeMode, 0, 0, lookAtRange); } catch (RuntimeBinderException rbex) { Debug.WriteLine("CreateBoundsView: " + rbex.Message, "KmlHelpers"); } return(lookat); }
/// <summary> /// Implements <see cref="IUIItem.RightClick()"/> /// </summary> public virtual void RightClick() { RightClickAt(Bounds.Center()); }
/// <summary> /// Implements <see cref="IUIItem.DoubleClick"/> /// </summary> public virtual void DoubleClick() { actionListener.ActionPerforming(this); PerformIfValid(() => mouse.DoubleClick(Bounds.Center(), actionListener)); }
/// <summary> /// Creates a kmlLookAt from a Bounds object. /// </summary> /// <param name="ge">the plug-in</param> /// <param name="bounds">the bounds object to create the view of</param> /// <param name="aspectRatio">Optional aspect ratio</param> /// <param name="defaultRange">Optional default range</param> /// <param name="scaleRange">Optional scale range</param> /// <returns>A KmlLookAt based on the <paramref name="bounds"/> (or null)</returns> public static dynamic CreateBoundsView( dynamic ge, Bounds bounds, double aspectRatio = 1.0, double defaultRange = 1000, double scaleRange = 1.5) { Coordinate center = bounds.Center(); Coordinate boundsSpan = bounds.Span(); double lookAtRange = defaultRange; dynamic lookat = null; if (Convert.ToBoolean(boundsSpan.Latitude) || Convert.ToBoolean(boundsSpan.Longitude)) { // Distance - using law of cosines for speed... double distEW = new Coordinate(center.Latitude, bounds.East) .Distance(new Coordinate(center.Latitude, bounds.West)); double distNS = new Coordinate(bounds.North, center.Longitude) .Distance(new Coordinate(bounds.South, center.Longitude)); aspectRatio = Math.Min(Math.Max(aspectRatio, distEW / distNS), 1.0); // Create a LookAt using the experimentally derived distance formula. double alpha = Maths.ConvertDegreesToRadians(45.0 / (aspectRatio + 0.4) - 2.0); double expandToDistance = Math.Max(distNS, distEW); double beta = Math.Min( Maths.ConvertDegreesToRadians(90), alpha + expandToDistance / (2 * Maths.EarthMeanRadiusKilometres)); lookAtRange = scaleRange * Maths.EarthMeanRadiusKilometres * (Math.Sin(beta) * Math.Sqrt(1 + 1 / Math.Pow(Math.Tan(alpha), 2)) - 1); } try { lookat = ge.createLookAt(string.Empty); lookat.set(center.Latitude, center.Longitude, bounds.Top, bounds.Northeast.AltitudeMode, 0, 0, lookAtRange); } catch (RuntimeBinderException rbex) { Debug.WriteLine("CreateBoundsView: " + rbex.Message, "KmlHelpers"); } return lookat; }
private void RightClickOnCenter() { RightClickAt(Bounds.Center()); }
public virtual void ClickAtCenter() { mouse.Click(Bounds.Center(), actionListener); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { Logger.LogInformation("Running OfflineCacheBackgroundTask."); using (IServiceScope scope = ScopeFactory.CreateScope()) { TileCacheRepository = scope.ServiceProvider.GetRequiredService <TileCacheRepository>(); TileSourceRepository = scope.ServiceProvider.GetRequiredService <TileSourceRepository>(); Mapper = scope.ServiceProvider.GetRequiredService <IMapper>(); do { TileCacheViewModel unfinishedTileCache = Mapper.Map <TileCacheViewModel>(await TileCacheRepository.GetFirstUnfinishedTileCache()); if (unfinishedTileCache != null) { await TileCacheRepository.SetTileCacheStarted(unfinishedTileCache.TileCacheId); TileCacheManager tileCacheManager = await CreateTileCacheManager(unfinishedTileCache.TileCacheId); TilesCount = 0; // Do not remove already downloaded tiles ////tileService.ClearTiles(); try { Bounds bounds = GeometryHelper.ToBounds(unfinishedTileCache.Bbox); TileSource tileSource = await TileSourceRepository.GetTileSourceWithId(unfinishedTileCache.TileSourceId); TileRangeCalculator calculator = new TileRangeCalculator { ValidBounds = GeometryHelper.ToBounds(tileSource.Bbox), ValidZoomRange = new ZoomRange { MinZoom = 0, MaxZoom = tileSource.ZoomLevelMax, }, }; TileRangeCollection tiles = new TileRangeCollectionCalculator(calculator).GetTileRanges(bounds, new ZoomRange { MinZoom = unfinishedTileCache.ZoomLevelMin ?? 0, MaxZoom = unfinishedTileCache.ZoomLevelMax, }); TilesTotal = tiles.TilesTotal; if (TilesTotal > 30000) { await TileCacheRepository.SetTileCacheError(unfinishedTileCache.TileCacheId); throw new ArgumentException($"Tile cache exceeding the maximum number of 30000 tiles: {TilesTotal}."); } TileDownloader tileDownloader = tileSource.AllowHiDefStitching ? new MergedTileDownloader() : new TileDownloader(); tileDownloader.TileServerUrls = tileSource.TileServerUrls.Select(x => x.Url).ToList(); await tileDownloader.Download(tiles, (zoomLevel, tileRow, tileColumn, tileData) => { // Note that in the TMS tiling scheme, the Y axis is reversed from the "XYZ" coordinate system commonly used in the URLs int mbtilesRow = (int)Math.Pow(2, zoomLevel) - 1 - tileRow; lock (OfflineCacheBackgroundTask.lockObject) { TilesCount++; } if (tileCacheManager.TryGetTile(tileColumn, mbtilesRow, zoomLevel) == null) { tileCacheManager.SaveTile(zoomLevel, mbtilesRow, tileColumn, tileData); } }); Bounds tileCacheBounds = GeometryHelper.ToBounds(unfinishedTileCache.Bbox); string metadataBounds = tileCacheBounds.ToCsv(); double centerLon = tileCacheBounds.Center().Lon; double centerLat = tileCacheBounds.Center().Lat; string metadataCenter = $"{centerLon},{centerLat},{unfinishedTileCache.ZoomLevelMin}"; string format = tileSource.TileServerUrls[0].Url.EndsWith("png") ? "png" : "jpg"; tileCacheManager.SaveMetadata(unfinishedTileCache.Name, format, metadataBounds, metadataCenter, unfinishedTileCache.ZoomLevelMin ?? 0, unfinishedTileCache.ZoomLevelMax); await TileCacheRepository.SetTileCacheFinished(unfinishedTileCache.TileCacheId, $"{unfinishedTileCache.TileCacheId}.mbtiles"); } catch (Exception exception) { Console.WriteLine(exception); Logger.LogWarning(exception, $"OfflineCacheBackgroundTask: Exception when creating tile cache for campaign {unfinishedTileCache.TileCacheId}."); } } await Task.Delay(5 * 1000, stoppingToken); }while (!stoppingToken.IsCancellationRequested); Logger.LogInformation("Exiting OfflineCacheBackgroundTask."); } }
IDiagram IRotatable.PerformRotate(Angle angle) { return(new PathDiagram(Instructions.RotateAbout(Bounds.Center(), angle), StrokeWidth, StrokeStyle)); }
public PathF Rotate(float angle) { var center = Bounds.Center(); return(Rotate(angle, center)); }
private void Render(PnPProcDoc D, Graphics G, bool after) { G.TranslateTransform(G.ClipBounds.Width / 2, G.ClipBounds.Height / 2); TheBox.Reset(); // TheBox.FitPoint(0, 0); TheBox.AddBox(D.Box); if (idx > -1) { var rd = pnp.selectedrefdes[idx % pnp.selectedrefdes.Count()]; BOMEntry.RefDesc refd = D.B.GetRefDes(rd); if (refd != null) { TheBox.Reset(); TheBox.FitPoint(refd.x - 10, refd.y - 10); TheBox.FitPoint(refd.x + 10, refd.y + 10); } } float S = (float)Math.Min(pictureBox1.Width / (TheBox.Width()), pictureBox1.Height / (TheBox.Height())); bool TopView = false; if (PostDisplay) { TopView = D.FlipBoard ? false : true; } var C = TheBox.Center(); G.ScaleTransform(S * 0.8f, -S * 0.8f); G.TranslateTransform((float)-C.X, (float)-C.Y); RenderLayerSets(G, S, BoardSide.Both, BoardLayer.Outline, Color.Gray, true); if (pnp.bottomsilkvisible) { RenderLayerSets(G, S, BoardSide.Bottom, BoardLayer.Silk, Color.White, true); } if (pnp.topsilkvisible) { RenderLayerSets(G, S, BoardSide.Top, BoardLayer.Silk, Color.DarkGray, true); } var B = D.B; if (after) { B = D.BPost; } int curpart = 0; foreach (var p in B.DeviceTree) { foreach (var pp in p.Value.Values) { var curcol = Helpers.RefractionNormalledMaxBrightnessAndSat(curpart / p.Value.Values.Count()); curpart++; foreach (var rf in pp.RefDes) { DrawMarker(curcol, G, rf, true, S, false, pnp.selectedrefdes.Contains(rf.NameOnBoard)); } } } }
private void LoadFile(string s) { string outfile = Path.Combine(Path.GetDirectoryName(s), Path.GetFileNameWithoutExtension(s) + "_carved.gcode"); try { var P = FenixSVG.LoadSVGToPolies(s,0,0); double tantoolangle = Math.Tan(toolangle / 2); cuttingdepth = -toolradiusatcuttingdepth / tantoolangle; Bounds B = new Bounds(); foreach(var a in P) { foreach( var b in a) { B.AddPolygon(b.ToPath()); } } var C = B.Center(); ClipPaths subj = new ClipPaths(); foreach(var a in P) { foreach( var b in a) { subj.Add(b.ToPath(-C.X*100000, -C.Y*100000)); } } GCodeFile F = new GCodeFile(); var R1 = ClipperLib.Clipper.OffsetPolygons(subj, (toolradiusatcuttingdepth * 1.5)*100000.0); // t = o / a // a = o / t // F.RectangularFillBetweenPolygons(R1, cuttingdepth, rapiddepth, toolradiusatcuttingdepth * 0.75, -B.Width() / 2 - 2, B.Width() / 2 + 2, -B.Height() / 2 - 2, B.Height() / 2 + 2, 0.2); // F.AddClipperPolygonsToCarve(R1, cuttingdepth, rapiddepth,0.5); var R = ClipperLib.Clipper.OffsetPolygons(subj, toolradiusatcuttingdepth * 100000.0); F.AddClipperPolygonsToCarve(R, cuttingdepth, rapiddepth,0.5); toolradiusatcuttingdepth = 0.25; cuttingdepth = -toolradiusatcuttingdepth / tantoolangle; var R3 = ClipperLib.Clipper.OffsetPolygons(subj, toolradiusatcuttingdepth * 100000.0); F.AddClipperPolygonsToCarve(R3, cuttingdepth, rapiddepth,0.5); F.MoveTo(0, 0, rapiddepth, GCodeFile.MoveMode.Fast); F.MoveTo(0, 0, 0, GCodeFile.MoveMode.Slow); F.Write(outfile); } catch (Exception) { BackColor = Color.Red; } }
IDiagram IRotatable.PerformRotate(Angle angle) => new BoundingBoxOverridingDiagram( Diagram.RotateAbout(Bounds.Center(), angle), Bounds.RotateAbout(Bounds.Center(), angle));