From 2555e9bf8051c2c7054c8216d1001c376254cec2 Mon Sep 17 00:00:00 2001 From: Marc Syp Date: Fri, 16 Aug 2019 15:33:14 -0400 Subject: [PATCH 01/24] Added SetButton component - Allows you to change the text and/or the icon for the component - Icon included - Updated debug target --- .../UI Output/SetButton_Component.cs | 167 ++ HumanUI/HumanUI/HumanUI.csproj | 2 + .../HumanUI/Properties/Resources.Designer.cs | 1774 +++++++++-------- HumanUI/HumanUI/Properties/Resources.resx | 735 +++---- HumanUI/HumanUI/Resources/SetButton.png | Bin 0 -> 3465 bytes HumanUI/icons/SetButton.png | Bin 0 -> 3465 bytes HumanUI/icons/SetButton.psd | Bin 0 -> 28520 bytes dist/HumanUI.gha | Bin 471040 -> 491520 bytes dist/HumanUIBaseApp.dll | Bin 10240 -> 10752 bytes 9 files changed, 1430 insertions(+), 1248 deletions(-) create mode 100644 HumanUI/HumanUI/Components/UI Output/SetButton_Component.cs create mode 100644 HumanUI/HumanUI/Resources/SetButton.png create mode 100644 HumanUI/icons/SetButton.png create mode 100644 HumanUI/icons/SetButton.psd diff --git a/HumanUI/HumanUI/Components/UI Output/SetButton_Component.cs b/HumanUI/HumanUI/Components/UI Output/SetButton_Component.cs new file mode 100644 index 0000000..6d57403 --- /dev/null +++ b/HumanUI/HumanUI/Components/UI Output/SetButton_Component.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; + +using Grasshopper.Kernel; +using Rhino.Geometry; +using GH_IO.Serialization; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using HumanUI.Properties; +using MahApps.Metro.Controls; +using HumanUIBaseApp; + +namespace HumanUI.Components.UI_Output +{ + public class SetButton_Component : GH_Component + { + /// + /// Initializes a new instance of the SetButton_Component class. + /// + public SetButton_Component() + : base("Set Button", "SetBtn", + "Change the content of an existing Button element.", + "Human UI", "UI Output") + { + } + + /// + /// Registers all the input parameters for this component. + /// + protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) + { + pManager.AddGenericParameter("Button to modify", "B", "The button object to modify", GH_ParamAccess.item); + pManager.AddTextParameter("Button Name", "N", "The new text to display on the button", GH_ParamAccess.item); + pManager[1].Optional = true; + pManager.AddTextParameter("Image Path", "I", "The new image to display on the button.", GH_ParamAccess.item); + pManager[2].Optional = true; + } + + /// + /// Registers all the output parameters for this component. + /// + protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) + { + } + + /// + /// This is the method that actually does the work. + /// + /// The DA object is used to retrieve from inputs and store in outputs. + protected override void SolveInstance(IGH_DataAccess DA) + { + object ButtonObject = null; + + string newButtonName = ""; + string newButtonImage = ""; + if (!DA.GetData("Button to modify", ref ButtonObject)) return; + bool hasText = DA.GetData("Button Name", ref newButtonName); + bool hasIcon = DA.GetData("Image Path", ref newButtonImage); + + Button btn = HUI_Util.GetUIElement