Skip to content

Commit

Permalink
Screen size fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVeld committed Aug 5, 2023
1 parent e402e0a commit 68bee5e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 18 deletions.
8 changes: 7 additions & 1 deletion CarboLifeAPI/Data/CarboProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";

Expand All @@ -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;

Expand Down
10 changes: 7 additions & 3 deletions CarboLifeCalc.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions CarboLifeRevit/CarboLifeRevit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CarboLifeRevit</RootNamespace>
<AssemblyName>CarboLifeRevit</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
Expand Down Expand Up @@ -66,11 +66,6 @@
<ApplicationIcon>ico_CarboLife.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="LiveCharts, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\CarboLifeCalc\LiveCharts.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="LiveCharts.Wpf, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LiveCharts.Wpf.0.9.7\lib\net45\LiveCharts.Wpf.dll</HintPath>
Expand All @@ -79,11 +74,11 @@
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="RevitAPI">
<HintPath>..\..\..\Program Files\Autodesk\Revit 2024\RevitAPI.dll</HintPath>
<HintPath>C:\Program Files\Autodesk\Revit 2022\RevitAPI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RevitAPIUI">
<HintPath>..\..\..\Program Files\Autodesk\Revit 2024\RevitAPIUI.dll</HintPath>
<HintPath>C:\Program Files\Autodesk\Revit 2022\RevitAPIUI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion CarboLifeRevit/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions CarboLifeUI/CarboLifeUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="RevitAPI">
<HintPath>..\..\..\Program Files\Autodesk\Revit 2024\RevitAPI.dll</HintPath>
<Private>False</Private>
<HintPath>C:\Program Files\Autodesk\Revit 2022\RevitAPI.dll</HintPath>
</Reference>
<Reference Include="RevitAPIUI">
<HintPath>..\..\..\Program Files\Autodesk\Revit 2024\RevitAPIUI.dll</HintPath>
<Private>False</Private>
<HintPath>C:\Program Files\Autodesk\Revit 2022\RevitAPIUI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion CarboLifeUI/UI/CarboLifeMainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
22 changes: 22 additions & 0 deletions CarboLifeUI/UI/CarboLifeMainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

}
}
}

0 comments on commit 68bee5e

Please sign in to comment.