Skip to content

Commit

Permalink
fix(LB_Samples): move to "5 :: Version"
Browse files Browse the repository at this point in the history
  • Loading branch information
MingboPeng committed Nov 5, 2024
1 parent 289d95c commit b39339f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Ladybug.Grasshopper/Component/Ladybug_Samples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ namespace LadybugGrasshopper
public class Ladybug_Samples : GH_Component
{
static Rhino.Runtime.PythonScript _script;

List<string> folderList = new List<string>();
List<List<string>> filesList = new List<List<string>>();
public Ladybug_Samples()
: base("LB Samples", "Samples",
"Load sample files",
"Ladybug", "4 :: Extra")
"Ladybug", "5 :: Version")
{
}
public override Guid ComponentGuid => new Guid("BF8CF596-EAAF-460A-8B51-97E53B0197FD");
Expand All @@ -44,7 +44,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
if (dirs == null || !dirs.Any())
dirs = GetSampleFolder();

dirs = dirs.Distinct().Where(_ => Directory.Exists(_)).ToList();
dirs = dirs.Distinct().Where(_ => Directory.Exists(_)).ToList();
if (dirs.Count == 0)
throw new ArgumentException("No template folder was found!");

Expand All @@ -60,10 +60,10 @@ protected override void SolveInstance(IGH_DataAccess DA)
this.filesList.Add(fs);
}
}
DA.SetDataList(0, this.filesList.SelectMany(_=>_));
DA.SetDataList(0, this.filesList.SelectMany(_ => _));

this.templateMenu = GetMenu();

}

private static List<string> GetSampleFolder()
Expand Down Expand Up @@ -98,7 +98,7 @@ from ladybug.config import folders as lb_folders
}
}
catch (Exception) { }

return folders;
}

Expand All @@ -107,7 +107,7 @@ private Size GetMoveVector(PointF FromLocation)
var moveX = this.Attributes.Bounds.Left - 80 - FromLocation.X;
var moveY = this.Attributes.Bounds.Y + 180 - FromLocation.Y;
var loc = new System.Drawing.Point(Convert.ToInt32(moveX), Convert.ToInt32(moveY));

return new Size(loc);
}

Expand Down Expand Up @@ -135,7 +135,7 @@ private void CreateTemplateFromFilePath(string filePath, ref bool run)
//move to where this component is...
var box = docTemp.BoundingBox(false);
var vec = GetMoveVector(box.Location);
docTemp.TranslateObjects(vec ,true);
docTemp.TranslateObjects(vec, true);

docTemp.ExpireSolution();
var docCurrent = canvasCurrent.Document;
Expand All @@ -149,15 +149,15 @@ private ToolStripDropDownMenu GetMenu()
var menu = new ToolStripDropDownMenu();

var rootFolder = this.folderList.FirstOrDefault();

var rmenuItem = addFromFolder(rootFolder);
if (rmenuItem != null)
{
var items = rmenuItem.DropDown.Items.OfType<ToolStripItem>().ToArray();
menu.Items.AddRange(items);

}

return menu;
}

Expand Down Expand Up @@ -201,7 +201,7 @@ private ToolStripMenuItem addFromFolder(string rootFolder)

Menu_AppendItem(t.DropDown, name, ev, null, item);
}

return t;
}

Expand All @@ -210,11 +210,11 @@ public override void CreateAttributes()
var att = new ComponentButtonAttributes(this);
att.ButtonText = "Load a sample";

att.MouseDownEvent += (object loc) => this.templateMenu.Show((GH.GUI.Canvas.GH_Canvas)loc,(loc as GH.GUI.Canvas.GH_Canvas).CursorControlPosition);
att.MouseDownEvent += (object loc) => this.templateMenu.Show((GH.GUI.Canvas.GH_Canvas)loc, (loc as GH.GUI.Canvas.GH_Canvas).CursorControlPosition);
this.Attributes = att;

}

}


Expand Down

0 comments on commit b39339f

Please sign in to comment.