static private void ReadFiles() { string path = Directory.GetCurrentDirectory() + "\\config\\colormaps"; DirectoryInfo TheFolder = new DirectoryInfo(path); if (!TheFolder.Exists) { return; } foreach (FileInfo NextFile in TheFolder.GetFiles()) { if (NextFile.Extension == ".cm") { try { Dictionary <float, oepVec4f> cm = new Dictionary <float, oepVec4f>(); using (StreamReader sr = new StreamReader(NextFile.FullName)) { string line; while ((line = sr.ReadLine()) != null) { var strs = line.Split(' '); float v = 0.0f; float r = 0.0f; float g = 0.0f; float b = 0.0f; float a = 0.0f; if (strs.Length == 5 && float.TryParse(strs[0], out v) && float.TryParse(strs[1], out r) && float.TryParse(strs[2], out g) && float.TryParse(strs[3], out b) && float.TryParse(strs[4], out a)) { cm[v] = new oepVec4f(r, g, b, a); } } } if (cm.Count > 1) { ColorMapList.Add(cm); } } catch (Exception) { continue; } } } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { oepVec4f input = (oepVec4f)value; return(Color.FromScRgb(input.a, input.x, input.y, input.z)); }