11using System ;
2+ using GHUI . Classes ;
23using Grasshopper . Kernel ;
34
45namespace GHUI
56{
6- public class BuildImageComponent : GH_Component
7+ public class BuildImageComponent : GH_ComponentTemplate
78 {
9+ private string _url ;
10+ private double _width = 300 ;
11+ private double _height = 300 ;
12+
813 /// <summary>
914 /// Component for building a HTML image component.
1015 /// </summary>
@@ -17,42 +22,24 @@ public BuildImageComponent()
1722
1823 protected override void RegisterInputParams ( GH_InputParamManager pManager )
1924 {
20- pManager . AddTextParameter ( "Name" , "name" , "The name of the image component." , GH_ParamAccess . item ,
21- "image" ) ;
22- pManager . AddTextParameter ( "ID" , "id" , "The id of the image component." , GH_ParamAccess . item ,
23- "image" ) ;
25+ RegisterDefaultInputParams ( pManager ) ;
2426 pManager . AddTextParameter ( "URL" , "url" , "The url of the image to show." ,
2527 GH_ParamAccess . item , "https://vuejs.org/images/logo.png" ) ;
26- pManager . AddNumberParameter ( "Height" , "height" , "The desired height of the image (pixels)." , GH_ParamAccess . item , 300 ) ;
27- pManager . AddNumberParameter ( "Width" , "width" , "The desired width of the image (pixels)." , GH_ParamAccess . item , 300 ) ;
28- pManager . AddTextParameter ( "CSS" , "css" , "The `style` attribute to apply to the element and its children." ,
29- GH_ParamAccess . item , "" ) ;
30- }
31-
32- protected override void RegisterOutputParams ( GH_OutputParamManager pManager )
33- {
34- pManager . AddTextParameter ( "HTML" , "html" , "The HTML code for the created image input." ,
35- GH_ParamAccess . list ) ;
28+ pManager . AddNumberParameter ( "Height" , "height" , "The desired height of the image (pixels)." ,
29+ GH_ParamAccess . item , 300 ) ;
30+ pManager . AddNumberParameter ( "Width" , "width" , "The desired width of the image (pixels)." ,
31+ GH_ParamAccess . item , 300 ) ;
3632 }
3733
3834 protected override void SolveInstance ( IGH_DataAccess da )
3935 {
40- string name = null ;
41- string id = null ;
42- string url = null ;
43- double height = 200 ;
44- double width = 200 ;
45- string cssStyle = null ;
46-
47- da . GetData ( 0 , ref name ) ;
48- da . GetData ( 1 , ref id ) ;
49- da . GetData ( 2 , ref url ) ;
50- da . GetData ( 3 , ref height ) ;
51- da . GetData ( 4 , ref width ) ;
52- da . GetData ( 5 , ref cssStyle ) ;
36+ GetStandardInputs ( da ) ;
37+ da . GetData ( "URL" , ref _url ) ;
38+ da . GetData ( "Width" , ref _width ) ;
39+ da . GetData ( "Height" , ref _height ) ;
5340
5441 string textString =
55- $ "<img id='{ id } ' height='{ height } ' width='{ width } ' src='{ url } ' alt='{ name } '>";
42+ $ "<img id='{ id } ' height='{ _height } ' width='{ _width } ' src='{ _url } ' alt='{ name } '>";
5643
5744 da . SetData ( 0 , textString ) ;
5845 }
0 commit comments