public static void SetStyle(string styleName) { foreach (MetalStyle style in loadedStyles) { if (style.Name == styleName) { activeStyle = style; break; } } }
static MetalStyleManager() { // We only create it once so that we can change the colors // that clients will be referencing on the fly systemStyle = new MetalStyle(); systemStyle.Name = "(System)"; useStyles = true; activeStyle = new MetalStyle(); RefreshSystemStyle(); }
static MetalStyleManager() { // We only create it once so that we can change the colors // that clients will be referencing on the fly systemStyle = new MetalStyle(); systemStyle.Name = "(System)"; useStyles = true; activeStyle = new MetalStyle(); RefreshSystemStyle(); }
public static MetalStyle LoadStyle(string fileName) { try { System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(MetalStyle)); System.IO.Stream stream = System.IO.File.OpenRead(fileName); MetalStyle style = (MetalStyle)serializer.Deserialize(stream); stream.Close(); stream = null; return(style); } catch { // TODO: Log return(new MetalStyle()); } }
public static void Refresh() { ArrayList styleFileList = new ArrayList(); string[] styleFiles = Directory.GetFiles(Environment.CurrentDirectory, "*.style"); foreach (string styleFile in styleFiles) { styleFileList.Add(styleFile); } // The Terrarium directory may not exist... try { string terrariumDocumentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\Terrarium"; styleFiles = Directory.GetFiles(terrariumDocumentsDirectory, "*.style"); foreach (string styleFile in styleFiles) { styleFileList.Add(styleFile); } } catch {} ArrayList styleList = new ArrayList(); MetalStyle defaultStyle = new MetalStyle(); defaultStyle.Name = "(Default)"; styleList.Add(defaultStyle); styleList.Add(systemStyle); foreach (string styleFile in styleFileList) { MetalStyle style = MetalStyleManager.LoadStyle(styleFile); styleList.Add(style); } loadedStyles = (MetalStyle[])styleList.ToArray(typeof(MetalStyle)); }
public static void SetStyle( string styleName ) { foreach( MetalStyle style in loadedStyles ) { if ( style.Name == styleName ) { activeStyle = style; break; } } }
public static void Refresh() { ArrayList styleFileList = new ArrayList(); string[] styleFiles = Directory.GetFiles( Environment.CurrentDirectory, "*.style" ); foreach( string styleFile in styleFiles ) styleFileList.Add( styleFile ); // The Terrarium directory may not exist... try { string terrariumDocumentsDirectory = Environment.GetFolderPath( Environment.SpecialFolder.Personal ) + "\\Terrarium"; styleFiles = Directory.GetFiles( terrariumDocumentsDirectory, "*.style" ); foreach( string styleFile in styleFiles ) styleFileList.Add( styleFile ); } catch{} ArrayList styleList = new ArrayList(); MetalStyle defaultStyle = new MetalStyle(); defaultStyle.Name = "(Default)"; styleList.Add( defaultStyle ); styleList.Add( systemStyle); foreach( string styleFile in styleFileList ) { MetalStyle style = MetalStyleManager.LoadStyle( styleFile ); styleList.Add( style ); } loadedStyles = (MetalStyle[])styleList.ToArray(typeof(MetalStyle)); }