public static void Setup() { new Thread(() => { var service = new WebfontsService(new Google.Apis.Services.BaseClientService.Initializer() { ApiKey = API_KEY }); var request = service.Webfonts.List(); request.Sort = WebfontsResource.ListRequest.SortEnum.Popularity; _fontlist = request.Execute().Items;// if you get an Exception here, plz disable your Firewall! Debug.Assert(_fontlist.Count > 0); // converts the Webfont list to JSON string string json = JsonConvert.SerializeObject(_fontlist); // converts the JSON string to SciterValue SciterValue sv = SciterValue.FromJSONString(json); // calls UI layer TIScript function with the font data Program.HostInstance.InvokePost(() => { Program.HostInstance.CallFunction("View_OnFontList", sv); //Program.HostInstance.EvalScript("view.Host_DownloadFont(\"D:/\", \"Open Sans\", function(res) {})"); }); }).Start(); }
public static void Setup() { new Thread(() => { var service = new WebfontsService(new Google.Apis.Services.BaseClientService.Initializer() { ApiKey = API_KEY }); var request = service.Webfonts.List(); request.Sort = WebfontsResource.ListRequest.SortEnum.Popularity; _fontlist = request.Execute().Items; // if you get an Exception here, plz disable your Firewall! Debug.Assert(_fontlist.Count > 0); // converts the Webfont list to JSON string string json = JsonConvert.SerializeObject(_fontlist); // converts the JSON string to SciterValue SciterValue sv = SciterValue.FromJSONString(json); // calls UI layer TIScript function with the font data App.AppHost.InvokePost(() => { App.AppHost.CallFunction("View_OnFontList", sv); App.AppHost.EvalScript("view.Host_DownloadFont(\"D:/\", \"Open Sans\", function(res) {})"); }); }).Start(); }
/// <summary> /// Retrieves the list of fonts currently served by the Google Fonts Developer API /// Documentation https://developers.google.com/webfonts/v1/reference/webfonts/list /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated Webfonts service.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>WebfontListResponse</returns> public static WebfontList List(WebfontsService service, WebfontsListOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } // Building the initial request. var request = service.Webfonts.List(); // Applying optional parameters to the request. request = (WebfontsResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Webfonts.List failed.", ex); } }