protected override void SolveInstance(IGH_DataAccess DA) { object preAccount = null; SpeckleAccount Account = null; DA.GetData(0, ref preAccount); Account = ((SpeckleAccount)preAccount.GetType().GetProperty("Value").GetValue(preAccount, null)); if (Account == null) { return; } DA.SetDataList(0, OwnedStreams); DA.SetDataList(1, SharedStreams); if (Account == OldAccount) { return; } OldAccount = Account; Client.BaseUrl = Account.restApi; Client.AuthToken = Account.apiToken; Client.UserStreamsGetAsync().ContinueWith(tsk => { OwnedStreams = tsk.Result.OwnedStreams.ToList(); SharedStreams = tsk.Result.SharedWithStreams.ToList(); Rhino.RhinoApp.MainApplicationWindow.Invoke(ExpireComponent); }); }
public override bool Read(GH_IReader reader) { string serialisedAccount = ""; reader.TryGetString("selectedAccount", ref serialisedAccount); if (serialisedAccount != "") { SpeckleAccount myAccount = JsonConvert.DeserializeObject <SpeckleAccount>(serialisedAccount); Selected = myAccount; } return(base.Read(reader)); }
public override void AppendAdditionalMenuItems(ToolStripDropDown menu) { base.AppendAdditionalMenuItems(menu); int count = 0; foreach (var account in Accounts) { Menu_AppendItem(menu, count++ + ". " + account.serverName, (sender, e) => { Selected = account; this.NickName = account.serverName; Rhino.RhinoApp.MainApplicationWindow.Invoke(ExpireComponent); }, true); } }