public override void AddedToDocument(GH_Document document) { if (readFailed) { return; } if (SelectedConstructor != null) { base.AddedToDocument(document); if (Grasshopper.Instances.ActiveCanvas.Document != null) { var otherSchemaBuilders = Grasshopper.Instances.ActiveCanvas.Document.FindObjects(new List <string>() { Name }, 10000); foreach (var comp in otherSchemaBuilders) { if (comp is CreateSchemaObject scb) { if (scb.Seed == Seed) { Seed = GenerateSeed(); break; } } } } return; } _document = document; var dialog = new CreateSchemaObjectDialog(); dialog.Owner = Grasshopper.Instances.EtoDocumentEditor; var mouse = GH_Canvas.MousePosition; dialog.Location = new Eto.Drawing.Point((int)((mouse.X - 150) / dialog.Screen.LogicalPixelSize), (int)((mouse.Y - 150) / dialog.Screen.LogicalPixelSize)); //approx the dialog half-size dialog.ShowModal(); if (dialog.HasResult) { base.AddedToDocument(document); SwitchConstructor(dialog.model.SelectedItem.Tag as ConstructorInfo); } else { document.RemoveObject(this.Attributes, true); } }
public override void AddedToDocument(GH_Document document) { if (readFailed) return; // To ensure conversion strategy does not change, we record if the user has modified this schema tag and will keep it as is. // If not, schemaTag will be synchronised with the default value every time the document opens. if (!UserSetSchemaTag) UseSchemaTag = SpeckleGHSettings.UseSchemaTag; if (SelectedConstructor != null) { base.AddedToDocument(document); if (Grasshopper.Instances.ActiveCanvas.Document == null) return; var otherSchemaBuilders = Grasshopper.Instances.ActiveCanvas.Document.FindObjects(new List<string>() { Name }, 10000); foreach (var comp in otherSchemaBuilders) { if (!(comp is CreateSchemaObject scb)) continue; if (scb.Seed != Seed) continue; Seed = GenerateSeed(); break; } (Params.Output[0] as SpeckleBaseParam).UseSchemaTag = UseSchemaTag; (Params.Output[0] as SpeckleBaseParam).ExpirePreview(true); return; } _document = document; var dialog = new CreateSchemaObjectDialog(); dialog.Owner = Grasshopper.Instances.EtoDocumentEditor; var mouse = GH_Canvas.MousePosition; dialog.Location = new Eto.Drawing.Point((int)((mouse.X - 150) / dialog.Screen.LogicalPixelSize), (int)((mouse.Y - 150) / dialog.Screen.LogicalPixelSize)); //approx the dialog half-size dialog.ShowModal(); if (dialog.HasResult) { base.AddedToDocument(document); SwitchConstructor(dialog.model.SelectedItem.Tag as ConstructorInfo); Params.ParameterChanged += (sender, args) => { if (args.ParameterSide != GH_ParameterSide.Input) return; switch (args.OriginalArguments.Type) { case GH_ObjectEventType.NickName: // This means the user is typing characters, debounce until it stops for 400ms before expiring the solution. // Prevents UI from locking too soon while writing new names for inputs. args.Parameter.Name = args.Parameter.NickName; nicknameChangeDebounce.Debounce(400, (e) => ExpireSolution(true)); break; case GH_ObjectEventType.NickNameAccepted: args.Parameter.Name = args.Parameter.NickName; ExpireSolution(true); break; } }; } else { document.RemoveObject(Attributes, true); } }