public TaskCardControl( IGH_Attributes parent, TH_Task task) : base(parent) { _task = task; AddControl(ControlLibrary.TaskName(task.Name, this), new SizeF(CardLeftMargin, CardPadV)); var labelHost = ControlLibrary.LabelHost(task, this); AddControl(labelHost, new SizeF(CardLeftMargin, 2 * CardPadV + TitleHeight)); float h = 3 * CardPadV + TitleHeight + labelHost.Size.Height; if (task.Description != "") { h += CardPadV; var dBox = ControlLibrary.DescriptionBox(task.Description, this); AddControl(dBox, new SizeF(CardLeftMargin, h)); h += dBox.Size.Height + CardPadV; } h += ChinHeight; Size = new SizeF(CardWidth, h); var statusBar = new StatusBar(task.StatusIn, task.Status, CardWidth, FlowBarTotalHeight, FlowBarHeight, this); AddControl(statusBar, new SizeF(0f, h - FlowBarTotalHeight)); Color = task.Color; }
public override GH_ObjectResponse RespondToMouseUp(GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e) { if (_drawing) { _drawing = false; sender.CanvasPostPaintObjects -= CanvasPostPaintObjects; GH_Document doc = sender.Document; if (doc != null) { IGH_Attributes att = doc.FindAttribute(e.CanvasLocation, true); if (att != null) { if (att is IRoomStructure <IGH_DocumentObject> target) { Owner.RecordUndoEvent("Add Modifier"); if (att.DocObject is RoomInstance) { if ((att.DocObject as RoomInstance).RoomId != (DocObject as RoomInstance).RoomId) { if (targetObjectList.Find(item => (item as RoomInstance).RoomId == (att.DocObject as RoomInstance).RoomId) == null) { AddAdjacence(att.DocObject); target.AddAdjacence(this.DocObject as IGH_DocumentObject); } else { RemoveAdjacence(att.DocObject); target.RemoveAdjacence(this.DocObject as IGH_DocumentObject); } } } else if (att.DocObject is HouseInstance houseInstance) { if ((att as HouseInstanceAttributes).roomInstancesList.Find(item => item.RoomId == (this.DocObject as RoomInstance).RoomId) == null) { target.AddAdjacence(this.DocObject as IGH_DocumentObject); } else { target.RemoveAdjacence(this.DocObject as IGH_DocumentObject); } } // Owner.AddTarget(att.DocObject.InstanceGuid); IGH_ActiveObject obj = att.DocObject as IGH_ActiveObject; // if (obj != null) // obj.ExpireSolution(true); // this.DocObject.ExpireSolution(true); } } } sender.Invalidate(); return(GH_ObjectResponse.Release); } return(base.RespondToMouseUp(sender, e)); }
protected CanvasControl(CanvasControl host) { if (host != null) { TopLevelAttributes = host.TopLevelAttributes; } }
public override GH_ObjectResponse RespondToMouseUp(GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e) { if (_drawing) { _drawing = false; sender.CanvasPostPaintObjects -= CanvasPostPaintObjects; GH_Document doc = sender.Document; if (doc != null) { IGH_Attributes att = doc.FindAttribute(e.CanvasLocation, true); if (att != null) { if (att.DocObject is IModifiable) { Owner.RecordUndoEvent("Add Modifier"); Owner.AddTarget(att.DocObject.InstanceGuid); IGH_ActiveObject obj = att.DocObject as IGH_ActiveObject; if (obj != null) { obj.ExpireSolution(true); } } } } sender.Invalidate(); return(GH_ObjectResponse.Release); } return(base.RespondToMouseUp(sender, e)); }
public FlowLayoutCanvasControlHost(IGH_Attributes parent, List <CanvasControl> controls, float width, float paddingH, float paddingV, Separator separatorRef) : this(parent, controls, width, paddingH, paddingV) { includeSeparators = true; sThk = separatorRef.Thk; sColor = separatorRef.Color; Layout(); }
public FlowLayoutCanvasControlHost(IGH_Attributes parent, List <CanvasControl> controls, float width, float paddingH, float paddingV) : base(parent) { controls.ForEach(c => AddControl(c, default)); Width = width; PaddingH = paddingH; PaddingV = paddingV; Layout(); }
//public static string GetSuffix(GH_ParamAccess access) //{ // switch (access) // { // case GH_ParamAccess.item: // return "I"; // case GH_ParamAccess.list: // return "L"; // case GH_ParamAccess.tree: // return "T"; // default: // throw new Exception("access is invalid!"); // } //} #endregion #region ParamLayout public static RectangleF ParamLayoutBase(IGH_Attributes targetAtt, int Width, RectangleF layoutBound, int sideDistance = 8, bool inflate = true) { RectangleF rect; //check whether input rect = new RectangleF(layoutBound.Left - Width - sideDistance, targetAtt.Bounds.Top, Width, targetAtt.Bounds.Height); if (inflate) { rect.Inflate(-2, -2); } else { rect = new RectangleF(new PointF(rect.X - 2, rect.Y), rect.Size); } return(rect); }
public override GH_ObjectResponse RespondToMouseMove(GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e) { if (_drawing) { _drawingBox = new RectangleF(e.CanvasLocation, new SizeF(0, 0)); GH_Document doc = sender.Document; if (doc != null) { IGH_Attributes att = doc.FindAttribute(e.CanvasLocation, true); if (att != null) { if (att.DocObject is IModifiable) { _drawingBox = att.Bounds; } } } sender.Invalidate(); return(GH_ObjectResponse.Handled); } return(base.RespondToMouseMove(sender, e)); }
// This is the method that actually does the work. protected override void SolveInstance(IGH_DataAccess DA) { // Creating this component in the grasshopperdocument IGH_Component Component = this; GH_Document GrasshopperDocument = this.OnPingDocument(); // Creating input parameters //object component = null; int nbCopy = 0; string groupName = null; bool trigger = false; // Getting the data from Grasshopper //DA.GetData<object>(0, ref component); DA.GetData <string>(1, ref groupName); DA.GetData <int>(2, ref nbCopy); DA.GetData <bool>(3, ref trigger); // If the botton is pressed it will proceed if (!trigger) { return; } Grasshopper.Kernel.IGH_Param selNumsInput = Component.Params.Input[0]; IList <Grasshopper.Kernel.IGH_Param> sources = selNumsInput.Sources; if (!sources.Any()) { return; } IGH_DocumentObject comp = sources[0].Attributes.GetTopLevel.DocObject; // Gets component attributes like the bounds of the component which is used to shift // the next one and get the size of the panels IGH_Attributes att = comp.Attributes; RectangleF bounds = att.Bounds; int vShift = (int)Math.Round(bounds.Height) + 10; int vStart = 30 + vShift; List <Guid> objectsToCopy = new List <Guid>(); objectsToCopy.Add(comp.InstanceGuid); // Creating a Grasshopper Group g and assignning a nickname and color to it. // Adding group g to the GrasshopperDocument Grasshopper.Kernel.Special.GH_Group g = new Grasshopper.Kernel.Special.GH_Group(); g.NickName = groupName; g.Colour = Grasshopper.GUI.Canvas.GH_Skin.group_back; GrasshopperDocument.AddObject(g, false); List <IGH_Component> components = new List <IGH_Component>(); // For-loop used to duplicate component and to assign properties to it (size, datalist...) for (int i = 0; i < nbCopy; i++) { GH_DocumentIO documentIO = new GH_DocumentIO(GrasshopperDocument); documentIO.Copy(GH_ClipboardType.System, objectsToCopy); documentIO.Paste(GH_ClipboardType.System); documentIO.Document.TranslateObjects(new Size(0, vStart + i * vShift), false); documentIO.Document.SelectAll(); documentIO.Document.MutateAllIds(); GrasshopperDocument.DeselectAll(); GrasshopperDocument.MergeDocument(documentIO.Document); g.AddObject(documentIO.Document.Objects[0].InstanceGuid); } GrasshopperDocument.DeselectAll(); }
// This is the method that actually does the work. protected override void SolveInstance(IGH_DataAccess DA) { IGH_Component Component = this; GH_Document GrasshopperDocument = this.OnPingDocument(); // Creating input parameters List <string> data = new List <string>(); string groupName = ""; bool trigger = false; object template = null; // Getting the data from Grasshopper DA.GetDataList <string>(0, data); DA.GetData <string>(1, ref groupName); DA.GetData <object>(2, ref template); DA.GetData <bool>(3, ref trigger); // If the botton is pressed it will proceed if (!trigger) { return; } // Detecting the the source parameter for the templateInput Grasshopper.Kernel.IGH_Param templateInput = Component.Params.Input[2]; IList <Grasshopper.Kernel.IGH_Param> sources = templateInput.Sources; if (!sources.Any()) { return; } IGH_DocumentObject templateComp = sources[0].Attributes.GetTopLevel.DocObject; // Gets component attributes like the bounds of the Panel which is used to shift //the next one and get the size of the panels IGH_Attributes att = templateComp.Attributes; RectangleF bounds = att.Bounds; int vShift = (int)Math.Round(bounds.Height) + 10; float refX = bounds.X; float refY = bounds.Y + 30 + vShift; // Creating a Grasshopper Group g and assignning a nickname and color to it. //Adding group g to the GrasshopperDocument Grasshopper.Kernel.Special.GH_Group g = new Grasshopper.Kernel.Special.GH_Group(); g.NickName = groupName; g.Colour = Grasshopper.GUI.Canvas.GH_Skin.group_back; GrasshopperDocument.AddObject(g, false); List <IGH_Component> components = new List <IGH_Component>(); // For-loop used to create panels and assign properties to it (size, datalist...) int nbCopy = data.Count; for (int i = 0; i < nbCopy; i++) { Grasshopper.Kernel.Special.GH_Panel panel = new Grasshopper.Kernel.Special.GH_Panel(); panel.CreateAttributes(); panel.SetUserText(data[i]); panel.Attributes.Bounds = bounds; panel.Attributes.Pivot = new PointF(refX, refY + i * vShift); GrasshopperDocument.AddObject(panel, false); g.AddObject(panel.InstanceGuid); } GrasshopperDocument.DeselectAll(); }
public OutputParamAttributes(IGH_Param owner, IGH_Attributes parentAtts) : base(owner) { Parent = parentAtts; }
public void LayoutOutputParams2(IGH_Component owner, RectangleF componentBox, int add_offset) { GH_SwitcherComponent gH_SwitcherComponent = (GH_SwitcherComponent)owner; List <IGH_Param> componentOutputSection = gH_SwitcherComponent.StaticData.GetComponentOutputSection(); int count = componentOutputSection.Count; if (count == 0) { return; } int num = 0; int num2 = 0; foreach (IGH_Param componentOutput in gH_SwitcherComponent.StaticData.GetComponentOutputs()) { int val = ((List <IGH_StateTag>)componentOutput.StateTags).Count * 20; num2 = Math.Max(num2, val); num = Math.Max(num, GH_FontServer.StringWidth(componentOutput.NickName, StandardFont.font())); } num = Math.Max(num + 6, 12); num += num2 + add_offset; float num3 = componentBox.Height / (float)count; for (int i = 0; i < count; i++) { IGH_Param val2 = componentOutputSection[i]; if (val2.Attributes == null) { val2.Attributes = (new GH_LinkedParamAttributes(val2, owner.Attributes)); } float num4 = componentBox.Right + 3f; float num5 = componentBox.Y + (float)i * num3; float width = num; float height = num3; PointF pivot = new PointF(num4 + 0.5f * (float)num, num5 + 0.5f * num3); val2.Attributes.Pivot = (pivot); RectangleF rectangleF = new RectangleF(num4, num5, width, height); val2.Attributes.Bounds = ((RectangleF)GH_Convert.ToRectangle(rectangleF)); } bool flag = false; for (int j = 0; j < count; j++) { IGH_Param val3 = componentOutputSection[j]; GH_LinkedParamAttributes val4 = (GH_LinkedParamAttributes)val3.Attributes; FieldInfo field = typeof(GH_LinkedParamAttributes).GetField("m_renderTags", BindingFlags.Instance | BindingFlags.NonPublic); GH_StateTagList val5 = val3.StateTags; if (!(field != null)) { continue; } if (((List <IGH_StateTag>)val5).Count == 0) { val5 = null; field.SetValue(val4, val5); } if (val5 != null) { flag = true; Rectangle rectangle = GH_Convert.ToRectangle(val4.Bounds); rectangle.Width -= num2; val5.Layout(rectangle, GH_StateTagLayoutDirection.Right); rectangle = val5.BoundingBox; if (!rectangle.IsEmpty) { val4.Bounds = (RectangleF.Union(val4.Bounds, rectangle)); } field.SetValue(val4, val5); } } if (flag) { float num6 = float.MinValue; for (int k = 0; k < count; k++) { IGH_Attributes attributes = componentOutputSection[k].Attributes; num6 = Math.Max(num6, attributes.Bounds.Right); } for (int l = 0; l < count; l++) { IGH_Attributes attributes2 = componentOutputSection[l].Attributes; RectangleF bounds = attributes2.Bounds; bounds.Width = num6 - bounds.X; attributes2.Bounds = (bounds); } } }
protected CanvasControl(IGH_Attributes parent) { TopLevelAttributes = parent; }
internal void SetTopLevelAttributes(IGH_Attributes attributes) => TopLevelAttributes = attributes;
//public override bool HasOutputGrip => false; public NeuralNetTrainerParamAttributes(IGH_Param parameter, IGH_Attributes parent) : base(parameter, parent) //public CustomAttributes(NeuralNetTrainerComponent component) : base(component) { component = (Boa_TrainerComponent)parent.DocObject; //this.component = component; }
public override GH_ObjectResponse RespondToMouseUp(GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e) { if (_drawing) { _drawing = false; sender.CanvasPostPaintObjects -= CanvasPostPaintObjects; GH_Document doc = sender.Document; if (doc != null) { IGH_Attributes att = doc.FindAttribute(e.CanvasLocation, true); if (att != null) { if (att is IRoomStructure <IGH_DocumentObject> target) { Owner.RecordUndoEvent("Add Modifier"); if (att.DocObject is RoomInstance) { if ((att.DocObject as RoomInstance).InstanceGuid != (DocObject as RoomInstance).InstanceGuid) { if (RoomInstance.allAdjacencesList.Find(i => i.a == att.DocObject.InstanceGuid.ToString() && i.b == DocObject.InstanceGuid.ToString()) == null && RoomInstance.allAdjacencesList.Find(i => i.b == att.DocObject.InstanceGuid.ToString() && i.a == DocObject.InstanceGuid.ToString()) == null) { AddAdjacence(att.DocObject); target.AddAdjacence(this.DocObject as IGH_DocumentObject); } /* * if (targetObjectList.Find(item => (item as RoomInstance).RoomId == (att.DocObject as RoomInstance).RoomId) == null) * { * AddAdjacence(att.DocObject); * target.AddAdjacence(this.DocObject as IGH_DocumentObject); * }*/ else { RemoveAdjacence(att.DocObject); target.RemoveAdjacence(this.DocObject as IGH_DocumentObject); } RoomInstance.allAdjacencesList = RoomInstance.allAdjacencesList.Distinct().ToList(); } } else if (att.DocObject is HouseInstance houseInstance) { if ((att as HouseInstanceAttributes).roomInstancesGuidList.Find(item => item == (this.DocObject as RoomInstance).InstanceGuid.ToString()) == null) { target.AddAdjacence(this.DocObject as IGH_DocumentObject); } else { target.RemoveAdjacence(this.DocObject as IGH_DocumentObject); } } IGH_ActiveObject obj = att.DocObject as IGH_ActiveObject; } } } sender.Invalidate(); return(GH_ObjectResponse.Release); } return(base.RespondToMouseUp(sender, e)); }
public SpecialLinkedAttributes(IGH_Param param, IGH_Attributes parent) : base(param, parent) { }
protected override void SolveInstance(IGH_DataAccess DA) { IGH_Component Component = this; GH_Document GrasshopperDocument = this.OnPingDocument(); List <object> data = new List <object>(); string groupName = ""; bool trigger = false; object template = null; DA.GetDataList <object>(0, data); DA.GetData <string>(1, ref groupName); DA.GetData <object>(2, ref template); DA.GetData <bool>(3, ref trigger); // Trigger input if (!trigger) { return; } // Taking out the position and attributes of the template panel Grasshopper.Kernel.IGH_Param templateInput = Component.Params.Input[2]; IList <Grasshopper.Kernel.IGH_Param> sources = templateInput.Sources; if (!sources.Any()) { return; } IGH_DocumentObject templateComp = sources[0].Attributes.GetTopLevel.DocObject; IGH_Attributes att = templateComp.Attributes; // taking out the measures from the template panel and adding a shift RectangleF bounds = att.Bounds; int vShift = (int)Math.Round(bounds.Height) + 10; float refX = bounds.X; float refY = bounds.Y + 30 + vShift; int nbCopy = data.Count; // Creating a group, naming it, assigning color, adding it to the document Grasshopper.Kernel.Special.GH_Group g = new Grasshopper.Kernel.Special.GH_Group(); g.NickName = groupName; g.Colour = Grasshopper.GUI.Canvas.GH_Skin.group_back; GrasshopperDocument.AddObject(g, false); // Putting in all the new components in the document and grouping them for (int i = 0; i < nbCopy; i++) { Grasshopper.Kernel.Parameters.Param_GenericObject comp = new Grasshopper.Kernel.Parameters.Param_GenericObject(); comp.CreateAttributes(); comp.SetPersistentData(data[i]); float w = comp.Attributes.Bounds.Width; comp.Attributes.Pivot = new PointF(refX + w / 2, refY + i * vShift); GrasshopperDocument.AddObject(comp, false); g.AddObject(comp.InstanceGuid); } GrasshopperDocument.DeselectAll(); }
public KanbanBoard(IGH_Attributes parent, Dictionary <string, List <TH_Task> > board) : base(parent) { }