Explorar o código

Converting to Use FastReports.Wpf (Source Code Version)
Created Location.DistanceTo static function

frogsoftware hai 1 ano
pai
achega
ba4b215b60

+ 14 - 4
InABox.Core/Classes/Location.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Drawing;
 
 namespace InABox.Core
 {
@@ -35,11 +36,11 @@ namespace InABox.Core
         [TextBoxEditor(Editable = Editable.Hidden, Visible = Visible.Optional)]
         public string Address { get; set; }
 
-        public double DistanceTo(Location location, UnitOfLength unitOfLength)
+        public static double DistanceBetween(PointF from, PointF to, UnitOfLength unitOfLength)
         {
-            var baseRad = Math.PI * Latitude / 180;
-            var targetRad = Math.PI * location.Latitude / 180;
-            var theta = Longitude - location.Longitude;
+            var baseRad = Math.PI * from.Y / 180;
+            var targetRad = Math.PI * to.Y / 180;
+            var theta = from.X - to.X;
             var thetaRad = Math.PI * theta / 180;
 
             var dist =
@@ -52,6 +53,15 @@ namespace InABox.Core
 
             return unitOfLength.ConvertFromMiles(dist);
         }
+        
+        public double DistanceTo(Location location, UnitOfLength unitOfLength)
+        {
+            return DistanceBetween(
+                new PointF((float)Longitude, (float)Latitude), 
+                new PointF((float)location.Longitude, (float)location.Latitude),
+                unitOfLength
+            );
+        }
 
         public void CopyFrom(Location location)
         {

+ 1 - 1
inabox.wpf/InABox.Wpf.csproj

@@ -119,6 +119,7 @@
     </ItemGroup>
 
     <ItemGroup>
+        <ProjectReference Include="..\..\3rdpartylibs\fastreports.wpf\FastReport.WPF\FastReport.WPF.csproj" />
         <ProjectReference Include="..\..\3rdpartylibs\roslynpad\src\RoslynPad.Editor.Windows\RoslynPad.Editor.Windows.csproj" />
         <ProjectReference Include="..\InABox.Dxf\InABox.Dxf.csproj" />
         <ProjectReference Include="..\InABox.Scripting\InABox.Scripting.csproj" />
@@ -128,7 +129,6 @@
         <PackageReference Include="ColorHelper" Version="1.8.0" />
         <PackageReference Include="ControlzEx" Version="5.0.2" />
         <PackageReference Include="Extended.Wpf.Toolkit" Version="4.4.0" />
-        <PackageReference Include="FastReport.WPF" Version="2024.2.0" />
         <PackageReference Include="FluentResults" Version="3.15.2" />
         <PackageReference Include="GhostScript.NetCore" Version="1.0.1" />
         <PackageReference Include="HtmlRenderer.Core" Version="1.5.0.6" />

+ 2 - 0
inabox.wpf/Reports/ReportUtils.cs

@@ -129,6 +129,8 @@ namespace InABox.Wpf.Reports
             }
 
             var report = new Report();
+            report.Log += (sender, args) =>
+                Logger.Send(args.IsError ? LogType.Error : LogType.Information, "", args.Message);
             Config.ReportSettings.ShowProgress = false;
             report.LoadFromString(templaterdl);
             report.FileName = template?.Name ?? "";