/// <summary> /// Returns deep copy of this instance /// </summary> /// <returns></returns> public IClonable Clone() { ColorTheme thisClone = new ColorTheme(); foreach (ColorInfo colorInfo in m_AppInterfaceColorsDictionary.Values) { if (colorInfo == null || string.IsNullOrEmpty(colorInfo.SystemName)) { continue; } ColorInfo colorInfoClone = colorInfo.Clone() as ColorInfo; if (colorInfoClone == null || string.IsNullOrEmpty(colorInfoClone.SystemName)) { continue; } thisClone.AddInterfaceColor(colorInfoClone); } if (m_GeometryColorsTheme != null) { thisClone.GeometryColorsTheme = m_GeometryColorsTheme.Clone() as IGeometryColorsTheme; } return(thisClone); }
/// <summary> /// Add color info to m_AppInterfaceColorsDictionary /// </summary> protected bool AddInterfaceColor(ColorInfo colorInfo) { if (colorInfo == null || string.IsNullOrEmpty(colorInfo.SystemName)) { return(false); } m_AppInterfaceColorsDictionary[colorInfo.SystemName] = colorInfo; return(true); }
/// <summary> /// Read colors from stream /// </summary> public bool ReadFromStream(StreamReader sr) { if (sr == null) { return(false); } bool bInterfaceColor = false; bool bGeometryColor = false; string line; while ((line = sr.ReadLine()) != null) { if (HEADER_INTERFACE_COLORS == line) { bInterfaceColor = true; bGeometryColor = false; } else if (HEADER_GEOMETRY_COLORS == line) { bInterfaceColor = false; bGeometryColor = true; } else { string[] arr = line.Split(COLORINFO_VALUES_DELIMITER); if (arr.Count() >= 2) { string sysname = arr[0]; string value = arr[1]; string localname = string.Empty; if (arr.Count() >= 3) { localname = arr[2]; } string description = string.Empty; if (arr.Count() >= 4) { description = arr[3]; } if (string.IsNullOrEmpty(sysname)) { continue; } Color colorValue = Colors.Black; try { colorValue = (Color)ColorConverter.ConvertFromString(value); } catch { continue; } if (bInterfaceColor) { ColorInfo colorInfo = new ColorInfo(sysname, colorValue, localname, description); AddInterfaceColor(colorInfo); } else if (bGeometryColor) { eColorType colorType = ColorTheme.SystemNameToColorType(sysname); AddGeometryColor(colorType, colorValue); //// replace local name and descriptions //if (m_ColorTypeToDescriptionDict != null && m_ColorTypeToDescriptionDict.ContainsKey(colorType)) // m_ColorTypeToDescriptionDict[colorType] = description; //if (m_ColorTypeToLocalNameDict != null && m_ColorTypeToLocalNameDict.ContainsKey(colorType)) // m_ColorTypeToLocalNameDict[colorType] = localname; } } } } return(true); }