public settingspage()
        {
            InitializeComponent();
            Setting_Tree tree = SettingsController.tree;

            entryNormalR.Text = tree.normal.r.ToString();
            entryNormalG.Text = tree.normal.g.ToString();
            entryNormalB.Text = tree.normal.b.ToString();

            entryBlinkR.Text = tree.blink.r.ToString();
            entryBlinkG.Text = tree.blink.g.ToString();
            entryBlinkB.Text = tree.blink.b.ToString();
        }
    public static void load()
    {
        string json = "";

        if (!File.Exists(_settingServerFilePath))
        {
            using (FileStream file = File.Create(_settingServerFilePath)) {
                json = JSONWriter.ToJson(new Setting_Info()
                {
                    name = "Tree Of Live", ip = "192.168.1.3", port = 11000, auth_key = "AABBCCDD11223344"
                });
                Byte[] data = new UTF8Encoding(true).GetBytes(json);
                file.Write(data, 0, data.Length);
            }
        }
        else
        {
            json = "";
            using (StreamReader sr = File.OpenText(_settingServerFilePath)){
                json = sr.ReadLine();
            }
        }
        info = JSONParser.FromJson <Setting_Info>(json);
        Console.WriteLine(string.Format("[JSON] info file: {0}", json));

        json = "";
        if (!File.Exists(_settingTreeFilePath))
        {
            using (FileStream file = File.Create(_settingTreeFilePath)) {
                Setting_RGB _normal = new Setting_RGB()
                {
                    r = 255, g = 255, b = 255
                };
                Setting_RGB _blink = new Setting_RGB()
                {
                    r = 123, g = 123, b = 123
                };
                json = JSONWriter.ToJson(new Setting_Tree()
                {
                    normal = _normal, blink = _blink
                });
                Byte[] data = new UTF8Encoding(true).GetBytes(json);
                file.Write(data, 0, data.Length);
            }
        }
        else
        {
            json = "";
            using (StreamReader sr = File.OpenText(_settingTreeFilePath)){
                json = sr.ReadLine();
            }
        }
        tree = JSONParser.FromJson <Setting_Tree>(json);
        Console.WriteLine(string.Format("[JSON] info file: {0}", json));

        json = "";
        if (!File.Exists(_settingCommandFilePath))
        {
            using (FileStream file = File.Create(_settingCommandFilePath)) {
                json = JSONWriter.ToJson(new Setting_Device_Commmand[0]);
                Byte[] data = new UTF8Encoding(true).GetBytes(json);
                file.Write(data, 0, data.Length);
            }
        }
        else
        {
            json = "";
            using (StreamReader sr = File.OpenText(_settingCommandFilePath)){
                json = sr.ReadLine();
            }
        }
        commands = JSONParser.FromJson <Setting_Device_Commmand[]>(json);
        Console.WriteLine(string.Format("[JSON] info file: {0}", json));

        return;
    }
Exemple #3
0
 public static void resyncTree(Setting_Tree _tree)
 {
     ServerConnection.send("RESYNCSET;tree;" + JSONWriter.ToJson(_tree));
     tree = _tree;
 }
 public static void resyncTree(string _json)
 {
     Console.WriteLine(string.Format("[JSON] resync info: {0}", _json));
     tree = JSONParser.FromJson <Setting_Tree>(_json);
     save();
 }
Exemple #5
0
 public static void loadTree(string _json)
 {
     tree = JSONParser.FromJson <Setting_Tree>(_json);
     return;
 }