This commit is contained in:
2010-08-12 16:05:52 +00:00
parent f91459b9f0
commit 0849b002b4
18 changed files with 231 additions and 212 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using System.Text.RegularExpressions;
namespace VEPROMS.CSLA.Library
{
@@ -83,6 +84,24 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Printing_Length");
}
}
private static Regex byARGB = new Regex(@"Color \[A=([0-9]*), R=([0-9]*), G=([0-9]*), B=([0-9]*)\]");
private static Regex byName = new Regex(@"Color \[(.*)\]");
public static Color ColorFromString(string sColor)
{
Match myMatch = byARGB.Match(sColor);
if (myMatch.Groups.Count == 5)
return Color.FromArgb(int.Parse(myMatch.Groups[1].Value), int.Parse(myMatch.Groups[2].Value), int.Parse(myMatch.Groups[3].Value), int.Parse(myMatch.Groups[4].Value));
myMatch = byName.Match(sColor);
if (myMatch.Groups.Count == 2)
return Color.FromName(myMatch.Groups[1].Value);
if (sColor[0] == '[')
{
string[] parts = sColor.Substring(1, sColor.Length - 2).Split(",".ToCharArray());
return Color.FromArgb(Int32.Parse(parts[0]), Int32.Parse(parts[1]), Int32.Parse(parts[2]), Int32.Parse(parts[3]));
}
else return Color.FromName(sColor);
}
[Category("Printing")]
[DisplayName("Color")]
[Description("Color of Document Text")]
@@ -91,21 +110,11 @@ namespace VEPROMS.CSLA.Library
get
{
string sColor = _Xp["Printing", "Color"];
if (sColor == string.Empty) sColor = "Transparent";
if (sColor[0] == '[')
{
string[] parts = sColor.Substring(1, sColor.Length - 2).Split(",".ToCharArray());
return Color.FromArgb(Int32.Parse(parts[0]), Int32.Parse(parts[1]), Int32.Parse(parts[2]), Int32.Parse(parts[3]));
}
else return Color.FromName(sColor);
return ColorFromString(sColor);
}
set
{
if (value.IsNamedColor) _Xp["Printing", "Color"] = value.Name;
else
{
_Xp["Printing", "Color"] = string.Format("[{0},{1},{2},{3}]", value.A, value.R, value.G, value.B);
}
_Xp["Printing", "Color"] = value.ToString();
OnPropertyChanged("Printing_Color");
}
}