Exemplo n.º 1
0
 public static void blink(Setting_RGB _rgb, int _amount)
 {
     if (NetworkTree.treeConnection == null)
     {
         return;
     }
     NetworkTree.treeConnection.send("BLK;" + _rgb.formatToString());
 }
Exemplo n.º 2
0
 public static void set(Setting_RGB _rgb, bool _fade)
 {
     if (NetworkTree.treeConnection == null)
     {
         return;
     }
     NetworkTree.treeConnection.send("SET;" + _rgb.formatToString());
 }
        private void clickResyncSettingsTree(object sender, EventArgs e)
        {
            Setting_RGB _normal = new Setting_RGB()
            {
                r = 255, g = 255, b = 255
            };

            int.TryParse(entryNormalR.Text, out _normal.r);
            int.TryParse(entryNormalG.Text, out _normal.g);
            int.TryParse(entryNormalB.Text, out _normal.b);
            Setting_RGB _blink = new Setting_RGB()
            {
                r = 255, g = 255, b = 255
            };

            int.TryParse(entryBlinkR.Text, out _blink.r);
            int.TryParse(entryBlinkG.Text, out _blink.g);
            int.TryParse(entryBlinkB.Text, out _blink.b);

            SettingsController.resyncTree(new Setting_Tree()
            {
                normal = _normal, blink = _blink
            });
        }
    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;
    }