public ConfigurationFloat(float val, Changable father = null, bool is_explicit = false, float lowest = float.MinValue, float highest = float.MaxValue, string name = "", bool is_low_bound = false, bool is_high_bound = false, string description = "", string notes = "") : base(father, ConfigurationFloat.brush, name, is_explicit, description, notes)
 {
     if (lowest > highest)
     {
         throw new Exception("Invlid bounderies");
     }
     Value = new FloatType(this, val, lowest, highest, is_low_bound, is_high_bound, is_explicit);
 }
 public ConfigurationComposite(JObject array, Changable father = null, string name = "", bool is_explicit = false, string description = "", string notes = "") : base(father, ConfigurationComposite.brush, name, is_explicit, description, notes)
 {
     foreach (KeyValuePair <String, JToken> value in array)
     {
         ConfigurationVariable cv = ConfigurationVariable.ConvertJsonToConfiguration(value.Key, value.Value, this);
         if (cv != null)
         {
             Variables.Add(ConfigurationVariable.ConvertJsonToConfiguration(value.Key, value.Value, this));
         }
     }
     IsComposite = true;
 }
Exemple #3
0
 protected ConfigurationVariable(ConfigurationVariable other, Changable father = null)
 {
     if (father == null)
     {
         Father = new EmptyFather();
     }
     else
     {
         Father = father;
     }
     UpdateBy(other);
 }
Exemple #4
0
 protected ConfigurationVariable(Changable father = null, Brush font_color = null, string name = "", bool is_explicit = false, string description = "", string notes = "")
 {
     Father                   = father != null ? father : new EmptyFather();
     FontColor                = font_color;
     ConfigurationName        = name;
     Variables                = new ObservableCollection <ConfigurationVariable>();
     Dirty                    = false;
     IsComposite              = false;
     this.is_explicit         = is_explicit;
     _is_name_visible         = !(Father is ConfigurationList);
     _description             = description;
     _notes                   = notes;
     IsExplicitnessChangeable = true;
 }
        public ConfigurationList(JArray array, Changable father = null, string name = "", bool is_explicit = false, string description = "", string notes = "") : base(father, ConfigurationList.brush, name, is_explicit, description, notes)
        {
            int index = 1;

            foreach (JToken value in array)
            {
                ConfigurationVariable cv = ConfigurationVariable.ConvertJsonToConfiguration("Element " + index.ToString(), value, this);
                if (cv != null)
                {
                    Variables.Add(ConfigurationVariable.ConvertJsonToConfiguration("Element " + index.ToString(), value, this));
                    index++;
                }
            }
            IsComposite = true;
        }
Exemple #6
0
 public ProjectExplorerItem(string path, Changable father, ProjectModel pm)
 {
     FullPath = path;
     ProjectExplorerItemsLabel = GetFileName(path);
     Father = father;
     PM     = pm;
     ProjectExplorerItems = new List <ProjectExplorerItem>();
     if (path.EndsWith(".json"))
     {
         using StreamReader r = new StreamReader(path);
         string  json  = r.ReadToEnd();
         JObject array = (JObject)JsonConvert.DeserializeObject(json);
         Content = new ConfigurationFile(array);
     }
     DirSearch(path, ProjectExplorerItems);
     IsOpened      = false;
     AutoReference = this;
 }
Exemple #7
0
 public ConfigurationString(ConfigurationString other, Changable father = null) : base(other, father)
 {
 }
Exemple #8
0
 public ConfigurationInteger(ConfigurationInteger other, Changable father = null) : base(other, father)
 {
 }
Exemple #9
0
 public ConfigurationInteger(int val, Changable father = null, bool is_explicit = false, int lowest = int.MinValue, int highest = int.MaxValue, string name = "", bool is_low_bound = false, bool is_high_bound = false, string description = "", string notes = "") : base(father, ConfigurationInteger.brush, name, is_explicit, description, notes)
 {
     Value = new IntegerType(this, val, lowest, highest, is_low_bound, is_high_bound, is_explicit);
 }
Exemple #10
0
 public abstract ConfigurationVariable Clone(Changable father = null);
Exemple #11
0
 /// <summary>
 /// Creates ConfigurationVariable object from loaded data if the data is of the relevant type.
 /// If the data doesnt sute the current type, return null.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="fromJson"></param>
 /// <param name="father"></param>
 /// <returns></returns>
 public static ConfigurationVariable TryConvert(string name, JToken fromJson, Changable father) => throw new NotImplementedException();
Exemple #12
0
 public ConfigurationString(string val, Changable father = null, bool is_explicit = false, string name = "", string description = "", string notes = "") : base(father, ConfigurationString.brush, name, is_explicit, description, notes)
 {
     Value = new StringType(this, val, is_explicit);
 }
 public static new ConfigurationVariable TryConvert(string name, JToken fromJson, Changable father)
 {
     if (IsImplicitType(fromJson))
     {
         return(new ConfigurationComposite(array: (JObject)fromJson, father: father, name: name));
     }
     else if (IsExplicitType(fromJson))
     {
         JObject x           = fromJson as JObject;
         string  description = x.ContainsKey("description") ? x["description"].ToString() : "";
         string  notes       = x.ContainsKey("notes") ? x["notes"].ToString() : "";
         return(new ConfigurationComposite(array: (JObject)(x["value"]), father: father, name: name, is_explicit: true, description: description, notes: notes));
     }
     return(null);
 }
Exemple #14
0
        public static new ConfigurationVariable TryConvert(string name, JToken fromJson, Changable father)
        {
            if (fromJson.Type != JTokenType.Object)
            {
                return(null);
            }
            JObject j = (JObject)fromJson;

            if (!j.ContainsKey("type"))
            {
                return(null);
            }
            string description = j.ContainsKey("description") ? j["description"].ToString() : "";
            string notes       = j.ContainsKey("notes") ? j["notes"].ToString() : "";

            JToken t = j["type"];

            if (t.Type == JTokenType.String)
            {
                string type_name = t.ToObject <string>();
                if (GlobalEnums.HasEnum(type_name))
                {
                    return(new ConfigurationEnumeration(j["value"].ToObject <string>(), father, type_name, name, description, notes));
                }
            }
            else if (t.Type == JTokenType.Array)
            {
                JArray vals = (JArray)t;
                if (vals[0].Type != JTokenType.String)
                {
                    return(null);
                }
                List <string> values = new List <string>();
                foreach (JToken value in vals)
                {
                    values.Add(value.ToObject <string>());
                }
                return(new ConfigurationEnumeration(j["value"].ToObject <string>(), father, values, name, description, notes));
            }
            return(null);
        }
Exemple #15
0
 public ConfigurationEnumeration(ConfigurationEnumeration other, Changable father = null) : base(other, father)
 {
 }
Exemple #16
0
 public ConfigurationEnumeration(string value, Changable father = null, List <string> enum_values = null, string name = "", string description = "", string notes = "") : base(father, Brushes.DarkGoldenrod, name, true, description, notes)
 {
     Value = new EnumType(this, value, enum_values);
     IsExplicitnessChangeable = false;
 }
Exemple #17
0
 public ConfigurationEnumeration(string value, Changable father = null, string enum_name = "", string name = "", string description = "", string notes = "") : base(father, ConfigurationEnumeration.brush, name, true, description, notes)
 {
     Value = new EnumType(this, value, enum_name);
     IsExplicitnessChangeable = false;
 }
 public ConfigurationFloat(ConfigurationFloat other, Changable father = null) : base(other, father)
 {
 }
 public ConfigurationBool(ConfigurationBool other, Changable father = null) : base(other, father)
 {
 }
 public static new ConfigurationVariable TryConvert(string name, JToken fromJson, Changable father)
 {
     if (IsImplicitType(fromJson))
     {
         return(new ConfigurationFloat(fromJson.ToObject <float>(), father, false, name: name));
     }
     else if (IsExplicitType(fromJson))
     {
         JObject j           = (JObject)fromJson;
         string  description = j.ContainsKey("description") ? j["description"].ToString() : "";
         string  notes       = j.ContainsKey("notes") ? j["notes"].ToString() : "";
         bool    isLowBound  = j.ContainsKey("lower_bound");
         bool    isHighBound = j.ContainsKey("higher_bound");
         float   l           = isLowBound ? j["lower_bound"].ToObject <float>() : float.MinValue;
         float   h           = isHighBound ? j["higher_bound"].ToObject <float>() : float.MaxValue;
         return(new ConfigurationFloat(fromJson["value"].ToObject <float>(), father, true, lowest: l, highest: h, name: name, is_low_bound: isLowBound, is_high_bound: isHighBound, description: description, notes: notes));
     }
     return(null);
 }
Exemple #21
0
 /// <summary>
 /// When loading file from the disk, each configuration variable needs to be casted to the right ConfigurationVariable
 /// type. We retrieve every ConfigurationVariable type using reflection and try to convert the loaded content to
 /// each of the types, until one of them successes converting the loaded data.
 /// </summary>
 /// <returns></returns>
 public static ConfigurationVariable ConvertJsonToConfiguration(string name, JToken fromJson, Changable father)
 {
     try
     {
         return(GetAllConfigurationTypes().Select(t => t.GetMethod("TryConvert").Invoke(null, new object[] { name, fromJson, father })).First(o => o != null) as ConfigurationVariable);
     } catch (InvalidOperationException e)
     {
         string           messageBoxText = "Coud not load variable: " + name;
         string           caption        = "Word Processor";
         MessageBoxButton button         = MessageBoxButton.OK;
         MessageBoxImage  icon           = MessageBoxImage.Error;
         MessageBoxResult result         = MessageBox.Show(messageBoxText, caption, button, icon);
         return(null);
     }
 }
 public ConfigurationComposite(ConfigurationComposite other, Changable father = null) : base(other, father)
 {
 }
Exemple #23
0
 public static new ConfigurationString TryConvert(string name, JToken fromJson, Changable father)
 {
     if (IsImplicitType(fromJson))
     {
         return(new ConfigurationString(fromJson.ToObject <string>(), father, false, name));
     }
     else if (IsExplicitType(fromJson))
     {
         JObject x           = fromJson as JObject;
         string  description = x.ContainsKey("description") ? x["description"].ToString() : "";
         string  notes       = x.ContainsKey("notes") ? x["notes"].ToString() : "";
         return(new ConfigurationString(fromJson["value"].ToObject <string>(), father, true, name, description, notes));
     }
     return(null);
 }
 public override ConfigurationVariable Clone(Changable father = null)
 {
     return(new ConfigurationComposite(this, father));
 }
 public Sensor(int id, string type, Changable changeable)
 {
     Id         = id;
     Type       = type;
     Changeable = changeable;
 }