From 68bee5e93c08a136cd3e38b602c3a5c2386fe98f Mon Sep 17 00:00:00 2001 From: David In't veld Date: Sat, 5 Aug 2023 22:06:36 +0100 Subject: [PATCH] Screen size fix --- CarboLifeAPI/Data/CarboProject.cs | 8 ++++++- CarboLifeCalc.sln | 10 ++++++--- CarboLifeRevit/CarboLifeRevit.csproj | 11 +++------- .../Properties/Resources.Designer.cs | 2 +- CarboLifeUI/CarboLifeUI.csproj | 6 ++--- CarboLifeUI/UI/CarboLifeMainWindow.xaml | 2 +- CarboLifeUI/UI/CarboLifeMainWindow.xaml.cs | 22 +++++++++++++++++++ 7 files changed, 43 insertions(+), 18 deletions(-) diff --git a/CarboLifeAPI/Data/CarboProject.cs b/CarboLifeAPI/Data/CarboProject.cs index 67bfb8d..f2bdef3 100644 --- a/CarboLifeAPI/Data/CarboProject.cs +++ b/CarboLifeAPI/Data/CarboProject.cs @@ -1216,6 +1216,12 @@ public string getGeneralText() double socialCarbonCost = Math.Round(this.SocialCost * calculatedCo2, 0, MidpointRounding.AwayFromZero); //DOuble 4,434 tCo2/death double carbonDeathCost = Math.Round(calculatedCo2 / 4.434, 0, MidpointRounding.AwayFromZero); + string peopleUnits = "people"; + + if(Math.Round(carbonDeathCost, 0) <= 1) + { + peopleUnits = "person"; + } string generalText = ""; @@ -1225,7 +1231,7 @@ public string getGeneralText() generalText += "The calculated value equals to: " + Math.Round(calculatedCo2 / 1.40, 2) + " average car emission per year (1.40 tCO₂/car). (UK)" + Environment.NewLine; generalText += "This requires " + Math.Round((calculatedCo2 * 40), 0) + " trees (Spruce or Fir) to grow for at least 30 years" + Environment.NewLine; generalText += "The Social Carbon Cost (SCC) of this project is: " + this.valueUnit + " " + socialCarbonCost.ToString("N") + Environment.NewLine; - generalText += "Between now and 2100 this will likely cause the death of: " + carbonDeathCost.ToString("N") + " people." + Environment.NewLine; + generalText += "Between now and 2100 this will likely cause the death of: " + Math.Round(carbonDeathCost,0) + " " + peopleUnits + "." + Environment.NewLine; result = generalText; diff --git a/CarboLifeCalc.sln b/CarboLifeCalc.sln index b231eca..9661dd2 100644 --- a/CarboLifeCalc.sln +++ b/CarboLifeCalc.sln @@ -85,9 +85,13 @@ Global {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Debug|Default.ActiveCfg = Debug|Any CPU {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Debug|Default.Build.0 = Debug|Any CPU {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Debug|x64.ActiveCfg = Debug|Any CPU - {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Release|Any CPU.ActiveCfg = Debug|Any CPU - {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Release|Default.ActiveCfg = Debug|Any CPU - {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Release|x64.ActiveCfg = Debug|Any CPU + {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Debug|x64.Build.0 = Debug|Any CPU + {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Release|Any CPU.Build.0 = Release|Any CPU + {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Release|Default.ActiveCfg = Release|Any CPU + {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Release|Default.Build.0 = Release|Any CPU + {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Release|x64.ActiveCfg = Release|Any CPU + {E72AD7FC-8E68-4BE9-966B-B174A4E0B7DF}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CarboLifeRevit/CarboLifeRevit.csproj b/CarboLifeRevit/CarboLifeRevit.csproj index aca161f..f1c4334 100644 --- a/CarboLifeRevit/CarboLifeRevit.csproj +++ b/CarboLifeRevit/CarboLifeRevit.csproj @@ -11,7 +11,7 @@ Properties CarboLifeRevit CarboLifeRevit - v4.8 + v4.7 512 true @@ -66,11 +66,6 @@ ico_CarboLife.ico - - False - ..\..\..\CarboLifeCalc\LiveCharts.dll - True - False ..\packages\LiveCharts.Wpf.0.9.7\lib\net45\LiveCharts.Wpf.dll @@ -79,11 +74,11 @@ - ..\..\..\Program Files\Autodesk\Revit 2024\RevitAPI.dll + C:\Program Files\Autodesk\Revit 2022\RevitAPI.dll False - ..\..\..\Program Files\Autodesk\Revit 2024\RevitAPIUI.dll + C:\Program Files\Autodesk\Revit 2022\RevitAPIUI.dll False diff --git a/CarboLifeRevit/Properties/Resources.Designer.cs b/CarboLifeRevit/Properties/Resources.Designer.cs index 4412cd6..83e1b1f 100644 --- a/CarboLifeRevit/Properties/Resources.Designer.cs +++ b/CarboLifeRevit/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace CarboLifeRevit.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/CarboLifeUI/CarboLifeUI.csproj b/CarboLifeUI/CarboLifeUI.csproj index eb5dd53..5414d91 100644 --- a/CarboLifeUI/CarboLifeUI.csproj +++ b/CarboLifeUI/CarboLifeUI.csproj @@ -70,12 +70,10 @@ - ..\..\..\Program Files\Autodesk\Revit 2024\RevitAPI.dll - False + C:\Program Files\Autodesk\Revit 2022\RevitAPI.dll - ..\..\..\Program Files\Autodesk\Revit 2024\RevitAPIUI.dll - False + C:\Program Files\Autodesk\Revit 2022\RevitAPIUI.dll diff --git a/CarboLifeUI/UI/CarboLifeMainWindow.xaml b/CarboLifeUI/UI/CarboLifeMainWindow.xaml index c8efa1a..4e05b61 100644 --- a/CarboLifeUI/UI/CarboLifeMainWindow.xaml +++ b/CarboLifeUI/UI/CarboLifeMainWindow.xaml @@ -5,7 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:CarboLifeUI.UI" mc:Ignorable="d" Title="Carbo Life Calculator" - d:DesignHeight="744" MinHeight="744" Height="744" d:DesignWidth="1366" MinWidth="1366" Width="1366" Closing="Window_Closing"> + d:DesignHeight="744" MinHeight="744" Height="744" d:DesignWidth="1366" MinWidth="1366" Width="1366" Closing="Window_Closing" Loaded="Window_Loaded"> diff --git a/CarboLifeUI/UI/CarboLifeMainWindow.xaml.cs b/CarboLifeUI/UI/CarboLifeMainWindow.xaml.cs index d82f545..4569655 100644 --- a/CarboLifeUI/UI/CarboLifeMainWindow.xaml.cs +++ b/CarboLifeUI/UI/CarboLifeMainWindow.xaml.cs @@ -616,5 +616,27 @@ private void mnu_EditTemplate_Click(object sender, RoutedEventArgs e) MessageBox.Show(ex.Message); } } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + System.Drawing.Rectangle resolution = System.Windows.Forms.Screen.PrimaryScreen.Bounds; + int height = resolution.Height; + + if(height > 744) + { + this.Height = (height - 100); + + //centre the window + + double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth; + double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight; + double windowWidth = this.Width; + double windowHeight = this.Height; + this.Left = (screenWidth / 2) - (windowWidth / 2); + this.Top = (screenHeight / 2) - (windowHeight / 2); + + } + + } } }