- painter_src.zip
- Painter_src
- Globe
- Globe Framework
- Core
- Converters
- Utilities
- Graphics
- Bidimensional
- Base
- Common
- Resources
- Rotate.ico
- Xml
- Serialization
- CSharp
- Globe Programs
- Painter
- Globe.sln
- painter_demo.zip
- Painter_demo
- Disegno.xml
- Globe.Core.Converters.dll
- Globe.Core.Utilities.dll
- Globe.Graphics.Bidimensional.Base.dll
- Globe.Graphics.Bidimensional.Common.dll
- Globe.Xml.Serialization.dll
- Painter.exe
- painter_docs.zip
- Painter_docs
- Globe.Graphics.Bidimensional Documentation.chm
- Globe.Graphics.Bidimensional.vsd
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace Globe.Core.Converters
{
/// <summary>
/// Manages some conversions of a color.
/// </summary>
public class ColorConverter
{
#region Constructors
/// <summary>
/// Default constructor.
/// </summary>
public ColorConverter()
{
}
#endregion
#region Public Functions
/// <summary>
/// Gets a color from string.
/// </summary>
/// <param name="argb">String to convert.</param>
/// <param name="separator">Char separator for a, r, g, b.</param>
/// <returns>Color.</returns>
public static Color ColorFromString(string argb, char separator)
{
string[] components = argb.Split(new char[] {separator});
Color color = Color.White;
try
{
color = Color.FromArgb(
int.Parse(components[0]),
int.Parse(components[1]),
int.Parse(components[2]),
int.Parse(components[3]));
}
catch
{
throw new ApplicationException();
}
return color;
}
/// <summary>
/// Gets a string from a color.
/// </summary>
/// <param name="color">Color to convert.</param>
/// <param name="separator">Char separator for a, r, g, b.</param>
/// <returns>String that rapresents the color (format: a'separator'r'separator'g'separator'b).</returns>
public static string StringFromColor(Color color, char separator)
{
string argb = color.A.ToString() + separator + color.R.ToString() + separator + color.G.ToString() + separator + color.B.ToString();
return argb;
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a biomedical engineer. I work in Genoa as software developer. I developed MFC ActiveX controls for industrial automation for 2 years and packages for Visual Studio 2005 for 1 year. Currently I'm working in .NET 3.5 in biomedical area.