示例#1
0
        public FormSimpleSetting(Config_Type config_Type)
        {
            string model_id = SystemConfig.Get().SystemMode;

            InitializeComponent();
            sql = Global.Config_sql(config_Type);
        }
示例#2
0
        public static string Config_sql(Config_Type config_Type)
        {
            string sql = "";

            switch (config_Type)
            {
            case Config_Type.DEVICE:
                sql = CONFIG_DEVICE_SQL;
                break;

            case Config_Type.NODE:
                sql = CONFIG_NODE_SQL;
                break;

            case Config_Type.POINT:
                sql = CONFIG_POINT_SQL;
                break;

            case Config_Type.RECIPE:
                sql = CONFIG_RECIPE_SQL;
                break;

            case Config_Type.DIO:
                sql = CONFIG_DIO_SQL;
                break;
            }
            return(sql);
        }
示例#3
0
 /// <summary>
 /// Converts a config type to a string, This is mainly used for when saving the config as a local file.
 /// </summary>
 /// <param name="type">The config type you're converting to a string</param>
 private static string GetNameByType(this Config_Type type)
 {
     if (type == Config_Type.FLOAT)
     {
         return("f");
     }
     if (type == Config_Type.INTEGER)
     {
         return("i");
     }
     if (type == Config_Type.LONG)
     {
         return("l");
     }
     if (type == Config_Type.STRING)
     {
         return("s");
     }
     throw new KeyNotFoundException();
 }
示例#4
0
        private static void ManualInsert(string parent, string name, string value, string encoding, Config_Type type)
        {
            parent = CleanName(parent);
            name   = CleanName(name);

            for (int i = 0; i < m_config.Count; i++)
            {
                if (m_config[i].name == parent)
                {
                    for (int j = 0; j < m_config[i].nodes.Count; j++)
                    {
                        if (m_config[i].nodes[j].name == name)
                        {
                            // F*****g lists, not allowing me to edit a value -.-
                            m_config[i].nodes[j] = new Config_Child()
                            {
                                encoding = encoding,
                                value    = value,
                                name     = name,
                                type     = type
                            };

                            // Updating existing, let's return
                            return;
                        }
                    }

                    // Variable doesn't exist, but parrrent does. Let's insert to parent.
                    m_config[i].nodes.Add(new Config_Child()
                    {
                        encoding = encoding,
                        value    = value,
                        name     = name,
                        type     = type
                    });


                    // Returning.
                    return;
                }
            }


            // Parent doesn't exist, let's insert one.
            InsertParent(parent);

            // Now we need to find the newly inserted parent.
            for (int i = 0; i < m_config.Count; i++)
            {
                if (m_config[i].name == parent)
                {
                    m_config[i].nodes.Add(new Config_Child()
                    {
                        encoding = encoding,
                        value    = value,
                        name     = name,
                        type     = type
                    });
                }
            }
        }