Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BHoM_UI: New boolean toggle component #472

Merged
merged 9 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions BHoM_UI/BHoM_UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
<Compile Include="Components\oM\CreateType.cs" />
<Compile Include="Components\oM\CreateObject.cs" />
<Compile Include="Components\oM\CreateDictionary.cs" />
<Compile Include="Components\UI\FalseStartToggle.cs" />
<Compile Include="Components\UI\UnitTest.cs" />
<Compile Include="Global\DocumentListener.cs" />
<Compile Include="Global\Initialisation.cs" />
Expand Down Expand Up @@ -228,11 +229,13 @@
<Content Include="Properties\Resources\BHoM_FromJSON.png" />
<Content Include="Properties\Resources\BHoM_GetProperty.png" />
<Content Include="Properties\Resources\BHoM_GetPropertyNames.png" />
<None Include="Resources\BooleanToggle.bmp" />
<None Include="Properties\Resources\BHoM_Logo.png" />
<None Include="Properties\Resources\BHoM_Icon.ico" />
<Content Include="Properties\Resources\BHoM_Read _CustomData.png" />
<Content Include="Properties\Resources\BHoM_SetProperty.png" />
<Content Include="Properties\Resources\BHoM_ToJSON.png" />
<Content Include="Properties\Resources\BooleanToggle.png" />
<Content Include="Properties\Resources\BS_Script.png" />
<Content Include="Properties\Resources\Compute.png" />
<Content Include="Properties\Resources\Convert.png" />
Expand All @@ -252,6 +255,7 @@
<Content Include="Properties\Resources\GetInfo.png" />
<Content Include="Properties\Resources\Modify.png" />
<Content Include="Properties\Resources\Move.png" />
<None Include="Properties\Resources\newBooleanToggle.png" />
<Content Include="Properties\Resources\Pull.png" />
<Content Include="Properties\Resources\Push.png" />
<Content Include="Properties\Resources\Query.png" />
Expand Down
115 changes: 115 additions & 0 deletions BHoM_UI/Components/UI/FalseStartToggle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, 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;
using System.Reflection;
using System.ComponentModel;
using BH.oM.UI;
using BH.oM.Data.Collections;
using BH.Engine.Reflection;
using BH.Engine.Data;
using BH.Engine.Serialiser;
using System.Windows.Forms;

namespace BH.UI.Base.Components
{
public class FalseStartToggleCaller : Caller
{
/*************************************/
/**** Properties ****/
/*************************************/

public override System.Drawing.Bitmap Icon_24x24 { get; protected set; } = Properties.Resources.BooleanToggle;

public override Guid Id { get; protected set; } = new Guid("e1e0d75f-41b0-4268-ae5c-a55673d77851");

public override string Category { get; protected set; } = "UI";

public override string Name { get; protected set; } = "FalseStart";
albinber marked this conversation as resolved.
Show resolved Hide resolved

public override string Description { get; protected set; } = "A boolean toggle that changes to false on load.";
albinber marked this conversation as resolved.
Show resolved Hide resolved

public bool Value
{
get
{
return (bool)SelectedItem;
}
protected set
{
SelectedItem = value;
}
}


/*************************************/
/**** Constructors ****/
/*************************************/

public FalseStartToggleCaller() : base()
{
SelectedItem = false;
Description = "Boolean toggle";
Name = "";
albinber marked this conversation as resolved.
Show resolved Hide resolved
OutputParams = new List<ParamInfo>() { new ParamInfo { DataType = typeof(bool), Kind = ParamKind.Output, Name = Name, Description = Description, IsRequired = true } };
}



albinber marked this conversation as resolved.
Show resolved Hide resolved
/*************************************/
/**** Public Method ****/
/*************************************/

public override void SetItem(object value, bool sendNotification = true, bool updateOriginal = true)
{
if (updateOriginal)
m_OriginalItem = value;
SelectedItem = (bool)value;

if (sendNotification)
{
MarkAsModified(new CallerUpdate
{
Cause = CallerUpdateCause.ItemSelected,
ComponentUpdate = new ComponentUpdate { Name = Name, Description = Description }
});
}
}

/*************************************/

public override object Run(List<object> inputs)
{
return Value;
}

/*************************************/
}
}




albinber marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 13 additions & 1 deletion BHoM_UI/Properties/Resources.Designer.cs

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

3 changes: 3 additions & 0 deletions BHoM_UI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,7 @@
<data name="BHoM_Logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\BHoM_Logo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="BooleanToggle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\BooleanToggle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added BHoM_UI/Properties/Resources/BooleanToggle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BHoM_UI/Resources/BooleanToggle.bmp
Binary file not shown.