-
Notifications
You must be signed in to change notification settings - Fork 5
New boolean toggle component #687
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
be22b01
BooleanToggles automatically sets to false whenever a new file is opened
albinber e07df51
Now only targets toggles connected to pull, push and execute components
albinber c9e8063
New boolean toggle component
albinber 84c4ff1
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
albinber 4629902
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
albinber 2de995f
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
albinber 919d648
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
albinber fac6fc2
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
albinber 9ce15d2
Update Grasshopper_UI/Global/GlobalSearch.cs
albinber cef81c1
Update Grasshopper_UI/Global/GlobalSearch.cs
albinber 0a139f1
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
albinber f3a5e13
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
albinber 1a45030
Making requested changes
albinber c1341e1
Merge branch 'BHoM_UI-#684-NewToggleForBHoM' of https://github.com/BH…
albinber 94f6f25
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
efe30f2
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
b44a549
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
49c60bd
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
e72a746
Update Grasshopper_UI/Components/UI/FalseStartToggle.cs
053e9c9
Updates following testing
4af76e8
Expire solution
43cbb94
Tidy up
a97ccd1
Tidy up attributes
17a8c91
Fix project compliance
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* 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.Drawing; | ||
using Grasshopper.Kernel; | ||
using Grasshopper.GUI; | ||
using BH.oM.Base; | ||
using BH.UI.Grasshopper.Templates; | ||
using BH.UI.Base; | ||
using BH.UI.Base.Components; | ||
using GH = Grasshopper; | ||
using System.Windows.Forms; | ||
using GH_IO.Serialization; | ||
using BH.Engine.Reflection; | ||
using BH.oM.UI; | ||
using Grasshopper.GUI.RemotePanel; | ||
using Grasshopper.Kernel.Attributes; | ||
using Grasshopper.GUI.Canvas; | ||
using Rhino.Runtime; | ||
using BH.Engine.Base; | ||
|
||
namespace BH.UI.Grasshopper.Components | ||
{ | ||
public class FalseStartToggleComponent : CallerComponent | ||
{ | ||
/*******************************************/ | ||
/**** Properties ****/ | ||
/*******************************************/ | ||
|
||
public override Caller Caller { get; } = new FalseStartToggleCaller(); | ||
|
||
/*******************************************/ | ||
|
||
public FalseStartToggleComponent() | ||
{ | ||
|
||
} | ||
|
||
public override bool Read(GH_IReader reader) | ||
{ | ||
bool success = base.Read(reader); | ||
|
||
Caller.SetItem(false); | ||
albinber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Adding a tag under the component | ||
bool value = (bool)Caller.SelectedItem; | ||
|
||
albinber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Message = value.ToString(); | ||
|
||
return success; | ||
} | ||
|
||
albinber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public override void CreateAttributes() | ||
{ | ||
m_attributes = new FalseStartToggleAttributes(this); | ||
} | ||
|
||
albinber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public void UpdateComponent() | ||
{ | ||
(Caller as FalseStartToggleCaller).SetItem(!(Caller as FalseStartToggleCaller).Value); | ||
|
||
albinber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
albinber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
protected override void OnCallerModified(object sender, CallerUpdate update) | ||
{ | ||
// Adding a tag under the component | ||
bool value = (bool)Caller.SelectedItem; | ||
|
||
Message = value.ToString(); | ||
|
||
base.OnCallerModified(sender, update); | ||
} | ||
} | ||
|
||
public class FalseStartToggleAttributes : GH_ComponentAttributes | ||
FraserGreenroyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
public FalseStartToggleAttributes(IGH_Component component) : base(component) | ||
{ | ||
} | ||
|
||
public override GH_ObjectResponse RespondToMouseDoubleClick(GH_Canvas sender, GH_CanvasMouseEvent e) | ||
{ | ||
((FalseStartToggleComponent)Owner).UpdateComponent(); | ||
|
||
return GH_ObjectResponse.Handled; | ||
} | ||
|
||
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) | ||
{ | ||
if (channel == GH_CanvasChannel.Objects) | ||
{ | ||
var value = (bool)((FalseStartToggleComponent)Owner).Caller.SelectedItem; | ||
|
||
// Cache the existing style. | ||
GH_PaletteStyle dstyle = GH_Skin.palette_hidden_standard; | ||
|
||
// Swap out palette for boolean toggle components based on the current output. | ||
|
||
if (value) | ||
GH_Skin.palette_hidden_standard = new GH_PaletteStyle(Color.Green); | ||
else | ||
{ | ||
GH_Skin.palette_hidden_standard = new GH_PaletteStyle(Color.Red); | ||
} | ||
|
||
base.Render(canvas, graphics, channel); | ||
|
||
// Put the original style back. | ||
GH_Skin.palette_hidden_standard = dstyle; | ||
} | ||
else | ||
base.Render(canvas, graphics, channel); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
FraserGreenroyd marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.