You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
4.1 KiB

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using EGFramework.UI;
using Godot;
using LiteDB;
using Newtonsoft.Json;
using Renci.SshNet;
namespace EGFramework.Examples.Test {
public partial class ViewSaveSystem : Node, IEGFramework
{
3 months ago
public string[][] DataList { get; set; }
public string[][] DataList2 { get; set; }
Container container{ set; get; }
public override void _Ready()
{
TestTree();
}
public override void _ExitTree()
{
}
public void TestJson()
{
string json = @"{
'CPU': 'Intel',
'PSU': '500W',
'Drives': [
'DVD read/writer'
/*(broken)*/,
'500 gigabyte hard drive',
'200 gigabyte hard drive'
],
'My' : {
'AA':'BB',
'Date': new Date(123456789)
}
}";
JsonTextReader reader = new JsonTextReader(new StringReader(json));
while (reader.Read())
{
if (reader.Value != null)
{
GD.Print("Token: {"+reader.TokenType+"}, Value: {"+ reader.Value+"}");
}
else
{
GD.Print("Token: {"+ reader.TokenType+"}");
}
}
}
public void TestTree()
{
string json = @"{
'CPU': 'Intel',
'PSU': '500W',
'My' : {
'AA':'BB',
'Date': 111
}
}";
container = this.GetNode<TabContainer>("TabContainer");
EGodotTree eGodotTree = container.CreateNode<EGodotTree>("TestTree");
eGodotTree.InitByJson(json);
}
public void TestTable()
{
container = this.GetNode<TabContainer>("TabContainer");
3 months ago
List<DataStudent> dataStudents = new List<DataStudent>();
2 months ago
for (int stu = 0; stu < 10; stu++)
{
dataStudents.Add(new DataStudent("stu" + stu, 18));
2 months ago
}
for (int stu = 0; stu < 11; stu++)
2 months ago
{
dataStudents.Add(new DataStudent("A" + stu, 20 + stu));
2 months ago
}
EGodotTable table = container.CreateNode<EGodotTable>("Default");
2 months ago
table.InitData<DataStudent>(dataStudents);
1 month ago
EGSqliteSave SqliteTest = this.EGSave().Load<EGSqliteSave>("SaveData/test.db");
// IEnumerable<string> dataBaseKey = SqliteTest.GetKeys();
// GD.Print(dataBaseKey);
// foreach (string data in dataBaseKey)
// {
// GD.Print(data);
// }
EGodotSaveTable PersonTable = container.CreateNode<EGodotSaveTable>("SQLite");
PersonTable.InitSaveData<EGSqliteSave>(SqliteTest);
PersonTable.InitData<DataPerson>("person");
2 months ago
// EGodotTableRowData rowData = container.CreateNode<EGodotTableRowData>("RowData");
// rowData.Init(new Dictionary<string, object>() { { "Name", "Tom" }, { "Age", 18 } });
// EGodotRowData rowData2 = container.CreateNode<EGodotRowData>("RowData2");
// rowData2.Init(new Dictionary<string, object>() { { "Name", "Z" }, { "Age", 1 } });
// EGodotEditParam editParam = container.CreateNode<EGodotEditParam>("editParam");
// editParam.Init(new KeyValuePair<string, object>("数量",1));
}
}
2 months ago
public struct DataStudent
{
3 months ago
public string Name { get; set; }
public int Age;
public int ID;
2 months ago
public EGPathSelect Path { set; get; }
public DataStudent(string name, int age)
{
3 months ago
Name = name;
Age = age;
ID = 0;
2 months ago
Path = new EGPathSelect();
3 months ago
}
}
public struct DataPerson{
public string id { get; set; }
public string namee { set; get; }
public string workPlace { set; get; }
public string policeNum { set; get; }
}
}