Skip to content

Commit

Permalink
Introduce settings options within the UI framework (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser Greenroyd authored Feb 27, 2024
2 parents b40e1d0 + 8ed1988 commit 9d40804
Show file tree
Hide file tree
Showing 14 changed files with 876 additions and 8 deletions.
10 changes: 8 additions & 2 deletions BHoM_UI.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1169
# Visual Studio Version 17
VisualStudioVersion = 17.9.34616.47
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BHoM_UI", "BHoM_UI\BHoM_UI.csproj", "{69F4F042-E23A-4673-AB32-3D787CFA976C}"
EndProject
Expand All @@ -12,6 +12,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UI_Engine", "UI_Engine\UI_E
{50D4C1ED-C16C-4365-A742-938BF49EC4B0} = {50D4C1ED-C16C-4365-A742-938BF49EC4B0}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BHoM_Windows_UI", "BHoM_Windows_UI\BHoM_Windows_UI.csproj", "{9BA156D1-851D-4267-A94F-6F238D17B634}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -30,6 +32,10 @@ Global
{565DDBD0-5C04-4BE9-B57D-CE54C2124ABB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{565DDBD0-5C04-4BE9-B57D-CE54C2124ABB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{565DDBD0-5C04-4BE9-B57D-CE54C2124ABB}.Release|Any CPU.Build.0 = Release|Any CPU
{9BA156D1-851D-4267-A94F-6F238D17B634}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BA156D1-851D-4267-A94F-6F238D17B634}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BA156D1-851D-4267-A94F-6F238D17B634}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BA156D1-851D-4267-A94F-6F238D17B634}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
21 changes: 19 additions & 2 deletions BHoM_UI/Global/GlobalSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,20 @@ private static void M_SearchMenu_Disposed(object sender, EventArgs e)

private static void ShowWithConstraint(SearchConfig config)
{
var settings = BH.Engine.Settings.Query.GetSettings(typeof(BH.oM.UI.SearchSettings)) as SearchSettings;
List<string> excludedToolkits = new List<string>();
if (settings != null)
excludedToolkits = settings.Toolkits.Where(x => !x.Include).Select(x => x.Toolkit).ToList();

if (config != null)
{
m_SearchMenu.PossibleItems = m_PossibleItems.Select(x =>
m_SearchMenu.PossibleItems = m_PossibleItems.Where(x =>
{
if (excludedToolkits.Any(y => x.Text.Contains(y)))
return false;
return true; //If the text does not contain any of the excluded toolkits then include it in this display
}).Select(x =>
{
SearchItem withWeight = x.ShallowClone() as SearchItem;
withWeight.Weight = withWeight.Weight(config);
Expand All @@ -166,7 +177,13 @@ private static void ShowWithConstraint(SearchConfig config)
}
else
{
m_SearchMenu.PossibleItems = m_PossibleItems;
m_SearchMenu.PossibleItems = m_PossibleItems.Where(x =>
{
if (excludedToolkits.Any(y => x.Text.Contains(y)))
return false;
return true; //If the text does not contain any of the excluded toolkits then include it in this display
}).ToList();
}

m_SearchMenu.HitsOnEmptySearch = config != null;
Expand Down
101 changes: 101 additions & 0 deletions BHoM_Windows_UI/BHoM_Windows_UI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9BA156D1-851D-4267-A94F-6F238D17B634}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BH.UI.Base.Windows</RootNamespace>
<AssemblyName>BHoM_Windows_UI</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Build\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BHoM">
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BHoM_Engine">
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Settings_Engine">
<HintPath>$(ProgramData)\BHoM\Assemblies\Settings_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Interface\ISettingsWindow.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Settings\SearchSettingsWindow.xaml.cs">
<DependentUpon>SearchSettingsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModel\ToolkitSelectItemModel.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="Settings\SearchSettingsWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UI_oM\UI_oM.csproj">
<Project>{50d4c1ed-c16c-4365-a742-938bf49ec4b0}</Project>
<Name>UI_oM</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\BHoM_Logo.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(TargetDir)$(TargetFileName)" "$(ProgramData)\BHoM\Assemblies" /Y</PostBuildEvent>
</PropertyGroup>
</Project>
35 changes: 35 additions & 0 deletions BHoM_Windows_UI/Interface/ISettingsWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BH.UI.Base.Windows
{
public interface ISettingsWindow
{
void OnPopUpClose();
}
}
58 changes: 58 additions & 0 deletions BHoM_Windows_UI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BHoM_Windows_UI")]
[assembly: AssemblyDescription("https://github.com/BHoM/BHoM_UI")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("BuroHappold Engineering")]
[assembly: AssemblyProduct("BHoM_Windows_UI")]
[assembly: AssemblyCopyright("Copyright © BuroHappold Engineering 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9ba156d1-851d-4267-a94f-6f238d17b634")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.1.0.0")]
95 changes: 95 additions & 0 deletions BHoM_Windows_UI/Properties/Resources.Designer.cs

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

Loading

0 comments on commit 9d40804

Please sign in to comment.