static Primitive XML(string URI) { int StackPointer = Stack.Add("Settings.XML"); LDxml.Open(URI); Primitive Data = LDxml.ToArray(); Data = Data["root"]["children"]; Primitive RData = null; for (int i = 1; i <= Data.GetItemCount(); i++) { Primitive indicies = Data[i].GetAllIndices(); if (Data[i][indicies[1]]["Data"] != string.Empty) { RData[indicies[1]] = Data[i][indicies[1]]["Data"]; } else if (Data[i][indicies[1]]["Children"] != string.Empty) { Primitive Temp = null; for (int ii = 1; ii <= Data[i][indicies[1]]["Children"].GetItemCount(); ii++) { Primitive Index = Data[i][indicies[1]]["Children"][ii].GetAllIndices(); Temp[Index[1]] += Data[i][indicies[1]]["Children"][ii][Index[1]]["Data"]; } RData[indicies[1]] = Temp; } else { //GraphicsWindow.ShowMessage(Data[i], "XML"); } } Stack.Exit(StackPointer); return(RData); }
private void buttonTest_Click(object sender, EventArgs e) { Primitive shp = Microsoft.SmallBasic.Library.Controls.AddButton("Button", 10, 10); LDShapes.ReSize(shp, 100, 100); LDShapes.ReSize(shp, 200, 200); Primitive xx = LDFastArray.Add(); LDFastArray.Set(xx, "1 2 3", 24); FieldInfo _primitive = typeof(Primitive).GetField("_primitive", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance); Primitive aa = "1 23 45"; string bb = (string)_primitive.GetValue(aa); Primitive sb = "1=1\\=\"hello\"\\;2\\=1\\;3\\=2\\;;2=1\\=3\\;2\\=test\\;3\\=3\\;;"; Primitive arr = LDFastArray.CreateFromValues(sb); Primitive sb1 = LDFastArray.ToArray(arr); Primitive a = LDFastArray.Add(); LDFastArray.Set2D(a, 2, 5, 10); LDFastArray.Set2D(a, 2, 2, 20); LDFastArray.Set2D(a, 1, 8, 30); LDFastArray.Collapse(a); Primitive b = LDFastArray.ToArray(a); Primitive img = Microsoft.SmallBasic.Library.ImageList.LoadImage("https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/STS120LaunchHiRes-edit1.jpg/153px-STS120LaunchHiRes-edit1.jpg"); Primitive x1 = LDImage.Copy(img); LDImage.EffectCharcoal(x1); Primitive image = LDImage.NewImage(100, 100, "Red"); LDImage.OpenWorkingImage(image); Primitive xml = LDxml.Open("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\sample.xml"); Primitive data = LDxml.ToArray(); LDxml.FromArray(data); LDxml.Save("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\sample1.xml"); Primitive txt = Microsoft.SmallBasic.Library.File.ReadContents("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\txt.txt"); LDSearch.GetProof(txt, ""); LDSearch.GetWeb("bill gates"); return; //TextWindow.Show(); //LDTextWindow.SetColours("Pink", "Orange"); //TextWindow.WriteLine("Hello World"); LDPhysics.ReadJson("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\LDPysics.json", 1, "False", "False", 0, 0); LDWaveForm.PlayWave(256, 1000, "0=-1;1=1;5=0;"); Primitive shape = Shapes.AddRectangle(100, 100); LDEffect.Bloom(shape, ""); Program.Delay(1000); LDControls.AddDataView(GraphicsWindow.Width, GraphicsWindow.Height, "1=Hello;2=World;"); //string _urlTemplate = "https://api.flickr.com/services/rest/?sort=interestingness-desc&safe_search=1&license=1,2,3,4,5,6,7&api_key="; //string _picUrlTemplate = "http://farm{0}.static.flickr.com/{1}/{2}_{3}.jpg"; byte[] array = Convert.FromBase64String("MWY5ZmI5ODE4Mjk2NzAwNTgwYmYzMzQwMjc5MzQ2YjY="); //_urlTemplate += Encoding.UTF8.GetString(array, 0, array.Length); TextWindow.WriteLine(Encoding.UTF8.GetString(array, 0, array.Length)); Primitive rtb = LDControls.AddRichTextBox(100, 100); LDControls.RichTextBoxSetText(rtb, "Hello", "True"); LDCall.Compile("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\testinclude.sb"); Primitive include = LDCall.Include("C:\\Users\\Steve\\Documents\\SmallBasic\\steve\\testinclude.exe"); TextWindow.WriteLine(include); LDUtilities.FixFlickr();//FCClipboard.GetText LDCall.CallAsync("SmallBasicLibrary.dll", "Microsoft.SmallBasic.Library", "Flickr", "GetRandomPicture", "Car"); string tempFileName = Path.GetTempFileName(); Stream stream = null; Stream stream2 = null; WebResponse webResponse = null; try { string url = "https://a75b9da71f50095fc4dc527d860da4427f274b07.googledrive.com/host/0B9s0FFxEQDb6T3VUdEw3QTJDS1E/efecast00.mp3"; Uri uri = new Uri(url); WebRequest webRequest = WebRequest.Create(url); webResponse = webRequest.GetResponse(); stream = System.IO.File.Open(tempFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read); byte[] buffer = new byte[16384]; long num = webResponse.ContentLength; stream2 = webResponse.GetResponseStream(); int readCount = stream2.Read(buffer, 0, 16384); while (readCount > 0L) { stream.Write(buffer, 0, readCount); readCount = stream2.Read(buffer, 0, 16384); } } catch (Exception ex) { TextWindow.WriteLine(ex.Message); } finally { if (stream != null) { stream.Close(); } if (stream2 != null) { stream2.Close(); } if (webResponse != null) { webResponse.Close(); } } LDGraphicsWindow.SetFontFromFile("C:\\temp\\04b.ttf"); TextWindow.Show(); //Primitive source = "class Evaluator { public static function Eval(expr : String) : String { return eval(expr); } }"; //LDInline.IncludeJScript(source,"",""); //Primitive result = LDInline.Call("Eval","5+3"); //TextWindow.WriteLine(result); //TextWindow.Hide(); Primitive x = LDMath.Evaluate("1e6 + 6/4"); Primitive y = LDMath.Evaluate2("1e6 + 6/4"); //TextWindow.Hide(); TextWindow.WriteLine("HERE " + x + " :" + y); LDImage.LoadSVG("C:\\temp\\snowtitle.svg"); TextWindow.WriteLine(LDNetwork.LAN(1000)); GraphicsWindow.Show(); LDText.GetWidth("Hello World"); Primitive server = LDServer.Start("True"); LDClient.Connect(server, "True"); LDClient.SendMessage("Hello1"); LDClient.SendMessage("World1"); LDServer.Disconnect("Client1"); LDClient.Connect(server, "True"); LDClient.SendMessage("Hello3"); LDClient.SendMessage("World3"); GraphicsWindow.Show(); LDGraphicsWindow.FloodFill(200, 100, "#5588ee"); //Program.Delay(1000000); //Primitive languages = LDTranslate.Languages(); //Primitive indices = SBArray.GetAllIndices(languages); //for (int i = 1; i <= SBArray.GetItemCount(languages); i++) //{ // TextWindow.WriteLine(indices[i] + " : " + languages[indices[i]]); //} //Primitive result = LDTranslate.Translate("Hello World", "", "de"); //TextWindow.WriteLine(result); //TextWindow.WriteLine(GraphicsWindow.FontName); //GraphicsWindow.DrawText(10, 10, "Hello World"); //Primitive result = LDGraphicsWindow.SetFontFromFile("C:\\Users\\Public\\Documents\\SmallBasic\\steve\\WWFlakes.ttf"); //TextWindow.WriteLine(GraphicsWindow.FontName); //GraphicsWindow.DrawText(10, 50, "Hello World"); //PrivateFontCollection fntColl = new PrivateFontCollection(); //fntColl.AddFontFile("C:\\Users\\Public\\Documents\\SmallBasic\\steve\\WWFlakes.ttf"); //buttonTest.Font = new Font(fntColl.Families[0], 16, FontStyle.Regular); //LDDictionary.GetDefinition("Car"); }