diff options
| author | j-p <jp.bruyere@live.be> | 2018-04-14 12:15:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-14 12:15:08 +0200 |
| commit | 907358fed63b4a89e8dee5184cc9901a7107ab9f (patch) | |
| tree | 18c473a86b553dbe9f08cfe345b6278c71e9594e /src | |
| parent | 7c735fa149bf23223eda734f19d5547797ca8ac2 (diff) | |
| parent | 5a06966fd4be89263988d0838556b78a7988b5a9 (diff) | |
Merge pull request #40 from jpbruyere/devel
Devel
Diffstat (limited to 'src')
59 files changed, 2751 insertions, 3094 deletions
diff --git a/src/BmpPicture.cs b/src/BmpPicture.cs index b8271615..e3af9c79 100644 --- a/src/BmpPicture.cs +++ b/src/BmpPicture.cs @@ -55,7 +55,7 @@ namespace Crow /// load the image for rendering from the path given as argument /// </summary> /// <param name="path">image path, may be embedded</param> - public override void Load (string path) + public override void Load (Interface iface, string path) { Path = path; if (sharedResources.ContainsKey (path)) { @@ -64,11 +64,8 @@ namespace Crow Dimensions = sp.Dims; return; } - using (Stream stream = Interface.GetStreamFromPath (path)) { - using (MemoryStream ms = new MemoryStream ()) { - stream.CopyTo (ms); - loadBitmap (new System.Drawing.Bitmap (ms)); - } + using (Stream stream = iface.GetStreamFromPath (path)) { + loadBitmap (new System.Drawing.Bitmap (stream)); } sharedResources [path] = new sharedPicture (image, Dimensions); } diff --git a/src/Colors.cs b/src/Colors.cs index e62abb75..0b1b3ad7 100644 --- a/src/Colors.cs +++ b/src/Colors.cs @@ -50,6 +50,8 @@ namespace Crow R = _R.Clamp(0,1); G = _G.Clamp(0,1); B = _B.Clamp(0,1); + predefinied = false; + htmlCode = ""; Name = ""; } internal Color(double _R, double _G, double _B, double _A, string _name) @@ -58,7 +60,20 @@ namespace Crow R = _R; G = _G; B = _B; + predefinied = false; Name = _name; + htmlCode = ""; + ColorDic.Add(_name,this); + } + internal Color(int _R, int _G, int _B, string _name, string _code) + { + A = 1.0; + R = _R / 255.0; + G = _G / 255.0; + B = _B / 255.0; + Name = _name; + htmlCode = _code; + predefinied = true; ColorDic.Add(_name,this); } #endregion @@ -68,7 +83,9 @@ namespace Crow /// </summary> public static Dictionary<string, Color> ColorDic = new Dictionary<string, Color>(); - internal string Name; + public string Name; + public string htmlCode; + internal bool predefinied; #region public fields public double A; @@ -86,15 +103,26 @@ namespace Crow { if (string.IsNullOrEmpty(s)) return White; + Color cc = default(Color); + if (s.StartsWith ("#")) { + cc.R = int.Parse (s.Substring (1, 2), System.Globalization.NumberStyles.HexNumber) / 255.0; + cc.G = int.Parse (s.Substring (3, 2), System.Globalization.NumberStyles.HexNumber) / 255.0; + cc.B = int.Parse (s.Substring (5, 2), System.Globalization.NumberStyles.HexNumber) / 255.0; + if (s.Length > 7) + cc.A = int.Parse (s.Substring (7, 2), System.Globalization.NumberStyles.HexNumber) / 255.0; + else + cc.A = 1.0; + return cc; + } - string[] c = s.Split(new char[] { ',' }); - - if (c.Length == 1) - { + if (char.IsLetter(s[0])){ if (ColorDic.ContainsKey (s)) return ColorDic[s]; throw new Exception ("Unknown color name: " + s); } + + string[] c = s.Split(new char[] { ',' }); + return new Color( double.Parse(c[0]), double.Parse(c[1]), @@ -114,6 +142,8 @@ namespace Crow public static bool operator ==(Color left, Color right) { + if (left.predefinied & right.predefinied) + return left.htmlCode == right.htmlCode; return left.A != right.A ? false : left.R != right.R ? false : left.G != right.G ? false : @@ -121,6 +151,8 @@ namespace Crow } public static bool operator !=(Color left, Color right) { + if (left.predefinied & right.predefinied) + return left.htmlCode != right.htmlCode; return left.A == right.A ? false : left.R == right.R ? false : left.G == right.G ? false : @@ -129,11 +161,15 @@ namespace Crow } public static bool operator ==(Color c, string n) { - return string.Equals(c.Name, n, StringComparison.Ordinal); + return n.StartsWith("#") ? + string.Equals(c.HtmlCode, n, StringComparison.Ordinal) : + string.Equals(c.Name, n, StringComparison.Ordinal); } public static bool operator !=(Color c, string n) { - return !string.Equals(c.Name, n, StringComparison.Ordinal); + return n.StartsWith("#") ? + !string.Equals(c.HtmlCode, n, StringComparison.Ordinal) : + !string.Equals(c.Name, n, StringComparison.Ordinal); } public static bool operator ==(string n, Color c) { @@ -210,7 +246,17 @@ namespace Crow return diff == 0 ? 0 : diff / max; } } - + public string HtmlCode { + get { + string tmp = "#" + + ((int)Math.Round (R * 255.0)).ToString ("X2") + + ((int)Math.Round (G * 255.0)).ToString ("X2") + + ((int)Math.Round (B * 255.0)).ToString ("X2"); + if (A < 1.0) + tmp += ((int)Math.Round(A * 255.0)).ToString ("X2"); + return tmp; + } + } public float[] floatArray { get { return new float[]{ (float)R, (float)G, (float)B, (float)A }; } @@ -226,896 +272,163 @@ namespace Crow } public void ResetName(){ Name = ""; + htmlCode = ""; } #region Predefined colors public static readonly Color Transparent = new Color(0, 0, 0, 0, "Transparent"); public static readonly Color Clear = new Color(-1, -1, -1, -1, "Clear"); - public static readonly Color Green = new Color(0, 1.0, 0, 1.0, "Green"); - public static readonly Color AirForceBlueRaf = new Color(0.364705882352941,0.541176470588235,0.658823529411765,1.0,"AirForceBlueRaf"); - public static readonly Color AirForceBlueUsaf = new Color(0,0.188235294117647,0.56078431372549,1.0,"AirForceBlueUsaf"); - public static readonly Color AirSuperiorityBlue = new Color(0.447058823529412,0.627450980392157,0.756862745098039,1.0,"AirSuperiorityBlue"); - public static readonly Color AlabamaCrimson = new Color(0.63921568627451,0.149019607843137,0.219607843137255,1.0,"AlabamaCrimson"); - public static readonly Color AliceBlue = new Color(0.941176470588235,0.972549019607843,1,1.0,"AliceBlue"); - public static readonly Color AlizarinCrimson = new Color(0.890196078431373,0.149019607843137,0.211764705882353,1.0,"AlizarinCrimson"); - public static readonly Color AlloyOrange = new Color(0.768627450980392,0.384313725490196,0.0627450980392157,1.0,"AlloyOrange"); - public static readonly Color Almond = new Color(0.937254901960784,0.870588235294118,0.803921568627451,1.0,"Almond"); - public static readonly Color Amaranth = new Color(0.898039215686275,0.168627450980392,0.313725490196078,1.0,"Amaranth"); - public static readonly Color Amber = new Color(1,0.749019607843137,0,1.0,"Amber"); - public static readonly Color AmberSaeEce = new Color(1,0.494117647058824,0,1.0,"AmberSaeEce"); - public static readonly Color AmericanRose = new Color(1,0.0117647058823529,0.243137254901961,1.0,"AmericanRose"); - public static readonly Color Amethyst = new Color(0.6,0.4,0.8,1.0,"Amethyst"); - public static readonly Color AndroidGreen = new Color(0.643137254901961,0.776470588235294,0.223529411764706,1.0,"AndroidGreen"); - public static readonly Color AntiFlashWhite = new Color(0.949019607843137,0.952941176470588,0.956862745098039,1.0,"AntiFlashWhite"); - public static readonly Color AntiqueBrass = new Color(0.803921568627451,0.584313725490196,0.458823529411765,1.0,"AntiqueBrass"); - public static readonly Color AntiqueFuchsia = new Color(0.568627450980392,0.36078431372549,0.513725490196078,1.0,"AntiqueFuchsia"); - public static readonly Color AntiqueRuby = new Color(0.517647058823529,0.105882352941176,0.176470588235294,1.0,"AntiqueRuby"); - public static readonly Color AntiqueWhite = new Color(0.980392156862745,0.92156862745098,0.843137254901961,1.0,"AntiqueWhite"); - public static readonly Color AoEnglish = new Color(0,0.501960784313725,0,1.0,"AoEnglish"); - public static readonly Color AppleGreen = new Color(0.552941176470588,0.713725490196078,0,1.0,"AppleGreen"); - public static readonly Color Apricot = new Color(0.984313725490196,0.807843137254902,0.694117647058824,1.0,"Apricot"); - public static readonly Color Aqua = new Color(0,1,1,1.0,"Aqua"); - public static readonly Color Aquamarine = new Color(0.498039215686275,1,0.831372549019608,1.0,"Aquamarine"); - public static readonly Color ArmyGreen = new Color(0.294117647058824,0.325490196078431,0.125490196078431,1.0,"ArmyGreen"); - public static readonly Color Arsenic = new Color(0.231372549019608,0.266666666666667,0.294117647058824,1.0,"Arsenic"); - public static readonly Color ArylideYellow = new Color(0.913725490196078,0.83921568627451,0.419607843137255,1.0,"ArylideYellow"); - public static readonly Color AshGrey = new Color(0.698039215686274,0.745098039215686,0.709803921568627,1.0,"AshGrey"); - public static readonly Color Asparagus = new Color(0.529411764705882,0.662745098039216,0.419607843137255,1.0,"Asparagus"); - public static readonly Color AtomicTangerine = new Color(1,0.6,0.4,1.0,"AtomicTangerine"); - public static readonly Color Auburn = new Color(0.647058823529412,0.164705882352941,0.164705882352941,1.0,"Auburn"); - public static readonly Color Aureolin = new Color(0.992156862745098,0.933333333333333,0,1.0,"Aureolin"); - public static readonly Color Aurometalsaurus = new Color(0.431372549019608,0.498039215686275,0.501960784313725,1.0,"Aurometalsaurus"); - public static readonly Color Avocado = new Color(0.337254901960784,0.509803921568627,0.0117647058823529,1.0,"Avocado"); - public static readonly Color Azure = new Color(0,0.498039215686275,1,1.0,"Azure"); - public static readonly Color AzureMistWeb = new Color(0.941176470588235,1,1,1.0,"AzureMistWeb"); - public static readonly Color BabyBlue = new Color(0.537254901960784,0.811764705882353,0.941176470588235,1.0,"BabyBlue"); - public static readonly Color BabyBlueEyes = new Color(0.631372549019608,0.792156862745098,0.945098039215686,1.0,"BabyBlueEyes"); - public static readonly Color BabyPink = new Color(0.956862745098039,0.76078431372549,0.76078431372549,1.0,"BabyPink"); - public static readonly Color BallBlue = new Color(0.129411764705882,0.670588235294118,0.803921568627451,1.0,"BallBlue"); - public static readonly Color BananaMania = new Color(0.980392156862745,0.905882352941176,0.709803921568627,1.0,"BananaMania"); - public static readonly Color BananaYellow = new Color(1,0.882352941176471,0.207843137254902,1.0,"BananaYellow"); - public static readonly Color BarnRed = new Color(0.486274509803922,0.0392156862745098,0.00784313725490196,1.0,"BarnRed"); - public static readonly Color BattleshipGrey = new Color(0.517647058823529,0.517647058823529,0.509803921568627,1.0,"BattleshipGrey"); - public static readonly Color Bazaar = new Color(0.596078431372549,0.466666666666667,0.482352941176471,1.0,"Bazaar"); - public static readonly Color BeauBlue = new Color(0.737254901960784,0.831372549019608,0.901960784313726,1.0,"BeauBlue"); - public static readonly Color Beaver = new Color(0.623529411764706,0.505882352941176,0.43921568627451,1.0,"Beaver"); - public static readonly Color Beige = new Color(0.96078431372549,0.96078431372549,0.862745098039216,1.0,"Beige"); - public static readonly Color BigDipORuby = new Color(0.611764705882353,0.145098039215686,0.258823529411765,1.0,"BigDipORuby"); - public static readonly Color Bisque = new Color(1,0.894117647058824,0.768627450980392,1.0,"Bisque"); - public static readonly Color Bistre = new Color(0.23921568627451,0.168627450980392,0.12156862745098,1.0,"Bistre"); - public static readonly Color Bittersweet = new Color(0.996078431372549,0.435294117647059,0.368627450980392,1.0,"Bittersweet"); - public static readonly Color BittersweetShimmer = new Color(0.749019607843137,0.309803921568627,0.317647058823529,1.0,"BittersweetShimmer"); - public static readonly Color Black = new Color(0,0,0,1.0,"Black"); - public static readonly Color BlackBean = new Color(0.23921568627451,0.0470588235294118,0.00784313725490196,1.0,"BlackBean"); - public static readonly Color BlackLeatherJacket = new Color(0.145098039215686,0.207843137254902,0.16078431372549,1.0,"BlackLeatherJacket"); - public static readonly Color BlackOlive = new Color(0.231372549019608,0.235294117647059,0.211764705882353,1.0,"BlackOlive"); - public static readonly Color BlanchedAlmond = new Color(1,0.92156862745098,0.803921568627451,1.0,"BlanchedAlmond"); - public static readonly Color BlastOffBronze = new Color(0.647058823529412,0.443137254901961,0.392156862745098,1.0,"BlastOffBronze"); - public static readonly Color BleuDeFrance = new Color(0.192156862745098,0.549019607843137,0.905882352941176,1.0,"BleuDeFrance"); - public static readonly Color BlizzardBlue = new Color(0.674509803921569,0.898039215686275,0.933333333333333,1.0,"BlizzardBlue"); - public static readonly Color Blond = new Color(0.980392156862745,0.941176470588235,0.745098039215686,1.0,"Blond"); - public static readonly Color Blue = new Color(0,0,1,1.0,"Blue"); - public static readonly Color BlueBell = new Color(0.635294117647059,0.635294117647059,0.815686274509804,1.0,"BlueBell"); - public static readonly Color BlueCrayola = new Color(0.12156862745098,0.458823529411765,0.996078431372549,1.0,"BlueCrayola"); - public static readonly Color BlueGray = new Color(0.4,0.6,0.8,1.0,"BlueGray"); - public static readonly Color BlueGreen = new Color(0.0509803921568627,0.596078431372549,0.729411764705882,1.0,"BlueGreen"); - public static readonly Color BlueMunsell = new Color(0,0.576470588235294,0.686274509803922,1.0,"BlueMunsell"); - public static readonly Color BlueNcs = new Color(0,0.529411764705882,0.741176470588235,1.0,"BlueNcs"); - public static readonly Color BluePigment = new Color(0.2,0.2,0.6,1.0,"BluePigment"); - public static readonly Color BlueRyb = new Color(0.00784313725490196,0.27843137254902,0.996078431372549,1.0,"BlueRyb"); - public static readonly Color BlueSapphire = new Color(0.0705882352941176,0.380392156862745,0.501960784313725,1.0,"BlueSapphire"); - public static readonly Color BlueViolet = new Color(0.541176470588235,0.168627450980392,0.886274509803922,1.0,"BlueViolet"); - public static readonly Color Blush = new Color(0.870588235294118,0.364705882352941,0.513725490196078,1.0,"Blush"); - public static readonly Color Bole = new Color(0.474509803921569,0.266666666666667,0.231372549019608,1.0,"Bole"); - public static readonly Color BondiBlue = new Color(0,0.584313725490196,0.713725490196078,1.0,"BondiBlue"); - public static readonly Color Bone = new Color(0.890196078431373,0.854901960784314,0.788235294117647,1.0,"Bone"); - public static readonly Color BostonUniversityRed = new Color(0.8,0,0,1.0,"BostonUniversityRed"); - public static readonly Color BottleGreen = new Color(0,0.415686274509804,0.305882352941176,1.0,"BottleGreen"); - public static readonly Color Boysenberry = new Color(0.529411764705882,0.196078431372549,0.376470588235294,1.0,"Boysenberry"); - public static readonly Color BrandeisBlue = new Color(0,0.43921568627451,1,1.0,"BrandeisBlue"); - public static readonly Color Brass = new Color(0.709803921568627,0.650980392156863,0.258823529411765,1.0,"Brass"); - public static readonly Color BrickRed = new Color(0.796078431372549,0.254901960784314,0.329411764705882,1.0,"BrickRed"); - public static readonly Color BrightCerulean = new Color(0.113725490196078,0.674509803921569,0.83921568627451,1.0,"BrightCerulean"); - public static readonly Color BrightGreen = new Color(0.4,1,0,1.0,"BrightGreen"); - public static readonly Color BrightLavender = new Color(0.749019607843137,0.580392156862745,0.894117647058824,1.0,"BrightLavender"); - public static readonly Color BrightMaroon = new Color(0.764705882352941,0.129411764705882,0.282352941176471,1.0,"BrightMaroon"); - public static readonly Color BrightPink = new Color(1,0,0.498039215686275,1.0,"BrightPink"); - public static readonly Color BrightTurquoise = new Color(0.0313725490196078,0.909803921568627,0.870588235294118,1.0,"BrightTurquoise"); - public static readonly Color BrightUbe = new Color(0.819607843137255,0.623529411764706,0.909803921568627,1.0,"BrightUbe"); - public static readonly Color BrilliantLavender = new Color(0.956862745098039,0.733333333333333,1,1.0,"BrilliantLavender"); - public static readonly Color BrilliantRose = new Color(1,0.333333333333333,0.63921568627451,1.0,"BrilliantRose"); - public static readonly Color BrinkPink = new Color(0.984313725490196,0.376470588235294,0.498039215686275,1.0,"BrinkPink"); - public static readonly Color BritishRacingGreen = new Color(0,0.258823529411765,0.145098039215686,1.0,"BritishRacingGreen"); - public static readonly Color Bronze = new Color(0.803921568627451,0.498039215686275,0.196078431372549,1.0,"Bronze"); - public static readonly Color BrownTraditional = new Color(0.588235294117647,0.294117647058824,0,1.0,"BrownTraditional"); - public static readonly Color BrownWeb = new Color(0.647058823529412,0.164705882352941,0.164705882352941,1.0,"BrownWeb"); - public static readonly Color BubbleGum = new Color(1,0.756862745098039,0.8,1.0,"BubbleGum"); - public static readonly Color Bubbles = new Color(0.905882352941176,0.996078431372549,1,1.0,"Bubbles"); - public static readonly Color Buff = new Color(0.941176470588235,0.862745098039216,0.509803921568627,1.0,"Buff"); - public static readonly Color BulgarianRose = new Color(0.282352941176471,0.0235294117647059,0.0274509803921569,1.0,"BulgarianRose"); - public static readonly Color Burgundy = new Color(0.501960784313725,0,0.125490196078431,1.0,"Burgundy"); - public static readonly Color Burlywood = new Color(0.870588235294118,0.72156862745098,0.529411764705882,1.0,"Burlywood"); - public static readonly Color BurntOrange = new Color(0.8,0.333333333333333,0,1.0,"BurntOrange"); - public static readonly Color BurntSienna = new Color(0.913725490196078,0.454901960784314,0.317647058823529,1.0,"BurntSienna"); - public static readonly Color BurntUmber = new Color(0.541176470588235,0.2,0.141176470588235,1.0,"BurntUmber"); - public static readonly Color Byzantine = new Color(0.741176470588235,0.2,0.643137254901961,1.0,"Byzantine"); - public static readonly Color Byzantium = new Color(0.43921568627451,0.16078431372549,0.388235294117647,1.0,"Byzantium"); - public static readonly Color Cadet = new Color(0.325490196078431,0.407843137254902,0.447058823529412,1.0,"Cadet"); - public static readonly Color CadetBlue = new Color(0.372549019607843,0.619607843137255,0.627450980392157,1.0,"CadetBlue"); - public static readonly Color CadetGrey = new Color(0.568627450980392,0.63921568627451,0.690196078431373,1.0,"CadetGrey"); - public static readonly Color CadmiumGreen = new Color(0,0.419607843137255,0.235294117647059,1.0,"CadmiumGreen"); - public static readonly Color CadmiumOrange = new Color(0.929411764705882,0.529411764705882,0.176470588235294,1.0,"CadmiumOrange"); - public static readonly Color CadmiumRed = new Color(0.890196078431373,0,0.133333333333333,1.0,"CadmiumRed"); - public static readonly Color CadmiumYellow = new Color(1,0.964705882352941,0,1.0,"CadmiumYellow"); - public static readonly Color CafAuLait = new Color(0.650980392156863,0.482352941176471,0.356862745098039,1.0,"CafAuLait"); - public static readonly Color CafNoir = new Color(0.294117647058824,0.211764705882353,0.129411764705882,1.0,"CafNoir"); - public static readonly Color CalPolyGreen = new Color(0.117647058823529,0.301960784313725,0.168627450980392,1.0,"CalPolyGreen"); - public static readonly Color CambridgeBlue = new Color(0.63921568627451,0.756862745098039,0.67843137254902,1.0,"CambridgeBlue"); - public static readonly Color Camel = new Color(0.756862745098039,0.603921568627451,0.419607843137255,1.0,"Camel"); - public static readonly Color CameoPink = new Color(0.937254901960784,0.733333333333333,0.8,1.0,"CameoPink"); - public static readonly Color CamouflageGreen = new Color(0.470588235294118,0.525490196078431,0.419607843137255,1.0,"CamouflageGreen"); - public static readonly Color CanaryYellow = new Color(1,0.937254901960784,0,1.0,"CanaryYellow"); - public static readonly Color CandyAppleRed = new Color(1,0.0313725490196078,0,1.0,"CandyAppleRed"); - public static readonly Color CandyPink = new Color(0.894117647058824,0.443137254901961,0.47843137254902,1.0,"CandyPink"); - public static readonly Color Capri = new Color(0,0.749019607843137,1,1.0,"Capri"); - public static readonly Color CaputMortuum = new Color(0.349019607843137,0.152941176470588,0.125490196078431,1.0,"CaputMortuum"); - public static readonly Color Cardinal = new Color(0.768627450980392,0.117647058823529,0.227450980392157,1.0,"Cardinal"); - public static readonly Color CaribbeanGreen = new Color(0,0.8,0.6,1.0,"CaribbeanGreen"); - public static readonly Color Carmine = new Color(0.588235294117647,0,0.0941176470588235,1.0,"Carmine"); - public static readonly Color CarmineMP = new Color(0.843137254901961,0,0.250980392156863,1.0,"CarmineMP"); - public static readonly Color CarminePink = new Color(0.92156862745098,0.298039215686275,0.258823529411765,1.0,"CarminePink"); - public static readonly Color CarmineRed = new Color(1,0,0.219607843137255,1.0,"CarmineRed"); - public static readonly Color CarnationPink = new Color(1,0.650980392156863,0.788235294117647,1.0,"CarnationPink"); - public static readonly Color Carnelian = new Color(0.701960784313725,0.105882352941176,0.105882352941176,1.0,"Carnelian"); - public static readonly Color CarolinaBlue = new Color(0.6,0.729411764705882,0.866666666666667,1.0,"CarolinaBlue"); - public static readonly Color CarrotOrange = new Color(0.929411764705882,0.568627450980392,0.129411764705882,1.0,"CarrotOrange"); - public static readonly Color CatalinaBlue = new Color(0.0235294117647059,0.164705882352941,0.470588235294118,1.0,"CatalinaBlue"); - public static readonly Color Ceil = new Color(0.572549019607843,0.631372549019608,0.811764705882353,1.0,"Ceil"); - public static readonly Color Celadon = new Color(0.674509803921569,0.882352941176471,0.686274509803922,1.0,"Celadon"); - public static readonly Color CeladonBlue = new Color(0,0.482352941176471,0.654901960784314,1.0,"CeladonBlue"); - public static readonly Color CeladonGreen = new Color(0.184313725490196,0.517647058823529,0.486274509803922,1.0,"CeladonGreen"); - public static readonly Color CelesteColour = new Color(0.698039215686274,1,1,1.0,"CelesteColour"); - public static readonly Color CelestialBlue = new Color(0.286274509803922,0.592156862745098,0.815686274509804,1.0,"CelestialBlue"); - public static readonly Color Cerise = new Color(0.870588235294118,0.192156862745098,0.388235294117647,1.0,"Cerise"); - public static readonly Color CerisePink = new Color(0.925490196078431,0.231372549019608,0.513725490196078,1.0,"CerisePink"); - public static readonly Color Cerulean = new Color(0,0.482352941176471,0.654901960784314,1.0,"Cerulean"); - public static readonly Color CeruleanBlue = new Color(0.164705882352941,0.32156862745098,0.745098039215686,1.0,"CeruleanBlue"); - public static readonly Color CeruleanFrost = new Color(0.427450980392157,0.607843137254902,0.764705882352941,1.0,"CeruleanFrost"); - public static readonly Color CgBlue = new Color(0,0.47843137254902,0.647058823529412,1.0,"CgBlue"); - public static readonly Color CgRed = new Color(0.87843137254902,0.235294117647059,0.192156862745098,1.0,"CgRed"); - public static readonly Color Chamoisee = new Color(0.627450980392157,0.470588235294118,0.352941176470588,1.0,"Chamoisee"); - public static readonly Color Champagne = new Color(0.980392156862745,0.83921568627451,0.647058823529412,1.0,"Champagne"); - public static readonly Color Charcoal = new Color(0.211764705882353,0.270588235294118,0.309803921568627,1.0,"Charcoal"); - public static readonly Color CharmPink = new Color(0.901960784313726,0.56078431372549,0.674509803921569,1.0,"CharmPink"); - public static readonly Color ChartreuseTraditional = new Color(0.874509803921569,1,0,1.0,"ChartreuseTraditional"); - public static readonly Color ChartreuseWeb = new Color(0.498039215686275,1,0,1.0,"ChartreuseWeb"); - public static readonly Color Cherry = new Color(0.870588235294118,0.192156862745098,0.388235294117647,1.0,"Cherry"); - public static readonly Color CherryBlossomPink = new Color(1,0.717647058823529,0.772549019607843,1.0,"CherryBlossomPink"); - public static readonly Color Chestnut = new Color(0.803921568627451,0.36078431372549,0.36078431372549,1.0,"Chestnut"); - public static readonly Color ChinaPink = new Color(0.870588235294118,0.435294117647059,0.631372549019608,1.0,"ChinaPink"); - public static readonly Color ChinaRose = new Color(0.658823529411765,0.317647058823529,0.431372549019608,1.0,"ChinaRose"); - public static readonly Color ChineseRed = new Color(0.666666666666667,0.219607843137255,0.117647058823529,1.0,"ChineseRed"); - public static readonly Color ChocolateTraditional = new Color(0.482352941176471,0.247058823529412,0,1.0,"ChocolateTraditional"); - public static readonly Color ChocolateWeb = new Color(0.823529411764706,0.411764705882353,0.117647058823529,1.0,"ChocolateWeb"); - public static readonly Color ChromeYellow = new Color(1,0.654901960784314,0,1.0,"ChromeYellow"); - public static readonly Color Cinereous = new Color(0.596078431372549,0.505882352941176,0.482352941176471,1.0,"Cinereous"); - public static readonly Color Cinnabar = new Color(0.890196078431373,0.258823529411765,0.203921568627451,1.0,"Cinnabar"); - public static readonly Color Cinnamon = new Color(0.823529411764706,0.411764705882353,0.117647058823529,1.0,"Cinnamon"); - public static readonly Color Citrine = new Color(0.894117647058824,0.815686274509804,0.0392156862745098,1.0,"Citrine"); - public static readonly Color ClassicRose = new Color(0.984313725490196,0.8,0.905882352941176,1.0,"ClassicRose"); - public static readonly Color Cobalt = new Color(0,0.27843137254902,0.670588235294118,1.0,"Cobalt"); - public static readonly Color CocoaBrown = new Color(0.823529411764706,0.411764705882353,0.117647058823529,1.0,"CocoaBrown"); - public static readonly Color Coffee = new Color(0.435294117647059,0.305882352941176,0.215686274509804,1.0,"Coffee"); - public static readonly Color ColumbiaBlue = new Color(0.607843137254902,0.866666666666667,1,1.0,"ColumbiaBlue"); - public static readonly Color CongoPink = new Color(0.972549019607843,0.513725490196078,0.474509803921569,1.0,"CongoPink"); - public static readonly Color CoolBlack = new Color(0,0.180392156862745,0.388235294117647,1.0,"CoolBlack"); - public static readonly Color CoolGrey = new Color(0.549019607843137,0.572549019607843,0.674509803921569,1.0,"CoolGrey"); - public static readonly Color Copper = new Color(0.72156862745098,0.450980392156863,0.2,1.0,"Copper"); - public static readonly Color CopperCrayola = new Color(0.854901960784314,0.541176470588235,0.403921568627451,1.0,"CopperCrayola"); - public static readonly Color CopperPenny = new Color(0.67843137254902,0.435294117647059,0.411764705882353,1.0,"CopperPenny"); - public static readonly Color CopperRed = new Color(0.796078431372549,0.427450980392157,0.317647058823529,1.0,"CopperRed"); - public static readonly Color CopperRose = new Color(0.6,0.4,0.4,1.0,"CopperRose"); - public static readonly Color Coquelicot = new Color(1,0.219607843137255,0,1.0,"Coquelicot"); - public static readonly Color Coral = new Color(1,0.498039215686275,0.313725490196078,1.0,"Coral"); - public static readonly Color CoralPink = new Color(0.972549019607843,0.513725490196078,0.474509803921569,1.0,"CoralPink"); - public static readonly Color CoralRed = new Color(1,0.250980392156863,0.250980392156863,1.0,"CoralRed"); - public static readonly Color Cordovan = new Color(0.537254901960784,0.247058823529412,0.270588235294118,1.0,"Cordovan"); - public static readonly Color Corn = new Color(0.984313725490196,0.925490196078431,0.364705882352941,1.0,"Corn"); - public static readonly Color CornellRed = new Color(0.701960784313725,0.105882352941176,0.105882352941176,1.0,"CornellRed"); - public static readonly Color CornflowerBlue = new Color(0.392156862745098,0.584313725490196,0.929411764705882,1.0,"CornflowerBlue"); - public static readonly Color Cornsilk = new Color(1,0.972549019607843,0.862745098039216,1.0,"Cornsilk"); - public static readonly Color CosmicLatte = new Color(1,0.972549019607843,0.905882352941176,1.0,"CosmicLatte"); - public static readonly Color CottonCandy = new Color(1,0.737254901960784,0.850980392156863,1.0,"CottonCandy"); - public static readonly Color Cream = new Color(1,0.992156862745098,0.815686274509804,1.0,"Cream"); - public static readonly Color Crimson = new Color(0.862745098039216,0.0784313725490196,0.235294117647059,1.0,"Crimson"); - public static readonly Color CrimsonGlory = new Color(0.745098039215686,0,0.196078431372549,1.0,"CrimsonGlory"); - public static readonly Color Cyan = new Color(0,1,1,1.0,"Cyan"); - public static readonly Color CyanProcess = new Color(0,0.717647058823529,0.92156862745098,1.0,"CyanProcess"); - public static readonly Color Daffodil = new Color(1,1,0.192156862745098,1.0,"Daffodil"); - public static readonly Color Dandelion = new Color(0.941176470588235,0.882352941176471,0.188235294117647,1.0,"Dandelion"); - public static readonly Color DarkBlue = new Color(0,0,0.545098039215686,1.0,"DarkBlue"); - public static readonly Color DarkBrown = new Color(0.396078431372549,0.262745098039216,0.129411764705882,1.0,"DarkBrown"); - public static readonly Color DarkByzantium = new Color(0.364705882352941,0.223529411764706,0.329411764705882,1.0,"DarkByzantium"); - public static readonly Color DarkCandyAppleRed = new Color(0.643137254901961,0,0,1.0,"DarkCandyAppleRed"); - public static readonly Color DarkCerulean = new Color(0.0313725490196078,0.270588235294118,0.494117647058824,1.0,"DarkCerulean"); - public static readonly Color DarkChestnut = new Color(0.596078431372549,0.411764705882353,0.376470588235294,1.0,"DarkChestnut"); - public static readonly Color DarkCoral = new Color(0.803921568627451,0.356862745098039,0.270588235294118,1.0,"DarkCoral"); - public static readonly Color DarkCyan = new Color(0,0.545098039215686,0.545098039215686,1.0,"DarkCyan"); - public static readonly Color DarkElectricBlue = new Color(0.325490196078431,0.407843137254902,0.470588235294118,1.0,"DarkElectricBlue"); - public static readonly Color DarkGoldenrod = new Color(0.72156862745098,0.525490196078431,0.0431372549019608,1.0,"DarkGoldenrod"); - public static readonly Color DarkGray = new Color(0.662745098039216,0.662745098039216,0.662745098039216,1.0,"DarkGray"); - public static readonly Color DarkGreen = new Color(0.00392156862745098,0.196078431372549,0.125490196078431,1.0,"DarkGreen"); - public static readonly Color DarkImperialBlue = new Color(0,0.254901960784314,0.415686274509804,1.0,"DarkImperialBlue"); - public static readonly Color DarkJungleGreen = new Color(0.101960784313725,0.141176470588235,0.129411764705882,1.0,"DarkJungleGreen"); - public static readonly Color DarkKhaki = new Color(0.741176470588235,0.717647058823529,0.419607843137255,1.0,"DarkKhaki"); - public static readonly Color DarkLava = new Color(0.282352941176471,0.235294117647059,0.196078431372549,1.0,"DarkLava"); - public static readonly Color DarkLavender = new Color(0.450980392156863,0.309803921568627,0.588235294117647,1.0,"DarkLavender"); - public static readonly Color DarkMagenta = new Color(0.545098039215686,0,0.545098039215686,1.0,"DarkMagenta"); - public static readonly Color DarkMidnightBlue = new Color(0,0.2,0.4,1.0,"DarkMidnightBlue"); - public static readonly Color DarkOliveGreen = new Color(0.333333333333333,0.419607843137255,0.184313725490196,1.0,"DarkOliveGreen"); - public static readonly Color DarkOrange = new Color(1,0.549019607843137,0,1.0,"DarkOrange"); - public static readonly Color DarkOrchid = new Color(0.6,0.196078431372549,0.8,1.0,"DarkOrchid"); - public static readonly Color DarkPastelBlue = new Color(0.466666666666667,0.619607843137255,0.796078431372549,1.0,"DarkPastelBlue"); - public static readonly Color DarkPastelGreen = new Color(0.0117647058823529,0.752941176470588,0.235294117647059,1.0,"DarkPastelGreen"); - public static readonly Color DarkPastelPurple = new Color(0.588235294117647,0.435294117647059,0.83921568627451,1.0,"DarkPastelPurple"); - public static readonly Color DarkPastelRed = new Color(0.76078431372549,0.231372549019608,0.133333333333333,1.0,"DarkPastelRed"); - public static readonly Color DarkPink = new Color(0.905882352941176,0.329411764705882,0.501960784313725,1.0,"DarkPink"); - public static readonly Color DarkPowderBlue = new Color(0,0.2,0.6,1.0,"DarkPowderBlue"); - public static readonly Color DarkRaspberry = new Color(0.529411764705882,0.149019607843137,0.341176470588235,1.0,"DarkRaspberry"); - public static readonly Color DarkRed = new Color(0.545098039215686,0,0,1.0,"DarkRed"); - public static readonly Color DarkSalmon = new Color(0.913725490196078,0.588235294117647,0.47843137254902,1.0,"DarkSalmon"); - public static readonly Color DarkScarlet = new Color(0.337254901960784,0.0117647058823529,0.0980392156862745,1.0,"DarkScarlet"); - public static readonly Color DarkSeaGreen = new Color(0.56078431372549,0.737254901960784,0.56078431372549,1.0,"DarkSeaGreen"); - public static readonly Color DarkSienna = new Color(0.235294117647059,0.0784313725490196,0.0784313725490196,1.0,"DarkSienna"); - public static readonly Color DarkSlateBlue = new Color(0.282352941176471,0.23921568627451,0.545098039215686,1.0,"DarkSlateBlue"); - public static readonly Color DarkSlateGray = new Color(0.184313725490196,0.309803921568627,0.309803921568627,1.0,"DarkSlateGray"); - public static readonly Color DarkSpringGreen = new Color(0.0901960784313725,0.447058823529412,0.270588235294118,1.0,"DarkSpringGreen"); - public static readonly Color DarkTan = new Color(0.568627450980392,0.505882352941176,0.317647058823529,1.0,"DarkTan"); - public static readonly Color DarkTangerine = new Color(1,0.658823529411765,0.0705882352941176,1.0,"DarkTangerine"); - public static readonly Color DarkTaupe = new Color(0.282352941176471,0.235294117647059,0.196078431372549,1.0,"DarkTaupe"); - public static readonly Color DarkTerraCotta = new Color(0.8,0.305882352941176,0.36078431372549,1.0,"DarkTerraCotta"); - public static readonly Color DarkTurquoise = new Color(0,0.807843137254902,0.819607843137255,1.0,"DarkTurquoise"); - public static readonly Color DarkViolet = new Color(0.580392156862745,0,0.827450980392157,1.0,"DarkViolet"); - public static readonly Color DarkYellow = new Color(0.607843137254902,0.529411764705882,0.0470588235294118,1.0,"DarkYellow"); - public static readonly Color DartmouthGreen = new Color(0,0.43921568627451,0.235294117647059,1.0,"DartmouthGreen"); - public static readonly Color DavySGrey = new Color(0.333333333333333,0.333333333333333,0.333333333333333,1.0,"DavySGrey"); - public static readonly Color DebianRed = new Color(0.843137254901961,0.0392156862745098,0.325490196078431,1.0,"DebianRed"); - public static readonly Color DeepCarmine = new Color(0.662745098039216,0.125490196078431,0.243137254901961,1.0,"DeepCarmine"); - public static readonly Color DeepCarminePink = new Color(0.937254901960784,0.188235294117647,0.219607843137255,1.0,"DeepCarminePink"); - public static readonly Color DeepCarrotOrange = new Color(0.913725490196078,0.411764705882353,0.172549019607843,1.0,"DeepCarrotOrange"); - public static readonly Color DeepCerise = new Color(0.854901960784314,0.196078431372549,0.529411764705882,1.0,"DeepCerise"); - public static readonly Color DeepChampagne = new Color(0.980392156862745,0.83921568627451,0.647058823529412,1.0,"DeepChampagne"); - public static readonly Color DeepChestnut = new Color(0.725490196078431,0.305882352941176,0.282352941176471,1.0,"DeepChestnut"); - public static readonly Color DeepCoffee = new Color(0.43921568627451,0.258823529411765,0.254901960784314,1.0,"DeepCoffee"); - public static readonly Color DeepFuchsia = new Color(0.756862745098039,0.329411764705882,0.756862745098039,1.0,"DeepFuchsia"); - public static readonly Color DeepJungleGreen = new Color(0,0.294117647058824,0.286274509803922,1.0,"DeepJungleGreen"); - public static readonly Color DeepLilac = new Color(0.6,0.333333333333333,0.733333333333333,1.0,"DeepLilac"); - public static readonly Color DeepMagenta = new Color(0.8,0,0.8,1.0,"DeepMagenta"); - public static readonly Color DeepPeach = new Color(1,0.796078431372549,0.643137254901961,1.0,"DeepPeach"); - public static readonly Color DeepPink = new Color(1,0.0784313725490196,0.576470588235294,1.0,"DeepPink"); - public static readonly Color DeepRuby = new Color(0.517647058823529,0.247058823529412,0.356862745098039,1.0,"DeepRuby"); - public static readonly Color DeepSaffron = new Color(1,0.6,0.2,1.0,"DeepSaffron"); - public static readonly Color DeepSkyBlue = new Color(0,0.749019607843137,1,1.0,"DeepSkyBlue"); - public static readonly Color DeepTuscanRed = new Color(0.4,0.258823529411765,0.301960784313725,1.0,"DeepTuscanRed"); - public static readonly Color Denim = new Color(0.0823529411764706,0.376470588235294,0.741176470588235,1.0,"Denim"); - public static readonly Color Desert = new Color(0.756862745098039,0.603921568627451,0.419607843137255,1.0,"Desert"); - public static readonly Color DesertSand = new Color(0.929411764705882,0.788235294117647,0.686274509803922,1.0,"DesertSand"); - public static readonly Color DimGray = new Color(0.411764705882353,0.411764705882353,0.411764705882353,1.0,"DimGray"); - public static readonly Color DodgerBlue = new Color(0.117647058823529,0.564705882352941,1,1.0,"DodgerBlue"); - public static readonly Color DogwoodRose = new Color(0.843137254901961,0.0941176470588235,0.407843137254902,1.0,"DogwoodRose"); - public static readonly Color DollarBill = new Color(0.52156862745098,0.733333333333333,0.396078431372549,1.0,"DollarBill"); - public static readonly Color Drab = new Color(0.588235294117647,0.443137254901961,0.0901960784313725,1.0,"Drab"); - public static readonly Color DukeBlue = new Color(0,0,0.611764705882353,1.0,"DukeBlue"); - public static readonly Color EarthYellow = new Color(0.882352941176471,0.662745098039216,0.372549019607843,1.0,"EarthYellow"); - public static readonly Color Ebony = new Color(0.333333333333333,0.364705882352941,0.313725490196078,1.0,"Ebony"); - public static readonly Color Ecru = new Color(0.76078431372549,0.698039215686274,0.501960784313725,1.0,"Ecru"); - public static readonly Color Eggplant = new Color(0.380392156862745,0.250980392156863,0.317647058823529,1.0,"Eggplant"); - public static readonly Color Eggshell = new Color(0.941176470588235,0.917647058823529,0.83921568627451,1.0,"Eggshell"); - public static readonly Color EgyptianBlue = new Color(0.0627450980392157,0.203921568627451,0.650980392156863,1.0,"EgyptianBlue"); - public static readonly Color ElectricBlue = new Color(0.490196078431373,0.976470588235294,1,1.0,"ElectricBlue"); - public static readonly Color ElectricCrimson = new Color(1,0,0.247058823529412,1.0,"ElectricCrimson"); - public static readonly Color ElectricCyan = new Color(0,1,1,1.0,"ElectricCyan"); - public static readonly Color ElectricGreen = new Color(0,1,0,1.0,"ElectricGreen"); - public static readonly Color ElectricIndigo = new Color(0.435294117647059,0,1,1.0,"ElectricIndigo"); - public static readonly Color ElectricLavender = new Color(0.956862745098039,0.733333333333333,1,1.0,"ElectricLavender"); - public static readonly Color ElectricLime = new Color(0.8,1,0,1.0,"ElectricLime"); - public static readonly Color ElectricPurple = new Color(0.749019607843137,0,1,1.0,"ElectricPurple"); - public static readonly Color ElectricUltramarine = new Color(0.247058823529412,0,1,1.0,"ElectricUltramarine"); - public static readonly Color ElectricViolet = new Color(0.56078431372549,0,1,1.0,"ElectricViolet"); - public static readonly Color ElectricYellow = new Color(1,1,0,1.0,"ElectricYellow"); - public static readonly Color Emerald = new Color(0.313725490196078,0.784313725490196,0.470588235294118,1.0,"Emerald"); - public static readonly Color EnglishLavender = new Color(0.705882352941177,0.513725490196078,0.584313725490196,1.0,"EnglishLavender"); - public static readonly Color EtonBlue = new Color(0.588235294117647,0.784313725490196,0.635294117647059,1.0,"EtonBlue"); - public static readonly Color Fallow = new Color(0.756862745098039,0.603921568627451,0.419607843137255,1.0,"Fallow"); - public static readonly Color FaluRed = new Color(0.501960784313725,0.0941176470588235,0.0941176470588235,1.0,"FaluRed"); - public static readonly Color Fandango = new Color(0.709803921568627,0.2,0.537254901960784,1.0,"Fandango"); - public static readonly Color FashionFuchsia = new Color(0.956862745098039,0,0.631372549019608,1.0,"FashionFuchsia"); - public static readonly Color Fawn = new Color(0.898039215686275,0.666666666666667,0.43921568627451,1.0,"Fawn"); - public static readonly Color Feldgrau = new Color(0.301960784313725,0.364705882352941,0.325490196078431,1.0,"Feldgrau"); - public static readonly Color FernGreen = new Color(0.309803921568627,0.474509803921569,0.258823529411765,1.0,"FernGreen"); - public static readonly Color FerrariRed = new Color(1,0.156862745098039,0,1.0,"FerrariRed"); - public static readonly Color FieldDrab = new Color(0.423529411764706,0.329411764705882,0.117647058823529,1.0,"FieldDrab"); - public static readonly Color FireEngineRed = new Color(0.807843137254902,0.125490196078431,0.16078431372549,1.0,"FireEngineRed"); - public static readonly Color Firebrick = new Color(0.698039215686274,0.133333333333333,0.133333333333333,1.0,"Firebrick"); - public static readonly Color Flame = new Color(0.886274509803922,0.345098039215686,0.133333333333333,1.0,"Flame"); - public static readonly Color FlamingoPink = new Color(0.988235294117647,0.556862745098039,0.674509803921569,1.0,"FlamingoPink"); - public static readonly Color Flavescent = new Color(0.968627450980392,0.913725490196078,0.556862745098039,1.0,"Flavescent"); - public static readonly Color Flax = new Color(0.933333333333333,0.862745098039216,0.509803921568627,1.0,"Flax"); - public static readonly Color FloralWhite = new Color(1,0.980392156862745,0.941176470588235,1.0,"FloralWhite"); - public static readonly Color FluorescentOrange = new Color(1,0.749019607843137,0,1.0,"FluorescentOrange"); - public static readonly Color FluorescentPink = new Color(1,0.0784313725490196,0.576470588235294,1.0,"FluorescentPink"); - public static readonly Color FluorescentYellow = new Color(0.8,1,0,1.0,"FluorescentYellow"); - public static readonly Color Folly = new Color(1,0,0.309803921568627,1.0,"Folly"); - public static readonly Color ForestGreenTraditional = new Color(0.00392156862745098,0.266666666666667,0.129411764705882,1.0,"ForestGreenTraditional"); - public static readonly Color ForestGreenWeb = new Color(0.133333333333333,0.545098039215686,0.133333333333333,1.0,"ForestGreenWeb"); - public static readonly Color FrenchBeige = new Color(0.650980392156863,0.482352941176471,0.356862745098039,1.0,"FrenchBeige"); - public static readonly Color FrenchBlue = new Color(0,0.447058823529412,0.733333333333333,1.0,"FrenchBlue"); - public static readonly Color FrenchLilac = new Color(0.525490196078431,0.376470588235294,0.556862745098039,1.0,"FrenchLilac"); - public static readonly Color FrenchLime = new Color(0.8,1,0,1.0,"FrenchLime"); - public static readonly Color FrenchRaspberry = new Color(0.780392156862745,0.172549019607843,0.282352941176471,1.0,"FrenchRaspberry"); - public static readonly Color FrenchRose = new Color(0.964705882352941,0.290196078431373,0.541176470588235,1.0,"FrenchRose"); - public static readonly Color Fuchsia = new Color(1,0,1,1.0,"Fuchsia"); - public static readonly Color FuchsiaCrayola = new Color(0.756862745098039,0.329411764705882,0.756862745098039,1.0,"FuchsiaCrayola"); - public static readonly Color FuchsiaPink = new Color(1,0.466666666666667,1,1.0,"FuchsiaPink"); - public static readonly Color FuchsiaRose = new Color(0.780392156862745,0.262745098039216,0.458823529411765,1.0,"FuchsiaRose"); - public static readonly Color Fulvous = new Color(0.894117647058824,0.517647058823529,0,1.0,"Fulvous"); - public static readonly Color FuzzyWuzzy = new Color(0.8,0.4,0.4,1.0,"FuzzyWuzzy"); - public static readonly Color Gainsboro = new Color(0.862745098039216,0.862745098039216,0.862745098039216,1.0,"Gainsboro"); - public static readonly Color Gamboge = new Color(0.894117647058824,0.607843137254902,0.0588235294117647,1.0,"Gamboge"); - public static readonly Color GhostWhite = new Color(0.972549019607843,0.972549019607843,1,1.0,"GhostWhite"); - public static readonly Color Ginger = new Color(0.690196078431373,0.396078431372549,0,1.0,"Ginger"); - public static readonly Color Glaucous = new Color(0.376470588235294,0.509803921568627,0.713725490196078,1.0,"Glaucous"); - public static readonly Color Glitter = new Color(0.901960784313726,0.909803921568627,0.980392156862745,1.0,"Glitter"); - public static readonly Color GoldMetallic = new Color(0.831372549019608,0.686274509803922,0.215686274509804,1.0,"GoldMetallic"); - public static readonly Color GoldWebGolden = new Color(1,0.843137254901961,0,1.0,"GoldWebGolden"); - public static readonly Color GoldenBrown = new Color(0.6,0.396078431372549,0.0823529411764706,1.0,"GoldenBrown"); - public static readonly Color GoldenPoppy = new Color(0.988235294117647,0.76078431372549,0,1.0,"GoldenPoppy"); - public static readonly Color GoldenYellow = new Color(1,0.874509803921569,0,1.0,"GoldenYellow"); - public static readonly Color Goldenrod = new Color(0.854901960784314,0.647058823529412,0.125490196078431,1.0,"Goldenrod"); - public static readonly Color GrannySmithApple = new Color(0.658823529411765,0.894117647058824,0.627450980392157,1.0,"GrannySmithApple"); - public static readonly Color Gray = new Color(0.501960784313725,0.501960784313725,0.501960784313725,1.0,"Gray"); - public static readonly Color GrayAsparagus = new Color(0.274509803921569,0.349019607843137,0.270588235294118,1.0,"GrayAsparagus"); - public static readonly Color GrayHtmlCssGray = new Color(0.501960784313725,0.501960784313725,0.501960784313725,1.0,"GrayHtmlCssGray"); - public static readonly Color GrayX11Gray = new Color(0.745098039215686,0.745098039215686,0.745098039215686,1.0,"GrayX11Gray"); - public static readonly Color GreenColorWheelX11Green = new Color(0,1,0,1.0,"GreenColorWheelX11Green"); - public static readonly Color GreenCrayola = new Color(0.109803921568627,0.674509803921569,0.470588235294118,1.0,"GreenCrayola"); - public static readonly Color GreenHtmlCssGreen = new Color(0,0.501960784313725,0,1.0,"GreenHtmlCssGreen"); - public static readonly Color GreenMunsell = new Color(0,0.658823529411765,0.466666666666667,1.0,"GreenMunsell"); - public static readonly Color GreenNcs = new Color(0,0.623529411764706,0.419607843137255,1.0,"GreenNcs"); - public static readonly Color GreenPigment = new Color(0,0.647058823529412,0.313725490196078,1.0,"GreenPigment"); - public static readonly Color GreenRyb = new Color(0.4,0.690196078431373,0.196078431372549,1.0,"GreenRyb"); - public static readonly Color GreenYellow = new Color(0.67843137254902,1,0.184313725490196,1.0,"GreenYellow"); - public static readonly Color Grullo = new Color(0.662745098039216,0.603921568627451,0.525490196078431,1.0,"Grullo"); - public static readonly Color GuppieGreen = new Color(0,1,0.498039215686275,1.0,"GuppieGreen"); - public static readonly Color HalayBe = new Color(0.4,0.219607843137255,0.329411764705882,1.0,"HalayBe"); - public static readonly Color HanBlue = new Color(0.266666666666667,0.423529411764706,0.811764705882353,1.0,"HanBlue"); - public static readonly Color HanPurple = new Color(0.32156862745098,0.0941176470588235,0.980392156862745,1.0,"HanPurple"); - public static readonly Color HansaYellow = new Color(0.913725490196078,0.83921568627451,0.419607843137255,1.0,"HansaYellow"); - public static readonly Color Harlequin = new Color(0.247058823529412,1,0,1.0,"Harlequin"); - public static readonly Color HarvardCrimson = new Color(0.788235294117647,0,0.0862745098039216,1.0,"HarvardCrimson"); - public static readonly Color HarvestGold = new Color(0.854901960784314,0.568627450980392,0,1.0,"HarvestGold"); - public static readonly Color HeartGold = new Color(0.501960784313725,0.501960784313725,0,1.0,"HeartGold"); - public static readonly Color Heliotrope = new Color(0.874509803921569,0.450980392156863,1,1.0,"Heliotrope"); - public static readonly Color HollywoodCerise = new Color(0.956862745098039,0,0.631372549019608,1.0,"HollywoodCerise"); - public static readonly Color Honeydew = new Color(0.941176470588235,1,0.941176470588235,1.0,"Honeydew"); - public static readonly Color HonoluluBlue = new Color(0,0.498039215686275,0.749019607843137,1.0,"HonoluluBlue"); - public static readonly Color HookerSGreen = new Color(0.286274509803922,0.474509803921569,0.419607843137255,1.0,"HookerSGreen"); - public static readonly Color HotMagenta = new Color(1,0.113725490196078,0.807843137254902,1.0,"HotMagenta"); - public static readonly Color HotPink = new Color(1,0.411764705882353,0.705882352941177,1.0,"HotPink"); - public static readonly Color HunterGreen = new Color(0.207843137254902,0.368627450980392,0.231372549019608,1.0,"HunterGreen"); - public static readonly Color Iceberg = new Color(0.443137254901961,0.650980392156863,0.823529411764706,1.0,"Iceberg"); - public static readonly Color Icterine = new Color(0.988235294117647,0.968627450980392,0.368627450980392,1.0,"Icterine"); - public static readonly Color ImperialBlue = new Color(0,0.137254901960784,0.584313725490196,1.0,"ImperialBlue"); - public static readonly Color Inchworm = new Color(0.698039215686274,0.925490196078431,0.364705882352941,1.0,"Inchworm"); - public static readonly Color IndiaGreen = new Color(0.0745098039215686,0.533333333333333,0.0313725490196078,1.0,"IndiaGreen"); - public static readonly Color IndianRed = new Color(0.803921568627451,0.36078431372549,0.36078431372549,1.0,"IndianRed"); - public static readonly Color IndianYellow = new Color(0.890196078431373,0.658823529411765,0.341176470588235,1.0,"IndianYellow"); - public static readonly Color Indigo = new Color(0.435294117647059,0,1,1.0,"Indigo"); - public static readonly Color IndigoDye = new Color(0,0.254901960784314,0.415686274509804,1.0,"IndigoDye"); - public static readonly Color IndigoWeb = new Color(0.294117647058824,0,0.509803921568627,1.0,"IndigoWeb"); - public static readonly Color InternationalKleinBlue = new Color(0,0.184313725490196,0.654901960784314,1.0,"InternationalKleinBlue"); - public static readonly Color InternationalOrangeAerospace = new Color(1,0.309803921568627,0,1.0,"InternationalOrangeAerospace"); - public static readonly Color InternationalOrangeEngineering = new Color(0.729411764705882,0.0862745098039216,0.0470588235294118,1.0,"InternationalOrangeEngineering"); - public static readonly Color InternationalOrangeGoldenGateBridge = new Color(0.752941176470588,0.211764705882353,0.172549019607843,1.0,"InternationalOrangeGoldenGateBridge"); - public static readonly Color Iris = new Color(0.352941176470588,0.309803921568627,0.811764705882353,1.0,"Iris"); - public static readonly Color Isabelline = new Color(0.956862745098039,0.941176470588235,0.925490196078431,1.0,"Isabelline"); - public static readonly Color IslamicGreen = new Color(0,0.564705882352941,0,1.0,"IslamicGreen"); - public static readonly Color Ivory = new Color(1,1,0.941176470588235,1.0,"Ivory"); - public static readonly Color Jade = new Color(0,0.658823529411765,0.419607843137255,1.0,"Jade"); - public static readonly Color Jasmine = new Color(0.972549019607843,0.870588235294118,0.494117647058824,1.0,"Jasmine"); - public static readonly Color Jasper = new Color(0.843137254901961,0.231372549019608,0.243137254901961,1.0,"Jasper"); - public static readonly Color JazzberryJam = new Color(0.647058823529412,0.0431372549019608,0.368627450980392,1.0,"JazzberryJam"); - public static readonly Color Jet = new Color(0.203921568627451,0.203921568627451,0.203921568627451,1.0,"Jet"); - public static readonly Color Jonquil = new Color(0.980392156862745,0.854901960784314,0.368627450980392,1.0,"Jonquil"); - public static readonly Color JuneBud = new Color(0.741176470588235,0.854901960784314,0.341176470588235,1.0,"JuneBud"); - public static readonly Color JungleGreen = new Color(0.16078431372549,0.670588235294118,0.529411764705882,1.0,"JungleGreen"); - public static readonly Color KellyGreen = new Color(0.298039215686275,0.733333333333333,0.0901960784313725,1.0,"KellyGreen"); - public static readonly Color KenyanCopper = new Color(0.486274509803922,0.109803921568627,0.0196078431372549,1.0,"KenyanCopper"); - public static readonly Color KhakiHtmlCssKhaki = new Color(0.764705882352941,0.690196078431373,0.568627450980392,1.0,"KhakiHtmlCssKhaki"); - public static readonly Color KhakiX11LightKhaki = new Color(0.941176470588235,0.901960784313726,0.549019607843137,1.0,"KhakiX11LightKhaki"); - public static readonly Color KuCrimson = new Color(0.909803921568627,0,0.0509803921568627,1.0,"KuCrimson"); - public static readonly Color LaSalleGreen = new Color(0.0313725490196078,0.470588235294118,0.188235294117647,1.0,"LaSalleGreen"); - public static readonly Color LanguidLavender = new Color(0.83921568627451,0.792156862745098,0.866666666666667,1.0,"LanguidLavender"); - public static readonly Color LapisLazuli = new Color(0.149019607843137,0.380392156862745,0.611764705882353,1.0,"LapisLazuli"); - public static readonly Color LaserLemon = new Color(0.996078431372549,0.996078431372549,0.133333333333333,1.0,"LaserLemon"); - public static readonly Color LaurelGreen = new Color(0.662745098039216,0.729411764705882,0.615686274509804,1.0,"LaurelGreen"); - public static readonly Color Lava = new Color(0.811764705882353,0.0627450980392157,0.125490196078431,1.0,"Lava"); - public static readonly Color LavenderBlue = new Color(0.8,0.8,1,1.0,"LavenderBlue"); - public static readonly Color LavenderBlush = new Color(1,0.941176470588235,0.96078431372549,1.0,"LavenderBlush"); - public static readonly Color LavenderFloral = new Color(0.709803921568627,0.494117647058824,0.862745098039216,1.0,"LavenderFloral"); - public static readonly Color LavenderGray = new Color(0.768627450980392,0.764705882352941,0.815686274509804,1.0,"LavenderGray"); - public static readonly Color LavenderIndigo = new Color(0.580392156862745,0.341176470588235,0.92156862745098,1.0,"LavenderIndigo"); - public static readonly Color LavenderMagenta = new Color(0.933333333333333,0.509803921568627,0.933333333333333,1.0,"LavenderMagenta"); - public static readonly Color LavenderMist = new Color(0.901960784313726,0.901960784313726,0.980392156862745,1.0,"LavenderMist"); - public static readonly Color LavenderPink = new Color(0.984313725490196,0.682352941176471,0.823529411764706,1.0,"LavenderPink"); - public static readonly Color LavenderPurple = new Color(0.588235294117647,0.482352941176471,0.713725490196078,1.0,"LavenderPurple"); - public static readonly Color LavenderRose = new Color(0.984313725490196,0.627450980392157,0.890196078431373,1.0,"LavenderRose"); - public static readonly Color LavenderWeb = new Color(0.901960784313726,0.901960784313726,0.980392156862745,1.0,"LavenderWeb"); - public static readonly Color LawnGreen = new Color(0.486274509803922,0.988235294117647,0,1.0,"LawnGreen"); - public static readonly Color Lemon = new Color(1,0.968627450980392,0,1.0,"Lemon"); - public static readonly Color LemonChiffon = new Color(1,0.980392156862745,0.803921568627451,1.0,"LemonChiffon"); - public static readonly Color LemonLime = new Color(0.890196078431373,1,0,1.0,"LemonLime"); - public static readonly Color Licorice = new Color(0.101960784313725,0.0666666666666667,0.0627450980392157,1.0,"Licorice"); - public static readonly Color LightApricot = new Color(0.992156862745098,0.835294117647059,0.694117647058824,1.0,"LightApricot"); - public static readonly Color LightBlue = new Color(0.67843137254902,0.847058823529412,0.901960784313726,1.0,"LightBlue"); - public static readonly Color LightBrown = new Color(0.709803921568627,0.396078431372549,0.113725490196078,1.0,"LightBrown"); - public static readonly Color LightCarminePink = new Color(0.901960784313726,0.403921568627451,0.443137254901961,1.0,"LightCarminePink"); - public static readonly Color LightCoral = new Color(0.941176470588235,0.501960784313725,0.501960784313725,1.0,"LightCoral"); - public static readonly Color LightCornflowerBlue = new Color(0.576470588235294,0.8,0.917647058823529,1.0,"LightCornflowerBlue"); - public static readonly Color LightCrimson = new Color(0.96078431372549,0.411764705882353,0.568627450980392,1.0,"LightCrimson"); - public static readonly Color LightCyan = new Color(0.87843137254902,1,1,1.0,"LightCyan"); - public static readonly Color LightFuchsiaPink = new Color(0.976470588235294,0.517647058823529,0.937254901960784,1.0,"LightFuchsiaPink"); - public static readonly Color LightGoldenrodYellow = new Color(0.980392156862745,0.980392156862745,0.823529411764706,1.0,"LightGoldenrodYellow"); - public static readonly Color LightGray = new Color(0.827450980392157,0.827450980392157,0.827450980392157,1.0,"LightGray"); - public static readonly Color LightGreen = new Color(0.564705882352941,0.933333333333333,0.564705882352941,1.0,"LightGreen"); - public static readonly Color LightKhaki = new Color(0.941176470588235,0.901960784313726,0.549019607843137,1.0,"LightKhaki"); - public static readonly Color LightPastelPurple = new Color(0.694117647058824,0.611764705882353,0.850980392156863,1.0,"LightPastelPurple"); - public static readonly Color LightPink = new Color(1,0.713725490196078,0.756862745098039,1.0,"LightPink"); - public static readonly Color LightRedOchre = new Color(0.913725490196078,0.454901960784314,0.317647058823529,1.0,"LightRedOchre"); - public static readonly Color LightSalmon = new Color(1,0.627450980392157,0.47843137254902,1.0,"LightSalmon"); - public static readonly Color LightSalmonPink = new Color(1,0.6,0.6,1.0,"LightSalmonPink"); - public static readonly Color LightSeaGreen = new Color(0.125490196078431,0.698039215686274,0.666666666666667,1.0,"LightSeaGreen"); - public static readonly Color LightSkyBlue = new Color(0.529411764705882,0.807843137254902,0.980392156862745,1.0,"LightSkyBlue"); - public static readonly Color LightSlateGray = new Color(0.466666666666667,0.533333333333333,0.6,1.0,"LightSlateGray"); - public static readonly Color LightTaupe = new Color(0.701960784313725,0.545098039215686,0.427450980392157,1.0,"LightTaupe"); - public static readonly Color LightThulianPink = new Color(0.901960784313726,0.56078431372549,0.674509803921569,1.0,"LightThulianPink"); - public static readonly Color LightYellow = new Color(1,1,0.87843137254902,1.0,"LightYellow"); - public static readonly Color Lilac = new Color(0.784313725490196,0.635294117647059,0.784313725490196,1.0,"Lilac"); - public static readonly Color LimeColorWheel = new Color(0.749019607843137,1,0,1.0,"LimeColorWheel"); - public static readonly Color LimeGreen = new Color(0.196078431372549,0.803921568627451,0.196078431372549,1.0,"LimeGreen"); - public static readonly Color LimeWebX11Green = new Color(0,1,0,1.0,"LimeWebX11Green"); - public static readonly Color Limerick = new Color(0.615686274509804,0.76078431372549,0.0352941176470588,1.0,"Limerick"); - public static readonly Color LincolnGreen = new Color(0.0980392156862745,0.349019607843137,0.0196078431372549,1.0,"LincolnGreen"); - public static readonly Color Linen = new Color(0.980392156862745,0.941176470588235,0.901960784313726,1.0,"Linen"); - public static readonly Color Lion = new Color(0.756862745098039,0.603921568627451,0.419607843137255,1.0,"Lion"); - public static readonly Color LittleBoyBlue = new Color(0.423529411764706,0.627450980392157,0.862745098039216,1.0,"LittleBoyBlue"); - public static readonly Color Liver = new Color(0.325490196078431,0.294117647058824,0.309803921568627,1.0,"Liver"); - public static readonly Color Lust = new Color(0.901960784313726,0.125490196078431,0.125490196078431,1.0,"Lust"); - public static readonly Color Magenta = new Color(1,0,1,1.0,"Magenta"); - public static readonly Color MagentaDye = new Color(0.792156862745098,0.12156862745098,0.482352941176471,1.0,"MagentaDye"); - public static readonly Color MagentaProcess = new Color(1,0,0.564705882352941,1.0,"MagentaProcess"); - public static readonly Color MagicMint = new Color(0.666666666666667,0.941176470588235,0.819607843137255,1.0,"MagicMint"); - public static readonly Color Magnolia = new Color(0.972549019607843,0.956862745098039,1,1.0,"Magnolia"); - public static readonly Color Mahogany = new Color(0.752941176470588,0.250980392156863,0,1.0,"Mahogany"); - public static readonly Color Maize = new Color(0.984313725490196,0.925490196078431,0.364705882352941,1.0,"Maize"); - public static readonly Color MajorelleBlue = new Color(0.376470588235294,0.313725490196078,0.862745098039216,1.0,"MajorelleBlue"); - public static readonly Color Malachite = new Color(0.0431372549019608,0.854901960784314,0.317647058823529,1.0,"Malachite"); - public static readonly Color Manatee = new Color(0.592156862745098,0.603921568627451,0.666666666666667,1.0,"Manatee"); - public static readonly Color MangoTango = new Color(1,0.509803921568627,0.262745098039216,1.0,"MangoTango"); - public static readonly Color Mantis = new Color(0.454901960784314,0.764705882352941,0.396078431372549,1.0,"Mantis"); - public static readonly Color MardiGras = new Color(0.533333333333333,0,0.52156862745098,1.0,"MardiGras"); - public static readonly Color MaroonCrayola = new Color(0.764705882352941,0.129411764705882,0.282352941176471,1.0,"MaroonCrayola"); - public static readonly Color MaroonHtmlCss = new Color(0.501960784313725,0,0,1.0,"MaroonHtmlCss"); - public static readonly Color MaroonX11 = new Color(0.690196078431373,0.188235294117647,0.376470588235294,1.0,"MaroonX11"); - public static readonly Color Mauve = new Color(0.87843137254902,0.690196078431373,1,1.0,"Mauve"); - public static readonly Color MauveTaupe = new Color(0.568627450980392,0.372549019607843,0.427450980392157,1.0,"MauveTaupe"); - public static readonly Color Mauvelous = new Color(0.937254901960784,0.596078431372549,0.666666666666667,1.0,"Mauvelous"); - public static readonly Color MayaBlue = new Color(0.450980392156863,0.76078431372549,0.984313725490196,1.0,"MayaBlue"); - public static readonly Color MeatBrown = new Color(0.898039215686275,0.717647058823529,0.231372549019608,1.0,"MeatBrown"); - public static readonly Color MediumAquamarine = new Color(0.4,0.866666666666667,0.666666666666667,1.0,"MediumAquamarine"); - public static readonly Color MediumBlue = new Color(0,0,0.803921568627451,1.0,"MediumBlue"); - public static readonly Color MediumCandyAppleRed = new Color(0.886274509803922,0.0235294117647059,0.172549019607843,1.0,"MediumCandyAppleRed"); - public static readonly Color MediumCarmine = new Color(0.686274509803922,0.250980392156863,0.207843137254902,1.0,"MediumCarmine"); - public static readonly Color MediumChampagne = new Color(0.952941176470588,0.898039215686275,0.670588235294118,1.0,"MediumChampagne"); - public static readonly Color MediumElectricBlue = new Color(0.0117647058823529,0.313725490196078,0.588235294117647,1.0,"MediumElectricBlue"); - public static readonly Color MediumJungleGreen = new Color(0.109803921568627,0.207843137254902,0.176470588235294,1.0,"MediumJungleGreen"); - public static readonly Color MediumLavenderMagenta = new Color(0.866666666666667,0.627450980392157,0.866666666666667,1.0,"MediumLavenderMagenta"); - public static readonly Color MediumOrchid = new Color(0.729411764705882,0.333333333333333,0.827450980392157,1.0,"MediumOrchid"); - public static readonly Color MediumPersianBlue = new Color(0,0.403921568627451,0.647058823529412,1.0,"MediumPersianBlue"); - public static readonly Color MediumPurple = new Color(0.576470588235294,0.43921568627451,0.858823529411765,1.0,"MediumPurple"); - public static readonly Color MediumRedViolet = new Color(0.733333333333333,0.2,0.52156862745098,1.0,"MediumRedViolet"); - public static readonly Color MediumRuby = new Color(0.666666666666667,0.250980392156863,0.411764705882353,1.0,"MediumRuby"); - public static readonly Color MediumSeaGreen = new Color(0.235294117647059,0.701960784313725,0.443137254901961,1.0,"MediumSeaGreen"); - public static readonly Color MediumSlateBlue = new Color(0.482352941176471,0.407843137254902,0.933333333333333,1.0,"MediumSlateBlue"); - public static readonly Color MediumSpringBud = new Color(0.788235294117647,0.862745098039216,0.529411764705882,1.0,"MediumSpringBud"); - public static readonly Color MediumSpringGreen = new Color(0,0.980392156862745,0.603921568627451,1.0,"MediumSpringGreen"); - public static readonly Color MediumTaupe = new Color(0.403921568627451,0.298039215686275,0.27843137254902,1.0,"MediumTaupe"); - public static readonly Color MediumTurquoise = new Color(0.282352941176471,0.819607843137255,0.8,1.0,"MediumTurquoise"); - public static readonly Color MediumTuscanRed = new Color(0.474509803921569,0.266666666666667,0.231372549019608,1.0,"MediumTuscanRed"); - public static readonly Color MediumVermilion = new Color(0.850980392156863,0.376470588235294,0.231372549019608,1.0,"MediumVermilion"); - public static readonly Color MediumVioletRed = new Color(0.780392156862745,0.0823529411764706,0.52156862745098,1.0,"MediumVioletRed"); - public static readonly Color MellowApricot = new Color(0.972549019607843,0.72156862745098,0.470588235294118,1.0,"MellowApricot"); - public static readonly Color MellowYellow = new Color(0.972549019607843,0.870588235294118,0.494117647058824,1.0,"MellowYellow"); - public static readonly Color Melon = new Color(0.992156862745098,0.737254901960784,0.705882352941177,1.0,"Melon"); - public static readonly Color MidnightBlue = new Color(0.0980392156862745,0.0980392156862745,0.43921568627451,1.0,"MidnightBlue"); - public static readonly Color MidnightGreenEagleGreen = new Color(0,0.286274509803922,0.325490196078431,1.0,"MidnightGreenEagleGreen"); - public static readonly Color MikadoYellow = new Color(1,0.768627450980392,0.0470588235294118,1.0,"MikadoYellow"); - public static readonly Color Mint = new Color(0.243137254901961,0.705882352941177,0.537254901960784,1.0,"Mint"); - public static readonly Color MintCream = new Color(0.96078431372549,1,0.980392156862745,1.0,"MintCream"); - public static readonly Color MintGreen = new Color(0.596078431372549,1,0.596078431372549,1.0,"MintGreen"); - public static readonly Color MistyRose = new Color(1,0.894117647058824,0.882352941176471,1.0,"MistyRose"); - public static readonly Color Moccasin = new Color(0.980392156862745,0.92156862745098,0.843137254901961,1.0,"Moccasin"); - public static readonly Color ModeBeige = new Color(0.588235294117647,0.443137254901961,0.0901960784313725,1.0,"ModeBeige"); - public static readonly Color MoonstoneBlue = new Color(0.450980392156863,0.662745098039216,0.76078431372549,1.0,"MoonstoneBlue"); - public static readonly Color MordantRed19 = new Color(0.682352941176471,0.0470588235294118,0,1.0,"MordantRed19"); - public static readonly Color MossGreen = new Color(0.67843137254902,0.874509803921569,0.67843137254902,1.0,"MossGreen"); - public static readonly Color MountainMeadow = new Color(0.188235294117647,0.729411764705882,0.56078431372549,1.0,"MountainMeadow"); - public static readonly Color MountbattenPink = new Color(0.6,0.47843137254902,0.552941176470588,1.0,"MountbattenPink"); - public static readonly Color MsuGreen = new Color(0.0941176470588235,0.270588235294118,0.231372549019608,1.0,"MsuGreen"); - public static readonly Color Mulberry = new Color(0.772549019607843,0.294117647058824,0.549019607843137,1.0,"Mulberry"); - public static readonly Color Mustard = new Color(1,0.858823529411765,0.345098039215686,1.0,"Mustard"); - public static readonly Color Myrtle = new Color(0.129411764705882,0.258823529411765,0.117647058823529,1.0,"Myrtle"); - public static readonly Color NadeshikoPink = new Color(0.964705882352941,0.67843137254902,0.776470588235294,1.0,"NadeshikoPink"); - public static readonly Color NapierGreen = new Color(0.164705882352941,0.501960784313725,0,1.0,"NapierGreen"); - public static readonly Color NaplesYellow = new Color(0.980392156862745,0.854901960784314,0.368627450980392,1.0,"NaplesYellow"); - public static readonly Color NavajoWhite = new Color(1,0.870588235294118,0.67843137254902,1.0,"NavajoWhite"); - public static readonly Color NavyBlue = new Color(0,0,0.501960784313725,1.0,"NavyBlue"); - public static readonly Color NeonCarrot = new Color(1,0.63921568627451,0.262745098039216,1.0,"NeonCarrot"); - public static readonly Color NeonFuchsia = new Color(0.996078431372549,0.254901960784314,0.392156862745098,1.0,"NeonFuchsia"); - public static readonly Color NeonGreen = new Color(0.223529411764706,1,0.0784313725490196,1.0,"NeonGreen"); - public static readonly Color NewYorkPink = new Color(0.843137254901961,0.513725490196078,0.498039215686275,1.0,"NewYorkPink"); - public static readonly Color NonPhotoBlue = new Color(0.643137254901961,0.866666666666667,0.929411764705882,1.0,"NonPhotoBlue"); - public static readonly Color NorthTexasGreen = new Color(0.0196078431372549,0.564705882352941,0.2,1.0,"NorthTexasGreen"); - public static readonly Color OceanBoatBlue = new Color(0,0.466666666666667,0.745098039215686,1.0,"OceanBoatBlue"); - public static readonly Color Ochre = new Color(0.8,0.466666666666667,0.133333333333333,1.0,"Ochre"); - public static readonly Color OfficeGreen = new Color(0,0.501960784313725,0,1.0,"OfficeGreen"); - public static readonly Color OldGold = new Color(0.811764705882353,0.709803921568627,0.231372549019608,1.0,"OldGold"); - public static readonly Color OldLace = new Color(0.992156862745098,0.96078431372549,0.901960784313726,1.0,"OldLace"); - public static readonly Color OldLavender = new Color(0.474509803921569,0.407843137254902,0.470588235294118,1.0,"OldLavender"); - public static readonly Color OldMauve = new Color(0.403921568627451,0.192156862745098,0.27843137254902,1.0,"OldMauve"); - public static readonly Color OldRose = new Color(0.752941176470588,0.501960784313725,0.505882352941176,1.0,"OldRose"); - public static readonly Color Olive = new Color(0.501960784313725,0.501960784313725,0,1.0,"Olive"); - public static readonly Color OliveDrab7 = new Color(0.235294117647059,0.203921568627451,0.12156862745098,1.0,"OliveDrab7"); - public static readonly Color OliveDrabWebOliveDrab3 = new Color(0.419607843137255,0.556862745098039,0.137254901960784,1.0,"OliveDrabWebOliveDrab3"); - public static readonly Color Olivine = new Color(0.603921568627451,0.725490196078431,0.450980392156863,1.0,"Olivine"); - public static readonly Color Onyx = new Color(0.207843137254902,0.219607843137255,0.223529411764706,1.0,"Onyx"); - public static readonly Color OperaMauve = new Color(0.717647058823529,0.517647058823529,0.654901960784314,1.0,"OperaMauve"); - public static readonly Color OrangeColorWheel = new Color(1,0.498039215686275,0,1.0,"OrangeColorWheel"); - public static readonly Color OrangePeel = new Color(1,0.623529411764706,0,1.0,"OrangePeel"); - public static readonly Color OrangeRed = new Color(1,0.270588235294118,0,1.0,"OrangeRed"); - public static readonly Color OrangeRyb = new Color(0.984313725490196,0.6,0.00784313725490196,1.0,"OrangeRyb"); - public static readonly Color OrangeWebColor = new Color(1,0.647058823529412,0,1.0,"OrangeWebColor"); - public static readonly Color Orchid = new Color(0.854901960784314,0.43921568627451,0.83921568627451,1.0,"Orchid"); - public static readonly Color OtterBrown = new Color(0.396078431372549,0.262745098039216,0.129411764705882,1.0,"OtterBrown"); - public static readonly Color OuCrimsonRed = new Color(0.6,0,0,1.0,"OuCrimsonRed"); - public static readonly Color OuterSpace = new Color(0.254901960784314,0.290196078431373,0.298039215686275,1.0,"OuterSpace"); - public static readonly Color OutrageousOrange = new Color(1,0.431372549019608,0.290196078431373,1.0,"OutrageousOrange"); - public static readonly Color OxfordBlue = new Color(0,0.129411764705882,0.27843137254902,1.0,"OxfordBlue"); - public static readonly Color PakistanGreen = new Color(0,0.4,0,1.0,"PakistanGreen"); - public static readonly Color PalatinateBlue = new Color(0.152941176470588,0.231372549019608,0.886274509803922,1.0,"PalatinateBlue"); - public static readonly Color PalatinatePurple = new Color(0.407843137254902,0.156862745098039,0.376470588235294,1.0,"PalatinatePurple"); - public static readonly Color PaleAqua = new Color(0.737254901960784,0.831372549019608,0.901960784313726,1.0,"PaleAqua"); - public static readonly Color PaleBlue = new Color(0.686274509803922,0.933333333333333,0.933333333333333,1.0,"PaleBlue"); - public static readonly Color PaleBrown = new Color(0.596078431372549,0.462745098039216,0.329411764705882,1.0,"PaleBrown"); - public static readonly Color PaleCarmine = new Color(0.686274509803922,0.250980392156863,0.207843137254902,1.0,"PaleCarmine"); - public static readonly Color PaleCerulean = new Color(0.607843137254902,0.768627450980392,0.886274509803922,1.0,"PaleCerulean"); - public static readonly Color PaleChestnut = new Color(0.866666666666667,0.67843137254902,0.686274509803922,1.0,"PaleChestnut"); - public static readonly Color PaleCopper = new Color(0.854901960784314,0.541176470588235,0.403921568627451,1.0,"PaleCopper"); - public static readonly Color PaleCornflowerBlue = new Color(0.670588235294118,0.803921568627451,0.937254901960784,1.0,"PaleCornflowerBlue"); - public static readonly Color PaleGold = new Color(0.901960784313726,0.745098039215686,0.541176470588235,1.0,"PaleGold"); - public static readonly Color PaleGoldenrod = new Color(0.933333333333333,0.909803921568627,0.666666666666667,1.0,"PaleGoldenrod"); - public static readonly Color PaleGreen = new Color(0.596078431372549,0.984313725490196,0.596078431372549,1.0,"PaleGreen"); - public static readonly Color PaleLavender = new Color(0.862745098039216,0.815686274509804,1,1.0,"PaleLavender"); - public static readonly Color PaleMagenta = new Color(0.976470588235294,0.517647058823529,0.898039215686275,1.0,"PaleMagenta"); - public static readonly Color PalePink = new Color(0.980392156862745,0.854901960784314,0.866666666666667,1.0,"PalePink"); - public static readonly Color PalePlum = new Color(0.866666666666667,0.627450980392157,0.866666666666667,1.0,"PalePlum"); - public static readonly Color PaleRedViolet = new Color(0.858823529411765,0.43921568627451,0.576470588235294,1.0,"PaleRedViolet"); - public static readonly Color PaleRobinEggBlue = new Color(0.588235294117647,0.870588235294118,0.819607843137255,1.0,"PaleRobinEggBlue"); - public static readonly Color PaleSilver = new Color(0.788235294117647,0.752941176470588,0.733333333333333,1.0,"PaleSilver"); - public static readonly Color PaleSpringBud = new Color(0.925490196078431,0.92156862745098,0.741176470588235,1.0,"PaleSpringBud"); - public static readonly Color PaleTaupe = new Color(0.737254901960784,0.596078431372549,0.494117647058824,1.0,"PaleTaupe"); - public static readonly Color PaleVioletRed = new Color(0.858823529411765,0.43921568627451,0.576470588235294,1.0,"PaleVioletRed"); - public static readonly Color PansyPurple = new Color(0.470588235294118,0.0941176470588235,0.290196078431373,1.0,"PansyPurple"); - public static readonly Color PapayaWhip = new Color(1,0.937254901960784,0.835294117647059,1.0,"PapayaWhip"); - public static readonly Color ParisGreen = new Color(0.313725490196078,0.784313725490196,0.470588235294118,1.0,"ParisGreen"); - public static readonly Color PastelBlue = new Color(0.682352941176471,0.776470588235294,0.811764705882353,1.0,"PastelBlue"); - public static readonly Color PastelBrown = new Color(0.513725490196078,0.411764705882353,0.325490196078431,1.0,"PastelBrown"); - public static readonly Color PastelGray = new Color(0.811764705882353,0.811764705882353,0.768627450980392,1.0,"PastelGray"); - public static readonly Color PastelGreen = new Color(0.466666666666667,0.866666666666667,0.466666666666667,1.0,"PastelGreen"); - public static readonly Color PastelMagenta = new Color(0.956862745098039,0.603921568627451,0.76078431372549,1.0,"PastelMagenta"); - public static readonly Color PastelOrange = new Color(1,0.701960784313725,0.27843137254902,1.0,"PastelOrange"); - public static readonly Color PastelPink = new Color(0.870588235294118,0.647058823529412,0.643137254901961,1.0,"PastelPink"); - public static readonly Color PastelPurple = new Color(0.701960784313725,0.619607843137255,0.709803921568627,1.0,"PastelPurple"); - public static readonly Color PastelRed = new Color(1,0.411764705882353,0.380392156862745,1.0,"PastelRed"); - public static readonly Color PastelViolet = new Color(0.796078431372549,0.6,0.788235294117647,1.0,"PastelViolet"); - public static readonly Color PastelYellow = new Color(0.992156862745098,0.992156862745098,0.588235294117647,1.0,"PastelYellow"); - public static readonly Color Patriarch = new Color(0.501960784313725,0,0.501960784313725,1.0,"Patriarch"); - public static readonly Color PayneSGrey = new Color(0.325490196078431,0.407843137254902,0.470588235294118,1.0,"PayneSGrey"); - public static readonly Color Peach = new Color(1,0.898039215686275,0.705882352941177,1.0,"Peach"); - public static readonly Color PeachCrayola = new Color(1,0.796078431372549,0.643137254901961,1.0,"PeachCrayola"); - public static readonly Color PeachOrange = new Color(1,0.8,0.6,1.0,"PeachOrange"); - public static readonly Color PeachPuff = new Color(1,0.854901960784314,0.725490196078431,1.0,"PeachPuff"); - public static readonly Color PeachYellow = new Color(0.980392156862745,0.874509803921569,0.67843137254902,1.0,"PeachYellow"); - public static readonly Color Pear = new Color(0.819607843137255,0.886274509803922,0.192156862745098,1.0,"Pear"); - public static readonly Color Pearl = new Color(0.917647058823529,0.87843137254902,0.784313725490196,1.0,"Pearl"); - public static readonly Color PearlAqua = new Color(0.533333333333333,0.847058823529412,0.752941176470588,1.0,"PearlAqua"); - public static readonly Color PearlyPurple = new Color(0.717647058823529,0.407843137254902,0.635294117647059,1.0,"PearlyPurple"); - public static readonly Color Peridot = new Color(0.901960784313726,0.886274509803922,0,1.0,"Peridot"); - public static readonly Color Periwinkle = new Color(0.8,0.8,1,1.0,"Periwinkle"); - public static readonly Color PersianBlue = new Color(0.109803921568627,0.223529411764706,0.733333333333333,1.0,"PersianBlue"); - public static readonly Color PersianGreen = new Color(0,0.650980392156863,0.576470588235294,1.0,"PersianGreen"); - public static readonly Color PersianIndigo = new Color(0.196078431372549,0.0705882352941176,0.47843137254902,1.0,"PersianIndigo"); - public static readonly Color PersianOrange = new Color(0.850980392156863,0.564705882352941,0.345098039215686,1.0,"PersianOrange"); - public static readonly Color PersianPink = new Color(0.968627450980392,0.498039215686275,0.745098039215686,1.0,"PersianPink"); - public static readonly Color PersianPlum = new Color(0.43921568627451,0.109803921568627,0.109803921568627,1.0,"PersianPlum"); - public static readonly Color PersianRed = new Color(0.8,0.2,0.2,1.0,"PersianRed"); - public static readonly Color PersianRose = new Color(0.996078431372549,0.156862745098039,0.635294117647059,1.0,"PersianRose"); - public static readonly Color Persimmon = new Color(0.925490196078431,0.345098039215686,0,1.0,"Persimmon"); - public static readonly Color Peru = new Color(0.803921568627451,0.52156862745098,0.247058823529412,1.0,"Peru"); - public static readonly Color Phlox = new Color(0.874509803921569,0,1,1.0,"Phlox"); - public static readonly Color PhthaloBlue = new Color(0,0.0588235294117647,0.537254901960784,1.0,"PhthaloBlue"); - public static readonly Color PhthaloGreen = new Color(0.0705882352941176,0.207843137254902,0.141176470588235,1.0,"PhthaloGreen"); - public static readonly Color PiggyPink = new Color(0.992156862745098,0.866666666666667,0.901960784313726,1.0,"PiggyPink"); - public static readonly Color PineGreen = new Color(0.00392156862745098,0.474509803921569,0.435294117647059,1.0,"PineGreen"); - public static readonly Color Pink = new Color(1,0.752941176470588,0.796078431372549,1.0,"Pink"); - public static readonly Color PinkLace = new Color(1,0.866666666666667,0.956862745098039,1.0,"PinkLace"); - public static readonly Color PinkOrange = new Color(1,0.6,0.4,1.0,"PinkOrange"); - public static readonly Color PinkPearl = new Color(0.905882352941176,0.674509803921569,0.811764705882353,1.0,"PinkPearl"); - public static readonly Color PinkSherbet = new Color(0.968627450980392,0.56078431372549,0.654901960784314,1.0,"PinkSherbet"); - public static readonly Color Pistachio = new Color(0.576470588235294,0.772549019607843,0.447058823529412,1.0,"Pistachio"); - public static readonly Color Platinum = new Color(0.898039215686275,0.894117647058824,0.886274509803922,1.0,"Platinum"); - public static readonly Color PlumTraditional = new Color(0.556862745098039,0.270588235294118,0.52156862745098,1.0,"PlumTraditional"); - public static readonly Color PlumWeb = new Color(0.866666666666667,0.627450980392157,0.866666666666667,1.0,"PlumWeb"); - public static readonly Color PortlandOrange = new Color(1,0.352941176470588,0.211764705882353,1.0,"PortlandOrange"); - public static readonly Color PowderBlueWeb = new Color(0.690196078431373,0.87843137254902,0.901960784313726,1.0,"PowderBlueWeb"); - public static readonly Color PrincetonOrange = new Color(1,0.56078431372549,0,1.0,"PrincetonOrange"); - public static readonly Color Prune = new Color(0.43921568627451,0.109803921568627,0.109803921568627,1.0,"Prune"); - public static readonly Color PrussianBlue = new Color(0,0.192156862745098,0.325490196078431,1.0,"PrussianBlue"); - public static readonly Color PsychedelicPurple = new Color(0.874509803921569,0,1,1.0,"PsychedelicPurple"); - public static readonly Color Puce = new Color(0.8,0.533333333333333,0.6,1.0,"Puce"); - public static readonly Color Pumpkin = new Color(1,0.458823529411765,0.0941176470588235,1.0,"Pumpkin"); - public static readonly Color PurpleHeart = new Color(0.411764705882353,0.207843137254902,0.611764705882353,1.0,"PurpleHeart"); - public static readonly Color PurpleHtmlCss = new Color(0.501960784313725,0,0.501960784313725,1.0,"PurpleHtmlCss"); - public static readonly Color PurpleMountainMajesty = new Color(0.588235294117647,0.470588235294118,0.713725490196078,1.0,"PurpleMountainMajesty"); - public static readonly Color PurpleMunsell = new Color(0.623529411764706,0,0.772549019607843,1.0,"PurpleMunsell"); - public static readonly Color PurplePizzazz = new Color(0.996078431372549,0.305882352941176,0.854901960784314,1.0,"PurplePizzazz"); - public static readonly Color PurpleTaupe = new Color(0.313725490196078,0.250980392156863,0.301960784313725,1.0,"PurpleTaupe"); - public static readonly Color PurpleX11 = new Color(0.627450980392157,0.125490196078431,0.941176470588235,1.0,"PurpleX11"); - public static readonly Color Quartz = new Color(0.317647058823529,0.282352941176471,0.309803921568627,1.0,"Quartz"); - public static readonly Color Rackley = new Color(0.364705882352941,0.541176470588235,0.658823529411765,1.0,"Rackley"); - public static readonly Color RadicalRed = new Color(1,0.207843137254902,0.368627450980392,1.0,"RadicalRed"); - public static readonly Color Rajah = new Color(0.984313725490196,0.670588235294118,0.376470588235294,1.0,"Rajah"); - public static readonly Color Raspberry = new Color(0.890196078431373,0.0431372549019608,0.364705882352941,1.0,"Raspberry"); - public static readonly Color RaspberryGlace = new Color(0.568627450980392,0.372549019607843,0.427450980392157,1.0,"RaspberryGlace"); - public static readonly Color RaspberryPink = new Color(0.886274509803922,0.313725490196078,0.596078431372549,1.0,"RaspberryPink"); - public static readonly Color RaspberryRose = new Color(0.701960784313725,0.266666666666667,0.423529411764706,1.0,"RaspberryRose"); - public static readonly Color RawUmber = new Color(0.509803921568627,0.4,0.266666666666667,1.0,"RawUmber"); - public static readonly Color RazzleDazzleRose = new Color(1,0.2,0.8,1.0,"RazzleDazzleRose"); - public static readonly Color Razzmatazz = new Color(0.890196078431373,0.145098039215686,0.419607843137255,1.0,"Razzmatazz"); - public static readonly Color Red = new Color(1,0,0,1.0,"Red"); - public static readonly Color RedBrown = new Color(0.647058823529412,0.164705882352941,0.164705882352941,1.0,"RedBrown"); - public static readonly Color RedDevil = new Color(0.525490196078431,0.00392156862745098,0.0666666666666667,1.0,"RedDevil"); - public static readonly Color RedMunsell = new Color(0.949019607843137,0,0.235294117647059,1.0,"RedMunsell"); - public static readonly Color RedNcs = new Color(0.768627450980392,0.00784313725490196,0.2,1.0,"RedNcs"); - public static readonly Color RedOrange = new Color(1,0.325490196078431,0.286274509803922,1.0,"RedOrange"); - public static readonly Color RedPigment = new Color(0.929411764705882,0.109803921568627,0.141176470588235,1.0,"RedPigment"); - public static readonly Color RedRyb = new Color(0.996078431372549,0.152941176470588,0.0705882352941176,1.0,"RedRyb"); - public static readonly Color RedViolet = new Color(0.780392156862745,0.0823529411764706,0.52156862745098,1.0,"RedViolet"); - public static readonly Color Redwood = new Color(0.670588235294118,0.305882352941176,0.32156862745098,1.0,"Redwood"); - public static readonly Color Regalia = new Color(0.32156862745098,0.176470588235294,0.501960784313725,1.0,"Regalia"); - public static readonly Color ResolutionBlue = new Color(0,0.137254901960784,0.529411764705882,1.0,"ResolutionBlue"); - public static readonly Color RichBlack = new Color(0,0.250980392156863,0.250980392156863,1.0,"RichBlack"); - public static readonly Color RichBrilliantLavender = new Color(0.945098039215686,0.654901960784314,0.996078431372549,1.0,"RichBrilliantLavender"); - public static readonly Color RichCarmine = new Color(0.843137254901961,0,0.250980392156863,1.0,"RichCarmine"); - public static readonly Color RichElectricBlue = new Color(0.0313725490196078,0.572549019607843,0.815686274509804,1.0,"RichElectricBlue"); - public static readonly Color RichLavender = new Color(0.654901960784314,0.419607843137255,0.811764705882353,1.0,"RichLavender"); - public static readonly Color RichLilac = new Color(0.713725490196078,0.4,0.823529411764706,1.0,"RichLilac"); - public static readonly Color RichMaroon = new Color(0.690196078431373,0.188235294117647,0.376470588235294,1.0,"RichMaroon"); - public static readonly Color RifleGreen = new Color(0.254901960784314,0.282352941176471,0.2,1.0,"RifleGreen"); - public static readonly Color RobinEggBlue = new Color(0,0.8,0.8,1.0,"RobinEggBlue"); - public static readonly Color Rose = new Color(1,0,0.498039215686275,1.0,"Rose"); - public static readonly Color RoseBonbon = new Color(0.976470588235294,0.258823529411765,0.619607843137255,1.0,"RoseBonbon"); - public static readonly Color RoseEbony = new Color(0.403921568627451,0.282352941176471,0.274509803921569,1.0,"RoseEbony"); - public static readonly Color RoseGold = new Color(0.717647058823529,0.431372549019608,0.474509803921569,1.0,"RoseGold"); - public static readonly Color RoseMadder = new Color(0.890196078431373,0.149019607843137,0.211764705882353,1.0,"RoseMadder"); - public static readonly Color RosePink = new Color(1,0.4,0.8,1.0,"RosePink"); - public static readonly Color RoseQuartz = new Color(0.666666666666667,0.596078431372549,0.662745098039216,1.0,"RoseQuartz"); - public static readonly Color RoseTaupe = new Color(0.564705882352941,0.364705882352941,0.364705882352941,1.0,"RoseTaupe"); - public static readonly Color RoseVale = new Color(0.670588235294118,0.305882352941176,0.32156862745098,1.0,"RoseVale"); - public static readonly Color Rosewood = new Color(0.396078431372549,0,0.0431372549019608,1.0,"Rosewood"); - public static readonly Color RossoCorsa = new Color(0.831372549019608,0,0,1.0,"RossoCorsa"); - public static readonly Color RosyBrown = new Color(0.737254901960784,0.56078431372549,0.56078431372549,1.0,"RosyBrown"); - public static readonly Color RoyalAzure = new Color(0,0.219607843137255,0.658823529411765,1.0,"RoyalAzure"); - public static readonly Color RoyalBlueTraditional = new Color(0,0.137254901960784,0.4,1.0,"RoyalBlueTraditional"); - public static readonly Color RoyalBlueWeb = new Color(0.254901960784314,0.411764705882353,0.882352941176471,1.0,"RoyalBlueWeb"); - public static readonly Color RoyalFuchsia = new Color(0.792156862745098,0.172549019607843,0.572549019607843,1.0,"RoyalFuchsia"); - public static readonly Color RoyalPurple = new Color(0.470588235294118,0.317647058823529,0.662745098039216,1.0,"RoyalPurple"); - public static readonly Color RoyalYellow = new Color(0.980392156862745,0.854901960784314,0.368627450980392,1.0,"RoyalYellow"); - public static readonly Color RubineRed = new Color(0.819607843137255,0,0.337254901960784,1.0,"RubineRed"); - public static readonly Color Ruby = new Color(0.87843137254902,0.0666666666666667,0.372549019607843,1.0,"Ruby"); - public static readonly Color RubyRed = new Color(0.607843137254902,0.0666666666666667,0.117647058823529,1.0,"RubyRed"); - public static readonly Color Ruddy = new Color(1,0,0.156862745098039,1.0,"Ruddy"); - public static readonly Color RuddyBrown = new Color(0.733333333333333,0.396078431372549,0.156862745098039,1.0,"RuddyBrown"); - public static readonly Color RuddyPink = new Color(0.882352941176471,0.556862745098039,0.588235294117647,1.0,"RuddyPink"); - public static readonly Color Rufous = new Color(0.658823529411765,0.109803921568627,0.0274509803921569,1.0,"Rufous"); - public static readonly Color Russet = new Color(0.501960784313725,0.274509803921569,0.105882352941176,1.0,"Russet"); - public static readonly Color Rust = new Color(0.717647058823529,0.254901960784314,0.0549019607843137,1.0,"Rust"); - public static readonly Color RustyRed = new Color(0.854901960784314,0.172549019607843,0.262745098039216,1.0,"RustyRed"); - public static readonly Color SacramentoStateGreen = new Color(0,0.337254901960784,0.247058823529412,1.0,"SacramentoStateGreen"); - public static readonly Color SaddleBrown = new Color(0.545098039215686,0.270588235294118,0.0745098039215686,1.0,"SaddleBrown"); - public static readonly Color SafetyOrangeBlazeOrange = new Color(1,0.403921568627451,0,1.0,"SafetyOrangeBlazeOrange"); - public static readonly Color Saffron = new Color(0.956862745098039,0.768627450980392,0.188235294117647,1.0,"Saffron"); - public static readonly Color Salmon = new Color(1,0.549019607843137,0.411764705882353,1.0,"Salmon"); - public static readonly Color SalmonPink = new Color(1,0.568627450980392,0.643137254901961,1.0,"SalmonPink"); - public static readonly Color Sand = new Color(0.76078431372549,0.698039215686274,0.501960784313725,1.0,"Sand"); - public static readonly Color SandDune = new Color(0.588235294117647,0.443137254901961,0.0901960784313725,1.0,"SandDune"); - public static readonly Color Sandstorm = new Color(0.925490196078431,0.835294117647059,0.250980392156863,1.0,"Sandstorm"); - public static readonly Color SandyBrown = new Color(0.956862745098039,0.643137254901961,0.376470588235294,1.0,"SandyBrown"); - public static readonly Color SandyTaupe = new Color(0.588235294117647,0.443137254901961,0.0901960784313725,1.0,"SandyTaupe"); - public static readonly Color Sangria = new Color(0.572549019607843,0,0.0392156862745098,1.0,"Sangria"); - public static readonly Color SapGreen = new Color(0.313725490196078,0.490196078431373,0.164705882352941,1.0,"SapGreen"); - public static readonly Color Sapphire = new Color(0.0588235294117647,0.32156862745098,0.729411764705882,1.0,"Sapphire"); - public static readonly Color SapphireBlue = new Color(0,0.403921568627451,0.647058823529412,1.0,"SapphireBlue"); - public static readonly Color SatinSheenGold = new Color(0.796078431372549,0.631372549019608,0.207843137254902,1.0,"SatinSheenGold"); - public static readonly Color Scarlet = new Color(1,0.141176470588235,0,1.0,"Scarlet"); - public static readonly Color ScarletCrayola = new Color(0.992156862745098,0.0549019607843137,0.207843137254902,1.0,"ScarletCrayola"); - public static readonly Color SchoolBusYellow = new Color(1,0.847058823529412,0,1.0,"SchoolBusYellow"); - public static readonly Color ScreaminGreen = new Color(0.462745098039216,1,0.47843137254902,1.0,"ScreaminGreen"); - public static readonly Color SeaBlue = new Color(0,0.411764705882353,0.580392156862745,1.0,"SeaBlue"); - public static readonly Color SeaGreen = new Color(0.180392156862745,0.545098039215686,0.341176470588235,1.0,"SeaGreen"); - public static readonly Color SealBrown = new Color(0.196078431372549,0.0784313725490196,0.0784313725490196,1.0,"SealBrown"); - public static readonly Color Seashell = new Color(1,0.96078431372549,0.933333333333333,1.0,"Seashell"); - public static readonly Color SelectiveYellow = new Color(1,0.729411764705882,0,1.0,"SelectiveYellow"); - public static readonly Color Sepia = new Color(0.43921568627451,0.258823529411765,0.0784313725490196,1.0,"Sepia"); - public static readonly Color Shadow = new Color(0.541176470588235,0.474509803921569,0.364705882352941,1.0,"Shadow"); - public static readonly Color ShamrockGreen = new Color(0,0.619607843137255,0.376470588235294,1.0,"ShamrockGreen"); - public static readonly Color ShockingPink = new Color(0.988235294117647,0.0588235294117647,0.752941176470588,1.0,"ShockingPink"); - public static readonly Color ShockingPinkCrayola = new Color(1,0.435294117647059,1,1.0,"ShockingPinkCrayola"); - public static readonly Color Sienna = new Color(0.533333333333333,0.176470588235294,0.0901960784313725,1.0,"Sienna"); - public static readonly Color Silver = new Color(0.752941176470588,0.752941176470588,0.752941176470588,1.0,"Silver"); - public static readonly Color Sinopia = new Color(0.796078431372549,0.254901960784314,0.0431372549019608,1.0,"Sinopia"); - public static readonly Color Skobeloff = new Color(0,0.454901960784314,0.454901960784314,1.0,"Skobeloff"); - public static readonly Color SkyBlue = new Color(0.529411764705882,0.807843137254902,0.92156862745098,1.0,"SkyBlue"); - public static readonly Color SkyMagenta = new Color(0.811764705882353,0.443137254901961,0.686274509803922,1.0,"SkyMagenta"); - public static readonly Color SlateBlue = new Color(0.415686274509804,0.352941176470588,0.803921568627451,1.0,"SlateBlue"); - public static readonly Color SlateGray = new Color(0.43921568627451,0.501960784313725,0.564705882352941,1.0,"SlateGray"); - public static readonly Color SmaltDarkPowderBlue = new Color(0,0.2,0.6,1.0,"SmaltDarkPowderBlue"); - public static readonly Color SmokeyTopaz = new Color(0.576470588235294,0.23921568627451,0.254901960784314,1.0,"SmokeyTopaz"); - public static readonly Color SmokyBlack = new Color(0.0627450980392157,0.0470588235294118,0.0313725490196078,1.0,"SmokyBlack"); - public static readonly Color Snow = new Color(1,0.980392156862745,0.980392156862745,1.0,"Snow"); - public static readonly Color SpiroDiscoBall = new Color(0.0588235294117647,0.752941176470588,0.988235294117647,1.0,"SpiroDiscoBall"); - public static readonly Color SpringBud = new Color(0.654901960784314,0.988235294117647,0,1.0,"SpringBud"); - public static readonly Color SpringGreen = new Color(0,1,0.498039215686275,1.0,"SpringGreen"); - public static readonly Color StPatrickSBlue = new Color(0.137254901960784,0.16078431372549,0.47843137254902,1.0,"StPatrickSBlue"); - public static readonly Color SteelBlue = new Color(0.274509803921569,0.509803921568627,0.705882352941177,1.0,"SteelBlue"); - public static readonly Color StilDeGrainYellow = new Color(0.980392156862745,0.854901960784314,0.368627450980392,1.0,"StilDeGrainYellow"); - public static readonly Color Stizza = new Color(0.6,0,0,1.0,"Stizza"); - public static readonly Color Stormcloud = new Color(0.309803921568627,0.4,0.415686274509804,1.0,"Stormcloud"); - public static readonly Color Straw = new Color(0.894117647058824,0.850980392156863,0.435294117647059,1.0,"Straw"); - public static readonly Color Sunglow = new Color(1,0.8,0.2,1.0,"Sunglow"); - public static readonly Color Sunset = new Color(0.980392156862745,0.83921568627451,0.647058823529412,1.0,"Sunset"); - public static readonly Color Tan = new Color(0.823529411764706,0.705882352941177,0.549019607843137,1.0,"Tan"); - public static readonly Color Tangelo = new Color(0.976470588235294,0.301960784313725,0,1.0,"Tangelo"); - public static readonly Color Tangerine = new Color(0.949019607843137,0.52156862745098,0,1.0,"Tangerine"); - public static readonly Color TangerineYellow = new Color(1,0.8,0,1.0,"TangerineYellow"); - public static readonly Color TangoPink = new Color(0.894117647058824,0.443137254901961,0.47843137254902,1.0,"TangoPink"); - public static readonly Color Taupe = new Color(0.282352941176471,0.235294117647059,0.196078431372549,1.0,"Taupe"); - public static readonly Color TaupeGray = new Color(0.545098039215686,0.52156862745098,0.537254901960784,1.0,"TaupeGray"); - public static readonly Color TeaGreen = new Color(0.815686274509804,0.941176470588235,0.752941176470588,1.0,"TeaGreen"); - public static readonly Color TeaRoseOrange = new Color(0.972549019607843,0.513725490196078,0.474509803921569,1.0,"TeaRoseOrange"); - public static readonly Color TeaRoseRose = new Color(0.956862745098039,0.76078431372549,0.76078431372549,1.0,"TeaRoseRose"); - public static readonly Color Teal = new Color(0,0.501960784313725,0.501960784313725,1.0,"Teal"); - public static readonly Color TealBlue = new Color(0.211764705882353,0.458823529411765,0.533333333333333,1.0,"TealBlue"); - public static readonly Color TealGreen = new Color(0,0.509803921568627,0.498039215686275,1.0,"TealGreen"); - public static readonly Color Telemagenta = new Color(0.811764705882353,0.203921568627451,0.462745098039216,1.0,"Telemagenta"); - public static readonly Color TennTawny = new Color(0.803921568627451,0.341176470588235,0,1.0,"TennTawny"); - public static readonly Color TerraCotta = new Color(0.886274509803922,0.447058823529412,0.356862745098039,1.0,"TerraCotta"); - public static readonly Color Thistle = new Color(0.847058823529412,0.749019607843137,0.847058823529412,1.0,"Thistle"); - public static readonly Color ThulianPink = new Color(0.870588235294118,0.435294117647059,0.631372549019608,1.0,"ThulianPink"); - public static readonly Color TickleMePink = new Color(0.988235294117647,0.537254901960784,0.674509803921569,1.0,"TickleMePink"); - public static readonly Color TiffanyBlue = new Color(0.0392156862745098,0.729411764705882,0.709803921568627,1.0,"TiffanyBlue"); - public static readonly Color TigerSEye = new Color(0.87843137254902,0.552941176470588,0.235294117647059,1.0,"TigerSEye"); - public static readonly Color Timberwolf = new Color(0.858823529411765,0.843137254901961,0.823529411764706,1.0,"Timberwolf"); - public static readonly Color TitaniumYellow = new Color(0.933333333333333,0.901960784313726,0,1.0,"TitaniumYellow"); - public static readonly Color Tomato = new Color(1,0.388235294117647,0.27843137254902,1.0,"Tomato"); - public static readonly Color Toolbox = new Color(0.454901960784314,0.423529411764706,0.752941176470588,1.0,"Toolbox"); - public static readonly Color Topaz = new Color(1,0.784313725490196,0.486274509803922,1.0,"Topaz"); - public static readonly Color TractorRed = new Color(0.992156862745098,0.0549019607843137,0.207843137254902,1.0,"TractorRed"); - public static readonly Color TrolleyGrey = new Color(0.501960784313725,0.501960784313725,0.501960784313725,1.0,"TrolleyGrey"); - public static readonly Color TropicalRainForest = new Color(0,0.458823529411765,0.368627450980392,1.0,"TropicalRainForest"); - public static readonly Color TrueBlue = new Color(0,0.450980392156863,0.811764705882353,1.0,"TrueBlue"); - public static readonly Color TuftsBlue = new Color(0.254901960784314,0.490196078431373,0.756862745098039,1.0,"TuftsBlue"); - public static readonly Color Tumbleweed = new Color(0.870588235294118,0.666666666666667,0.533333333333333,1.0,"Tumbleweed"); - public static readonly Color TurkishRose = new Color(0.709803921568627,0.447058823529412,0.505882352941176,1.0,"TurkishRose"); - public static readonly Color Turquoise = new Color(0.188235294117647,0.835294117647059,0.784313725490196,1.0,"Turquoise"); - public static readonly Color TurquoiseBlue = new Color(0,1,0.937254901960784,1.0,"TurquoiseBlue"); - public static readonly Color TurquoiseGreen = new Color(0.627450980392157,0.83921568627451,0.705882352941177,1.0,"TurquoiseGreen"); - public static readonly Color TuscanRed = new Color(0.486274509803922,0.282352941176471,0.282352941176471,1.0,"TuscanRed"); - public static readonly Color TwilightLavender = new Color(0.541176470588235,0.286274509803922,0.419607843137255,1.0,"TwilightLavender"); - public static readonly Color TyrianPurple = new Color(0.4,0.00784313725490196,0.235294117647059,1.0,"TyrianPurple"); - public static readonly Color UaBlue = new Color(0,0.2,0.666666666666667,1.0,"UaBlue"); - public static readonly Color UaRed = new Color(0.850980392156863,0,0.298039215686275,1.0,"UaRed"); - public static readonly Color Ube = new Color(0.533333333333333,0.470588235294118,0.764705882352941,1.0,"Ube"); - public static readonly Color UclaBlue = new Color(0.325490196078431,0.407843137254902,0.584313725490196,1.0,"UclaBlue"); - public static readonly Color UclaGold = new Color(1,0.701960784313725,0,1.0,"UclaGold"); - public static readonly Color UfoGreen = new Color(0.235294117647059,0.815686274509804,0.43921568627451,1.0,"UfoGreen"); - public static readonly Color UltraPink = new Color(1,0.435294117647059,1,1.0,"UltraPink"); - public static readonly Color Ultramarine = new Color(0.0705882352941176,0.0392156862745098,0.56078431372549,1.0,"Ultramarine"); - public static readonly Color UltramarineBlue = new Color(0.254901960784314,0.4,0.96078431372549,1.0,"UltramarineBlue"); - public static readonly Color Umber = new Color(0.388235294117647,0.317647058823529,0.27843137254902,1.0,"Umber"); - public static readonly Color UnbleachedSilk = new Color(1,0.866666666666667,0.792156862745098,1.0,"UnbleachedSilk"); - public static readonly Color UnitedNationsBlue = new Color(0.356862745098039,0.572549019607843,0.898039215686275,1.0,"UnitedNationsBlue"); - public static readonly Color UniversityOfCaliforniaGold = new Color(0.717647058823529,0.529411764705882,0.152941176470588,1.0,"UniversityOfCaliforniaGold"); - public static readonly Color UnmellowYellow = new Color(1,1,0.4,1.0,"UnmellowYellow"); - public static readonly Color UpForestGreen = new Color(0.00392156862745098,0.266666666666667,0.129411764705882,1.0,"UpForestGreen"); - public static readonly Color UpMaroon = new Color(0.482352941176471,0.0666666666666667,0.0745098039215686,1.0,"UpMaroon"); - public static readonly Color UpsdellRed = new Color(0.682352941176471,0.125490196078431,0.16078431372549,1.0,"UpsdellRed"); - public static readonly Color Urobilin = new Color(0.882352941176471,0.67843137254902,0.129411764705882,1.0,"Urobilin"); - public static readonly Color UsafaBlue = new Color(0,0.309803921568627,0.596078431372549,1.0,"UsafaBlue"); - public static readonly Color UscCardinal = new Color(0.6,0,0,1.0,"UscCardinal"); - public static readonly Color UscGold = new Color(1,0.8,0,1.0,"UscGold"); - public static readonly Color UtahCrimson = new Color(0.827450980392157,0,0.247058823529412,1.0,"UtahCrimson"); - public static readonly Color Vanilla = new Color(0.952941176470588,0.898039215686275,0.670588235294118,1.0,"Vanilla"); - public static readonly Color VegasGold = new Color(0.772549019607843,0.701960784313725,0.345098039215686,1.0,"VegasGold"); - public static readonly Color VenetianRed = new Color(0.784313725490196,0.0313725490196078,0.0823529411764706,1.0,"VenetianRed"); - public static readonly Color Verdigris = new Color(0.262745098039216,0.701960784313725,0.682352941176471,1.0,"Verdigris"); - public static readonly Color VermilionCinnabar = new Color(0.890196078431373,0.258823529411765,0.203921568627451,1.0,"VermilionCinnabar"); - public static readonly Color VermilionPlochere = new Color(0.850980392156863,0.376470588235294,0.231372549019608,1.0,"VermilionPlochere"); - public static readonly Color Veronica = new Color(0.627450980392157,0.125490196078431,0.941176470588235,1.0,"Veronica"); - public static readonly Color Violet = new Color(0.56078431372549,0,1,1.0,"Violet"); - public static readonly Color VioletBlue = new Color(0.196078431372549,0.290196078431373,0.698039215686274,1.0,"VioletBlue"); - public static readonly Color VioletColorWheel = new Color(0.498039215686275,0,1,1.0,"VioletColorWheel"); - public static readonly Color VioletRyb = new Color(0.525490196078431,0.00392156862745098,0.686274509803922,1.0,"VioletRyb"); - public static readonly Color VioletWeb = new Color(0.933333333333333,0.509803921568627,0.933333333333333,1.0,"VioletWeb"); - public static readonly Color Viridian = new Color(0.250980392156863,0.509803921568627,0.427450980392157,1.0,"Viridian"); - public static readonly Color VividAuburn = new Color(0.572549019607843,0.152941176470588,0.141176470588235,1.0,"VividAuburn"); - public static readonly Color VividBurgundy = new Color(0.623529411764706,0.113725490196078,0.207843137254902,1.0,"VividBurgundy"); - public static readonly Color VividCerise = new Color(0.854901960784314,0.113725490196078,0.505882352941176,1.0,"VividCerise"); - public static readonly Color VividTangerine = new Color(1,0.627450980392157,0.537254901960784,1.0,"VividTangerine"); - public static readonly Color VividViolet = new Color(0.623529411764706,0,1,1.0,"VividViolet"); - public static readonly Color WarmBlack = new Color(0,0.258823529411765,0.258823529411765,1.0,"WarmBlack"); - public static readonly Color Waterspout = new Color(0.643137254901961,0.956862745098039,0.976470588235294,1.0,"Waterspout"); - public static readonly Color Wenge = new Color(0.392156862745098,0.329411764705882,0.32156862745098,1.0,"Wenge"); - public static readonly Color Wheat = new Color(0.96078431372549,0.870588235294118,0.701960784313725,1.0,"Wheat"); - public static readonly Color White = new Color(1,1,1,1.0,"White"); - public static readonly Color WhiteSmoke = new Color(0.96078431372549,0.96078431372549,0.96078431372549,1.0,"WhiteSmoke"); - public static readonly Color WildBlueYonder = new Color(0.635294117647059,0.67843137254902,0.815686274509804,1.0,"WildBlueYonder"); - public static readonly Color WildStrawberry = new Color(1,0.262745098039216,0.643137254901961,1.0,"WildStrawberry"); - public static readonly Color WildWatermelon = new Color(0.988235294117647,0.423529411764706,0.52156862745098,1.0,"WildWatermelon"); - public static readonly Color Wine = new Color(0.447058823529412,0.184313725490196,0.215686274509804,1.0,"Wine"); - public static readonly Color WineDregs = new Color(0.403921568627451,0.192156862745098,0.27843137254902,1.0,"WineDregs"); - public static readonly Color Wisteria = new Color(0.788235294117647,0.627450980392157,0.862745098039216,1.0,"Wisteria"); - public static readonly Color WoodBrown = new Color(0.756862745098039,0.603921568627451,0.419607843137255,1.0,"WoodBrown"); - public static readonly Color Xanadu = new Color(0.450980392156863,0.525490196078431,0.470588235294118,1.0,"Xanadu"); - public static readonly Color YaleBlue = new Color(0.0588235294117647,0.301960784313725,0.572549019607843,1.0,"YaleBlue"); - public static readonly Color Yellow = new Color(1,1,0,1.0,"Yellow"); - public static readonly Color YellowGreen = new Color(0.603921568627451,0.803921568627451,0.196078431372549,1.0,"YellowGreen"); - public static readonly Color YellowMunsell = new Color(0.937254901960784,0.8,0,1.0,"YellowMunsell"); - public static readonly Color YellowNcs = new Color(1,0.827450980392157,0,1.0,"YellowNcs"); - public static readonly Color YellowOrange = new Color(1,0.682352941176471,0.258823529411765,1.0,"YellowOrange"); - public static readonly Color YellowProcess = new Color(1,0.937254901960784,0,1.0,"YellowProcess"); - public static readonly Color YellowRyb = new Color(0.996078431372549,0.996078431372549,0.2,1.0,"YellowRyb"); - public static readonly Color Zaffre = new Color(0,0.0784313725490196,0.658823529411765,1.0,"Zaffre"); - public static readonly Color ZinnwalditeBrown = new Color(0.172549019607843,0.0862745098039216,0.0313725490196078,1.0,"ZinnwalditeBrown"); - #endregion + public static readonly Color AliceBlue = new Color(240,248,255,"AliceBlue","#F0F8FF"); + public static readonly Color AntiqueWhite = new Color(250,235,215,"AntiqueWhite","#FAEBD7"); + public static readonly Color Aqua = new Color(0,255,255,"Aqua","#00FFFF"); + public static readonly Color Aquamarine = new Color(127,255,212,"Aquamarine","#7FFFD4"); + public static readonly Color Azure = new Color(240,255,255,"Azure","#F0FFFF"); + public static readonly Color Beige = new Color(245,245,220,"Beige","#F5F5DC"); + public static readonly Color Bisque = new Color(255,228,196,"Bisque","#FFE4C4"); + public static readonly Color Black = new Color(0,0,0,"Black","#000000"); + public static readonly Color BlanchedAlmond = new Color(255,235,205,"BlanchedAlmond","#FFEBCD"); + public static readonly Color Blue = new Color(0,0,255,"Blue","#0000FF"); + public static readonly Color BlueViolet = new Color(138,43,226,"BlueViolet","#8A2BE2"); + public static readonly Color Brown = new Color(165,42,42,"Brown","#A52A2A"); + public static readonly Color BurlyWood = new Color(222,184,135,"BurlyWood","#DEB887"); + public static readonly Color CadetBlue = new Color(95,158,160,"CadetBlue","#5F9EA0"); + public static readonly Color Chartreuse = new Color(127,255,0,"Chartreuse","#7FFF00"); + public static readonly Color Chocolate = new Color(210,105,30,"Chocolate","#D2691E"); + public static readonly Color Coral = new Color(255,127,80,"Coral","#FF7F50"); + public static readonly Color CornflowerBlue = new Color(100,149,237,"CornflowerBlue","#6495ED"); + public static readonly Color Cornsilk = new Color(255,248,220,"Cornsilk","#FFF8DC"); + public static readonly Color Crimson = new Color(220,20,60,"Crimson","#DC143C"); + public static readonly Color Cyan = new Color(0,255,255,"Cyan","#00FFFF"); + public static readonly Color DarkBlue = new Color(0,0,139,"DarkBlue","#00008B"); + public static readonly Color DarkCyan = new Color(0,139,139,"DarkCyan","#008B8B"); + public static readonly Color DarkGoldenRod = new Color(184,134,11,"DarkGoldenRod","#B8860B"); + public static readonly Color DarkGray = new Color(169,169,169,"DarkGray","#A9A9A9"); + public static readonly Color DarkGrey = new Color(169,169,169,"DarkGrey","#A9A9A9"); + public static readonly Color DarkGreen = new Color(0,100,0,"DarkGreen","#006400"); + public static readonly Color DarkKhaki = new Color(189,183,107,"DarkKhaki","#BDB76B"); + public static readonly Color DarkMagenta = new Color(139,0,139,"DarkMagenta","#8B008B"); + public static readonly Color DarkOliveGreen = new Color(85,107,47,"DarkOliveGreen","#556B2F"); + public static readonly Color DarkOrange = new Color(255,140,0,"DarkOrange","#FF8C00"); + public static readonly Color DarkOrchid = new Color(153,50,204,"DarkOrchid","#9932CC"); + public static readonly Color DarkRed = new Color(139,0,0,"DarkRed","#8B0000"); + public static readonly Color DarkSalmon = new Color(233,150,122,"DarkSalmon","#E9967A"); + public static readonly Color DarkSeaGreen = new Color(143,188,143,"DarkSeaGreen","#8FBC8F"); + public static readonly Color DarkSlateBlue = new Color(72,61,139,"DarkSlateBlue","#483D8B"); + public static readonly Color DarkSlateGray = new Color(47,79,79,"DarkSlateGray","#2F4F4F"); + public static readonly Color DarkSlateGrey = new Color(47,79,79,"DarkSlateGrey","#2F4F4F"); + public static readonly Color DarkTurquoise = new Color(0,206,209,"DarkTurquoise","#00CED1"); + public static readonly Color DarkViolet = new Color(148,0,211,"DarkViolet","#9400D3"); + public static readonly Color DeepPink = new Color(255,20,147,"DeepPink","#FF1493"); + public static readonly Color DeepSkyBlue = new Color(0,191,255,"DeepSkyBlue","#00BFFF"); + public static readonly Color DimGray = new Color(105,105,105,"DimGray","#696969"); + public static readonly Color DimGrey = new Color(105,105,105,"DimGrey","#696969"); + public static readonly Color DodgerBlue = new Color(30,144,255,"DodgerBlue","#1E90FF"); + public static readonly Color FireBrick = new Color(178,34,34,"FireBrick","#B22222"); + public static readonly Color FloralWhite = new Color(255,250,240,"FloralWhite","#FFFAF0"); + public static readonly Color ForestGreen = new Color(34,139,34,"ForestGreen","#228B22"); + public static readonly Color Fuchsia = new Color(255,0,255,"Fuchsia","#FF00FF"); + public static readonly Color Gainsboro = new Color(220,220,220,"Gainsboro","#DCDCDC"); + public static readonly Color GhostWhite = new Color(248,248,255,"GhostWhite","#F8F8FF"); + public static readonly Color Gold = new Color(255,215,0,"Gold","#FFD700"); + public static readonly Color GoldenRod = new Color(218,165,32,"GoldenRod","#DAA520"); + public static readonly Color Gray = new Color(128,128,128,"Gray","#808080"); + public static readonly Color Grey = new Color(128,128,128,"Grey","#808080"); + public static readonly Color Green = new Color(0,128,0,"Green","#008000"); + public static readonly Color GreenYellow = new Color(173,255,47,"GreenYellow","#ADFF2F"); + public static readonly Color HoneyDew = new Color(240,255,240,"HoneyDew","#F0FFF0"); + public static readonly Color HotPink = new Color(255,105,180,"HotPink","#FF69B4"); + public static readonly Color IndianRed = new Color(205,92,92,"IndianRed","#CD5C5C"); + public static readonly Color Indigo = new Color(75,0,130,"Indigo","#4B0082"); + public static readonly Color Ivory = new Color(255,255,240,"Ivory","#FFFFF0"); + public static readonly Color Jet = new Color(52,52,52,"Jet","#343434"); + public static readonly Color Khaki = new Color(240,230,140,"Khaki","#F0E68C"); + public static readonly Color Lavender = new Color(230,230,250,"Lavender","#E6E6FA"); + public static readonly Color LavenderBlush = new Color(255,240,245,"LavenderBlush","#FFF0F5"); + public static readonly Color LawnGreen = new Color(124,252,0,"LawnGreen","#7CFC00"); + public static readonly Color LemonChiffon = new Color(255,250,205,"LemonChiffon","#FFFACD"); + public static readonly Color LightBlue = new Color(173,216,230,"LightBlue","#ADD8E6"); + public static readonly Color LightCoral = new Color(240,128,128,"LightCoral","#F08080"); + public static readonly Color LightCyan = new Color(224,255,255,"LightCyan","#E0FFFF"); + public static readonly Color LightGoldenRodYellow = new Color(250,250,210,"LightGoldenRodYellow","#FAFAD2"); + public static readonly Color LightGray = new Color(211,211,211,"LightGray","#D3D3D3"); + public static readonly Color LightGrey = new Color(211,211,211,"LightGrey","#D3D3D3"); + public static readonly Color LightGreen = new Color(144,238,144,"LightGreen","#90EE90"); + public static readonly Color LightPink = new Color(255,182,193,"LightPink","#FFB6C1"); + public static readonly Color LightSalmon = new Color(255,160,122,"LightSalmon","#FFA07A"); + public static readonly Color LightSeaGreen = new Color(32,178,170,"LightSeaGreen","#20B2AA"); + public static readonly Color LightSkyBlue = new Color(135,206,250,"LightSkyBlue","#87CEFA"); + public static readonly Color LightSlateGray = new Color(119,136,153,"LightSlateGray","#778899"); + public static readonly Color LightSlateGrey = new Color(119,136,153,"LightSlateGrey","#778899"); + public static readonly Color LightSteelBlue = new Color(176,196,222,"LightSteelBlue","#B0C4DE"); + public static readonly Color LightYellow = new Color(255,255,224,"LightYellow","#FFFFE0"); + public static readonly Color Lime = new Color(0,255,0,"Lime","#00FF00"); + public static readonly Color LimeGreen = new Color(50,205,50,"LimeGreen","#32CD32"); + public static readonly Color Linen = new Color(250,240,230,"Linen","#FAF0E6"); + public static readonly Color Magenta = new Color(255,0,255,"Magenta","#FF00FF"); + public static readonly Color Maroon = new Color(128,0,0,"Maroon","#800000"); + public static readonly Color MediumAquaMarine = new Color(102,205,170,"MediumAquaMarine","#66CDAA"); + public static readonly Color MediumBlue = new Color(0,0,205,"MediumBlue","#0000CD"); + public static readonly Color MediumOrchid = new Color(186,85,211,"MediumOrchid","#BA55D3"); + public static readonly Color MediumPurple = new Color(147,112,219,"MediumPurple","#9370DB"); + public static readonly Color MediumSeaGreen = new Color(60,179,113,"MediumSeaGreen","#3CB371"); + public static readonly Color MediumSlateBlue = new Color(123,104,238,"MediumSlateBlue","#7B68EE"); + public static readonly Color MediumSpringGreen = new Color(0,250,154,"MediumSpringGreen","#00FA9A"); + public static readonly Color MediumTurquoise = new Color(72,209,204,"MediumTurquoise","#48D1CC"); + public static readonly Color MediumVioletRed = new Color(199,21,133,"MediumVioletRed","#C71585"); + public static readonly Color MidnightBlue = new Color(25,25,112,"MidnightBlue","#191970"); + public static readonly Color MintCream = new Color(245,255,250,"MintCream","#F5FFFA"); + public static readonly Color MistyRose = new Color(255,228,225,"MistyRose","#FFE4E1"); + public static readonly Color Moccasin = new Color(255,228,181,"Moccasin","#FFE4B5"); + public static readonly Color NavajoWhite = new Color(255,222,173,"NavajoWhite","#FFDEAD"); + public static readonly Color Navy = new Color(0,0,128,"Navy","#000080"); + public static readonly Color OldLace = new Color(253,245,230,"OldLace","#FDF5E6"); + public static readonly Color Olive = new Color(128,128,0,"Olive","#808000"); + public static readonly Color OliveDrab = new Color(107,142,35,"OliveDrab","#6B8E23"); + public static readonly Color Onyx = new Color(53,56,57,"Onyx","#353839"); + public static readonly Color Orange = new Color(255,165,0,"Orange","#FFA500"); + public static readonly Color OrangeRed = new Color(255,69,0,"OrangeRed","#FF4500"); + public static readonly Color Orchid = new Color(218,112,214,"Orchid","#DA70D6"); + public static readonly Color PaleGoldenRod = new Color(238,232,170,"PaleGoldenRod","#EEE8AA"); + public static readonly Color PaleGreen = new Color(152,251,152,"PaleGreen","#98FB98"); + public static readonly Color PaleTurquoise = new Color(175,238,238,"PaleTurquoise","#AFEEEE"); + public static readonly Color PaleVioletRed = new Color(219,112,147,"PaleVioletRed","#DB7093"); + public static readonly Color PapayaWhip = new Color(255,239,213,"PapayaWhip","#FFEFD5"); + public static readonly Color PeachPuff = new Color(255,218,185,"PeachPuff","#FFDAB9"); + public static readonly Color Peru = new Color(205,133,63,"Peru","#CD853F"); + public static readonly Color Pink = new Color(255,192,203,"Pink","#FFC0CB"); + public static readonly Color Plum = new Color(221,160,221,"Plum","#DDA0DD"); + public static readonly Color PowderBlue = new Color(176,224,230,"PowderBlue","#B0E0E6"); + public static readonly Color Purple = new Color(128,0,128,"Purple","#800080"); + public static readonly Color RebeccaPurple = new Color(102,51,153,"RebeccaPurple","#663399"); + public static readonly Color Red = new Color(255,0,0,"Red","#FF0000"); + public static readonly Color RosyBrown = new Color(188,143,143,"RosyBrown","#BC8F8F"); + public static readonly Color RoyalBlue = new Color(65,105,225,"RoyalBlue","#4169E1"); + public static readonly Color SaddleBrown = new Color(139,69,19,"SaddleBrown","#8B4513"); + public static readonly Color Salmon = new Color(250,128,114,"Salmon","#FA8072"); + public static readonly Color SandyBrown = new Color(244,164,96,"SandyBrown","#F4A460"); + public static readonly Color SeaGreen = new Color(46,139,87,"SeaGreen","#2E8B57"); + public static readonly Color SeaShell = new Color(255,245,238,"SeaShell","#FFF5EE"); + public static readonly Color Sienna = new Color(160,82,45,"Sienna","#A0522D"); + public static readonly Color Silver = new Color(192,192,192,"Silver","#C0C0C0"); + public static readonly Color SkyBlue = new Color(135,206,235,"SkyBlue","#87CEEB"); + public static readonly Color SlateBlue = new Color(106,90,205,"SlateBlue","#6A5ACD"); + public static readonly Color SlateGray = new Color(112,128,144,"SlateGray","#708090"); + public static readonly Color SlateGrey = new Color(112,128,144,"SlateGrey","#708090"); + public static readonly Color Snow = new Color(255,250,250,"Snow","#FFFAFA"); + public static readonly Color SpringGreen = new Color(0,255,127,"SpringGreen","#00FF7F"); + public static readonly Color SteelBlue = new Color(70,130,180,"SteelBlue","#4682B4"); + public static readonly Color Tan = new Color(210,180,140,"Tan","#D2B48C"); + public static readonly Color Teal = new Color(0,128,128,"Teal","#008080"); + public static readonly Color Thistle = new Color(216,191,216,"Thistle","#D8BFD8"); + public static readonly Color Tomato = new Color(255,99,71,"Tomato","#FF6347"); + public static readonly Color Turquoise = new Color(64,224,208,"Turquoise","#40E0D0"); + public static readonly Color Violet = new Color(238,130,238,"Violet","#EE82EE"); + public static readonly Color Wheat = new Color(245,222,179,"Wheat","#F5DEB3"); + public static readonly Color White = new Color(255,255,255,"White","#FFFFFF"); + public static readonly Color WhiteSmoke = new Color(245,245,245,"WhiteSmoke","#F5F5F5"); + public static readonly Color Yellow = new Color(255,255,0,"Yellow","#FFFF00"); + public static readonly Color YellowGreen = new Color(154,205,50,"YellowGreen","#9ACD32"); - #region IXmlSerializable - public void ReadXml(System.Xml.XmlReader reader) - { - string[] c = reader["Color"].Split(new char[] { ',' }); - R = double.Parse(c[0]); - G = double.Parse(c[1]); - B = double.Parse(c[2]); - A = double.Parse(c[3]); - } - public void WriteXml(System.Xml.XmlWriter writer) - { - writer.WriteAttributeString("Color", this.ToString()); - } - public System.Xml.Schema.XmlSchema GetSchema() - { - return null; - } #endregion public override int GetHashCode () @@ -1141,11 +454,11 @@ namespace Crow { if (!string.IsNullOrEmpty(Name)) return Name; - Color tc = this; - if (ColorDic.ContainsValue (this)) - return ColorDic.FirstOrDefault (c => c.Value == tc).Key; - - return string.Format("{0},{1},{2},{3}", R, G, B, A); + if (!string.IsNullOrEmpty (htmlCode)) + return htmlCode; + string hc = HtmlCode; + Color pc = ColorDic.Values.FirstOrDefault (c => c.htmlCode == hc); + return pc.predefinied ? pc.Name : hc; } public static object Parse(string s) diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index dbd12d41..e315f761 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -77,7 +77,7 @@ namespace Crow.IML internal static MethodInfo miDSChangeEmitHelper = typeof(Instantiator).GetMethod("dataSourceChangedEmitHelper", BindingFlags.Instance | BindingFlags.NonPublic); internal static MethodInfo miDSReverseBinding = typeof(Instantiator).GetMethod("dataSourceReverseBinding", BindingFlags.Static | BindingFlags.NonPublic); - internal static FieldInfo miSetCurIface = typeof(GraphicObject).GetField ("CurrentInterface", BindingFlags.Public | BindingFlags.Instance); + internal static FieldInfo miSetCurIface = typeof(GraphicObject).GetField ("IFace", BindingFlags.Public | BindingFlags.Instance); internal static MethodInfo miFindByName = typeof (GraphicObject).GetMethod ("FindByName"); internal static MethodInfo miGetGObjItem = typeof(List<GraphicObject>).GetMethod("get_Item", new Type[] { typeof(Int32) }); internal static MethodInfo miLoadDefaultVals = typeof (GraphicObject).GetMethod ("loadDefaultValues"); @@ -87,7 +87,7 @@ namespace Crow.IML internal static EventInfo eiLogicalParentChanged = typeof(GraphicObject).GetEvent("LogicalParentChanged"); internal static MethodInfo miIFaceLoad = typeof(Interface).GetMethod ("Load", BindingFlags.Instance | BindingFlags.Public); - internal static MethodInfo miGetITemp = typeof(Interface).GetMethod ("GetItemTemplate"); + internal static MethodInfo miGetITemp = typeof(Interface).GetMethod ("GetItemTemplate", BindingFlags.Instance | BindingFlags.Public); internal static MethodInfo miAddITemp = typeof(Dictionary<string, ItemTemplate>).GetMethod ("set_Item", new Type[] { typeof(string), typeof(ItemTemplate) }); internal static MethodInfo miGetITempFromDic = typeof(Dictionary<string, ItemTemplate>).GetMethod ("get_Item", new Type[] { typeof(string) }); @@ -97,6 +97,11 @@ namespace Crow.IML internal static MethodInfo miCreateExpDel = typeof(ItemTemplate).GetMethod ("CreateExpandDelegate"); internal static FieldInfo fiFetchMethodName = typeof(ItemTemplate).GetField("fetchMethodName", BindingFlags.Instance | BindingFlags.NonPublic); + + #if DESIGN_MODE + internal static MethodInfo miDicStrStrAdd = typeof(Dictionary<string, string>).GetMethod ("set_Item", new Type[] { typeof(string), typeof(string) }); + #endif + #region tree handling methods internal static FieldInfo fiChild = typeof(PrivateContainer).GetField ("child", BindingFlags.Instance | BindingFlags.NonPublic); internal static MethodInfo miSetChild = typeof (Container).GetMethod ("SetChild"); @@ -159,18 +164,18 @@ namespace Crow.IML else il.Emit (OpCodes.Ldc_I4_0); break; - // case TypeCode.Empty: - // break; - // case TypeCode.Object: - // break; - // case TypeCode.DBNull: - // break; - // case TypeCode.SByte: - // break; - // case TypeCode.Decimal: - // break; - // case TypeCode.DateTime: - // break; +// case TypeCode.Empty: +// break; +// case TypeCode.Object: +// break; +// case TypeCode.DBNull: +// break; +// case TypeCode.SByte: +// break; +// case TypeCode.Decimal: +// break; +// case TypeCode.DateTime: +// break; case TypeCode.Char: il.Emit (OpCodes.Ldc_I4, Convert.ToChar (val)); break; @@ -271,7 +276,11 @@ namespace Crow.IML #region Reflexion helpers static MemberInfo getMemberInfoWithReflexion(object instance, string member){ - return instance.GetType ().GetMember (member)?.FirstOrDefault(); + Type t = instance.GetType(); + MemberInfo mi = t.GetMember (member)?.FirstOrDefault(); + if (mi == null) + mi = CompilerServices.SearchExtMethod (t, member); + return mi; } static MethodInfo getMethodInfoWithReflexion(object instance, string method){ return instance.GetType ().GetMethod (method, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); @@ -339,12 +348,20 @@ namespace Crow.IML PropertyInfo pi = mi as PropertyInfo; tmp = pi.GetValue (instance); dstType = pi.PropertyType; - } - if (mi.MemberType == MemberTypes.Field) { + }else if (mi.MemberType == MemberTypes.Field) { FieldInfo fi = mi as FieldInfo; tmp = fi.GetValue (instance); dstType = fi.FieldType; + }else if (mi.MemberType == MemberTypes.Method) { + MethodInfo gi = mi as MethodInfo; + if (gi.IsStatic) + tmp = gi.Invoke(null, new object[] {instance}); + else + tmp = gi.Invoke(instance, null); + dstType = gi.ReturnType; } + + if (tmp != null) return tmp; if (dstType == typeof(string) || dstType == CompilerServices.TObject)//TODO:object should be allowed to return null and not "" @@ -688,7 +705,7 @@ namespace Crow.IML /// <summary> /// create delegate helper /// </summary> - static Delegate createDel(Type eventType, object instance, string method){ + static Delegate createDel(object instance, Type eventType, string method){ Type t = instance.GetType (); MethodInfo mi = t.GetMethod (method, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (mi == null) { diff --git a/src/Configuration.cs b/src/Configuration.cs index a6b0f0b0..a6328c0a 100644 --- a/src/Configuration.cs +++ b/src/Configuration.cs @@ -169,7 +169,8 @@ namespace Crow using (StreamWriter sw = new StreamWriter (s)) { lock (items) { foreach (string key in items.Keys) { - sw.WriteLine (key + "=" + (string)items [key].curVal.ToString ()); + if (items [key].curVal != null) + sw.WriteLine (key + "=" + (string)items [key].curVal.ToString ()); } } } diff --git a/src/CrowThread.cs b/src/CrowThread.cs index c3a4ba3b..a1b4c38e 100644 --- a/src/CrowThread.cs +++ b/src/CrowThread.cs @@ -41,15 +41,15 @@ namespace Crow thread = new Thread (start); thread.IsBackground = true; Host = host; - lock (Host.CurrentInterface.CrowThreads) - Host.CurrentInterface.CrowThreads.Add (this); + lock (Host.IFace.CrowThreads) + Host.IFace.CrowThreads.Add (this); } public void CheckState(){ if (thread.ThreadState != ThreadState.Stopped) return; Finished.Raise (Host, null); - lock (Host.CurrentInterface.CrowThreads) - Host.CurrentInterface.CrowThreads.Remove (this); + lock (Host.IFace.CrowThreads) + Host.IFace.CrowThreads.Remove (this); } public void Start() { thread.Start();} public void Cancel(){ @@ -57,8 +57,8 @@ namespace Crow cancelRequested = true; thread.Join (); } - lock (Host.CurrentInterface.CrowThreads) - Host.CurrentInterface.CrowThreads.Remove (this); + lock (Host.IFace.CrowThreads) + Host.IFace.CrowThreads.Remove (this); } } } diff --git a/src/Enums.cs b/src/Enums.cs index 6249135b..8b90d6ea 100644 --- a/src/Enums.cs +++ b/src/Enums.cs @@ -47,7 +47,8 @@ namespace Crow Bottom = 0x08, BottomLeft = 0x0a, BottomRight = 0x0c, - Center = 0x10 + Center = 0x10, + Undefined = 0x40 } public enum HorizontalAlignment { diff --git a/src/ExtensionsMethods.cs b/src/ExtensionsMethods.cs index 6697be62..340a8ceb 100644 --- a/src/ExtensionsMethods.cs +++ b/src/ExtensionsMethods.cs @@ -58,17 +58,18 @@ namespace Crow public static Cairo.PointD Substract(this Cairo.PointD p1, Cairo.PointD p2){ return new Cairo.PointD(p1.X - p2.X, p1.Y - p2.Y); } + public static Cairo.PointD Divide(this Cairo.PointD p1, double d){ + return new Cairo.PointD(p1.X / d, p1.Y / d); + } public static Cairo.PointD Add(this Cairo.PointD p1, Cairo.PointD p2){ return new Cairo.PointD(p1.X + p2.X, p1.Y + p2.Y); } public static Cairo.PointD Multiply(this Cairo.PointD p1, double v){ return new Cairo.PointD(p1.X * v, p1.Y * v); } - public static void DrawCote(this Cairo.Context ctx, Cairo.PointD p1, Cairo.PointD p2, double stroke = 1.0) - { - const double arrowWidth = 4.0; - const double arrowLength = 10.0; - + public static void DrawCote(this Cairo.Context ctx, Cairo.PointD p1, Cairo.PointD p2, + double stroke = 1.0, bool fill = false, double arrowWidth = 3.0, double arrowLength = 7.0) + { Cairo.PointD vDir = p2.Substract(p1); vDir = vDir.GetNormalized (); Cairo.PointD vPerp = vDir.GetPerp (); @@ -80,21 +81,77 @@ namespace Crow ctx.MoveTo (p1); ctx.LineTo (pA0.Add (vA)); - ctx.LineTo (pA0.Substract (vA)); + if (fill) + ctx.LineTo (pA0.Substract (vA)); + else + ctx.MoveTo (pA0.Substract (vA)); + ctx.LineTo (p1); ctx.MoveTo (p2); ctx.LineTo (pA1.Add (vA)); - ctx.LineTo (pA1.Substract (vA)); + if (fill) + ctx.LineTo (pA1.Substract (vA)); + else + ctx.MoveTo (pA1.Substract (vA)); ctx.LineTo (p2); - ctx.Fill (); + if (fill) + ctx.Fill (); ctx.MoveTo (p1); ctx.LineTo (p2); ctx.LineWidth = stroke; ctx.Stroke (); + } + public static void DrawCoteInverse(this Cairo.Context ctx, Cairo.PointD p1, Cairo.PointD p2, + double stroke = 1.0, bool fill = false, double arrowWidth = 3.0, double arrowLength = 7.0) + { + Cairo.PointD vDir = p2.Substract(p1); + vDir = vDir.GetNormalized (); + Cairo.PointD vPerp = vDir.GetPerp (); + + Cairo.PointD pA0 = p1.Add(vDir.Multiply(arrowLength)); + Cairo.PointD pA1 = p2.Substract(vDir.Multiply(arrowLength)); + + Cairo.PointD vA = vPerp.Multiply (arrowWidth); + + ctx.MoveTo (p1.Add (vA)); + ctx.LineTo (pA0); + ctx.LineTo (p1.Substract (vA)); + if (fill) + ctx.LineTo (p1.Add (vA)); + + ctx.MoveTo (p2.Add (vA)); + ctx.LineTo (pA1); + ctx.LineTo (p2.Substract (vA)); + + if (fill) { + ctx.LineTo (p2.Add (vA)); + ctx.Fill (); + } + ctx.MoveTo (pA0); + ctx.LineTo (pA1); + ctx.LineWidth = stroke; + ctx.Stroke (); + } + public static void DrawCoteFixed(this Cairo.Context ctx, Cairo.PointD p1, Cairo.PointD p2, + double stroke = 1.0, double coteWidth = 3.0) + { + Cairo.PointD vDir = p2.Substract(p1); + vDir = vDir.GetNormalized (); + Cairo.PointD vPerp = vDir.GetPerp (); + Cairo.PointD vA = vPerp.Multiply (coteWidth); + + ctx.MoveTo (p1.Add (vA)); + ctx.LineTo (p1.Substract (vA)); + ctx.MoveTo (p2.Add (vA)); + ctx.LineTo (p2.Substract (vA)); + ctx.MoveTo (p1); + ctx.LineTo (p2); + ctx.LineWidth = stroke; + ctx.Stroke (); } public static void SetSourceColor(this Cairo.Context ctx, Color c) { @@ -106,6 +163,30 @@ namespace Crow } #endregion + public static Orientation GetOrientation(this Alignment a){ + return (a==Alignment.Left) ||(a==Alignment.Right) ? Orientation.Horizontal : Orientation.Vertical; + } + public static Alignment GetOpposite(this Alignment a){ + switch (a) { + case Alignment.Left: + return Alignment.Right; + case Alignment.Right: + return Alignment.Left; + case Alignment.Top: + return Alignment.Bottom; + case Alignment.Bottom: + return Alignment.Top; + case Alignment.TopLeft: + return Alignment.BottomRight; + case Alignment.TopRight: + return Alignment.BottomLeft; + case Alignment.BottomLeft: + return Alignment.TopRight; + case Alignment.BottomRight: + return Alignment.TopLeft; + } + return Alignment.Center; + } public static void Raise(this EventHandler handler, object sender, EventArgs e) { if(handler != null) @@ -120,7 +201,12 @@ namespace Crow handler(sender, e); } } - + public static byte[] GetBytes(this string str) + { + byte[] bytes = new byte[str.Length * sizeof(char)]; + System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length); + return bytes; + } public static bool IsWhiteSpaceOrNewLine (this char c) { return c == '\t' || c == '\r' || c == '\n' || char.IsWhiteSpace (c); diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs index f2be5993..adeb32e7 100644 --- a/src/GraphicObjects/Border.cs +++ b/src/GraphicObjects/Border.cs @@ -55,7 +55,7 @@ namespace Crow int _borderWidth; BorderStyle _borderStyle; Fill raisedColor = Color.Gray; - Fill sunkenColor = Color.Jet; + Fill sunkenColor = Color.DimGray; #endregion #region public properties diff --git a/src/GraphicObjects/ColorPicker.cs b/src/GraphicObjects/ColorPicker.cs index 3a5ec23f..cc955191 100644 --- a/src/GraphicObjects/ColorPicker.cs +++ b/src/GraphicObjects/ColorPicker.cs @@ -165,7 +165,12 @@ namespace Crow NotifyValueChanged ("SelectedColorName", n); else NotifyValueChanged ("SelectedColorName", "-"); - NotifyValueChanged ("HexColor", ((int)R).ToString ("X2") + ((int)G).ToString ("X2") + ((int)B).ToString ("X2") + ((int)A).ToString ("X2")); + string tmp = ((int)Math.Round (R)).ToString ("X2") + + ((int)Math.Round (G)).ToString ("X2") + + ((int)Math.Round (B)).ToString ("X2"); + if (curColor.A < 1.0) + tmp += ((int)Math.Round (A)).ToString ("X2"); + NotifyValueChanged ("HexColor", tmp); } void notifyRGBAHasChanged(){ NotifyValueChanged ("R", R); diff --git a/src/GraphicObjects/ColorSelector.cs b/src/GraphicObjects/ColorSelector.cs index 5b32fc95..ee57a262 100644 --- a/src/GraphicObjects/ColorSelector.cs +++ b/src/GraphicObjects/ColorSelector.cs @@ -33,6 +33,7 @@ namespace Crow /// <summary> /// simple squarred rgb color selector /// </summary> + [DesignIgnore] public class ColorSelector : GraphicObject { #region CTOR @@ -47,7 +48,7 @@ namespace Crow public override void onMouseMove (object sender, MouseMoveEventArgs e) { base.onMouseMove (sender, e); - if (CurrentInterface.Mouse.LeftButton == ButtonState.Released) + if (IFace.Mouse.LeftButton == ButtonState.Released) return; updateMouseLocalPos (e.Position); } diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs index fedee0af..364bad83 100644 --- a/src/GraphicObjects/Container.cs +++ b/src/GraphicObjects/Container.cs @@ -38,6 +38,18 @@ namespace Crow /// </summary> public class Container : PrivateContainer { + #if DESIGN_MODE + public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem) + { + if (this.design_isTGItem) + return; + base.getIML (doc, parentElem); + if (child == null) + return; + child.getIML (doc, parentElem.LastChild); + } + #endif + #region CTOR protected Container() : base(){} public Container (Interface iface) : base(iface){} diff --git a/src/GraphicObjects/DockStack.cs b/src/GraphicObjects/DockStack.cs new file mode 100644 index 00000000..ae8b9c89 --- /dev/null +++ b/src/GraphicObjects/DockStack.cs @@ -0,0 +1,363 @@ +// +// DockStack.cs +// +// Author: +// Jean-Philippe Bruyère <jp_bruyere@hotmail.com> +// +// Copyright (c) 2013-2017 Jean-Philippe Bruyère +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Crow.IML; + +namespace Crow +{ + [DesignIgnore] + public class DockStack : GenericStack + { + #region CTor + public DockStack () {} + public DockStack (Interface iface) : base (iface) {} + #endregion + + public override void AddChild (GraphicObject g) + { + base.AddChild (g); + if (localLogicalParentIsNull) + g.LogicalParent = this; + else + g.LogicalParent = this.LogicalParent; + } + public override void InsertChild (int idx, GraphicObject g) + { + base.InsertChild (idx, g); + g.LogicalParent = this.LogicalParent; + } + + public override bool PointIsIn (ref Point m) + { + if (!base.PointIsIn(ref m)) + return false; + + Group p = Parent as Group; + if (p != null) { + childrenRWLock.EnterReadLock (); + for (int i = p.Children.Count - 1; i >= 0; i--) { + if (p.Children [i] == this) + break; + if (p.Children [i].IsDragged) + continue; + if (p.Children [i].Slot.ContainsOrIsEqual (m)) { + childrenRWLock.ExitReadLock (); + return false; + } + } + } + childrenRWLock.ExitReadLock (); + return Slot.ContainsOrIsEqual(m); + } + +// public override void OnLayoutChanges (LayoutingType layoutType) +// { +// base.OnLayoutChanges (layoutType); +// +// if ((layoutType & LayoutingType.Sizing) > 0) +// computeRects(); +// } + + Rectangle rIn = default(Rectangle); + double dockThresh = 0.2; + GraphicObject focusedChild; + internal GraphicObject stretchedChild; + + void getFocusedChild (Point lm) { + Rectangle cb = ClientRectangle; + + childrenRWLock.EnterReadLock (); + foreach (GraphicObject c in Children) { + Rectangle bounds = c.Slot + cb.Position; + if (!bounds.ContainsOrIsEqual (lm)) + continue; + rIn = bounds; + focusedChild = c; + break; + } + childrenRWLock.ExitReadLock (); + } + + public override void onMouseMove (object sender, MouseMoveEventArgs e) + { + if (IsDropTarget) { + DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow; + if (dw.IsDocked) { + base.onMouseMove (sender, e); + return; + } + + Alignment curDockPos = dw.DockingPosition; + dw.DockingPosition = Alignment.Undefined; + + Rectangle cb = ClientRectangle; + Point lm = ScreenPointToLocal (e.Position); + + if (Children.Count == 0) { + Rectangle r = cb; + r.Inflate (r.Width / -5, r.Height / -5); + if (r.ContainsOrIsEqual(lm)) + dw.DockingPosition = Alignment.Center; + } else { + rIn = cb; + + if (Orientation == Orientation.Horizontal || Children.Count == 1) { + if (lm.Y > cb.Top + cb.Height / 3 && lm.Y < cb.Bottom - cb.Height / 3) { + if (lm.X < cb.Left + cb.Width / 3) + dw.DockingPosition = Alignment.Left; + else if (lm.X > cb.Right - cb.Width / 3) + dw.DockingPosition = Alignment.Right; + } else { + getFocusedChild (lm); + if (focusedChild != null) { + if (lm.Y < rIn.Top + rIn.Height / 3) + dw.DockingPosition = Alignment.Top; + else if (lm.Y > rIn.Bottom - rIn.Height / 3) + dw.DockingPosition = Alignment.Bottom; + } + } + } + if (Orientation == Orientation.Vertical || Children.Count == 1) { + if (lm.X > cb.Left + cb.Width / 3 && lm.X < cb.Right - cb.Width / 3) { + if (lm.Y < cb.Top + cb.Height / 3) + dw.DockingPosition = Alignment.Top; + else if (lm.Y > cb.Bottom - cb.Height / 3) + dw.DockingPosition = Alignment.Bottom; + } else { + getFocusedChild (lm); + if (focusedChild != null) { + if (lm.X < rIn.Left + rIn.Width / 3) + dw.DockingPosition = Alignment.Left; + else if (lm.X > rIn.Right - rIn.Width / 3) + dw.DockingPosition = Alignment.Right; + } + } + } + } + + if (curDockPos != dw.DockingPosition) + RegisterForGraphicUpdate (); + } + base.onMouseMove (sender, e); + } + + protected override void onDragEnter (object sender, DragDropEventArgs e) + { + base.onDragEnter (sender, e); + RegisterForGraphicUpdate (); + } + protected override void onDragLeave (object sender, DragDropEventArgs e) + { + DockWindow dw = e.DragSource as DockWindow; + if (dw != null) + dw.DockingPosition = Alignment.Undefined; + base.onDragLeave (sender, e); + RegisterForGraphicUpdate (); + } + + protected override void onDraw (Cairo.Context gr) + { + gr.Save (); + + Rectangle rBack = new Rectangle (Slot.Size); + + Background.SetAsSource (gr, rBack); + CairoHelpers.CairoRectangle (gr, rBack, CornerRadius); + gr.Fill (); + + if (ClipToClientRect) { + //clip to client zone + CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius); + gr.Clip (); + } + + childrenRWLock.EnterReadLock (); + + foreach (GraphicObject g in Children) + g.Paint (ref gr); + + childrenRWLock.ExitReadLock (); + + + if (!IsDropTarget) { + gr.Restore (); + return; + } + + DockWindow dw = IFace.DragAndDropOperation.DragSource as DockWindow; + if (dw == null) + return; + if (!dw.IsDocked) { + Rectangle cb = ClientRectangle; + double minDim = Math.Min (cb.Width, cb.Height); + + Rectangle r = rIn; + if (Children.Count <= 1 || dw.DockingPosition.GetOrientation()==Orientation ) + r = cb; + + switch (dw.DockingPosition) { + case Alignment.Top: + gr.Rectangle (r.Left, r.Top, r.Width, r.Height * dockThresh); + break; + case Alignment.Bottom: + gr.Rectangle (r.Left, r.Bottom - r.Height * dockThresh, r.Width, r.Height * dockThresh); + break; + case Alignment.Left: + gr.Rectangle (r.Left, r.Top, r.Width * dockThresh, r.Height); + break; + case Alignment.Right: + gr.Rectangle (r.Right - r.Width * dockThresh, r.Top, r.Width * dockThresh, r.Height); + break; + case Alignment.Center: + r.Inflate ((int)Math.Ceiling (Math.Min (r.Width, r.Height) * -0.05)); + gr.Rectangle (r); + break; + } + gr.LineWidth = 1; + gr.SetSourceRGBA (0.4, 0.4, 0.9, 0.4); + gr.FillPreserve (); + gr.SetSourceRGBA (0.9, 0.9, 1.0, 0.8); + gr.Stroke (); + } + gr.Restore (); + } + + public void Dock(DockWindow dw){ + DockStack activeStack = this; + + if (Children.Count == 1) { + Orientation = dw.DockingPosition.GetOrientation (); + if (Children [0] is DockWindow) { + (Children [0] as DockWindow).DockingPosition = dw.DockingPosition.GetOpposite (); + } + } else if (Children.Count > 0 && dw.DockingPosition.GetOrientation () != Orientation) { + activeStack = new DockStack (IFace); + activeStack.Orientation = dw.DockingPosition.GetOrientation (); + activeStack.Width = focusedChild.Width; + activeStack.Height = focusedChild.Height; + int idx = Children.IndexOf (focusedChild); + RemoveChild (focusedChild); + focusedChild.Height = Measure.Stretched; + focusedChild.Width = Measure.Stretched; + InsertChild (idx, activeStack); + activeStack.AddChild (focusedChild); + activeStack.stretchedChild = focusedChild; + if (focusedChild is DockWindow) + (focusedChild as DockWindow).DockingPosition = dw.DockingPosition.GetOpposite (); + focusedChild = null; + } + + Rectangle r = ClientRectangle; + int vTreshold = (int)(r.Height * dockThresh); + int hTreshold = (int)(r.Width * dockThresh); + + Console.WriteLine ("Docking {0} as {2} in {1}", dw.Name, activeStack.Name, dw.DockingPosition); + switch (dw.DockingPosition) { + case Alignment.Top: + dw.Height = vTreshold; + dw.Width = Measure.Stretched; + activeStack.InsertChild (0, dw); + activeStack.InsertChild (1, new Splitter(IFace)); + break; + case Alignment.Bottom: + dw.Height = vTreshold; + dw.Width = Measure.Stretched; + activeStack.AddChild (new Splitter(IFace)); + activeStack.AddChild (dw); + break; + case Alignment.Left: + dw.Width = hTreshold; + dw.Height = Measure.Stretched; + activeStack.InsertChild (0, dw); + activeStack.InsertChild (1, new Splitter(IFace)); + break; + case Alignment.Right: + dw.Width = hTreshold; + dw.Height = Measure.Stretched; + activeStack.AddChild (new Splitter(IFace)); + activeStack.AddChild (dw); + break; + case Alignment.Center: + dw.Width = dw.Height = Measure.Stretched; + AddChild (dw); + stretchedChild = dw; + break; + } + } + public void Undock (DockWindow dw){ + int idx = Children.IndexOf(dw); + + RemoveChild(dw); + + if (Children.Count == 0) + return; + + if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top) { + RemoveChild (idx); + if (stretchedChild == dw) { + stretchedChild = Children [idx]; + stretchedChild.Width = stretchedChild.Height = Measure.Stretched; + } + } else { + RemoveChild (idx - 1); + if (stretchedChild == dw) { + stretchedChild = Children [idx-2]; + stretchedChild.Width = stretchedChild.Height = Measure.Stretched; + } + } + + if (Children.Count == 1) { + DockStack dsp = Parent as DockStack; + if (dsp == null) { + Children [0].Width = Children [0].Height = Measure.Stretched; + return; + } + //remove level and move remaining obj to level above + GraphicObject g = Children [0]; + RemoveChild (g); + idx = dsp.Children.IndexOf (this); + dsp.RemoveChild (this); + dsp.InsertChild (idx, g); + g.Width = this.Width; + g.Height = this.Height; + if (dsp.stretchedChild == this) + dsp.stretchedChild = g; + dsp.checkAlignments (); + } else + checkAlignments (); + } + + internal void checkAlignments () { + DockWindow dw = Children[0] as DockWindow; + if (dw != null) + dw.DockingPosition = (Orientation == Orientation.Horizontal ? Alignment.Left : Alignment.Top); + dw = Children[Children.Count - 1] as DockWindow; + if (dw != null) + dw.DockingPosition = (Orientation == Orientation.Horizontal ? Alignment.Right : Alignment.Bottom); + } + } +} + diff --git a/src/GraphicObjects/DockWindow.cs b/src/GraphicObjects/DockWindow.cs index b68a3085..ca4b93f4 100644 --- a/src/GraphicObjects/DockWindow.cs +++ b/src/GraphicObjects/DockWindow.cs @@ -24,6 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; +using System.Xml.Serialization; namespace Crow { @@ -35,10 +36,10 @@ namespace Crow } #endregion + int undockThreshold = 4; bool isDocked = false; - Alignment docking = Alignment.Center; + Alignment docking = Alignment.Undefined; - Point lastMousePos; //last known mouse pos in this control Point undockingMousePosOrig; //mouse pos when docking was donne, use for undocking on mouse move Rectangle savedSlot; //last undocked slot recalled when view is undocked bool wasResizable; @@ -50,8 +51,11 @@ namespace Crow return; isDocked = value; NotifyValueChanged ("IsDocked", isDocked); + NotifyValueChanged ("IsFloating", !isDocked); } } + [XmlIgnore] public bool IsFloating { get { return !isDocked; }} + public Alignment DockingPosition { get { return docking; } set { @@ -61,12 +65,7 @@ namespace Crow NotifyValueChanged ("DockingPosition", DockingPosition); } } - protected override void onDrop (object sender, DragDropEventArgs e) - { - base.onDrop (sender, e); - Docker dv = Parent as Docker; - dv.Dock (this); - } + public override bool PointIsIn (ref Point m) { if (!base.PointIsIn(ref m)) @@ -78,6 +77,8 @@ namespace Crow for (int i = p.Children.Count - 1; i >= 0; i--) { if (p.Children [i] == this) break; + if (p.Children [i].IsDragged) + continue; if (p.Children [i].Slot.ContainsOrIsEqual (m)) { return false; } @@ -87,156 +88,91 @@ namespace Crow return Slot.ContainsOrIsEqual(m); } -// public override void OnLayoutChanges (LayoutingType layoutType) -// { -// base.OnLayoutChanges (layoutType); -// -// if (isDocked) -// return; - -// Docker dv = Parent as Docker; -// if (dv == null) -// return; -// -// Rectangle dvCliRect = dv.ClientRectangle; -// -// if (layoutType == LayoutingType.X) { -// if (Slot.X < dv.DockingThreshold) -// dock (Alignment.Left); -// else if (Slot.Right > dvCliRect.Width - dv.DockingThreshold) -// dock (Alignment.Right); -// }else if (layoutType == LayoutingType.Y) { -// if (Slot.Y < dv.DockingThreshold) -// dock (Alignment.Top); -// else if (Slot.Bottom > dvCliRect.Height - dv.DockingThreshold) -// dock (Alignment.Bottom); -// } -// } -// -// public override void onMouseMove (object sender, MouseMoveEventArgs e) -// { -// lastMousePos = e.Position; -// + public override void onMouseMove (object sender, MouseMoveEventArgs e) + { // if (this.HasFocus && e.Mouse.IsButtonDown (MouseButton.Left) && IsDocked) { -// Docker dv = Parent as Docker; -// if (docking == Alignment.Left) { -// if (lastMousePos.X - undockingMousePosOrig.X > dv.DockingThreshold) -// undock (); -// } else if (docking == Alignment.Right) { -// if (undockingMousePosOrig.X - lastMousePos.X > dv.DockingThreshold) -// undock (); -// } else if (docking == Alignment.Top) { -// if (lastMousePos.Y - undockingMousePosOrig.Y > dv.DockingThreshold) -// undock (); -// } else if (docking == Alignment.Bottom) { -// if (undockingMousePosOrig.Y - lastMousePos.Y > dv.DockingThreshold) -// undock (); -// } -// return; +// if (Math.Abs (e.Position.X - undockingMousePosOrig.X) > 10 || +// Math.Abs (e.Position.X - undockingMousePosOrig.X) > 10) +// Undock (); // } -// -// base.onMouseMove (sender, e); -// } -// public override void onMouseDown (object sender, MouseButtonEventArgs e) -// { -// base.onMouseDown (sender, e); -// -// if (this.HasFocus && IsDocked && e.Button == MouseButton.Left) -// undockingMousePosOrig = lastMousePos; -// } -// protected override void onBorderMouseEnter (object sender, MouseMoveEventArgs e) -// { -// base.onBorderMouseEnter (sender, e); -// -// if (isDocked) { -// switch (docking) { -// case Alignment.Top: -// if (this.currentDirection != Window.Direction.S) -// onBorderMouseLeave (this, null); -// break; -// case Alignment.Left: -// if (this.currentDirection != Window.Direction.E) -// onBorderMouseLeave (this, null); -// break; -// case Alignment.TopLeft: -// break; -// case Alignment.Right: -// if (this.currentDirection != Window.Direction.W) -// onBorderMouseLeave (this, null); -// break; -// case Alignment.TopRight: -// break; -// case Alignment.Bottom: -// if (this.currentDirection != Window.Direction.N) -// onBorderMouseLeave (this, null); -// break; -// case Alignment.BottomLeft: -// break; -// case Alignment.BottomRight: -// break; -// case Alignment.Center: -// break; -// default: -// break; -// } -// } -// } + if (this.HasFocus && e.Mouse.IsButtonDown (MouseButton.Left) && IsDocked) + CheckUndock (e.Position); - void undock () { - this.Left = savedSlot.Left; - this.Top = savedSlot.Top; - this.Width = savedSlot.Width; - this.Height = savedSlot.Height; + base.onMouseMove (sender, e); + } + public override void onMouseDown (object sender, MouseButtonEventArgs e) + { + base.onMouseDown (sender, e); - IsDocked = false; - Resizable = wasResizable; + if (this.HasFocus && IsDocked && e.Button == MouseButton.Left) + undockingMousePosOrig = e.Position; } - void dock (Alignment align){ - IsDocked = true; - docking = align; - undockingMousePosOrig = lastMousePos; - savedSlot = this.LastPaintedSlot; - wasResizable = Resizable; - Resizable = false; + public bool CheckUndock (Point mousePos) { + if (DockingPosition == Alignment.Center) + return false; + if (Math.Abs (mousePos.X - undockingMousePosOrig.X) < undockThreshold || + Math.Abs (mousePos.X - undockingMousePosOrig.X) < undockThreshold) + return false; + Undock (); + return true; + } + + protected override void onStartDrag (object sender, DragDropEventArgs e) + { + base.onStartDrag (sender, e); + + undockingMousePosOrig = IFace.Mouse.Position; + } + protected override void onDrop (object sender, DragDropEventArgs e) + { + if (!isDocked && DockingPosition != Alignment.Undefined) + Dock (e.DropTarget as DockStack); + base.onDrop (sender, e); + } + public void Undock () { + lock (IFace.UpdateMutex) { + DockStack ds = Parent as DockStack; + ds.Undock (this); + + IFace.AddWidget (this); - this.Left = this.Top = 0; + this.Left = savedSlot.Left; + this.Top = savedSlot.Top; + this.Width = savedSlot.Width; + this.Height = savedSlot.Height; - switch (align) { - case Alignment.Top: - this.HorizontalAlignment = HorizontalAlignment.Left; - this.VerticalAlignment = VerticalAlignment.Top; - this.Width = Measure.Stretched; - break; - case Alignment.Left: - this.HorizontalAlignment = HorizontalAlignment.Left; - this.VerticalAlignment = VerticalAlignment.Top; - this.Height = Measure.Stretched; - break; - case Alignment.TopLeft: - break; - case Alignment.Right: - this.HorizontalAlignment = HorizontalAlignment.Right; - this.VerticalAlignment = VerticalAlignment.Top; - this.Height = Measure.Stretched; - break; - case Alignment.TopRight: - break; - case Alignment.Bottom: - this.HorizontalAlignment = HorizontalAlignment.Left; - this.VerticalAlignment = VerticalAlignment.Bottom; - this.Width = Measure.Stretched; - break; - case Alignment.BottomLeft: - break; - case Alignment.BottomRight: - break; - case Alignment.Center: - break; - default: - break; + IsDocked = false; + DockingPosition = Alignment.Undefined; + Resizable = wasResizable; } - + } + + public void Dock (DockStack target){ + lock (IFace.UpdateMutex) { + IsDocked = true; + //undockingMousePosOrig = lastMousePos; + savedSlot = this.LastPaintedSlot; + wasResizable = Resizable; + Resizable = false; + LastSlots = LastPaintedSlot = Slot = default(Rectangle); + Left = Top = 0; + + IFace.RemoveWidget (this); + + target.Dock (this); + } + } + + protected override void close () + { + if (isDocked) + Undock (); + base.close (); + } + + public string ExportWinConfigs () { + return string.Format ("{0};{1};{2}", this.Name, DockingPosition, savedSlot); } } } diff --git a/src/GraphicObjects/Docker.cs b/src/GraphicObjects/Docker.cs deleted file mode 100644 index c52c094f..00000000 --- a/src/GraphicObjects/Docker.cs +++ /dev/null @@ -1,256 +0,0 @@ -// -// DocksView.cs -// -// Author: -// Jean-Philippe Bruyère <jp.bruyere@hotmail.com> -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; -using System.Xml.Serialization; -using System.ComponentModel; -using Crow.IML; - -namespace Crow -{ - public class Docker : Group - { - static Instantiator instStack, instSplit, instSpacer; - #region CTOR - static Docker () { - instStack = Instantiator.CreateFromImlFragment(@"<GenericStack Background='Blue' AllowDrop='true' DragEnter='onStackDragEnter'/>"); - instSplit = Instantiator.CreateFromImlFragment(@"<Splitter/>"); - instSpacer = Instantiator.CreateFromImlFragment(@"<GraphicObject Background='Red' IsEnabled='false'/>"); - } - public Docker () : base () - { - } - #endregion - - GenericStack rootStack = null; - - public override void AddChild (GraphicObject g) - { - DockWindow dw = g as DockWindow; - if (dw == null) - throw new Exception ("Docker accept only DockWindow as child"); - - base.AddChild (g); - - dw.LogicalParent = this; - } - public override void RemoveChild (GraphicObject child) - { - child.LogicalParent = null; - - - base.RemoveChild (child); - } - - GenericStack mainStack = null; - int dockingThreshold; - - [XmlAttributeAttribute][DefaultValue(10)] - public virtual int DockingThreshold { - get { return dockingThreshold; } - set { - if (dockingThreshold == value) - return; - dockingThreshold = value; - NotifyValueChanged ("DockingThreshold", dockingThreshold); - - } - } - - bool showDockingTarget = false; - Alignment dockingDirection = Alignment.Center; - int dockingDiv = 5; - - public override void onMouseMove (object sender, MouseMoveEventArgs e) - { - if (CurrentInterface.DragAndDropOperation?.DragSource as DockWindow != null) { - DockWindow dw = CurrentInterface.DragAndDropOperation?.DragSource as DockWindow; - if (CurrentInterface.DragAndDropOperation.DragSource.Parent == this && !dw.IsDocked) - dw.MoveAndResize (e.XDelta, e.YDelta); - - Rectangle r = ClientRectangle; - int vTreshold = r.Height / dockingDiv; - int hTreshold = r.Width / dockingDiv; - - - bool showDock = true; - - if (dw.Slot.Left < hTreshold) - dockingDirection = Alignment.Left; - else if (dw.Slot.Right > r.Right - hTreshold) - dockingDirection = Alignment.Right; - else if (dw.Slot.Top < vTreshold) - dockingDirection = Alignment.Top; - else if (dw.Slot.Bottom > r.Bottom - vTreshold) - dockingDirection = Alignment.Bottom; - else { - dockingDirection = Alignment.Center; - showDock = false; - } - - showDockingTarget = showDock; - - RegisterForGraphicUpdate (); - - //System.Diagnostics.Debug.WriteLine ("Dock: {0}", dockingDirection); - } else - showDockingTarget = false; - - base.onMouseMove (sender, e); - } - protected override void onDragEnter (object sender, DragDropEventArgs e) - { - base.onDragEnter (sender, e); - } - void onStackDragEnter (object sender, DragDropEventArgs e) - { - base.onDragEnter (sender, e); - - mainStack = sender as GenericStack; - } - protected override void onDraw (Cairo.Context gr) - { - gr.Save (); - - Rectangle rBack = new Rectangle (Slot.Size); - - Background.SetAsSource (gr, rBack); - CairoHelpers.CairoRectangle (gr, rBack, CornerRadius); - gr.Fill (); - - if (ClipToClientRect) { - //clip to client zone - CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius); - gr.Clip (); - } - - childrenRWLock.EnterReadLock (); - - foreach (GraphicObject g in Children) { - if (CurrentInterface.DragAndDropOperation?.DragSource == g) - continue; - g.Paint (ref gr); - } - - childrenRWLock.ExitReadLock (); - - if (showDockingTarget) { - Rectangle r; - if (mainStack == null) - r = ClientRectangle; - else - r = mainStack.ClientRectangle; - - switch (dockingDirection) { - case Alignment.Top: - gr.Rectangle (r.Left, r.Top, r.Width, r.Height / dockingDiv); - break; - case Alignment.Bottom: - gr.Rectangle (r.Left, r.Bottom - r.Height / dockingDiv, r.Width, r.Height / dockingDiv); - break; - case Alignment.Left: - gr.Rectangle (r.Left, r.Top, r.Width / dockingDiv, r.Height); - break; - case Alignment.Right: - gr.Rectangle (r.Right - r.Width / dockingDiv, r.Top, r.Width / dockingDiv, r.Height); - break; - } - gr.LineWidth = 1; - gr.SetSourceRGBA (0.4, 0.4, 0.9, 0.4); - gr.FillPreserve (); - gr.SetSourceRGBA (0.9, 0.9, 1.0, 0.8); - gr.Stroke (); - } - - if (CurrentInterface.DragAndDropOperation != null) - CurrentInterface.DragAndDropOperation.DragSource.Paint (ref gr); - - - gr.Restore (); - } - - public void Dock(DockWindow dw){ - if (dockingDirection == Alignment.Center) - return; - lock (CurrentInterface.UpdateMutex) { - - Splitter splitter = instSplit.CreateInstance<Splitter> (CurrentInterface); - - dw.Resizable = false; - dw.Left = dw.Top = 0; - this.RemoveChild (dw); - - Rectangle r; - if (mainStack == null) { - mainStack = instStack.CreateInstance<GenericStack> (CurrentInterface); - this.AddChild (mainStack); - this.putWidgetOnBottom (mainStack); - r = ClientRectangle; - } else - r = mainStack.ClientRectangle; - - int vTreshold = r.Height / dockingDiv; - int hTreshold = r.Width / dockingDiv; - - switch (dockingDirection) { - case Alignment.Top: - dw.Width = Measure.Stretched; - mainStack.Orientation = Orientation.Vertical; - mainStack.AddChild (dw); - mainStack.AddChild (splitter); - //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface)); - break; - case Alignment.Bottom: - dw.Width = Measure.Stretched; - mainStack.Orientation = Orientation.Vertical; - //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface)); - mainStack.AddChild (splitter); - mainStack.AddChild (dw); - break; - case Alignment.Left: - dw.Height = Measure.Stretched; - mainStack.Orientation = Orientation.Horizontal; - mainStack.AddChild (dw); - mainStack.AddChild (splitter); - //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface)); - break; - case Alignment.Right: - dw.Height = Measure.Stretched; - mainStack.Orientation = Orientation.Horizontal; - //mainStack.AddChild (instSpacer.CreateInstance (CurrentInterface)); - mainStack.AddChild (splitter); - mainStack.AddChild (dw); - break; - } - - } - } - protected override void onDrop (object sender, DragDropEventArgs e) - { - base.onDrop (sender, e); - } - } -} - diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs index aff804f8..1920a8fe 100644 --- a/src/GraphicObjects/Expandable.cs +++ b/src/GraphicObjects/Expandable.cs @@ -77,7 +77,7 @@ namespace Crow NotifyValueChanged ("Image", image); } } - [XmlAttributeAttribute][DefaultValue(false)] + [DefaultValue(false)] public bool IsExpanded { get { return _isExpanded; } @@ -90,7 +90,7 @@ namespace Crow bool isExp = IsExpandable; NotifyValueChanged ("IsExpandable", isExp); - if (!(HasContent & isExp)) + if (!isExp) _isExpanded = false; NotifyValueChanged ("IsExpanded", _isExpanded); diff --git a/src/GraphicObjects/FileDialog.cs b/src/GraphicObjects/FileDialog.cs index 285ca253..8069b8a7 100644 --- a/src/GraphicObjects/FileDialog.cs +++ b/src/GraphicObjects/FileDialog.cs @@ -143,12 +143,13 @@ namespace Crow CurrentDirectory = SelectedDirectory; else { OkClicked.Raise (this, null); - CurrentInterface.DeleteWidget (this); + IFace.DeleteWidget (this); } } void onCancel(object sender, MouseButtonEventArgs e){ - CurrentInterface.DeleteWidget (this); + IFace.DeleteWidget (this); } + } } diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 7976f837..64841d4b 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -28,6 +28,7 @@ using System.ComponentModel; using System.Diagnostics; using System.Xml.Serialization; using System; +using System.Linq; namespace Crow { @@ -79,13 +80,7 @@ namespace Crow } protected override int measureRawSize (LayoutingType lt) { - int totSpace = 0; - for (int i = 0; i < Children.Count; i++) { - if (Children [i].Visible) - totSpace += Spacing; - } - if (totSpace > 0) - totSpace -= Spacing; + int totSpace = Math.Max(0, Spacing * (Children.Count (c => c.Visible) - 1)); if (lt == LayoutingType.Width) { if (Orientation == Orientation.Horizontal) return contentSize.Width + totSpace + 2 * Margin; @@ -128,7 +123,7 @@ namespace Crow //if no layouting remains in queue for item, registre for redraw if (RegisteredLayoutings == LayoutingType.None && IsDirty) - CurrentInterface.EnqueueForRepaint (this); + IFace.EnqueueForRepaint (this); return true; } @@ -136,6 +131,46 @@ namespace Crow return base.UpdateLayout(layoutType); } + void adjustStretchedGo (LayoutingType lt){ + if (stretchedGO == null) + return; + if (lt == LayoutingType.Width) { + int newW = Math.Max ( + this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1), + stretchedGO.MinimumSize.Width); + if (stretchedGO.MaximumSize.Width > 0) + newW = Math.Min (newW, stretchedGO.MaximumSize.Width); + if (newW != stretchedGO.Slot.Width) { + stretchedGO.Slot.Width = newW; + stretchedGO.IsDirty = true; + #if DEBUG_LAYOUTING + Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString()); + #endif + stretchedGO.LayoutChanged -= OnChildLayoutChanges; + stretchedGO.OnLayoutChanges (LayoutingType.Width); + stretchedGO.LayoutChanged += OnChildLayoutChanges; + stretchedGO.LastSlots.Width = stretchedGO.Slot.Width; + } + } else { + int newH = Math.Max ( + this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1), + stretchedGO.MinimumSize.Height); + if (stretchedGO.MaximumSize.Height > 0) + newH = Math.Min (newH, stretchedGO.MaximumSize.Height); + if (newH != stretchedGO.Slot.Height) { + stretchedGO.Slot.Height = newH; + stretchedGO.IsDirty = true; + #if DEBUG_LAYOUTING + Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString()); + #endif + stretchedGO.LayoutChanged -= OnChildLayoutChanges; + stretchedGO.OnLayoutChanges (LayoutingType.Height); + stretchedGO.LayoutChanged += OnChildLayoutChanges; + stretchedGO.LastSlots.Height = stretchedGO.Slot.Height; + } + } + } + public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg) { GraphicObject go = sender as GraphicObject; @@ -154,24 +189,7 @@ namespace Crow } else contentSize.Width += go.Slot.Width - go.LastSlots.Width; - if (stretchedGO != null) { - int newW = Math.Max ( - this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1), - stretchedGO.MinimumSize.Width); - if (stretchedGO.MaximumSize.Width > 0) - newW = Math.Min (newW, stretchedGO.MaximumSize.Width); - if (newW != stretchedGO.Slot.Width) { - stretchedGO.Slot.Width = newW; - stretchedGO.IsDirty = true; -#if DEBUG_LAYOUTING - Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString()); -#endif - stretchedGO.LayoutChanged -= OnChildLayoutChanges; - stretchedGO.OnLayoutChanges (LayoutingType.Width); - stretchedGO.LayoutChanged += OnChildLayoutChanges; - stretchedGO.LastSlots.Width = stretchedGO.Slot.Width; - } - } + adjustStretchedGo (LayoutingType.Width); if (Width == Measure.Fit) this.RegisterForLayouting (LayoutingType.Width); @@ -193,24 +211,7 @@ namespace Crow } else contentSize.Height += go.Slot.Height - go.LastSlots.Height; - if (stretchedGO != null) { - int newH = Math.Max ( - this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1), - stretchedGO.MinimumSize.Height); - if (stretchedGO.MaximumSize.Height > 0) - newH = Math.Min (newH, stretchedGO.MaximumSize.Height); - if (newH != stretchedGO.Slot.Height) { - stretchedGO.Slot.Height = newH; - stretchedGO.IsDirty = true; -#if DEBUG_LAYOUTING - Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString()); -#endif - stretchedGO.LayoutChanged -= OnChildLayoutChanges; - stretchedGO.OnLayoutChanges (LayoutingType.Height); - stretchedGO.LayoutChanged += OnChildLayoutChanges; - stretchedGO.LastSlots.Height = stretchedGO.Slot.Height; - } - } + adjustStretchedGo (LayoutingType.Height); if (Height == Measure.Fit) this.RegisterForLayouting (LayoutingType.Height); @@ -224,6 +225,22 @@ namespace Crow } #endregion - + public override void RemoveChild (GraphicObject child) + { + if (child != stretchedGO) { + if (Orientation == Orientation.Horizontal) + contentSize.Width -= child.LastSlots.Width; + else + contentSize.Height -= child.LastSlots.Height; + } + base.RemoveChild (child); + if (child == stretchedGO) { + stretchedGO = null; + RegisterForLayouting (LayoutingType.Sizing); + }else if (Orientation == Orientation.Horizontal) + adjustStretchedGo (LayoutingType.Width); + else + adjustStretchedGo (LayoutingType.Height); + } } } diff --git a/src/GraphicObjects/GraduatedSlider.cs b/src/GraphicObjects/GraduatedSlider.cs index 52ba2960..e1d4dd46 100644 --- a/src/GraphicObjects/GraduatedSlider.cs +++ b/src/GraphicObjects/GraduatedSlider.cs @@ -33,6 +33,7 @@ using System.Xml.Serialization; namespace Crow { + [DesignIgnore] public class GraduatedSlider : Slider { #region CTOR diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index f671239d..bc955368 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -36,6 +36,12 @@ using System.Diagnostics; using Crow.IML; using System.Threading; + +#if DESIGN_MODE +using System.Xml; +using System.IO; +#endif + namespace Crow { /// <summary> @@ -45,6 +51,101 @@ namespace Crow { internal ReaderWriterLockSlim parentRWLock = new ReaderWriterLockSlim(); + #if DESIGN_MODE + static MethodInfo miDesignAddDefLoc = typeof(GraphicObject).GetMethod("design_add_style_location", + BindingFlags.Instance | BindingFlags.NonPublic); + static MethodInfo miDesignAddValLoc = typeof(GraphicObject).GetMethod("design_add_iml_location", + BindingFlags.Instance | BindingFlags.NonPublic); + + public volatile bool design_HasChanged = false; + public string design_id; + public int design_line; + public int design_column; + public string design_imlPath; + public bool design_isTGItem = false;//true if this is a templated item's root + public Dictionary<string,string> design_iml_values = new Dictionary<string, string>(); + public Dictionary<string,string> design_style_values = new Dictionary<string, string>(); + //public Dictionary<string,FileLocation> design_iml_locations = new Dictionary<string, FileLocation>(); + public Dictionary<string,FileLocation> design_style_locations = new Dictionary<string, FileLocation>(); + + internal void design_add_style_location (string memberName, string path, int line, int col) { + if (design_style_locations.ContainsKey(memberName)){ + Console.WriteLine ("default value localtion already set for {0}{1}.{2}", this.GetType().Name, this.design_id, memberName); + return; + } + design_style_locations.Add(memberName, new FileLocation(path,line,col)); + } +// internal void design_add_iml_location (string memberName, string path, int line, int col) { +// if (design_iml_locations.ContainsKey(memberName)){ +// Console.WriteLine ("IML value localtion already set for {0}{1}.{2}", this.GetType().Name, this.design_id, memberName); +// return; +// } +// design_iml_locations.Add(memberName, new FileLocation(path,line,col)); +// } + + public virtual bool FindByDesignID(string designID, out GraphicObject go){ + go = null; + if (this.design_id == designID){ + go = this; + return true; + } + return false; + } + + public string GetIML(){ + XmlDocument doc = new XmlDocument( ); + + using (StringWriter sw = new StringWriter ()) { + XmlWriterSettings settings = new XmlWriterSettings { + Indent = true, + IndentChars = "\t", + }; + using (XmlWriter xtw = XmlWriter.Create (sw, settings)) { + //(1) the xml declaration is recommended, but not mandatory + XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration ("1.0", "UTF-8", null); + doc.InsertBefore (xmlDeclaration, null); + getIML (doc, (XmlNode)doc); + doc.WriteTo (xtw); + } + this.design_HasChanged = false; + return sw.ToString (); + } + } + + public virtual void getIML(XmlDocument doc, XmlNode parentElem) { + if (this.design_isTGItem) + return; + + XmlElement xe = doc.CreateElement(this.GetType().Name); + + foreach (KeyValuePair<string,string> kv in design_iml_values) { + XmlAttribute xa = doc.CreateAttribute (kv.Key); + xa.Value = kv.Value; + xe.Attributes.Append (xa); + } + + parentElem.AppendChild (xe); + } + public Surface CreateIcon (int dragIconSize = 32) { + ImageSurface di = new ImageSurface (Format.Argb32, dragIconSize, dragIconSize); + using (Context ctx = new Context (di)) { + double div = Math.Max (LastPaintedSlot.Width, LastPaintedSlot.Height); + double s = (double)dragIconSize / div; + ctx.Scale (s, s); + if (bmp == null) + this.onDraw (ctx); + else { + if (LastPaintedSlot.Width>LastPaintedSlot.Height) + ctx.SetSourceSurface (bmp, 0, (LastPaintedSlot.Width-LastPaintedSlot.Height)/2); + else + ctx.SetSourceSurface (bmp, (LastPaintedSlot.Height-LastPaintedSlot.Width)/2, 0); + ctx.Paint (); + } + } + return di; + } + #endif + #region IDisposable implementation protected bool disposed = false; @@ -53,6 +154,7 @@ namespace Crow GC.SuppressFinalize(this); } ~GraphicObject(){ + Debug.WriteLine(this.ToString() + " not disposed by user"); Dispose(false); } protected virtual void Dispose(bool disposing){ @@ -70,18 +172,8 @@ namespace Crow throw new Exception("Trying to dispose an object queued for Redraw: " + this.ToString()); #endif - if (CurrentInterface.HoverWidget != null) { - if (CurrentInterface.HoverWidget.IsOrIsInside(this)) - CurrentInterface.HoverWidget = null; - } - if (CurrentInterface.ActiveWidget != null) { - if (CurrentInterface.ActiveWidget.IsOrIsInside (this)) - CurrentInterface.ActiveWidget = null; - } - if (CurrentInterface.FocusedWidget != null) { - if (CurrentInterface.FocusedWidget.IsOrIsInside (this)) - CurrentInterface.FocusedWidget = null; - } + unshownPostActions (); + if (!localDataSourceIsNull) DataSource = null; @@ -100,14 +192,14 @@ namespace Crow internal ulong uid = 0; internal bool isPopup = false; - internal GraphicObject focusParent { + public GraphicObject focusParent { get { return (isPopup ? LogicalParent : parent) as GraphicObject; } } /// <summary> /// interface this widget is bound to, this should not be changed once the instance is created /// </summary> - public Interface CurrentInterface = null; + public Interface IFace = null; /// <summary> /// contains the dirty rectangles in the coordinate system of the cache. those dirty zones @@ -159,17 +251,17 @@ namespace Crow /// <param name="iface">Iface.</param> public GraphicObject (Interface iface) : this() { - CurrentInterface = iface; + IFace = iface; Initialize (); } #endregion - internal bool initialized = false; + //internal bool initialized = false; /// <summary> /// Initialize this Graphic object instance by setting style and default values and loading template if required /// </summary> public virtual void Initialize(){ loadDefaultValues (); - initialized = true; + //initialized = true; } #region private fields LayoutingType registeredLayoutings = LayoutingType.All; @@ -186,6 +278,7 @@ namespace Crow bool focusable = false; bool hasFocus = false; bool isActive = false; + bool isHover = false; bool mouseRepeat; protected bool isVisible = true; bool isEnabled = true; @@ -196,6 +289,7 @@ namespace Crow bool cacheEnabled = false; bool clipToClientRect = true; protected object dataSource; + bool rootDataLevel; string style; object tag; bool isDragged; @@ -252,6 +346,7 @@ namespace Crow parentRWLock.EnterWriteLock(); parent = value; + Slot = LastSlots = default(Rectangle); parentRWLock.ExitWriteLock(); onParentChanged (this, e); @@ -288,11 +383,24 @@ namespace Crow Parent.ContextCoordinates (r); } public virtual Rectangle ScreenCoordinates (Rectangle r){ - return - Parent.ScreenCoordinates(r) + Parent.getSlot().Position + Parent.ClientRectangle.Position; + try { + return + Parent.ScreenCoordinates(r) + Parent.getSlot().Position + Parent.ClientRectangle.Position; + } catch (Exception ex) { + Debug.WriteLine (ex); + return default(Rectangle); + } } public virtual Rectangle getSlot () { return Slot;} #endregion + public Point ScreenPointToLocal(Point p){ + Point pt = p - ScreenCoordinates(Slot).TopLeft - ClientRectangle.TopLeft; + if (pt.X < 0) + pt.X = 0; + if (pt.Y < 0) + pt.Y = 0; + return pt; + } #region EVENT HANDLERS /// <summary>Occurs when mouse wheel is rolled in this object. It bubbles to the root</summary> @@ -321,15 +429,29 @@ namespace Crow public event EventHandler Focused; /// <summary>Occurs when this object loose focus</summary> public event EventHandler Unfocused; - /// <summary>Occurs when the enabled state this object is set to true</summary> + /// <summary>Occurs when mouse is over</summary> + public event EventHandler Hover; + /// <summary>Occurs when this control is no longer the Hover one</summary> + public event EventHandler UnHover; + /// <summary>Occurs when this object loose focus</summary> public event EventHandler Enabled; /// <summary>Occurs when the enabled state this object is set to false</summary> public event EventHandler Disabled; - public event EventHandler StartDrag; - public event EventHandler DragEnter; - public event EventHandler DragLeave; - public event EventHandler EndDrag; - public event EventHandler Drop; + + #region DragAndDrop Events + public event EventHandler<DragDropEventArgs> StartDrag; + public event EventHandler<DragDropEventArgs> DragEnter; + public event EventHandler<DragDropEventArgs> DragLeave; + public event EventHandler<DragDropEventArgs> EndDrag; + public event EventHandler<DragDropEventArgs> Drop; + #endregion + + /// <summary> + /// Occurs when default value and styling are loaded, and for templated control, + /// template is also loaded. Bindings should be functionnal as well. + /// </summary> + public event EventHandler Initialized; + /// <summary>Occurs when one part of the rendering slot changed</summary> public event EventHandler<LayoutingEventArgs> LayoutChanged; /// <summary>Occurs when DataSource changed</summary> @@ -342,7 +464,7 @@ namespace Crow #region public properties /// <summary>Random value placeholder</summary> - [XmlAttributeAttribute] + [DesignCategory ("Divers")] public object Tag { get { return tag; } set { @@ -356,7 +478,7 @@ namespace Crow /// If enabled, resulting bitmap of graphic object is cached /// speeding up rendering of complex object. Default is enabled. /// </summary> - [XmlAttributeAttribute][DefaultValue(true)] + [DesignCategory ("Behavior")][DefaultValue(true)] public virtual bool CacheEnabled { get { return cacheEnabled; } set { @@ -369,7 +491,7 @@ namespace Crow /// <summary> /// If true, rendering of GraphicObject is clipped inside client rectangle /// </summary> - [XmlAttributeAttribute][DefaultValue(true)] + [DesignCategory ("Appearance")][DefaultValue(true)] public virtual bool ClipToClientRect { get { return clipToClientRect; } set { @@ -390,7 +512,7 @@ namespace Crow /// and by template controls to find special element in their template implementation such /// as a container or a group to put children in. /// </summary> - [XmlAttributeAttribute][DefaultValue(null)] + [DesignCategory ("Divers")][DefaultValue(null)] public virtual string Name { get { #if DEBUG @@ -410,7 +532,7 @@ namespace Crow /// Vertical alignment inside parent, disabled if height is stretched /// or top coordinate is not null /// </summary> - [XmlAttributeAttribute ()][DefaultValue(VerticalAlignment.Center)] + [DesignCategory ("Layout")][DefaultValue(VerticalAlignment.Center)] public virtual VerticalAlignment VerticalAlignment { get { return verticalAlignment; } set { @@ -426,7 +548,7 @@ namespace Crow /// Horizontal alignment inside parent, disabled if width is stretched /// or left coordinate is not null /// </summary> - [XmlAttributeAttribute()][DefaultValue(HorizontalAlignment.Center)] + [DesignCategory ("Layout")][DefaultValue(HorizontalAlignment.Center)] public virtual HorizontalAlignment HorizontalAlignment { get { return horizontalAlignment; } set { @@ -440,7 +562,7 @@ namespace Crow /// <summary> /// x position inside parent /// </summary> - [XmlAttributeAttribute()][DefaultValue(0)] + [DesignCategory ("Layout")][DefaultValue(0)] public virtual int Left { get { return left; } set { @@ -454,7 +576,7 @@ namespace Crow /// <summary> /// y position inside parent /// </summary> - [XmlAttributeAttribute()][DefaultValue(0)] + [DesignCategory ("Layout")][DefaultValue(0)] public virtual int Top { get { return top; } set { @@ -468,7 +590,7 @@ namespace Crow /// <summary> /// Helper property used to set width and height to fit in one call /// </summary> - [XmlAttributeAttribute()][DefaultValue(false)] + [DesignCategory ("Layout")][DefaultValue(false)] public virtual bool Fit { get { return Width == Measure.Fit && Height == Measure.Fit ? true : false; } set { @@ -482,7 +604,7 @@ namespace Crow /// Width of this control, by default inherited from parent. May have special values /// such as Stretched or Fit. It may be proportionnal or absolute. /// </summary> - [XmlAttributeAttribute()][DefaultValue("Inherit")] + [DesignCategory ("Layout")][DefaultValue("Inherit")] public virtual Measure Width { get { return width.Units == Unit.Inherit ? @@ -496,23 +618,24 @@ namespace Crow if (value < MinimumSize.Width || (value > MaximumSize.Width && MaximumSize.Width > 0)) return; } - Measure lastWP = WidthPolicy; + Measure old = width; width = value; NotifyValueChanged ("Width", width); - if (WidthPolicy != lastWP) { - NotifyValueChanged ("WidthPolicy", WidthPolicy); + if (width == Measure.Stretched || old == Measure.Stretched) { + //NotifyValueChanged ("WidthPolicy", width.Policy); //contentSize in Stacks are only update on childLayoutChange, and the single stretched //child of the stack is not counted in contentSize, so when changing size policy of a child //we should adapt contentSize //TODO:check case when child become stretched, and another stretched item already exists. - if (parent is GenericStack) {//TODO:check if I should test Group instead - if ((parent as GenericStack).Orientation == Orientation.Horizontal) { - if (lastWP == Measure.Fit) - (parent as GenericStack).contentSize.Width -= this.LastSlots.Width; + GenericStack gs = Parent as GenericStack; + if (gs != null){ //TODO:check if I should test Group instead + if (gs.Orientation == Orientation.Horizontal) { + if (width == Measure.Stretched) + gs.contentSize.Width -= this.LastSlots.Width; else - (parent as GenericStack).contentSize.Width += this.LastSlots.Width; + gs.contentSize.Width += this.LastSlots.Width; } - } + } } this.RegisterForLayouting (LayoutingType.Width); @@ -522,7 +645,7 @@ namespace Crow /// Height of this control, by default inherited from parent. May have special values /// such as Stretched or Fit. It may be proportionnal or absolute. /// </summary> - [XmlAttributeAttribute()][DefaultValue("Inherit")] + [DesignCategory ("Layout")][DefaultValue("Inherit")] public virtual Measure Height { get { return height.Units == Unit.Inherit ? @@ -536,17 +659,18 @@ namespace Crow if (value < MinimumSize.Height || (value > MaximumSize.Height && MaximumSize.Height > 0)) return; } - Measure lastHP = HeightPolicy; + Measure old = height; height = value; NotifyValueChanged ("Height", height); - if (HeightPolicy != lastHP) { - NotifyValueChanged ("HeightPolicy", HeightPolicy); - if (parent is GenericStack) { - if ((parent as GenericStack).Orientation == Orientation.Vertical) { - if (lastHP == Measure.Fit) - (parent as GenericStack).contentSize.Height -= this.LastSlots.Height; + if (height == Measure.Stretched || old == Measure.Stretched) { + //NotifyValueChanged ("HeightPolicy", HeightPolicy); + GenericStack gs = Parent as GenericStack; + if (gs != null){ //TODO:check if I should test Group instead + if (gs.Orientation == Orientation.Vertical) { + if (height == Measure.Stretched) + gs.contentSize.Height -= this.LastSlots.Height; else - (parent as GenericStack).contentSize.Height += this.LastSlots.Height; + gs.contentSize.Height += this.LastSlots.Height; } } } @@ -555,13 +679,13 @@ namespace Crow } } /// <summary> - /// Used for binding on dimensions, this property will never hold fixed size, but instead only + /// Was Used for binding on dimensions, this property will never hold fixed size, but instead only /// Fit or Stretched, **with inherited state implementation, it is not longer used in binding** /// </summary> [XmlIgnore]public virtual Measure WidthPolicy { get { return Width.IsFit ? Measure.Fit : Measure.Stretched; } } /// <summary> - /// Used for binding on dimensions, this property will never hold fixed size, but instead only + /// Was Used for binding on dimensions, this property will never hold fixed size, but instead only /// Fit or Stretched, **with inherited state implementation, it is not longer used in binding** /// </summary> [XmlIgnore]public virtual Measure HeightPolicy { get { @@ -570,7 +694,7 @@ namespace Crow /// Indicate that this object may received focus or not, if not focusable all the descendants are /// affected. /// </summary> - [XmlAttributeAttribute()][DefaultValue(false)] + [DesignCategory ("Behaviour")][DefaultValue(false)] public virtual bool Focusable { get { return focusable; } set { @@ -612,9 +736,28 @@ namespace Crow } } /// <summary> + /// true if this control has the pointer hover + /// </summary> + [XmlIgnore]public virtual bool IsHover { + get { return isHover; } + set { + if (value == isHover) + return; + + isHover = value; + + if (isHover) + onHover (this, null); + else + onUnHover (this, null); + + NotifyValueChanged ("IsHover", isHover); + } + } + /// <summary> /// true if holding mouse button down should trigger multiple click events /// </summary> - [XmlAttributeAttribute()][DefaultValue(false)] + [DesignCategory ("Behaviour")][DefaultValue(false)] public virtual bool MouseRepeat { get { return mouseRepeat; } set { @@ -628,7 +771,7 @@ namespace Crow /// <summary> /// background fill of the control, maybe solid color, gradient, image, or svg /// </summary> - [XmlAttributeAttribute()][DefaultValue("Transparent")] + [DesignCategory ("Appearance")][DefaultValue("Transparent")] public virtual Fill Background { get { return background; } set { @@ -649,7 +792,7 @@ namespace Crow /// <summary> /// Foreground fill of the control, usage may be different among derived controls /// </summary> - [XmlAttributeAttribute()][DefaultValue("White")] + [DesignCategory ("Appearance")][DefaultValue("White")] public virtual Fill Foreground { get { return foreground; } set { @@ -663,7 +806,7 @@ namespace Crow /// <summary> /// Font being used in many controls, it is defined in the base GraphicObject class. /// </summary> - [XmlAttributeAttribute()][DefaultValue("sans,10")] + [DesignCategory ("Appearance")][DefaultValue("sans,10")] public virtual Font Font { get { return font; } set { @@ -677,7 +820,7 @@ namespace Crow /// <summary> /// to get rounded corners /// </summary> - [XmlAttributeAttribute()][DefaultValue(0.0)] + [DesignCategory ("Appearance")][DefaultValue(0.0)] public virtual double CornerRadius { get { return cornerRadius; } set { @@ -692,7 +835,7 @@ namespace Crow /// This is a single integer for the 4 direction, a gap between the control and it's container, /// by default it is filled with the background. /// </summary> - [XmlAttributeAttribute()][DefaultValue(0)] + [DesignCategory ("Layout")][DefaultValue(0)] public virtual int Margin { get { return margin; } set { @@ -706,7 +849,7 @@ namespace Crow /// <summary> /// set the visible state of the control, invisible controls does reserve space in the layouting system. /// </summary> - [XmlAttributeAttribute][DefaultValue(true)] + [DesignCategory ("Appearance")][DefaultValue(true)] public virtual bool Visible { get { return isVisible; } set { @@ -717,8 +860,8 @@ namespace Crow RegisterForLayouting (LayoutingType.Sizing); - //trigger a mouse to handle possible hover changes - //CurrentInterface.ProcessMouseMove (CurrentInterface.Mouse.X, CurrentInterface.Mouse.Y); + if (!isVisible) + unshownPostActions (); NotifyValueChanged ("Visible", isVisible); } @@ -727,7 +870,7 @@ namespace Crow /// get or set the enabled state, disabling a control will affect focuability and /// also it's rendering which will be grayed /// </summary> - [XmlAttributeAttribute][DefaultValue(true)] + [DesignCategory ("Behaviour")][DefaultValue(true)] public virtual bool IsEnabled { get { return isEnabled; } set { @@ -748,7 +891,7 @@ namespace Crow /// <summary> /// Minimal width and height for this control /// </summary> - [XmlAttributeAttribute()][DefaultValue("1,1")] + [DesignCategory ("Layout")][DefaultValue("1,1")] public virtual Size MinimumSize { get { return minimumSize; } set { @@ -764,7 +907,7 @@ namespace Crow /// <summary> /// Maximum width and height for this control, unlimited if null. /// </summary> - [XmlAttributeAttribute()][DefaultValue("0,0")] + [DesignCategory ("Layout")][DefaultValue("0,0")] public virtual Size MaximumSize { get { return maximumSize; } set { @@ -781,7 +924,7 @@ namespace Crow /// Seek first logical tree upward if logicalParent is set, or seek graphic tree for /// a not null dataSource that will be active for all descendants having dataSource=null /// </summary> - [XmlAttributeAttribute] + [DesignCategory ("Data")] public virtual object DataSource { set { if (DataSource == value) @@ -793,19 +936,36 @@ namespace Crow if (dse.NewDataSource == dse.OldDataSource) return; - - OnDataSourceChanged (this, dse); - - NotifyValueChanged ("DataSource", DataSource); + if (value != null) + rootDataLevel = true; + + lock (IFace.LayoutMutex) { + OnDataSourceChanged (this, dse); + NotifyValueChanged ("DataSource", DataSource); + } } get { - return dataSource == null ? + return rootDataLevel ? dataSource : dataSource == null ? LogicalParent == null ? null : LogicalParent is GraphicObject ? (LogicalParent as GraphicObject).DataSource : null : dataSource; } } + /// <summary> + /// If true, rendering of GraphicObject is clipped inside client rectangle + /// </summary> + [DesignCategory ("Data")][DefaultValue(false)] + public virtual bool RootDataLevel { + get { return rootDataLevel; } + set { + if (rootDataLevel == value) + return; + rootDataLevel = value; + NotifyValueChanged ("RootDataLevel", rootDataLevel); + this.RegisterForRedraw (); + } + } protected virtual void onLogicalParentDataSourceChanged(object sender, DataSourceChangeEventArgs e){ if (localDataSourceIsNull) OnDataSourceChanged (this, e); @@ -822,7 +982,7 @@ namespace Crow /// <summary> /// Style key to use for this control /// </summary> - [XmlAttributeAttribute] + [DesignCategory ("Appearance")] public virtual string Style { get { return style; } set { @@ -834,7 +994,7 @@ namespace Crow NotifyValueChanged ("Style", style); } } - [XmlAttributeAttribute] + [DesignCategory ("Divers")] public virtual string Tooltip { get { return tooltip; } set { @@ -844,7 +1004,7 @@ namespace Crow NotifyValueChanged("Tooltip", tooltip); } } - [XmlAttributeAttribute] + [DesignCategory ("Divers")] public IList<Command> ContextCommands { get { return contextCommands; } set { @@ -867,20 +1027,19 @@ namespace Crow Type thisType = this.GetType (); if (!string.IsNullOrEmpty (Style)) { - if (CurrentInterface.DefaultValuesLoader.ContainsKey (Style)) { - CurrentInterface.DefaultValuesLoader [Style] (this); + if (IFace.DefaultValuesLoader.ContainsKey (Style)) { + IFace.DefaultValuesLoader [Style] (this); + onInitialized (this, null); return; } - } else { - if (CurrentInterface.DefaultValuesLoader.ContainsKey (thisType.FullName)) { - CurrentInterface.DefaultValuesLoader [thisType.FullName] (this); - return; - } else if (!CurrentInterface.Styling.ContainsKey (thisType.FullName)) { - if (CurrentInterface.DefaultValuesLoader.ContainsKey (thisType.Name)) { - CurrentInterface.DefaultValuesLoader [thisType.Name] (this); - return; - } - } + } else if (IFace.DefaultValuesLoader.ContainsKey (thisType.FullName)) { + IFace.DefaultValuesLoader [thisType.FullName] (this); + onInitialized (this, null); + return; + } else if (IFace.DefaultValuesLoader.ContainsKey (thisType.Name)) { + IFace.DefaultValuesLoader [thisType.Name] (this); + onInitialized (this, null); + return; } List<Style> styling = new List<Style>(); @@ -892,17 +1051,17 @@ namespace Crow // those files being placed in a Styles folder string styleKey = Style; if (!string.IsNullOrEmpty (Style)) { - if (CurrentInterface.Styling.ContainsKey (Style)) { - styling.Add (CurrentInterface.Styling [Style]); + if (IFace.Styling.ContainsKey (Style)) { + styling.Add (IFace.Styling [Style]); } } - if (CurrentInterface.Styling.ContainsKey (thisType.FullName)) { - styling.Add (CurrentInterface.Styling [thisType.FullName]); + if (IFace.Styling.ContainsKey (thisType.FullName)) { + styling.Add (IFace.Styling [thisType.FullName]); if (string.IsNullOrEmpty (styleKey)) styleKey = thisType.FullName; } - if (CurrentInterface.Styling.ContainsKey (thisType.Name)) { - styling.Add (CurrentInterface.Styling [thisType.Name]); + if (IFace.Styling.ContainsKey (thisType.Name)) { + styling.Add (IFace.Styling [thisType.Name]); if (string.IsNullOrEmpty (styleKey)) styleKey = thisType.Name; } @@ -910,7 +1069,6 @@ namespace Crow if (string.IsNullOrEmpty (styleKey)) styleKey = thisType.FullName; - //Reflexion being very slow compared to dyn method or delegates, //I compile the initial values coded in the CustomAttribs of the class, //all other instance of this type would not longer use reflexion to init properly @@ -962,21 +1120,76 @@ namespace Crow foreach (PropertyInfo pi in thisType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { if (pi.GetSetMethod () == null) continue; - object defaultValue; - if (!getDefaultValue (pi, styling, out defaultValue)) + XmlIgnoreAttribute xia = (XmlIgnoreAttribute)pi.GetCustomAttribute (typeof(XmlIgnoreAttribute)); + if (xia != null) continue; + object defaultValue; + string name = ""; + XmlAttributeAttribute xaa = (XmlAttributeAttribute)pi.GetCustomAttribute (typeof(XmlAttributeAttribute)); + if (xaa != null) { + if (string.IsNullOrEmpty (xaa.AttributeName)) + name = pi.Name; + else + name = xaa.AttributeName; + }else + name = pi.Name; + + int styleIndex = -1; + if (styling.Count > 0){ + for (int i = 0; i < styling.Count; i++) { + if (styling[i].ContainsKey (name)){ + styleIndex = i; + break; + } + } + } + if (styleIndex >= 0){ + if (pi.PropertyType.IsEnum)//maybe should be in parser.. + defaultValue = Enum.Parse(pi.PropertyType, (string)styling[styleIndex] [name], true); + else + defaultValue = styling[styleIndex] [name]; + + #if DESIGN_MODE + if (defaultValue != null){ + FileLocation fl = styling[styleIndex].Locations[name]; + il.Emit (OpCodes.Ldloc_0); + il.Emit (OpCodes.Ldstr, name); + il.Emit (OpCodes.Ldstr, fl.FilePath); + il.Emit (OpCodes.Ldc_I4, fl.Line); + il.Emit (OpCodes.Ldc_I4, fl.Column); + il.Emit (OpCodes.Call, miDesignAddDefLoc); + + il.Emit (OpCodes.Ldloc_0); + il.Emit (OpCodes.Ldfld, typeof(GraphicObject).GetField("design_style_values")); + il.Emit (OpCodes.Ldstr, name); + il.Emit (OpCodes.Ldstr, defaultValue.ToString()); + il.Emit (OpCodes.Call, CompilerServices.miDicStrStrAdd); + } + #endif + + }else { + DefaultValueAttribute dv = (DefaultValueAttribute)pi.GetCustomAttribute (typeof (DefaultValueAttribute)); + if (dv == null) + continue; + defaultValue = dv.Value; + } + CompilerServices.EmitSetValue (il, pi, defaultValue); } il.Emit(OpCodes.Ret); #endregion try { - CurrentInterface.DefaultValuesLoader[styleKey] = (Interface.LoaderInvoker)dm.CreateDelegate(typeof(Interface.LoaderInvoker)); - CurrentInterface.DefaultValuesLoader[styleKey] (this); + IFace.DefaultValuesLoader[styleKey] = (Interface.LoaderInvoker)dm.CreateDelegate(typeof(Interface.LoaderInvoker)); + IFace.DefaultValuesLoader[styleKey] (this); } catch (Exception ex) { throw new Exception ("Error applying style <" + styleKey + ">:", ex); } + onInitialized (this, null); + } + protected virtual void onInitialized (object sender, EventArgs e){ + Initialized.Raise(sender, e); } bool getDefaultEvent(EventInfo ei, List<Style> styling, out string expression){ @@ -991,51 +1204,6 @@ namespace Crow } return false; } - /// <summary> - /// Gets the default value of the widget's property from either the style, or from xml default - /// </summary> - /// <returns><c>true</c>, if default value is defined, <c>false</c> otherwise.</returns> - /// <param name="pi">PropertyInfo</param> - /// <param name="styling">Styling informations</param> - /// <param name="defaultValue">output of Default value, null if not found</param> - bool getDefaultValue(PropertyInfo pi, List<Style> styling, - out object defaultValue){ - defaultValue = null; - string name = ""; - - XmlIgnoreAttribute xia = (XmlIgnoreAttribute)pi.GetCustomAttribute (typeof(XmlIgnoreAttribute)); - if (xia != null) - return false; - XmlAttributeAttribute xaa = (XmlAttributeAttribute)pi.GetCustomAttribute (typeof(XmlAttributeAttribute)); - if (xaa != null) { - if (string.IsNullOrEmpty (xaa.AttributeName)) - name = pi.Name; - else - name = xaa.AttributeName; - } - - int styleIndex = -1; - if (styling.Count > 0){ - for (int i = 0; i < styling.Count; i++) { - if (styling[i].ContainsKey (name)){ - styleIndex = i; - break; - } - } - } - if (styleIndex >= 0){ - if (pi.PropertyType.IsEnum)//maybe should be in parser.. - defaultValue = Enum.Parse(pi.PropertyType, (string)styling[styleIndex] [name], true); - else - defaultValue = styling[styleIndex] [name]; - }else { - DefaultValueAttribute dv = (DefaultValueAttribute)pi.GetCustomAttribute (typeof (DefaultValueAttribute)); - if (dv == null) - return false; - defaultValue = dv.Value; - } - return true; - } #endregion public virtual GraphicObject FindByName(string nameToFind){ @@ -1060,7 +1228,7 @@ namespace Crow } #region Drag&Drop - [XmlAttributeAttribute][DefaultValue(false)] + [DesignCategory ("DragAndDrop")][DefaultValue(false)] public virtual bool AllowDrag { get { return allowDrag; } set { @@ -1070,7 +1238,7 @@ namespace Crow NotifyValueChanged ("AllowDrag", allowDrag); } } - [XmlAttributeAttribute][DefaultValue(false)] + [DesignCategory ("DragAndDrop")][DefaultValue(false)] public virtual bool AllowDrop { get { return allowDrop; } set { @@ -1105,10 +1273,12 @@ namespace Crow /// fired when drag and drop operation start /// </summary> protected virtual void onStartDrag (object sender, DragDropEventArgs e){ - CurrentInterface.HoverWidget = null; + IFace.HoverWidget = null; IsDragged = true; StartDrag.Raise (this, e); + #if DEBUG_DRAGNDROP Debug.WriteLine(this.ToString() + " : START DRAG => " + e.ToString()); + #endif } /// <summary> /// Occured when dragging ends without dropping @@ -1116,22 +1286,34 @@ namespace Crow protected virtual void onEndDrag (object sender, DragDropEventArgs e){ IsDragged = false; EndDrag.Raise (this, e); + #if DEBUG_DRAGNDROP Debug.WriteLine(this.ToString() + " : END DRAG => " + e.ToString()); + #endif } protected virtual void onDragEnter (object sender, DragDropEventArgs e){ e.DropTarget = this; DragEnter.Raise (this, e); + #if DEBUG_DRAGNDROP Debug.WriteLine(this.ToString() + " : DRAG Enter => " + e.ToString()); + #endif } protected virtual void onDragLeave (object sender, DragDropEventArgs e){ e.DropTarget = null; DragLeave.Raise (this, e); + #if DEBUG_DRAGNDROP Debug.WriteLine(this.ToString() + " : DRAG Leave => " + e.ToString()); + #endif } protected virtual void onDrop (object sender, DragDropEventArgs e){ IsDragged = false; Drop.Raise (this, e); + //e.DropTarget.onDragLeave (this, e);//raise drag leave in target + #if DEBUG_DRAGNDROP Debug.WriteLine(this.ToString() + " : DROP => " + e.ToString()); + #endif + } + public bool IsDropTarget { + get { return IFace.DragAndDropOperation?.DropTarget == this; } } #endregion @@ -1180,7 +1362,7 @@ namespace Crow if (Width.IsFit || Height.IsFit) RegisterForLayouting (LayoutingType.Sizing); else if (RegisteredLayoutings == LayoutingType.None) - CurrentInterface.EnqueueForRepaint (this); + IFace.EnqueueForRepaint (this); } /// <summary> query an update of the content, a redraw </summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -1191,7 +1373,7 @@ namespace Crow #endif IsDirty = true; if (RegisteredLayoutings == LayoutingType.None) - CurrentInterface.EnqueueForRepaint (this); + IFace.EnqueueForRepaint (this); } #endregion @@ -1209,7 +1391,7 @@ namespace Crow public virtual void RegisterForLayouting(LayoutingType layoutType){ if (Parent == null) return; - lock (CurrentInterface.LayoutMutex) { + lock (IFace.LayoutMutex) { //prevent queueing same LayoutingType for this layoutType &= (~RegisteredLayoutings); @@ -1236,27 +1418,21 @@ namespace Crow //enqueue LQI LayoutingTypes separately if (layoutType.HasFlag (LayoutingType.Width)) - CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this)); + IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this)); if (layoutType.HasFlag (LayoutingType.Height)) - CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this)); + IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this)); if (layoutType.HasFlag (LayoutingType.X)) - CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this)); + IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this)); if (layoutType.HasFlag (LayoutingType.Y)) - CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this)); + IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this)); if (layoutType.HasFlag (LayoutingType.ArrangeChildren)) - CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this)); + IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this)); } } /// <summary> trigger dependant sizing component update </summary> public virtual void OnLayoutChanges(LayoutingType layoutType) { - #if DEBUG_LAYOUTING - CurrentInterface.currentLQI.Slot = LastSlots; - CurrentInterface.currentLQI.NewSlot = Slot; - Debug.WriteLine ("\t\t{0} => {1}",LastSlots,Slot); - #endif - switch (layoutType) { case LayoutingType.Width: RegisterForLayouting (LayoutingType.X); @@ -1420,7 +1596,7 @@ namespace Crow //if no layouting remains in queue for item, registre for redraw if (this.registeredLayoutings == LayoutingType.None && IsDirty) - CurrentInterface.EnqueueForRepaint (this); + IFace.EnqueueForRepaint (this); return true; } @@ -1557,8 +1733,8 @@ namespace Crow } public virtual void checkHoverWidget(MouseMoveEventArgs e) { - if (CurrentInterface.HoverWidget != this) { - CurrentInterface.HoverWidget = this; + if (IFace.HoverWidget != this) { + IFace.HoverWidget = this; onMouseEnter (this, e); } @@ -1567,12 +1743,17 @@ namespace Crow public virtual void onMouseMove(object sender, MouseMoveEventArgs e) { if (AllowDrag & HasFocus & e.Mouse.LeftButton == ButtonState.Pressed) { - if (CurrentInterface.DragAndDropOperation == null) { - CurrentInterface.DragAndDropOperation = new DragDropEventArgs (this); - onStartDrag (this, CurrentInterface.DragAndDropOperation); + if (IFace.DragAndDropOperation == null) { + IFace.DragAndDropOperation = new DragDropEventArgs (this); + onStartDrag (this, IFace.DragAndDropOperation); } } + //dont bubble event if dragged, mouse move is routed directely from iface + //to let other control behind have mouse entering + if (isDragged) + return; + //bubble event to the top GraphicObject p = focusParent; if (p != null) @@ -1585,15 +1766,15 @@ namespace Crow Debug.WriteLine("MOUSE DOWN => " + this.ToString()); #endif - if (CurrentInterface.ActiveWidget == null) - CurrentInterface.ActiveWidget = this; + if (IFace.ActiveWidget == null) + IFace.ActiveWidget = this; if (this.Focusable && !Interface.FocusOnHover) { BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg; if (be.Focused == null) { be.Focused = this; - CurrentInterface.FocusedWidget = this; + IFace.FocusedWidget = this; if (e.Button == MouseButton.Right && this.ContextCommands != null) - CurrentInterface.ShowContextMenu (this); + IFace.ShowContextMenu (this); } } //bubble event to the top @@ -1608,13 +1789,13 @@ namespace Crow Debug.WriteLine("MOUSE UP => " + this.ToString()); #endif - if (CurrentInterface.DragAndDropOperation != null){ - if (CurrentInterface.DragAndDropOperation.DragSource == this) { - if (CurrentInterface.DragAndDropOperation.DropTarget != null) - onDrop (this, CurrentInterface.DragAndDropOperation); + if (IFace.DragAndDropOperation != null){ + if (IFace.DragAndDropOperation.DragSource == this) { + if (IFace.DragAndDropOperation.DropTarget != null) + onDrop (this, IFace.DragAndDropOperation); else - onEndDrag (this, CurrentInterface.DragAndDropOperation); - CurrentInterface.DragAndDropOperation = null; + onEndDrag (this, IFace.DragAndDropOperation); + IFace.DragAndDropOperation = null; } } @@ -1655,14 +1836,6 @@ namespace Crow #if DEBUG_FOCUS Debug.WriteLine("MouseEnter => " + this.ToString()); #endif - - if (CurrentInterface.DragAndDropOperation != null) { - if (this.AllowDrop) { - if (CurrentInterface.DragAndDropOperation.DragSource != this && CurrentInterface.DragAndDropOperation.DropTarget != this) - onDragEnter (this, CurrentInterface.DragAndDropOperation); - } - } - MouseEnter.Raise (this, e); } public virtual void onMouseLeave(object sender, MouseMoveEventArgs e) @@ -1670,12 +1843,36 @@ namespace Crow #if DEBUG_FOCUS Debug.WriteLine("MouseLeave => " + this.ToString()); #endif - if (CurrentInterface.DragAndDropOperation != null) { - if (CurrentInterface.DragAndDropOperation.DropTarget == this) - onDragLeave (this, CurrentInterface.DragAndDropOperation); - } MouseLeave.Raise (this, e); } + public virtual void onHover(object sender, EventArgs e) + { + #if DEBUG_FOCUS + Debug.WriteLine("MouseHover => " + this.ToString()); + #endif + if (IFace.DragAndDropOperation != null) { + GraphicObject g = this; + while (g != null) { + if (g.AllowDrop) { + if (IFace.DragAndDropOperation.DragSource != this && IFace.DragAndDropOperation.DropTarget != this) { + if (IFace.DragAndDropOperation.DropTarget != null) + IFace.DragAndDropOperation.DropTarget.onDragLeave (this, IFace.DragAndDropOperation); + g.onDragEnter (this, IFace.DragAndDropOperation); + } + break; + } + g = g.focusParent; + } + } + Hover.Raise (this, e); + } + public virtual void onUnHover(object sender, EventArgs e) + { + #if DEBUG_FOCUS + Debug.WriteLine("MouseUnHover => " + this.ToString()); + #endif + UnHover.Raise (this, e); + } #endregion protected virtual void onFocused(object sender, EventArgs e){ @@ -1697,6 +1894,13 @@ namespace Crow Disabled.Raise (this, e); } protected virtual void onParentChanged(object sender, DataSourceChangeEventArgs e) { +// if (e.NewDataSource != null) { +// if (width == Measure.Inherit) +// RegisterForLayouting (LayoutingType.Width); +// if (height == Measure.Inherit) +// RegisterForLayouting (LayoutingType.Height); +// } + ParentChanged.Raise (this, e); if (logicalParent == null) LogicalParentChanged.Raise (this, e); @@ -1732,5 +1936,24 @@ namespace Crow return Name == "unamed" ? tmp + "." + this.GetType ().Name : tmp + "." + Name; #endif } + /// <summary> + /// Checks to handle when widget is removed from the visible graphic tree + /// </summary> + void unshownPostActions () { + if (IFace.ActiveWidget != null) { + if (IFace.ActiveWidget.IsOrIsInside (this)) + IFace.ActiveWidget = null; + } + if (IFace.FocusedWidget != null) { + if (IFace.FocusedWidget.IsOrIsInside (this)) + IFace.FocusedWidget = null; + } + if (IFace.HoverWidget != null) { + if (IFace.HoverWidget.IsOrIsInside (this)) { + IFace.HoverWidget = null; + IFace.ProcessMouseMove (IFace.Mouse.X, IFace.Mouse.Y); + } + } + } } } diff --git a/src/GraphicObjects/Grid.cs b/src/GraphicObjects/Grid.cs index f8a50264..4ae906a7 100644 --- a/src/GraphicObjects/Grid.cs +++ b/src/GraphicObjects/Grid.cs @@ -157,7 +157,7 @@ namespace Crow //if no layouting remains in queue for item, registre for redraw if (RegisteredLayoutings == LayoutingType.None && IsDirty) - CurrentInterface.EnqueueForRepaint (this); + IFace.EnqueueForRepaint (this); return true; } diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index e7604842..a90947a5 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -38,7 +38,33 @@ namespace Crow { public class Group : GraphicObject { - protected ReaderWriterLockSlim childrenRWLock = new ReaderWriterLockSlim(); + #if DESIGN_MODE + public override bool FindByDesignID(string designID, out GraphicObject go){ + go = null; + if (base.FindByDesignID (designID, out go)) + return true; + childrenRWLock.EnterReadLock (); + foreach (GraphicObject w in Children) { + if (!w.FindByDesignID (designID, out go)) + continue; + childrenRWLock.ExitReadLock (); + return true; + } + childrenRWLock.ExitReadLock (); + return false; + } + public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem) + { + if (this.design_isTGItem) + return; + base.getIML (doc, parentElem); + foreach (GraphicObject g in Children) { + g.getIML (doc, parentElem.LastChild); + } + } + #endif + + protected ReaderWriterLockSlim childrenRWLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); #region CTOR public Group () : base() {} @@ -80,14 +106,15 @@ namespace Crow { child.LayoutChanged -= OnChildLayoutChanges; //check if HoverWidget is removed from Tree - if (CurrentInterface.HoverWidget != null) { - if (this.Contains (CurrentInterface.HoverWidget)) - CurrentInterface.HoverWidget = null; + if (IFace.HoverWidget != null) { + if (this.Contains (IFace.HoverWidget)) + IFace.HoverWidget = null; } childrenRWLock.EnterWriteLock (); Children.Remove(child); + child.Parent = null; childrenRWLock.ExitWriteLock (); @@ -116,6 +143,9 @@ namespace Crow g.LayoutChanged += OnChildLayoutChanges; g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); } + public virtual void RemoveChild (int idx) { + RemoveChild (children[idx]); + } public virtual void DeleteChild (int idx) { DeleteChild (children[idx]); } @@ -137,6 +167,17 @@ namespace Crow this.RegisterForLayouting (LayoutingType.Sizing); ChildrenCleared.Raise (this, new EventArgs ()); } + public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e) + { + base.OnDataSourceChanged (this, e); + + childrenRWLock.EnterReadLock (); + foreach (GraphicObject g in Children) { + if (g.localDataSourceIsNull & g.localLogicalParentIsNull) + g.OnDataSourceChanged (g, e); + } + childrenRWLock.ExitReadLock (); + } public void putWidgetOnTop(GraphicObject w) { @@ -164,18 +205,7 @@ namespace Crow } #region GraphicObject overrides - public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e) - { - base.OnDataSourceChanged (this, e); - - childrenRWLock.EnterReadLock (); - foreach (GraphicObject g in children) - if (g.localDataSourceIsNull & g.localLogicalParentIsNull) - g.OnDataSourceChanged (g, e); - - childrenRWLock.ExitReadLock (); - } public override GraphicObject FindByName (string nameToFind) { if (Name == nameToFind) @@ -237,7 +267,7 @@ namespace Crow switch (layoutType) { case LayoutingType.Width: foreach (GraphicObject c in Children) { - if (c.Width.Units == Unit.Percent) + if (c.Width.IsRelativeToParent) c.RegisterForLayouting (LayoutingType.Width); else c.RegisterForLayouting (LayoutingType.X); @@ -245,7 +275,7 @@ namespace Crow break; case LayoutingType.Height: foreach (GraphicObject c in Children) { - if (c.Height.Units == Unit.Percent) + if (c.Height.IsRelativeToParent) c.RegisterForLayouting (LayoutingType.Height); else c.RegisterForLayouting (LayoutingType.Y); @@ -268,9 +298,9 @@ namespace Crow childrenRWLock.EnterReadLock (); - foreach (GraphicObject g in Children) { - g.Paint (ref gr); - } + foreach (GraphicObject g in Children) { + g.Paint (ref gr); + } childrenRWLock.ExitReadLock (); gr.Restore (); @@ -397,8 +427,8 @@ namespace Crow #region Mouse handling public override void checkHoverWidget (MouseMoveEventArgs e) { - if (CurrentInterface.HoverWidget != this) { - CurrentInterface.HoverWidget = this; + if (IFace.HoverWidget != this) { + IFace.HoverWidget = this; onMouseEnter (this, e); } for (int i = Children.Count - 1; i >= 0; i--) { diff --git a/src/GraphicObjects/HueSelector.cs b/src/GraphicObjects/HueSelector.cs index 518ee6c4..67f4ec6e 100644 --- a/src/GraphicObjects/HueSelector.cs +++ b/src/GraphicObjects/HueSelector.cs @@ -31,6 +31,7 @@ using Cairo; namespace Crow { + [DesignIgnore] public class HueSelector : ColorSelector { #region CTOR diff --git a/src/GraphicObjects/IMLContainer.cs b/src/GraphicObjects/IMLContainer.cs index a221a78b..84692284 100644 --- a/src/GraphicObjects/IMLContainer.cs +++ b/src/GraphicObjects/IMLContainer.cs @@ -41,7 +41,7 @@ namespace Crow if (path == value) return; path = value; - this.SetChild (CurrentInterface.Load (path)); + this.SetChild (IFace.Load (path)); NotifyValueChanged ("Path", path); } } diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs index 75c59f4a..e83183c0 100644 --- a/src/GraphicObjects/Image.cs +++ b/src/GraphicObjects/Image.cs @@ -93,9 +93,9 @@ namespace Crow if (string.IsNullOrEmpty(value)) Picture = null; else { - lock(CurrentInterface.LayoutMutex){ + //lock(IFace.LayoutMutex){ LoadImage (value); - } + //} } } catch (Exception ex) { Debug.WriteLine (ex.Message); @@ -169,11 +169,11 @@ namespace Crow { Picture pic; if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture)) - pic = new SvgPicture (); + pic = new SvgPicture (path); else - pic = new BmpPicture (); + pic = new BmpPicture (path); - pic.Load (path); + pic.Load (IFace, path); pic.Scaled = scaled; pic.KeepProportions = keepProps; diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index ea68fde0..0e0d9fe1 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -55,6 +55,7 @@ namespace Crow public virtual void OnTextChanged(Object sender, TextChangeEventArgs e) { + textMeasureIsUpToDate = false; NotifyValueChanged ("Text", Text); TextChanged.Raise (this, e); } @@ -86,7 +87,7 @@ namespace Crow protected TextExtents te; #endregion - [XmlAttributeAttribute][DefaultValue("BlueGray")] + [XmlAttributeAttribute][DefaultValue("SteelBlue")] public virtual Color SelectionBackground { get { return selBackground; } set { @@ -437,48 +438,49 @@ namespace Crow CurrentColumn = 0; OnTextChanged (this, new TextChangeEventArgs (Text)); } + bool textMeasureIsUpToDate = false; + Size cachedTextSize = default(Size); #region GraphicObject overrides protected override int measureRawSize(LayoutingType lt) - { + { if (lines == null) lines = getLines; + if (!textMeasureIsUpToDate) { + using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) { + using (Context gr = new Context (img)) { + //Cairo.FontFace cf = gr.GetContextFontFace (); - using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) { - using (Context gr = new Context (img)) { - //Cairo.FontFace cf = gr.GetContextFontFace (); - - gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight); - gr.SetFontSize (Font.Size); + gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight); + gr.SetFontSize (Font.Size); + gr.FontOptions = Interface.FontRenderingOptions; + gr.Antialias = Interface.Antialias; + fe = gr.FontExtents; + te = new TextExtents (); - fe = gr.FontExtents; - te = new TextExtents(); + cachedTextSize.Height = (int)Math.Ceiling ((fe.Ascent+fe.Descent) * Math.Max (1, lines.Count)) + Margin * 2; - if (lt == LayoutingType.Height){ - int lc = lines.Count; - //ensure minimal height = text line height - if (lc == 0) - lc = 1; - - return (int)Math.Ceiling(fe.Height * lc) + Margin * 2; - } - try { - foreach (string s in lines) { - string l = s.Replace("\t", new String (' ', Interface.TabSize)); + try { + foreach (string s in lines) { + string l = s.Replace ("\t", new String (' ', Interface.TabSize)); - TextExtents tmp = gr.TextExtents (l); + TextExtents tmp = gr.TextExtents (l); - if (tmp.XAdvance > te.XAdvance) - te = tmp; - } - } catch (Exception ex) { - return -1; + if (tmp.XAdvance > te.XAdvance) + te = tmp; + } + cachedTextSize.Width = (int)Math.Ceiling (te.XAdvance) + Margin * 2; + textMeasureIsUpToDate = true; + } catch { + return -1; + } } - return (int)Math.Ceiling (te.XAdvance) + Margin * 2; } + } - } + return lt == LayoutingType.Height ? cachedTextSize.Height : cachedTextSize.Width; + } protected override void onDraw (Context gr) { base.onDraw (gr); @@ -552,11 +554,12 @@ namespace Crow break; case Alignment.Center://ok rText.X = cb.X + cb.Width / 2 - rText.Width / 2; - rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2; + //rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2; + rText.Y = cb.Y + (int)Math.Floor((double)cb.Height / 2.0 - (double)rText.Height / 2.0); break; } - gr.FontMatrix = new Matrix(widthRatio * (float)Font.Size, 0, 0, heightRatio * (float)Font.Size, 0, 0); + //gr.FontMatrix = new Matrix(widthRatio * (float)Font.Size, 0, 0, heightRatio * (float)Font.Size, 0, 0); fe = gr.FontExtents; #region draw text cursor @@ -586,8 +589,8 @@ namespace Crow Foreground.SetAsSource (gr); gr.LineWidth = 1.0; - gr.MoveTo (0.5 + textCursorPos + rText.X, rText.Y + CurrentLine * fe.Height); - gr.LineTo (0.5 + textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * fe.Height); + gr.MoveTo (0.5 + textCursorPos + rText.X, rText.Y + CurrentLine * (fe.Ascent+fe.Descent)); + gr.LineTo (0.5 + textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * (fe.Ascent+fe.Descent)); gr.Stroke(); } #endregion @@ -597,9 +600,9 @@ namespace Crow // new SolidColor(Color.DarkGreen).SetAsSource(gr); // Rectangle R = new Rectangle ( // rText.X + (int)SelEndCursorPos - 3, -// rText.Y + (int)(SelRelease.Y * fe.Height), +// rText.Y + (int)(SelRelease.Y * (fe.Ascent+fe.Descent)), // 6, -// (int)fe.Height); +// (int)(fe.Ascent+fe.Descent)); // gr.Rectangle (R); // gr.Fill (); // } @@ -607,9 +610,9 @@ namespace Crow // new SolidColor(Color.DarkRed).SetAsSource(gr); // Rectangle R = new Rectangle ( // rText.X + (int)SelStartCursorPos - 3, -// rText.Y + (int)(SelBegin.Y * fe.Height), +// rText.Y + (int)(SelBegin.Y * (fe.Ascent+fe.Descent)), // 6, -// (int)fe.Height); +// (int)(fe.Ascent+fe.Descent)); // gr.Rectangle (R); // gr.Fill (); // } @@ -620,9 +623,9 @@ namespace Crow int lineLength = (int)gr.TextExtents (l).XAdvance; Rectangle lineRect = new Rectangle ( rText.X, - rText.Y + (int)Math.Ceiling(i * fe.Height), + rText.Y + i * (int)(fe.Ascent+fe.Descent), lineLength, - (int)Math.Ceiling(fe.Height)); + (int)(fe.Ascent+fe.Descent)); // if (TextAlignment == Alignment.Center || // TextAlignment == Alignment.Top || @@ -636,7 +639,7 @@ namespace Crow continue; Foreground.SetAsSource (gr); - gr.MoveTo (lineRect.X, rText.Y + fe.Ascent + fe.Height * i); + gr.MoveTo (lineRect.X,(double)rText.Y + fe.Ascent + (fe.Ascent+fe.Descent) * i) ; gr.ShowText (l); gr.Fill (); @@ -666,7 +669,7 @@ namespace Crow gr.Save (); gr.Clip (); gr.SetSourceColor (SelectionForeground); - gr.MoveTo (lineRect.X, rText.Y + fe.Ascent + fe.Height * i); + gr.MoveTo (lineRect.X, rText.Y + fe.Ascent + (fe.Ascent+fe.Descent) * i); gr.ShowText (l); gr.Fill (); gr.Restore (); @@ -688,12 +691,12 @@ namespace Crow { base.onMouseEnter (sender, e); if (Selectable) - CurrentInterface.MouseCursor = XCursor.Text; + IFace.MouseCursor = XCursor.Text; } public override void onMouseLeave (object sender, MouseMoveEventArgs e) { base.onMouseLeave (sender, e); - CurrentInterface.MouseCursor = XCursor.Default; + IFace.MouseCursor = XCursor.Default; } protected override void onFocused (object sender, EventArgs e) { @@ -774,7 +777,7 @@ namespace Crow double cPos = 0f; - CurrentLine = (int)(mouseLocalPos.Y / fe.Height); + CurrentLine = (int)(mouseLocalPos.Y / (fe.Ascent+fe.Descent)); //fix cu if (CurrentLine >= lines.Count) diff --git a/src/GraphicObjects/MessageBox.cs b/src/GraphicObjects/MessageBox.cs index c0754eaa..45ef1e00 100644 --- a/src/GraphicObjects/MessageBox.cs +++ b/src/GraphicObjects/MessageBox.cs @@ -38,10 +38,13 @@ namespace Crow #endregion public enum Type { + None, Information, - YesNo, Alert, - Error + Error, + YesNo, + YesNoCancel, + } protected override void loadTemplate (GraphicObject template) @@ -49,13 +52,14 @@ namespace Crow base.loadTemplate (template); NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.Informations.svg"); } - string message, okMessage, cancelMessage; - Type msgType = Type.Information; + string message, okMessage, cancelMessage, noMessage; + Type msgType = Type.None; - public event EventHandler Ok; + public event EventHandler Yes; + public event EventHandler No; public event EventHandler Cancel; - [XmlAttributeAttribute][DefaultValue("Informations")] + [DefaultValue("Informations")] public virtual string Message { get { return message; } @@ -66,7 +70,7 @@ namespace Crow NotifyValueChanged ("Message", message); } } - [XmlAttributeAttribute][DefaultValue("Ok")] + [DefaultValue("Ok")] public virtual string OkMessage { get { return okMessage; } @@ -77,7 +81,7 @@ namespace Crow NotifyValueChanged ("OkMessage", okMessage); } } - [XmlAttributeAttribute][DefaultValue("Cancel")] + [DefaultValue("Cancel")] public virtual string CancelMessage { get { return cancelMessage; } @@ -88,7 +92,18 @@ namespace Crow NotifyValueChanged ("CancelMessage", cancelMessage); } } - [XmlAttributeAttribute][DefaultValue("Information")] + [DefaultValue("No")] + public virtual string NoMessage + { + get { return cancelMessage; } + set { + if (cancelMessage == value) + return; + cancelMessage = value; + NotifyValueChanged ("NoMessage", cancelMessage); + } + } + [DefaultValue("Information")] public virtual Type MsgType { get { return msgType; } @@ -99,34 +114,58 @@ namespace Crow NotifyValueChanged ("MsgType", msgType); switch (msgType) { case Type.Information: - NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.Informations.svg"); + MsgIcon = "#Crow.Images.Icons.Informations.svg"; Caption = "Informations"; OkMessage = "Ok"; - CancelMessage = "Cancel"; + NotifyValueChanged ("CancelButIsVisible", false); + NotifyValueChanged ("NoButIsVisible", false); break; case Type.YesNo: - NotifyValueChanged ("MsgIcon", "#Crow.Icons.question.svg"); + case Type.YesNoCancel: + MsgIcon = "#Crow.Icons.question.svg"; Caption = "Choice"; OkMessage = "Yes"; - CancelMessage = "No"; + NoMessage = "No"; + NotifyValueChanged ("CancelButIsVisible", msgType == Type.YesNoCancel); + NotifyValueChanged ("NoButIsVisible", true); break; case Type.Alert: - NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.IconAlerte.svg"); + MsgIcon = "#Crow.Images.Icons.IconAlerte.svg"; Caption = "Alert"; OkMessage = "Ok"; CancelMessage = "Cancel"; + NotifyValueChanged ("CancelButIsVisible", true); + NotifyValueChanged ("NoButIsVisible", false); break; case Type.Error: - NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.exit.svg"); + MsgIcon = "#Crow.Images.Icons.exit.svg"; Caption = "Error"; OkMessage = "Ok"; + NotifyValueChanged ("CancelButIsVisible", false); + NotifyValueChanged ("NoButIsVisible", false); break; } } } + + string msgIcon = null; + public string MsgIcon { + get { return msgIcon; } + set { + if (value == MsgIcon) + return; + msgIcon = value; + NotifyValueChanged ("MsgIcon", MsgIcon); + } + } void onOkButtonClick (object sender, EventArgs e) { - Ok.Raise (this, null); + Yes.Raise (this, null); + close (); + } + void onNoButtonClick (object sender, EventArgs e) + { + No.Raise (this, null); close (); } void onCancelButtonClick (object sender, EventArgs e) @@ -137,7 +176,7 @@ namespace Crow public static MessageBox Show (Interface iface, Type msgBoxType, string message, string okMsg = "", string cancelMsg = ""){ lock (iface.UpdateMutex) { MessageBox mb = new MessageBox (iface); - mb.CurrentInterface.AddWidget (mb); + mb.IFace.AddWidget (mb); mb.MsgType = msgBoxType; mb.Message = message; if (!string.IsNullOrEmpty(okMsg)) @@ -147,6 +186,18 @@ namespace Crow return mb; } } + public static MessageBox ShowModal (Interface iface, Type msgBoxType, string message){ + lock (iface.UpdateMutex) { + MessageBox mb = new MessageBox (iface) { + Modal = true, + MsgType = msgBoxType, + Message = message + }; + + iface.AddWidget (mb); + return mb; + } + } } } diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 70804bda..1186e8e7 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -201,8 +201,8 @@ namespace Crow } public override void checkHoverWidget (MouseMoveEventArgs e) { - if (CurrentInterface.HoverWidget != this) { - CurrentInterface.HoverWidget = this; + if (IFace.HoverWidget != this) { + IFace.HoverWidget = this; onMouseEnter (this, e); } if (Content != null){ @@ -222,10 +222,10 @@ namespace Crow if (Content != null) { Content.Visible = true; if (Content.Parent == null) - CurrentInterface.AddWidget (Content); + IFace.AddWidget (Content); if (Content.LogicalParent != this) Content.LogicalParent = this; - CurrentInterface.PutOnTop (Content, true); + IFace.PutOnTop (Content, true); _content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing)); } Popped.Raise (this, e); diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 8383a274..d6637247 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -38,6 +38,7 @@ namespace Crow /// TemplatedControl may have 3 children (template,templateItem,content) but /// behave exactely as a container for layouting and drawing /// </summary> + [DesignIgnore] public class PrivateContainer : GraphicObject { #region CTOR @@ -45,6 +46,14 @@ namespace Crow public PrivateContainer (Interface iface) : base(iface){} #endregion + #if DESIGN_MODE + public override bool FindByDesignID(string designID, out GraphicObject go){ + go = null; + if (base.FindByDesignID (designID, out go)) + return true; + return (bool)child?.FindByDesignID (designID, out go); + } + #endif protected GraphicObject child; protected virtual void SetChild(GraphicObject _child) @@ -52,13 +61,12 @@ namespace Crow if (child != null) { //check if HoverWidget is removed from Tree - if (CurrentInterface.HoverWidget != null) { - if (this.Contains (CurrentInterface.HoverWidget)) - CurrentInterface.HoverWidget = null; + if (IFace.HoverWidget != null) { + if (this.Contains (IFace.HoverWidget)) + IFace.HoverWidget = null; } - contentSize = new Size (0, 0); + contentSize = default(Size); child.LayoutChanged -= OnChildLayoutChanges; - child.Dispose (); this.RegisterForGraphicUpdate (); } @@ -72,6 +80,13 @@ namespace Crow child.RegisterForLayouting (LayoutingType.Sizing); } } + //dispose child if not null + protected virtual void deleteChild () { + GraphicObject g = child; + SetChild (null); + if (g != null) + g.Dispose (); + } #region GraphicObject Overrides @@ -100,11 +115,11 @@ namespace Crow //force sizing to fit if sizing on children and child has stretched size switch (layoutType) { case LayoutingType.Width: - if (Width == Measure.Fit && child.Width.Units == Unit.Percent) + if (Width == Measure.Fit && child.Width.IsRelativeToParent) child.Width = Measure.Fit; break; case LayoutingType.Height: - if (Height == Measure.Fit && child.Height.Units == Unit.Percent) + if (Height == Measure.Fit && child.Height.IsRelativeToParent) child.Height = Measure.Fit; break; } @@ -121,14 +136,14 @@ namespace Crow LayoutingType ltChild = LayoutingType.None; if (layoutType == LayoutingType.Width) { - if (child.Width.Units == Unit.Percent) { + if (child.Width.IsRelativeToParent) { ltChild |= LayoutingType.Width; if (child.Width.Value < 100 && child.Left == 0) ltChild |= LayoutingType.X; } else if (child.Left == 0) ltChild |= LayoutingType.X; } else if (layoutType == LayoutingType.Height) { - if (child.Height.Units == Unit.Percent) { + if (child.Height.IsRelativeToParent) { ltChild |= LayoutingType.Height; if (child.Height.Value < 100 && child.Top == 0) ltChild |= LayoutingType.Y; diff --git a/src/GraphicObjects/SaturationValueSelector.cs b/src/GraphicObjects/SaturationValueSelector.cs index d9ee0a00..485a33d2 100644 --- a/src/GraphicObjects/SaturationValueSelector.cs +++ b/src/GraphicObjects/SaturationValueSelector.cs @@ -30,6 +30,7 @@ using System.Xml.Serialization; namespace Crow { + [DesignIgnore] public class SaturationValueSelector : ColorSelector { public SaturationValueSelector () : base(){} @@ -101,7 +102,7 @@ namespace Crow ctx.Translate (rb.X, rb.Y); - ctx.SetSourceColor (Color.Jet); + ctx.SetSourceColor (Color.DimGrey); ctx.Arc (mousePos.X, mousePos.Y, 3.5, 0, Math.PI * 2.0); ctx.LineWidth = 0.5; ctx.Stroke (); diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs index 397d7de0..30dd1480 100644 --- a/src/GraphicObjects/Scroller.cs +++ b/src/GraphicObjects/Scroller.cs @@ -42,160 +42,159 @@ namespace Crow public Scroller (Interface iface) : base(iface){} #endregion - bool _verticalScrolling; - bool _horizontalScrolling; - bool _scrollbarVisible; - int _scrollX = 0; - int _scrollY = 0; - int scrollSpeed; - public event EventHandler<ScrollingEventArgs> Scrolled; + int scrollX, scrollY, maxScrollX, maxScrollY, scrollSpeed; + + /// <summary> + /// if true, key stroke are handled in derrived class + /// </summary> + protected bool KeyEventsOverrides = false; + #region public properties - [XmlAttributeAttribute][DefaultValue(true)] - public bool VerticalScrolling { - get { return _verticalScrolling; } - set { _verticalScrolling = value; } - } + /// <summary> Horizontal Scrolling Position </summary> + [XmlAttributeAttribute][DefaultValue(0)] + public virtual int ScrollX { + get { return scrollX; } + set { + if (scrollX == value) + return; - [XmlAttributeAttribute][DefaultValue(false)] - public bool HorizontalScrolling { - get { return _horizontalScrolling; } - set { _horizontalScrolling = value; } - } - [XmlAttributeAttribute][DefaultValue(true)] - public bool ScrollbarVisible { - get { return _scrollbarVisible; } - set { _scrollbarVisible = value; } + int newS = value; + if (newS < 0) + newS = 0; + else if (newS > maxScrollX) + newS = maxScrollX; + + if (newS == scrollX) + return; + + scrollX = value; + + NotifyValueChanged ("ScrollX", scrollX); + RegisterForGraphicUpdate (); + } } + /// <summary> Vertical Scrolling Position </summary> [XmlAttributeAttribute][DefaultValue(0)] - public int ScrollX { - get { - return _scrollX; - } + public virtual int ScrollY { + get { return scrollY; } set { - if (_scrollX == value) + if (scrollY == value) return; - if (value < 0) - _scrollX = 0; - else if (value > Child.Slot.Width - ClientRectangle.Width) - _scrollX = Math.Max(0, Child.Slot.Width - ClientRectangle.Width); - else - _scrollX = value; - NotifyValueChanged("ScrollX", _scrollX); - RegisterForRedraw (); - Scrolled.Raise (this, new ScrollingEventArgs (Orientation.Horizontal)); + + int newS = value; + if (newS < 0) + newS = 0; + else if (newS > maxScrollY) + newS = maxScrollY; + + if (newS == scrollY) + return; + + scrollY = value; + + NotifyValueChanged ("ScrollY", scrollY); + RegisterForGraphicUpdate (); } } + /// <summary> Horizontal Scrolling maximum value </summary> [XmlAttributeAttribute][DefaultValue(0)] - public int ScrollY { - get { - return _scrollY; - } + public virtual int MaxScrollX { + get { return maxScrollX; } set { - if (_scrollY == value) + if (maxScrollX == value) return; - if (value < 0) - _scrollY = 0; - else if (value > Child.Slot.Height - ClientRectangle.Height) - _scrollY = Math.Max(0,Child.Slot.Height - ClientRectangle.Height); - else - _scrollY = value; - NotifyValueChanged("ScrollY", _scrollY); - RegisterForRedraw (); - Scrolled.Raise (this, new ScrollingEventArgs (Orientation.Vertical)); + + maxScrollX = value; + + if (scrollX > maxScrollX) + ScrollX = maxScrollX; + + NotifyValueChanged ("MaxScrollX", maxScrollX); + RegisterForGraphicUpdate (); } } + /// <summary> Vertical Scrolling maximum value </summary> + [XmlAttributeAttribute][DefaultValue(0)] + public virtual int MaxScrollY { + get { return maxScrollY; } + set { + if (maxScrollY == value) + return; + + maxScrollY = value; + + if (scrollY > maxScrollY) + ScrollY = maxScrollY; - [XmlIgnore] - public int MaximumScroll { - get { - try { - return VerticalScrolling ? - Math.Max(Child.Slot.Height - ClientRectangle.Height,0) : - Math.Max(Child.Slot.Width - ClientRectangle.Width,0); - } catch { - return 0; - } + NotifyValueChanged ("MaxScrollY", maxScrollY); + RegisterForGraphicUpdate (); } } - - [XmlAttributeAttribute][DefaultValue(30)] - public int ScrollSpeed { + /// <summary> Mouse Wheel Scrolling multiplier </summary> + [XmlAttributeAttribute][DefaultValue(50)] + public virtual int ScrollSpeed { get { return scrollSpeed; } set { + if (scrollSpeed == value) + return; + scrollSpeed = value; - NotifyValueChanged("ScrollSpeed", scrollSpeed); + + NotifyValueChanged ("ScrollSpeed", scrollSpeed); } } #endregion - #region GraphicObject Overrides - public override void OnLayoutChanges (LayoutingType layoutType) + public override void SetChild (GraphicObject _child) { - base.OnLayoutChanges (layoutType); + Group g = child as Group; + if (g != null) + g.ChildrenCleared -= onChildListCleared; + + base.SetChild (_child); - NotifyValueChanged("MaximumScroll", MaximumScroll); - if (layoutType == LayoutingType.Height) { - NotifyValueChanged ("PageHeight", Slot.Height); - if (child?.Slot.Height > 0) - NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height); - } else { - NotifyValueChanged ("PageWidth", Slot.Width); - if (child?.Slot.Width > 0) - NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width); - } + g = _child as Group; + if (g != null) + g.ChildrenCleared += onChildListCleared; } - void OnChildLayoutChanges (object sender, LayoutingEventArgs arg) + public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg) { - //Debug.WriteLine ("scroller childLayoutChanges"); - int maxScroll = MaximumScroll; - //Debug.WriteLine ("maxscroll={0}", maxScroll); - if (_verticalScrolling) { - if (arg.LayoutType == LayoutingType.Height) { - if (maxScroll < ScrollY) { - //Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll); - ScrollY = maxScroll; - } - NotifyValueChanged("MaximumScroll", maxScroll); - if (child?.Slot.Height > 0) - NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height); - } - } else if (arg.LayoutType == LayoutingType.Width) { - if (maxScroll < ScrollX) { - //Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll); - ScrollX = maxScroll; - } - NotifyValueChanged("MaximumScroll", maxScroll); - if (child?.Slot.Width > 0) - NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width); - } + base.OnChildLayoutChanges (sender, arg); + updateMaxScroll (arg.LayoutType); } - void onChildListCleared(object sender, EventArgs e){ - ScrollY = 0; - ScrollX = 0; + + + #region GraphicObject Overrides + public override Rectangle ScreenCoordinates (Rectangle r) + { + return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY); } - public override void SetChild (GraphicObject _child) + public override bool PointIsIn (ref Point m) { - GraphicObject c = child as GraphicObject; - Group g = child as Group; - if (c != null) { - c.LayoutChanged -= OnChildLayoutChanges; - if (g != null) - g.ChildrenCleared -= onChildListCleared; - } - c = _child as GraphicObject; - g = _child as Group; - if (c != null) { - c.LayoutChanged += OnChildLayoutChanges; - if (g != null) - g.ChildrenCleared += onChildListCleared; - } - base.SetChild (_child); + if (!base.PointIsIn(ref m)) + return false; + if (!Slot.ContainsOrIsEqual (m) || child==null) + return false; + m += new Point (ScrollX, ScrollY); + return true; } - public override Rectangle ScreenCoordinates (Rectangle r) + public override void RegisterClip (Rectangle clip) { - return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY); + base.RegisterClip (clip - new Point(ScrollX,ScrollY)); + } + public override void OnLayoutChanges (LayoutingType layoutType) + { + base.OnLayoutChanges (layoutType); + + if (layoutType == LayoutingType.Height) + NotifyValueChanged ("PageHeight", Slot.Height); + else if (layoutType == LayoutingType.Width) + NotifyValueChanged ("PageWidth", Slot.Width); + else + return; + updateMaxScroll(layoutType); } protected override void onDraw (Context gr) { @@ -218,50 +217,75 @@ namespace Crow gr.Restore (); } - #region Mouse handling - //internal Point savedMousePos; - - public override bool PointIsIn (ref Point m) - { - if (!base.PointIsIn(ref m)) - return false; - if (!Slot.ContainsOrIsEqual (m) || child==null) - return false; - m += new Point (ScrollX, ScrollY); - return true; - } -// public override bool MouseIsIn (Point m) -// { -// return Visible ? base.ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false; -// } -// public override void checkHoverWidget (MouseMoveEventArgs e) -// { -// savedMousePos = e.Position; -// Point m = e.Position - new Point (ScrollX, ScrollY); -// base.checkHoverWidget (new MouseMoveEventArgs(m.X,m.Y,e.XDelta,e.YDelta)); -// } + #region Mouse & Keyboard + /// <summary> Process scrolling vertically, or if shift is down, vertically </summary> public override void onMouseWheel (object sender, MouseWheelEventArgs e) { - if (Child == null) - return; - - if (VerticalScrolling ) + base.onMouseWheel (sender, e); + if (IFace.Keyboard.IsKeyDown (Key.ShiftLeft)) + ScrollX += e.Delta * ScrollSpeed; + else ScrollY -= e.Delta * ScrollSpeed; - if (HorizontalScrolling ) - ScrollX -= e.Delta * ScrollSpeed; } -// public override void onMouseMove (object sender, MouseMoveEventArgs e) -// { -// savedMousePos.X += e.XDelta; -// savedMousePos.Y += e.YDelta; -// base.onMouseMove (sender, new MouseMoveEventArgs(savedMousePos.X,savedMousePos.Y,e.XDelta,e.YDelta)); -// } - public override void RegisterClip (Rectangle clip) + /// <summary> Process scrolling with arrow keys, home and end keys. </summary> + public override void onKeyDown (object sender, KeyboardKeyEventArgs e) { - base.RegisterClip (clip - new Point(ScrollX,ScrollY)); + base.onKeyDown (sender, e); + + if (KeyEventsOverrides) + return; + + switch (e.Key) { + case Key.Up: + ScrollY--; + break; + case Key.Down: + ScrollY++; + break; + case Key.Left: + ScrollX--; + break; + case Key.Right: + ScrollX++; + break; + case Key.Home: + ScrollX = 0; + ScrollY = 0; + break; + case Key.End: + ScrollX = MaxScrollX; + ScrollY = MaxScrollY; + break; + } } #endregion #endregion + + void updateMaxScroll (LayoutingType lt){ + if (Child == null) { + MaxScrollX = 0; + MaxScrollY = 0; + return; + } + + Rectangle cb = ClientRectangle; + + if (lt == LayoutingType.Height) { + MaxScrollY = child.Slot.Height - cb.Height; + if (child.Slot.Height > 0) + NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height); + } else if (lt == LayoutingType.Width) { + MaxScrollX = child.Slot.Width - cb.Width; + if (child.Slot.Width > 0) + NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width); + } + } + void onChildListCleared(object sender, EventArgs e){ + ScrollY = 0; + ScrollX = 0; + } + + } } diff --git a/src/GraphicObjects/ScrollingObject.cs b/src/GraphicObjects/ScrollingObject.cs index 9059d8ed..de4b2113 100644 --- a/src/GraphicObjects/ScrollingObject.cs +++ b/src/GraphicObjects/ScrollingObject.cs @@ -36,6 +36,7 @@ namespace Crow /// <summary> /// generic class to build scrolling control in both directions /// </summary> + [DesignIgnore] public class ScrollingObject : GraphicObject { #region CTOR @@ -148,7 +149,7 @@ namespace Crow public override void onMouseWheel (object sender, MouseWheelEventArgs e) { base.onMouseWheel (sender, e); - if (CurrentInterface.Keyboard.IsKeyDown (Key.ShiftLeft)) + if (IFace.Keyboard.IsKeyDown (Key.ShiftLeft)) ScrollX += e.Delta * MouseWheelSpeed; else ScrollY -= e.Delta * MouseWheelSpeed; diff --git a/src/GraphicObjects/ScrollingTextBox.cs b/src/GraphicObjects/ScrollingTextBox.cs deleted file mode 100644 index c84594df..00000000 --- a/src/GraphicObjects/ScrollingTextBox.cs +++ /dev/null @@ -1,794 +0,0 @@ -// -// ScrollingTextBox.cs -// -// Author: -// Jean-Philippe Bruyère <jp.bruyere@hotmail.com> -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using System; -using System.Xml.Serialization; -using System.ComponentModel; -using System.Collections; -using Cairo; -using System.Text; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using System.Linq; - -namespace Crow -{ - /// <summary> - /// Scrolling text box optimized for monospace fonts, for coding - /// </summary> - public class ScrollingTextBox : ScrollingObject - { - #region CTOR - protected ScrollingTextBox ():base() - { - KeyEventsOverrides = true; - } - public ScrollingTextBox (Interface iface):base(iface){ - KeyEventsOverrides = true; - } - #endregion - - public event EventHandler TextChanged; - - public virtual void OnTextChanged(Object sender, EventArgs e) - { - TextChanged.Raise (this, e); - } - - #region private and protected fields - string lineBreak = Interface.LineBreak; - int visibleLines = 1; - List<string> lines; - string _text = "label"; - Color selBackground; - Color selForeground; - Point mouseLocalPos = 0;//mouse coord in widget space - int _currentCol; //0 based cursor position in string - int _currentLine; - Point _selBegin = -1; //selection start (row,column) - Point _selRelease = -1; //selection end (row,column) - - protected Rectangle rText; - protected FontExtents fe; - protected TextExtents te; - #endregion - - [XmlAttributeAttribute][DefaultValue("label")] - public string Text - { - get { - return lines == null ? - _text : lines.Aggregate((i, j) => i + Interface.LineBreak + j); - } - set - { - if (string.Equals (value, _text, StringComparison.Ordinal)) - return; - - _text = value; - - if (string.IsNullOrEmpty(_text)) - _text = ""; - - lines = getLines; - MaxScrollY = Math.Max (0, lines.Count - visibleLines); - - OnTextChanged (this, null); - RegisterForGraphicUpdate (); - } - } - - - [XmlAttributeAttribute][DefaultValue("BlueGray")] - public virtual Color SelectionBackground { - get { return selBackground; } - set { - if (value == selBackground) - return; - selBackground = value; - NotifyValueChanged ("SelectionBackground", selBackground); - RegisterForRedraw (); - } - } - [XmlAttributeAttribute][DefaultValue("White")] - public virtual Color SelectionForeground { - get { return selForeground; } - set { - if (value == selForeground) - return; - selForeground = value; - NotifyValueChanged ("SelectionForeground", selForeground); - RegisterForRedraw (); - } - } - [XmlAttributeAttribute][DefaultValue(0)] - public int CurrentColumn{ - get { return _currentCol; } - set { - if (value == _currentCol) - return; - if (value < 0) - _currentCol = 0; - else if (value > lines [_currentLine].Length) - _currentCol = lines [_currentLine].Length; - else - _currentCol = value; - NotifyValueChanged ("CurrentColumn", _currentCol); - } - } - [XmlAttributeAttribute][DefaultValue(0)] - public int CurrentLine{ - get { return _currentLine; } - set { - if (value == _currentLine) - return; - if (value >= lines.Count) - _currentLine = lines.Count-1; - else if (value < 0) - _currentLine = 0; - else - _currentLine = value; - //force recheck of currentCol for bounding - int cc = _currentCol; - _currentCol = 0; - CurrentColumn = cc; - NotifyValueChanged ("CurrentLine", _currentLine); - - if (CurrentLine < ScrollY) - ScrollY = CurrentLine; - else if (CurrentLine >= ScrollY + visibleLines) - ScrollY = Math.Max (0, CurrentLine - visibleLines + 1); - } - } - [XmlIgnore]public Point CurrentPosition { - get { return new Point(CurrentColumn, CurrentLine); } - } - //TODO:using HasFocus for drawing selection cause SelBegin and Release binding not to work - /// <summary> - /// Selection begin position in char units (line, column) - /// </summary> - [XmlAttributeAttribute][DefaultValue("-1")] - public Point SelBegin { - get { return _selBegin; } - set { - if (value == _selBegin) - return; - _selBegin = value; - System.Diagnostics.Debug.WriteLine ("SelBegin=" + _selBegin); - NotifyValueChanged ("SelBegin", _selBegin); - NotifyValueChanged ("SelectedText", SelectedText); - } - } - /// <summary> - /// Selection release position in char units (line, column) - /// </summary> - [XmlAttributeAttribute][DefaultValue("-1")] - public Point SelRelease { - get { - return _selRelease; - } - set { - if (value == _selRelease) - return; - _selRelease = value; - NotifyValueChanged ("SelRelease", _selRelease); - NotifyValueChanged ("SelectedText", SelectedText); - } - } - /// <summary> - /// return char at CurrentLine, CurrentColumn - /// </summary> - [XmlIgnore]protected Char CurrentChar - { - get { - return lines [CurrentLine] [CurrentColumn]; - } - } - /// <summary> - /// ordered selection start and end positions in char units - /// </summary> - [XmlIgnore]protected Point selectionStart - { - get { - return SelRelease < 0 || SelBegin.Y < SelRelease.Y ? SelBegin : - SelBegin.Y > SelRelease.Y ? SelRelease : - SelBegin.X < SelRelease.X ? SelBegin : SelRelease; - } - } - [XmlIgnore]public Point selectionEnd - { - get { - return SelRelease < 0 || SelBegin.Y > SelRelease.Y ? SelBegin : - SelBegin.Y < SelRelease.Y ? SelRelease : - SelBegin.X > SelRelease.X ? SelBegin : SelRelease; - } - } - [XmlIgnore]public string SelectedText - { - get { - - if (SelRelease < 0 || SelBegin < 0) - return ""; - if (selectionStart.Y == selectionEnd.Y) - return lines [selectionStart.Y].Substring (selectionStart.X, selectionEnd.X - selectionStart.X); - string tmp = ""; - tmp = lines [selectionStart.Y].Substring (selectionStart.X); - for (int l = selectionStart.Y + 1; l < selectionEnd.Y; l++) { - tmp += Interface.LineBreak + lines [l]; - } - tmp += Interface.LineBreak + lines [selectionEnd.Y].Substring (0, selectionEnd.X); - return tmp; - } - } - [XmlIgnore]public bool selectionIsEmpty - { get { return SelRelease == SelBegin; } } - - List<string> getLines { - get { - return Regex.Split (_text, "\r\n|\r|\n|\\\\n").ToList(); - } - } - /// <summary> - /// Moves cursor one char to the left. - /// </summary> - /// <returns><c>true</c> if move succeed</returns> - public bool MoveLeft(){ - int tmp = _currentCol - 1; - if (tmp < 0) { - if (_currentLine == 0) - return false; - CurrentLine--; - CurrentColumn = int.MaxValue; - } else - CurrentColumn = tmp; - return true; - } - /// <summary> - /// Moves cursor one char to the right. - /// </summary> - /// <returns><c>true</c> if move succeed</returns> - public bool MoveRight(){ - int tmp = _currentCol + 1; - if (tmp > lines [_currentLine].Length){ - if (CurrentLine == lines.Count - 1) - return false; - CurrentLine++; - CurrentColumn = 0; - } else - CurrentColumn = tmp; - return true; - } - public void GotoWordStart(){ - if (lines[CurrentLine].Length == 0) - return; - CurrentColumn--; - //skip white spaces - while (!char.IsLetterOrDigit (this.CurrentChar) && CurrentColumn > 0) - CurrentColumn--; - while (char.IsLetterOrDigit (lines [CurrentLine] [CurrentColumn]) && CurrentColumn > 0) - CurrentColumn--; - if (!char.IsLetterOrDigit (this.CurrentChar)) - CurrentColumn++; - } - public void GotoWordEnd(){ - //skip white spaces - if (CurrentColumn >= lines [CurrentLine].Length - 1) - return; - while (!char.IsLetterOrDigit (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1) - CurrentColumn++; - while (char.IsLetterOrDigit (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1) - CurrentColumn++; - if (char.IsLetterOrDigit (this.CurrentChar)) - CurrentColumn++; - } - public void DeleteChar() - { - if (selectionIsEmpty) { - if (CurrentColumn == 0) { - if (CurrentLine == 0 && lines.Count == 1) - return; - CurrentLine--; - CurrentColumn = lines [CurrentLine].Length; - lines [CurrentLine] += lines [CurrentLine + 1]; - lines.RemoveAt (CurrentLine + 1); - OnTextChanged (this, null); - return; - } - CurrentColumn--; - lines [CurrentLine] = lines [CurrentLine].Remove (CurrentColumn, 1); - } else { - int linesToRemove = selectionEnd.Y - selectionStart.Y + 1; - int l = selectionStart.Y; - - if (linesToRemove > 0) { - lines [l] = lines [l].Remove (selectionStart.X, lines [l].Length - selectionStart.X) + - lines [selectionEnd.Y].Substring (selectionEnd.X, lines [selectionEnd.Y].Length - selectionEnd.X); - l++; - for (int c = 0; c < linesToRemove-1; c++) - lines.RemoveAt (l); - CurrentLine = selectionStart.Y; - CurrentColumn = selectionStart.X; - } else - lines [l] = lines [l].Remove (selectionStart.X, selectionEnd.X - selectionStart.X); - CurrentColumn = selectionStart.X; - SelBegin = -1; - SelRelease = -1; - } - OnTextChanged (this, null); - } - - #region GraphicObject overrides - public override Font Font { - get { return base.Font; } - set { - base.Font = value; - - using (ImageSurface img = new ImageSurface (Format.Argb32, 1, 1)) { - using (Context gr = new Context (img)) { - gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight); - gr.SetFontSize (Font.Size); - - fe = gr.FontExtents; - } - } - MaxScrollY = 0; - RegisterForGraphicUpdate (); - } - } - protected override int measureRawSize(LayoutingType lt) - { - if (lt == LayoutingType.Height) - return (int)Math.Ceiling(fe.Height * lines.Count) + Margin * 2; - - string txt = _text.Replace("\t", new String (' ', Interface.TabSize)); - - - int maxChar = 0; - foreach (string s in Regex.Split (txt, "\r\n|\r|\n|\\\\n")) { - if (maxChar < s.Length) - maxChar = s.Length; - } - return (int)(fe.MaxXAdvance * maxChar) + Margin * 2; - } - public override void OnLayoutChanges (LayoutingType layoutType) - { - base.OnLayoutChanges (layoutType); - - if (layoutType == LayoutingType.Height) - updateVisibleLines (); - } - protected override void onDraw (Context gr) - { - base.onDraw (gr); - - gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight); - gr.SetFontSize (Font.Size); - gr.FontOptions = Interface.FontRenderingOptions; - gr.Antialias = Interface.Antialias; - - Rectangle cb = ClientRectangle; - - Foreground.SetAsSource (gr); - - bool selectionInProgress = false; - - #region draw text cursor - if (SelBegin != SelRelease) - selectionInProgress = true; - else if (HasFocus){ - gr.SetSourceColor(Color.Red); - gr.LineWidth = 2.0; - double cursorX = cb.X + (CurrentColumn - ScrollX) * fe.MaxXAdvance; - gr.MoveTo (0.5 + cursorX, cb.Y + (CurrentLine - ScrollY) * fe.Height); - gr.LineTo (0.5 + cursorX, cb.Y + (CurrentLine + 1 - ScrollY) * fe.Height); - gr.Stroke(); - } - #endregion - - Foreground.SetAsSource (gr); - - for (int i = 0; i < visibleLines; i++) { - int curL = i + ScrollY; - if (curL >= lines.Count) - break; - string lstr = lines[curL]; - - gr.MoveTo (cb.X, cb.Y + fe.Ascent + fe.Height * i); - gr.ShowText (lstr); - gr.Fill (); - - if (selectionInProgress && curL >= selectionStart.Y && curL <= selectionEnd.Y) { - - double rLineX = cb.X, - rLineY = cb.Y + i * fe.Height, - rLineW = lstr.Length * fe.MaxXAdvance; - - System.Diagnostics.Debug.WriteLine ("sel start: " + selectionStart + " sel end: " + selectionEnd); - if (curL == selectionStart.Y) { - rLineX += (selectionStart.X - ScrollX) * fe.MaxXAdvance; - rLineW -= selectionStart.X * fe.MaxXAdvance; - } - if (curL == selectionEnd.Y) - rLineW -= (lstr.Length - selectionEnd.X) * fe.MaxXAdvance; - - gr.Save (); - gr.Operator = Operator.Source; - gr.Rectangle (rLineX, rLineY, rLineW, fe.Height); - gr.SetSourceColor (SelectionBackground); - gr.FillPreserve (); - gr.Clip (); - gr.Operator = Operator.Over; - gr.SetSourceColor (SelectionForeground); - gr.MoveTo (cb.X, cb.Y + fe.Ascent + fe.Height * i); - gr.ShowText (lstr); - gr.Fill (); - gr.Restore (); - } - } - } - #endregion - - #region Mouse handling - void updatemouseLocalPos(Point mpos){ - Point mouseLocalPos = mpos - ScreenCoordinates(Slot).TopLeft - ClientRectangle.TopLeft; - if (mouseLocalPos.X < 0) - CurrentColumn--; - else - CurrentColumn = ScrollX + (int)Math.Round (mouseLocalPos.X / fe.MaxXAdvance); - - if (mouseLocalPos.Y < 0) - CurrentLine--; - else - CurrentLine = ScrollY + (int)Math.Floor (mouseLocalPos.Y / fe.Height); - } - public override void onMouseEnter (object sender, MouseMoveEventArgs e) - { - base.onMouseEnter (sender, e); - CurrentInterface.MouseCursor = XCursor.Text; - } - public override void onMouseLeave (object sender, MouseMoveEventArgs e) - { - base.onMouseLeave (sender, e); - CurrentInterface.MouseCursor = XCursor.Default; - } - protected override void onFocused (object sender, EventArgs e) - { - base.onFocused (sender, e); - - // SelBegin = new Point(0,0); - // SelRelease = new Point (lines.LastOrDefault ().Length, lines.Count-1); - RegisterForRedraw (); - } - protected override void onUnfocused (object sender, EventArgs e) - { - base.onUnfocused (sender, e); - - // SelBegin = -1; - // SelRelease = -1; - RegisterForRedraw (); - } - public override void onMouseMove (object sender, MouseMoveEventArgs e) - { - base.onMouseMove (sender, e); - - if (!e.Mouse.IsButtonDown (MouseButton.Left)) - return; - if (!HasFocus || SelBegin < 0) - return; - - updatemouseLocalPos (e.Position); - SelRelease = CurrentPosition; - - RegisterForRedraw(); - } - public override void onMouseDown (object sender, MouseButtonEventArgs e) - { - if (this.HasFocus){ - updatemouseLocalPos (e.Position); - SelBegin = SelRelease = CurrentPosition; - RegisterForRedraw();//TODO:should put it in properties - } - - //done at the end to set 'hasFocus' value after testing it - base.onMouseDown (sender, e); - } - public override void onMouseUp (object sender, MouseButtonEventArgs e) - { - base.onMouseUp (sender, e); - - if (SelBegin == SelRelease) - SelBegin = SelRelease = -1; - - updatemouseLocalPos (e.Position); - RegisterForRedraw (); - } - public override void onMouseDoubleClick (object sender, MouseButtonEventArgs e) - { - base.onMouseDoubleClick (sender, e); - - GotoWordStart (); - SelBegin = CurrentPosition; - GotoWordEnd (); - SelRelease = CurrentPosition; - RegisterForRedraw (); - } - #endregion - - #region Keyboard handling - public override void onKeyDown (object sender, KeyboardKeyEventArgs e) - { - base.onKeyDown (sender, e); - - Key key = e.Key; - - switch (key) - { - case Key.Back: - if (CurrentPosition == 0) - return; - this.DeleteChar(); - break; - case Key.Clear: - break; - case Key.Delete: - if (selectionIsEmpty) { - if (!MoveRight ()) - return; - }else if (e.Shift) - CurrentInterface.Clipboard = this.SelectedText; - this.DeleteChar (); - break; - case Key.Enter: - case Key.KeypadEnter: - if (!selectionIsEmpty) - this.DeleteChar (); - this.InsertLineBreak (); - break; - case Key.Escape: - Text = ""; - CurrentColumn = 0; - SelRelease = -1; - break; - case Key.Home: - if (e.Shift) { - if (selectionIsEmpty) - SelBegin = new Point (CurrentColumn, CurrentLine); - if (e.Control) - CurrentLine = 0; - CurrentColumn = 0; - SelRelease = new Point (CurrentColumn, CurrentLine); - break; - } - SelRelease = -1; - if (e.Control) - CurrentLine = 0; - CurrentColumn = 0; - break; - case Key.End: - if (e.Shift) { - if (selectionIsEmpty) - SelBegin = CurrentPosition; - if (e.Control) - CurrentLine = int.MaxValue; - CurrentColumn = int.MaxValue; - SelRelease = CurrentPosition; - break; - } - SelRelease = -1; - if (e.Control) - CurrentLine = int.MaxValue; - CurrentColumn = int.MaxValue; - break; - case Key.Insert: - if (e.Shift) - this.Insert (CurrentInterface.Clipboard); - else if (e.Control && !selectionIsEmpty) - CurrentInterface.Clipboard = this.SelectedText; - break; - case Key.Left: - if (e.Shift) { - if (selectionIsEmpty) - SelBegin = new Point(CurrentColumn, CurrentLine); - if (e.Control) - GotoWordStart (); - else if (!MoveLeft ()) - return; - SelRelease = CurrentPosition; - break; - } - SelRelease = -1; - if (e.Control) - GotoWordStart (); - else - MoveLeft(); - break; - case Key.Right: - if (e.Shift) { - if (selectionIsEmpty) - SelBegin = CurrentPosition; - if (e.Control) - GotoWordEnd (); - else if (!MoveRight ()) - return; - SelRelease = CurrentPosition; - break; - } - SelRelease = -1; - if (e.Control) - GotoWordEnd (); - else - MoveRight (); - break; - case Key.Up: - if (e.Shift) { - if (selectionIsEmpty) - SelBegin = CurrentPosition; - CurrentLine--; - SelRelease = CurrentPosition; - break; - } - SelRelease = -1; - CurrentLine--; - break; - case Key.Down: - if (e.Shift) { - if (selectionIsEmpty) - SelBegin = CurrentPosition; - CurrentLine++; - SelRelease = CurrentPosition; - break; - } - SelRelease = -1; - CurrentLine++; - break; - case Key.Menu: - break; - case Key.NumLock: - break; - case Key.PageDown: - if (e.Shift) { - if (selectionIsEmpty) - SelBegin = CurrentPosition; - CurrentLine += visibleLines; - SelRelease = CurrentPosition; - break; - } - SelRelease = -1; - CurrentLine += visibleLines; - break; - case Key.PageUp: - if (e.Shift) { - if (selectionIsEmpty) - SelBegin = CurrentPosition; - CurrentLine -= visibleLines; - SelRelease = CurrentPosition; - break; - } - CurrentLine -= visibleLines; - break; - case Key.RWin: - break; - case Key.Tab: - this.Insert ("\t"); - break; - default: - break; - } - RegisterForGraphicUpdate(); - } - public override void onKeyPress (object sender, KeyPressEventArgs e) - { - base.onKeyPress (sender, e); - - this.Insert (e.KeyChar.ToString()); - - SelRelease = -1; - SelBegin = -1; //new Point(CurrentColumn, SelBegin.Y); - - RegisterForGraphicUpdate(); - } - #endregion - - - /// <summary> Compute x offset in cairo unit from text position </summary> - double GetXFromTextPointer(Context gr, Point pos) - { - try { - string l = lines [pos.Y].Substring (0, pos.X). - Replace ("\t", new String (' ', Interface.TabSize)); - return gr.TextExtents (l).XAdvance; - } catch{ - return -1; - } - } - - /// <summary> line break could be '\r' or '\n' or '\r\n' </summary> - string detectLineBreakKind(){ - string strLB = ""; - - if (string.IsNullOrEmpty(_text)) - return Interface.LineBreak; - int i = 0; - while ( i < _text.Length) { - if (_text [i] == '\r') { - strLB += '\r'; - i++; - } - if (i < _text.Length) { - if (_text [i] == '\r') - return "\r"; - if (_text [i] == '\n') - strLB += '\n'; - } - if (!string.IsNullOrEmpty (strLB)) - return strLB; - i++; - } - return Interface.LineBreak; - } - - void updateVisibleLines(){ - visibleLines = (int)Math.Floor ((double)ClientRectangle.Height / fe.Height); - MaxScrollY = Math.Max (0, lines.Count - visibleLines); - - System.Diagnostics.Debug.WriteLine ("update visible lines: " + visibleLines); - System.Diagnostics.Debug.WriteLine ("update MaxScrollY: " + MaxScrollY); - } - - - /// <summary> - /// Insert new string at caret position, should be sure no line break is inside. - /// </summary> - /// <param name="str">String.</param> - protected void Insert(string str) - { - if (!selectionIsEmpty) - this.DeleteChar (); - string[] strLines = Regex.Split (str, "\r\n|\r|\n|" + @"\\n").ToArray(); - lines [CurrentLine] = lines [CurrentLine].Insert (CurrentColumn, strLines[0]); - CurrentColumn += strLines[0].Length; - for (int i = 1; i < strLines.Length; i++) { - InsertLineBreak (); - lines [CurrentLine] = lines [CurrentLine].Insert (CurrentColumn, strLines[i]); - CurrentColumn += strLines[i].Length; - } - OnTextChanged (this, null); - RegisterForGraphicUpdate(); - } - - /// <summary> - /// Insert a line break. - /// </summary> - protected void InsertLineBreak() - { - lines.Insert(CurrentLine + 1, lines[CurrentLine].Substring(CurrentColumn)); - lines [CurrentLine] = lines [CurrentLine].Substring (0, CurrentColumn); - CurrentLine++; - CurrentColumn = 0; - OnTextChanged (this, null); - } - } -}
\ No newline at end of file diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs index 2e4a5fef..2bdd5b8a 100644 --- a/src/GraphicObjects/Slider.cs +++ b/src/GraphicObjects/Slider.cs @@ -68,7 +68,7 @@ namespace Crow protected double unity; #region Public properties - [XmlAttributeAttribute()][DefaultValue("vgradient|0:White|0,1:LightGray|0,9:LightGray|1:DimGray")] + [DefaultValue("vgradient|0:White|0,1:LightGray|0,9:LightGray|1:DimGray")] public virtual Fill CursorColor { get { return _cursorColor; } set { @@ -79,7 +79,7 @@ namespace Crow NotifyValueChanged ("CursorColor", _cursorColor); } } - [XmlAttributeAttribute()][DefaultValue(20)] + [DefaultValue(20)] public virtual int CursorSize { get { return _cursorSize; } set { @@ -90,7 +90,7 @@ namespace Crow NotifyValueChanged ("CursorSize", _cursorSize); } } - [XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)] + [DefaultValue(Orientation.Horizontal)] public virtual Orientation Orientation { get { return _orientation; } @@ -105,7 +105,7 @@ namespace Crow } #endregion - [XmlAttributeAttribute()][DefaultValue(10.0)] + [DefaultValue(10.0)] public override double Maximum { get { return base.Maximum; } set { @@ -186,16 +186,24 @@ namespace Crow } cursor.Inflate (-1); } - + Point mouseDownInit; + double mouseDownInitValue; + #region mouse handling public override void onMouseDown (object sender, MouseButtonEventArgs e) { base.onMouseDown (sender, e); - + mouseDownInit = ScreenPointToLocal (e.Position); + mouseDownInitValue = Value; Rectangle cursInScreenCoord = ScreenCoordinates (cursor + Slot.Position); - if (cursInScreenCoord.ContainsOrIsEqual (e.Position)) + if (cursInScreenCoord.ContainsOrIsEqual (e.Position)){ +// Rectangle r = ClientRectangle; +// if (r.Width - _cursorSize > 0) { +// double unit = (Maximum - Minimum) / (double)(r.Width - _cursorSize); +// mouseDownInit += new Point ((int)(Value / unit), (int)(Value / unit)); +// } holdCursor = true; - else if (_orientation == Orientation.Horizontal) { + }else if (_orientation == Orientation.Horizontal) { if (e.Position.X < cursInScreenCoord.Left) Value -= LargeIncrement; else @@ -215,11 +223,25 @@ namespace Crow } public override void onMouseMove (object sender, MouseMoveEventArgs e) { - if (holdCursor) { - if (_orientation == Orientation.Horizontal) - Value += (double)e.XDelta / unity; - else - Value += (double)e.YDelta / unity; + if (holdCursor) { + Point m = ScreenPointToLocal (e.Position) - mouseDownInit; + Rectangle r = ClientRectangle; + + if (_orientation == Orientation.Horizontal) { + if (r.Width - _cursorSize == 0) + return; + double unit = (Maximum - Minimum) / (double)(r.Width - _cursorSize); + double tmp = mouseDownInitValue + (double)m.X * unit; + tmp -= tmp % SmallIncrement; + Value = tmp; + } else { + if (r.Height - _cursorSize == 0) + return; + double unit = (Maximum - Minimum) / (double)(r.Height - _cursorSize); + double tmp = mouseDownInitValue + (double)m.Y * unit; + tmp -= tmp % SmallIncrement; + Value = tmp; + } } base.onMouseMove (sender, e); diff --git a/src/GraphicObjects/Splitter.cs b/src/GraphicObjects/Splitter.cs index c688f773..84e1ade0 100644 --- a/src/GraphicObjects/Splitter.cs +++ b/src/GraphicObjects/Splitter.cs @@ -91,14 +91,14 @@ namespace Crow { base.onMouseEnter (sender, e); if ((Parent as GenericStack).Orientation == Orientation.Horizontal) - CurrentInterface.MouseCursor = XCursor.H; + IFace.MouseCursor = XCursor.H; else - CurrentInterface.MouseCursor = XCursor.V; + IFace.MouseCursor = XCursor.V; } public override void onMouseLeave (object sender, MouseMoveEventArgs e) { base.onMouseLeave (sender, e); - CurrentInterface.MouseCursor = XCursor.Default; + IFace.MouseCursor = XCursor.Default; } public override void onMouseDown (object sender, MouseButtonEventArgs e) { @@ -217,6 +217,20 @@ namespace Crow } return base.UpdateLayout (layoutType); } + public override bool PointIsIn (ref Point m) + { + if (!(Visible & IsEnabled)||IsDragged) + return false; + if (!Parent.PointIsIn(ref m)) + return false; + m -= (Parent.getSlot().Position + Parent.ClientRectangle.Position) ; + Rectangle r = Slot; + if (Width == Measure.Stretched) + r.Inflate (0, 5); + else + r.Inflate (5, 0); + return r.ContainsOrIsEqual (m); + } #endregion } } diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs index eab0cb0d..473fc313 100644 --- a/src/GraphicObjects/TabItem.cs +++ b/src/GraphicObjects/TabItem.cs @@ -42,6 +42,8 @@ namespace Crow public event EventHandler QueryClose; + internal TabView tview = null; + #region Private fields GraphicObject titleWidget; int tabOffset; @@ -87,20 +89,9 @@ namespace Crow NotifyValueChanged ("ViewIndex", viewIndex); } } - - [XmlAttributeAttribute][DefaultValue("18")] - public virtual Measure TabThickness { - get { return tabThickness; } - set { - if (tabThickness == value) - return; - tabThickness = value; - NotifyValueChanged ("TabThickness", tabThickness); - RegisterForGraphicUpdate (); - } - } - [XmlAttributeAttribute][DefaultValue(0)] - public virtual int TabOffset { + + [DefaultValue(0)] + public int TabOffset { get { return tabOffset; } set { if (tabOffset == value) @@ -112,8 +103,13 @@ namespace Crow RegisterForGraphicUpdate (); } } - - [XmlAttributeAttribute][DefaultValue(false)] + public Measure TabHeight { + get { return tview == null ? Measure.Fit : tview.TabHeight; } + } + public Measure TabWidth { + get { return tview == null ? Measure.Fit : tview.TabWidth; } + } + [DefaultValue(false)] public virtual bool IsSelected { get { return isSelected; } set { @@ -127,20 +123,23 @@ namespace Crow { gr.Save (); - int spacing = (Parent as TabView).Spacing; + TabView tv = Parent as TabView; + + Rectangle r = TabTitle.Slot; + r.Width = TabWidth; - gr.MoveTo (0.5, TabTitle.Slot.Bottom-0.5); - gr.LineTo (TabTitle.Slot.Left - spacing, TabTitle.Slot.Bottom-0.5); + gr.MoveTo (0.5, r.Bottom-0.5); + gr.LineTo (r.Left - tv.LeftSlope, r.Bottom-0.5); gr.CurveTo ( - TabTitle.Slot.Left - spacing / 2, TabTitle.Slot.Bottom-0.5, - TabTitle.Slot.Left - spacing / 2, 0.5, - TabTitle.Slot.Left, 0.5); - gr.LineTo (TabTitle.Slot.Right, 0.5); + r.Left - tv.LeftSlope / 2, r.Bottom-0.5, + r.Left - tv.LeftSlope / 2, 0.5, + r.Left, 0.5); + gr.LineTo (r.Right, 0.5); gr.CurveTo ( - TabTitle.Slot.Right + spacing / 2, 0.5, - TabTitle.Slot.Right + spacing / 2, TabTitle.Slot.Bottom-0.5, - TabTitle.Slot.Right + spacing, TabTitle.Slot.Bottom-0.5); - gr.LineTo (Slot.Width-0.5, TabTitle.Slot.Bottom-0.5); + r.Right + tv.RightSlope / 2, 0.5, + r.Right + tv.RightSlope / 2, r.Bottom-0.5, + r.Right + tv.RightSlope, r.Bottom-0.5); + gr.LineTo (Slot.Width-0.5, r.Bottom-0.5); gr.LineTo (Slot.Width-0.5, Slot.Height-0.5); @@ -149,61 +148,138 @@ namespace Crow gr.LineWidth = 1; Foreground.SetAsSource (gr); gr.StrokePreserve (); - gr.Clip (); base.onDraw (gr); gr.Restore (); } + Point dragStartPoint; + int dragThreshold = 16; + int dis = 128; + internal TabView savedParent = null; + + void makeFloating (TabView tv) { + lock (IFace.UpdateMutex) { + ImageSurface di = new ImageSurface (Format.Argb32, dis, dis); + IFace.DragImageHeight = dis; + IFace.DragImageWidth = dis; + using (Context ctx = new Context (di)) { + double div = Math.Max (LastPaintedSlot.Width, LastPaintedSlot.Height); + double s = (double)dis / div; + ctx.Scale (s, s); + if (bmp == null) + this.onDraw (ctx); + else { + if (LastPaintedSlot.Width>LastPaintedSlot.Height) + ctx.SetSourceSurface (bmp, 0, (LastPaintedSlot.Width-LastPaintedSlot.Height)/2); + else + ctx.SetSourceSurface (bmp, (LastPaintedSlot.Height-LastPaintedSlot.Width)/2, 0); + + ctx.Paint (); + } + } + IFace.DragImage = di; + } + tv.RemoveChild (this); + savedParent = tv; + } + + public override ILayoutable Parent { + get { + return base.Parent; + } + set { + base.Parent = value; + if (value != null) { + dragStartPoint = IFace.Mouse.Position; + savedParent = value as TabView; + } + } + } + protected override void onStartDrag (object sender, DragDropEventArgs e) + { + base.onStartDrag (sender, e); + + dragStartPoint = IFace.Mouse.Position; + } + protected override void onEndDrag (object sender, DragDropEventArgs e) + { + base.onEndDrag (sender, e); + + if (Parent != null) + return; + + savedParent.AddChild (this); + + IFace.ClearDragImage (); + } + protected override void onDrop (object sender, DragDropEventArgs e) + { + base.onDrop (sender, e); + if (Parent != null) + return; + TabView tv = e.DropTarget as TabView; + if (tv == null) + return; + + IFace.ClearDragImage (); + + tv.AddChild (this); + } #region Mouse Handling - public bool HoldCursor = false; public override bool PointIsIn (ref Point m) { if (!base.PointIsIn (ref m)) return false; - if (m.Y < tabThickness) + if (m.Y < tview.TabHeight) return TabTitle.Slot.ContainsOrIsEqual (m); else return this.isSelected; } - public override void onMouseDown (object sender, MouseButtonEventArgs e) - { - base.onMouseDown (sender, e); - HoldCursor = true; - } public override void onMouseUp (object sender, MouseButtonEventArgs e) { base.onMouseUp (sender, e); - HoldCursor = false; - (Parent as TabView).UpdateLayout (LayoutingType.ArrangeChildren); + tview.UpdateLayout (LayoutingType.ArrangeChildren); } public override void onMouseMove (object sender, MouseMoveEventArgs e) { base.onMouseMove (sender, e); - if (!(HasFocus && HoldCursor)) + if (Parent == null) return; + + if (!IsDragged) + return; + TabView tv = Parent as TabView; - TabItem previous = null, next = null; + if (Math.Abs (e.Position.Y - dragStartPoint.Y) > dragThreshold || + Math.Abs (e.Position.X - dragStartPoint.X) > dragThreshold) { + makeFloating (tv); + return; + } + + Rectangle cb = ClientRectangle; + int tmp = TabOffset + e.XDelta; - if (tmp < tv.Spacing) - TabOffset = tv.Spacing; - else if (tmp > Parent.getSlot ().Width - TabTitle.Slot.Width - tv.Spacing) - TabOffset = Parent.getSlot ().Width - TabTitle.Slot.Width - tv.Spacing; - else{ + if (tmp < tview.LeftSlope) { + TabOffset = tview.LeftSlope; + } else if (tmp > cb.Width - tv.RightSlope - tv.TabWidth) { + TabOffset = cb.Width - tv.RightSlope - tv.TabWidth; + }else{ + dragStartPoint.X = e.Position.X; TabItem[] tabItms = tv.Children.Cast<TabItem>().OrderBy (t=>t.ViewIndex).ToArray(); if (ViewIndex > 0 && e.XDelta < 0) { - previous = tabItms [ViewIndex - 1]; - if (tmp < previous.TabOffset + previous.TabTitle.Slot.Width / 2) { + TabItem previous = tabItms [ViewIndex - 1]; + if (tmp < previous.TabOffset + tview.TabWidth / 2) { previous.ViewIndex = ViewIndex; ViewIndex--; tv.UpdateLayout (LayoutingType.ArrangeChildren); } }else if (ViewIndex < tabItms.Length - 1 && e.XDelta > 0) { - next = tabItms [ViewIndex + 1]; - if (tmp > next.TabOffset - next.TabTitle.Slot.Width / 2){ + TabItem next = tabItms [ViewIndex + 1]; + if (tmp > next.TabOffset - tview.TabWidth / 2){ next.ViewIndex = ViewIndex; ViewIndex++; tv.UpdateLayout (LayoutingType.ArrangeChildren); @@ -217,7 +293,7 @@ namespace Crow //if tab is used as a templated item root in a templatedGroup, local datasource //is not null, in this case, removing the data entries will delete automatically the item if (localDataSourceIsNull) - (Parent as TabView).DeleteChild (this); + (Parent as TabView)?.DeleteChild (this); } #endregion diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs index abaa6ac0..304e820d 100644 --- a/src/GraphicObjects/TabView.cs +++ b/src/GraphicObjects/TabView.cs @@ -41,14 +41,16 @@ namespace Crow #endregion #region Private fields - int _spacing; - Measure tabThickness; + int adjustedTab = -1; + int leftSlope; + int rightSlope; + Measure tabHeight, tabWidth; Orientation _orientation; - int selectedTab = 0; + int selectedTab; #endregion #region public properties - [XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)] + [DefaultValue(Orientation.Horizontal)] public virtual Orientation Orientation { get { return _orientation; } @@ -60,30 +62,83 @@ namespace Crow if (_orientation == Orientation.Horizontal) NotifyValueChanged ("TabOrientation", Orientation.Vertical); else - NotifyValueChanged ("TabOrientation", Orientation.Horizontal); + NotifyValueChanged ("TabOrientation", Orientation.Horizontal); + this.RegisterForLayouting (LayoutingType.ArrangeChildren); + } + } + [DefaultValue(16)] + public int LeftSlope + { + get { return leftSlope; } + set { + if (leftSlope == value) + return; + leftSlope = value; + NotifyValueChanged ("leftSlope", leftSlope); + tabSizeHasChanged = true; + //RegisterForLayouting (LayoutingType.ArrangeChildren); } } - [XmlAttributeAttribute()][DefaultValue(16)] - public int Spacing + bool tabSizeHasChanged = false; + [DefaultValue(16)] + public int RightSlope { - get { return _spacing; } + get { return rightSlope; } + set { + if (rightSlope == value) + return; + rightSlope = value; + NotifyValueChanged ("RightSlope", rightSlope); + tabSizeHasChanged = true; + //RegisterForLayouting (LayoutingType.ArrangeChildren); + } + } + [DefaultValue("18")] + public Measure TabHeight { + get { return tabHeight; } set { - if (_spacing == value) + if (tabHeight == value) return; - _spacing = value; - NotifyValueChanged ("Spacing", Spacing); + tabHeight = value; + NotifyValueChanged ("TabHeight", tabHeight); +// childrenRWLock.EnterReadLock (); +// foreach (GraphicObject ti in Children) { +// ti.NotifyValueChanged ("TabHeight", tabHeight); +// } +// childrenRWLock.ExitReadLock (); + RegisterForLayouting (LayoutingType.ArrangeChildren); } } - [XmlAttributeAttribute()][DefaultValue(0)] + [DefaultValue("120")] + public Measure TabWidth { + get { return adjustedTab > 0 ? (Measure)adjustedTab : tabWidth; } + set { + if (tabWidth == value) + return; + tabWidth = value; + NotifyValueChanged ("TabWidth", TabWidth); +// +// childrenRWLock.EnterReadLock (); +// foreach (GraphicObject ti in Children) { +// ti.NotifyValueChanged ("TabWidth", tabWidth); +// } +// childrenRWLock.ExitReadLock (); + RegisterForLayouting (LayoutingType.ArrangeChildren); + } + } + public virtual int SelectedTab { get { return selectedTab; } set { - if (selectedTab < Children.Count && SelectedTab >= 0) + if (value == selectedTab) + return; + + if (selectedTab < Children.Count && selectedTab >= 0) (Children [selectedTab] as TabItem).IsSelected = false; selectedTab = value; - if (selectedTab < Children.Count && SelectedTab >= 0) + if (selectedTab < Children.Count && selectedTab >= 0) (Children [selectedTab] as TabItem).IsSelected = true; NotifyValueChanged ("SelectedTab", selectedTab); @@ -92,12 +147,6 @@ namespace Crow } #endregion - void Ti_TabTitle_LayoutChanged (object sender, LayoutingEventArgs e) - { - if (e.LayoutType == LayoutingType.Width) - this.RegisterForLayouting (LayoutingType.ArrangeChildren); - } - public override void AddChild (GraphicObject child) { TabItem ti = child as TabItem; @@ -106,13 +155,14 @@ namespace Crow ti.MouseDown += Ti_MouseDown; ti.TabTitle.LayoutChanged += Ti_TabTitle_LayoutChanged; + ti.tview = this; base.AddChild (child); SelectedTab = ti.ViewIndex = Children.Count - 1; + this.RegisterForLayouting (LayoutingType.ArrangeChildren); } - - public override void DeleteChild (GraphicObject child) + public override void RemoveChild (GraphicObject child) { TabItem ti = child as TabItem; if (ti == null) @@ -120,11 +170,30 @@ namespace Crow ti.MouseDown -= Ti_MouseDown; ti.TabTitle.LayoutChanged -= Ti_TabTitle_LayoutChanged; + ti.tview = null; - if (selectedTab > Children.Count - 2) - SelectedTab--; - - base.DeleteChild (child); + childrenRWLock.EnterReadLock (); + + TabItem[] tabItms = Children.Cast<TabItem>().OrderBy (t=>t.ViewIndex).ToArray(); + int selTabViewIdx = -1; + + if (SelectedTab < tabItms.Length && SelectedTab >= 0) + selTabViewIdx = (Children [SelectedTab] as TabItem).ViewIndex; + + for (int i = selTabViewIdx+1; i < tabItms.Length; i++) + tabItms [i].ViewIndex--; + + if (selTabViewIdx > tabItms.Length - 2) + selTabViewIdx = tabItms.Length - 2; + + if (selTabViewIdx < 0) + SelectedTab = -1; + else + SelectedTab = Children.IndexOf (tabItms [selTabViewIdx]); + + childrenRWLock.ExitReadLock (); + + base.RemoveChild (child); } public override bool ArrangeChildren { get { return true; } } @@ -132,34 +201,62 @@ namespace Crow { RegisteredLayoutings &= (~layoutType); - if (layoutType == LayoutingType.ArrangeChildren) { - int curOffset = Spacing; + if (layoutType == LayoutingType.ArrangeChildren && Children.Count > 0) { + Rectangle cb = ClientRectangle; + + int tabSpace = tabWidth + leftSlope; + int tc = Children.Count (c => c.Visible == true); + + if (tc > 0) + tabSpace = Math.Min(tabSpace, (cb.Width-rightSlope) / tc); + + if (tabSpace < tabWidth + leftSlope) + adjustedTab = tabSpace - leftSlope; + else + adjustedTab = -1; + + //Console.WriteLine ("tabspace: {0} tw:{1}", tabSpace, tabWidth); + + childrenRWLock.EnterReadLock(); TabItem[] tabItms = Children.Cast<TabItem>().OrderBy (t=>t.ViewIndex).ToArray(); + childrenRWLock.ExitReadLock(); + int curOffset = leftSlope; + for (int i = 0; i < tabItms.Length; i++) { if (!tabItms [i].Visible) continue; - if (!tabItms [i].HoldCursor) + tabItms [i].NotifyValueChanged ("TabHeight", tabHeight); + tabItms [i].NotifyValueChanged ("TabWidth", TabWidth); + if (!tabItms [i].IsDragged) { tabItms [i].TabOffset = curOffset; - if (Orientation == Orientation.Horizontal) { - if (tabItms [i].TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Width)) - return false; - curOffset += tabItms [i].TabTitle.Slot.Width + Spacing; - } else { - if (tabItms [i].TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Height)) - return false; - curOffset += tabItms [i].TabTitle.Slot.Height + Spacing; + //Console.WriteLine ("offset: {0}=>{1}", tabItms [i].Name, tabItms [i].TabOffset); } + if (Orientation == Orientation.Horizontal) { + curOffset += tabSpace; + } else + curOffset += tabSpace; } //if no layouting remains in queue for item, registre for redraw if (RegisteredLayoutings == LayoutingType.None && IsDirty) - CurrentInterface.EnqueueForRepaint (this); + IFace.EnqueueForRepaint (this); return true; } return base.UpdateLayout(layoutType); } + public override void OnLayoutChanges (LayoutingType layoutType) + { + if (_orientation == Orientation.Horizontal) { + if (layoutType == LayoutingType.Width) + RegisterForLayouting (LayoutingType.ArrangeChildren); + } else if (layoutType == LayoutingType.Height) + RegisterForLayouting (LayoutingType.ArrangeChildren); + + base.OnLayoutChanges (layoutType); + } + protected override void onDraw (Context gr) { Rectangle rBack = new Rectangle (Slot.Size); @@ -178,48 +275,59 @@ namespace Crow childrenRWLock.EnterReadLock (); - TabItem[] tabItms = Children.Cast<TabItem> ().OrderBy (t => t.ViewIndex).ToArray (); - for (int i = 0; i < tabItms.Length; i++) { - if (tabItms [i] == Children [SelectedTab]) - continue; - tabItms [i].Paint (ref gr); - } + TabItem[] tabItms = Children.Where(tt=>tt.Visible).Cast<TabItem> (). + OrderBy (t => t.ViewIndex).ToArray (); + int selTabViewIdx = -1; if (SelectedTab < tabItms.Length && SelectedTab >= 0) - Children [SelectedTab].Paint (ref gr); + selTabViewIdx = (Children [SelectedTab] as TabItem).ViewIndex; childrenRWLock.ExitReadLock (); + + int i = 0; + while (i < selTabViewIdx) { + tabItms [i].Paint (ref gr); + i++; + } + i = tabItms.Length - 1; + while (i > selTabViewIdx) { + tabItms [i].Paint (ref gr); + i--; + } + + if (selTabViewIdx >= 0) + tabItms [selTabViewIdx].Paint (ref gr); gr.Restore (); } - #region Mouse handling - public override void checkHoverWidget (MouseMoveEventArgs e) + protected override void onDragEnter (object sender, DragDropEventArgs e) { - if (CurrentInterface.HoverWidget != this) { - CurrentInterface.HoverWidget = this; - onMouseEnter (this, e); - } + base.onDragEnter (sender, e); - if (SelectedTab > Children.Count - 1) + TabItem ti = e.DragSource as TabItem; + if (ti == null) return; - - if (((Children[SelectedTab] as TabItem).Content.Parent as GraphicObject).MouseIsIn(e.Position)) - { - Children[SelectedTab].checkHoverWidget (e); + if (ti.Parent != null || ti.savedParent == this) return; - } - TabItem[] tabItms = Children.Cast<TabItem>().OrderBy (t=>t.ViewIndex).ToArray(); - for (int i = tabItms.Length - 1; i >= 0; i--) { - if (tabItms [i].TabTitle.MouseIsIn(e.Position)) - { - tabItms [i].checkHoverWidget (e); - return; - } - } + + this.AddChild (ti); + + Point p = ScreenPointToLocal (IFace.Mouse.Position) - Margin; + + p.X = Math.Max (leftSlope, p.X); + p.X = Math.Min (ClientRectangle.Width - rightSlope - TabWidth, p.X); + ti.TabOffset = p.X; + + IFace.ClearDragImage (); + } - #endregion + void Ti_TabTitle_LayoutChanged (object sender, LayoutingEventArgs e) + { + if (e.LayoutType == LayoutingType.X) + RegisterForLayouting (LayoutingType.ArrangeChildren); + } void Ti_MouseDown (object sender, MouseButtonEventArgs e) { SelectedTab = Children.IndexOf (sender as GraphicObject); diff --git a/src/GraphicObjects/TemplatedContainer.cs b/src/GraphicObjects/TemplatedContainer.cs index 3e0dd801..a779595d 100644 --- a/src/GraphicObjects/TemplatedContainer.cs +++ b/src/GraphicObjects/TemplatedContainer.cs @@ -38,6 +38,18 @@ namespace Crow /// </summary> public class TemplatedContainer : TemplatedControl { + #if DESIGN_MODE + public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem) + { + if (this.design_isTGItem) + return; + base.getIML (doc, parentElem); + if (!HasContent) + return; + Content.getIML (doc, parentElem.LastChild); + } + #endif + #region CTOR protected TemplatedContainer() : base(){} public TemplatedContainer (Interface iface) : base(iface){} diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index 34e4ce07..54991a41 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -43,6 +43,20 @@ namespace Crow /// </summary> public abstract class TemplatedControl : PrivateContainer { + #if DESIGN_MODE + public bool design_inlineTemplate = false; + public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem) + { + if (this.design_isTGItem) + return; + base.getIML (doc, parentElem); + if (child == null || !design_inlineTemplate) + return; + XmlElement xe = doc.CreateElement("Template"); + child.getIML (doc, xe); + parentElem.LastChild.AppendChild (xe); + } + #endif #region CTOR protected TemplatedControl() : base(){} public TemplatedControl (Interface iface) : base(iface){} @@ -66,7 +80,7 @@ namespace Crow if (string.IsNullOrEmpty(_template)) loadTemplate (); else - loadTemplate (CurrentInterface.Load (_template)); + loadTemplate (IFace.Load (_template)); } } /// <summary> @@ -133,9 +147,9 @@ namespace Crow this.ClearTemplateBinding(); if (template == null) { - if (!Interface.DefaultTemplates.ContainsKey (this.GetType ().FullName)) + if (!IFace.DefaultTemplates.ContainsKey (this.GetType ().FullName)) throw new Exception (string.Format ("No default template found for '{0}'", this.GetType ().FullName)); - this.SetChild (CurrentInterface.Load (Interface.DefaultTemplates[this.GetType ().FullName])); + this.SetChild (IFace.Load (IFace.DefaultTemplates[this.GetType ().FullName])); }else this.SetChild (template); } diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index 8025435d..f7c93763 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -40,6 +40,24 @@ namespace Crow { public abstract class TemplatedGroup : TemplatedControl { + #if DESIGN_MODE + public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem) + { + if (this.design_isTGItem) + return; + base.getIML (doc, parentElem); + + if (string.IsNullOrEmpty(_itemTemplate)) { + foreach (ItemTemplate it in ItemTemplates.Values) + it.getIML (doc, parentElem.LastChild); + } + + foreach (GraphicObject g in Items) { + g.getIML (doc, parentElem.LastChild); + } + } + #endif + #region CTOR protected TemplatedGroup() : base(){} public TemplatedGroup (Interface iface) : base(iface){} @@ -130,7 +148,7 @@ namespace Crow : items.Children; } } - [XmlAttributeAttribute][DefaultValue(-1)]public int SelectedIndex{ + [XmlAttributeAttribute][DefaultValue(-1)]public virtual int SelectedIndex{ get { return _selectedIndex; } set { if (value == _selectedIndex) @@ -427,17 +445,21 @@ namespace Crow iTemp = ItemTemplates ["default"]; } - //lock (CurrentInterface.LayoutMutex) { - g = iTemp.CreateInstance(CurrentInterface); + lock (IFace.LayoutMutex) { + g = iTemp.CreateInstance(); + #if DESIGN_MODE + g.design_isTGItem = true; + #endif page.AddChild (g); // if (isPaged) g.LogicalParent = this; g.MouseDown += itemClick; - //} + } if (iTemp.Expand != null && g is Expandable) { - (g as Expandable).Expand += iTemp.Expand; - (g as Expandable).GetIsExpandable = iTemp.HasSubItems; + Expandable e = g as Expandable; + e.Expand += iTemp.Expand; + e.GetIsExpandable = iTemp.HasSubItems; } g.DataSource = o; diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs index a14aea6a..e29ff9bf 100644 --- a/src/GraphicObjects/TextBox.cs +++ b/src/GraphicObjects/TextBox.cs @@ -86,7 +86,7 @@ namespace Crow if (!MoveRight ()) return; }else if (e.Shift) - CurrentInterface.Clipboard = this.SelectedText; + IFace.Clipboard = this.SelectedText; this.DeleteChar (); break; case Key.Enter: @@ -135,9 +135,9 @@ namespace Crow break; case Key.Insert: if (e.Shift) - this.Insert (CurrentInterface.Clipboard); + this.Insert (IFace.Clipboard); else if (e.Control && !selectionIsEmpty) - CurrentInterface.Clipboard = this.SelectedText; + IFace.Clipboard = this.SelectedText; break; case Key.Left: if (e.Shift) { diff --git a/src/GraphicObjects/TextRun.cs b/src/GraphicObjects/TextRun.cs index 69495647..17e3b770 100644 --- a/src/GraphicObjects/TextRun.cs +++ b/src/GraphicObjects/TextRun.cs @@ -36,6 +36,7 @@ using System.ComponentModel; namespace Crow { + [DesignIgnore] public class TextRun : GraphicObject { #region CTOR diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs index bbfb196d..56632ff3 100644 --- a/src/GraphicObjects/Window.cs +++ b/src/GraphicObjects/Window.cs @@ -47,11 +47,12 @@ namespace Crow } string _icon; - bool _resizable; - bool _movable; + bool resizable; + bool movable; + bool modal; protected bool hoverBorder = false; bool alwaysOnTop = false; - Fill titleBarBackground = Color.UnitedNationsBlue; + Fill titleBarBackground = Color.SteelBlue; Fill titleBarForeground = Color.White; Rectangle savedBounds; @@ -96,7 +97,7 @@ namespace Crow /// <summary> /// Background of the title bar if any. /// </summary> - [XmlAttributeAttribute][DefaultValue("vgradient|0:Onyx|1:UnitedNationsBlue")] + [XmlAttributeAttribute][DefaultValue("vgradient|0:Onyx|1:SteelBlue")] public virtual Fill TitleBarBackground { get { return titleBarBackground; } set { @@ -124,25 +125,37 @@ namespace Crow [XmlAttributeAttribute][DefaultValue(true)] public bool Resizable { get { - return _resizable; + return resizable; } set { - if (_resizable == value) + if (resizable == value) return; - _resizable = value; - NotifyValueChanged ("Resizable", _resizable); + resizable = value; + NotifyValueChanged ("Resizable", resizable); } } [XmlAttributeAttribute][DefaultValue(true)] public bool Movable { get { - return _movable; + return movable; } set { - if (_movable == value) + if (movable == value) return; - _movable = value; - NotifyValueChanged ("Movable", _movable); + movable = value; + NotifyValueChanged ("Movable", movable); + } + } + [XmlAttributeAttribute][DefaultValue(false)] + public bool Modal { + get { + return modal; + } + set { + if (modal == value) + return; + modal = value; + NotifyValueChanged ("Modal", modal); } } [XmlAttributeAttribute][DefaultValue(false)] @@ -167,17 +180,18 @@ namespace Crow [XmlAttributeAttribute][DefaultValue(false)] public bool AlwaysOnTop { get { - return alwaysOnTop; + return modal ? true : alwaysOnTop; } set { if (alwaysOnTop == value) return; + alwaysOnTop = value; - if (alwaysOnTop && Parent != null) - CurrentInterface.PutOnTop (this); + if (AlwaysOnTop && Parent != null) + IFace.PutOnTop (this); - NotifyValueChanged ("AlwaysOnTop", alwaysOnTop); + NotifyValueChanged ("AlwaysOnTop", AlwaysOnTop); } } // [XmlAttributeAttribute()][DefaultValue(WindowState.Normal)] @@ -278,15 +292,15 @@ namespace Crow { base.onMouseMove (sender, e); - Interface otkgw = CurrentInterface; + Interface otkgw = IFace; if (!hoverBorder) { currentDirection = Direction.None; - CurrentInterface.MouseCursor = XCursor.Default; + IFace.MouseCursor = XCursor.Default; return; } - if (this.HasFocus && _movable) { + if (this.HasFocus && movable) { if (e.Mouse.IsButtonDown (MouseButton.Left)) { MoveAndResize (e.XDelta, e.YDelta, currentDirection); return; @@ -353,10 +367,14 @@ namespace Crow { base.onMouseDown (sender, e); } + public override bool MouseIsIn (Point m) + { + return modal ? true : base.MouseIsIn (m); + } #endregion protected void onMaximized (object sender, EventArgs e){ - lock (CurrentInterface.LayoutMutex) { + lock (IFace.LayoutMutex) { if (!IsMinimized) savedBounds = this.LastPaintedSlot; this.Left = this.Top = 0; @@ -372,7 +390,7 @@ namespace Crow Maximized.Raise (sender, e); } protected void onUnmaximized (object sender, EventArgs e){ - lock (CurrentInterface.LayoutMutex) { + lock (IFace.LayoutMutex) { this.Left = savedBounds.Left; this.Top = savedBounds.Top; this.Width = savedBounds.Width; @@ -387,7 +405,7 @@ namespace Crow Unmaximized.Raise (sender, e); } protected void onMinimized (object sender, EventArgs e){ - lock (CurrentInterface.LayoutMutex) { + lock (IFace.LayoutMutex) { if (IsNormal) savedBounds = this.LastPaintedSlot; Width = 200; @@ -405,7 +423,7 @@ namespace Crow { hoverBorder = false; currentDirection = Direction.None; - CurrentInterface.MouseCursor = XCursor.Default; + IFace.MouseCursor = XCursor.Default; } protected virtual void onBorderMouseEnter (object sender, MouseMoveEventArgs e) { @@ -415,18 +433,33 @@ namespace Crow protected void butQuitPress (object sender, MouseButtonEventArgs e) { - CurrentInterface.MouseCursor = XCursor.Default; + IFace.MouseCursor = XCursor.Default; close (); } - protected void close(){ + protected virtual void close(){ Closing.Raise (this, null); if (Parent is Interface) (Parent as Interface).DeleteWidget (this); - else if (Parent is Group) - (Parent as Group).DeleteChild (this); - else if (Parent is PrivateContainer) - (Parent as Container).Child = null; + else { + GraphicObject p = Parent as GraphicObject; + if (p is Group) { + lock (IFace.UpdateMutex) { + RegisterClip (p.ScreenCoordinates (p.LastPaintedSlot)); + (p as Group).DeleteChild (this); + } + //(Parent as Group).RegisterForRedraw (); + } else if (Parent is PrivateContainer) + (Parent as Container).Child = null; + } + } + + public static Window Show (Interface iface, string imlPath, bool modal = false){ + lock (iface.UpdateMutex) { + Window w = iface.AddWidget (imlPath) as Window; + w.Modal = modal; + return w; + } } } } diff --git a/src/GraphicObjects/Wrapper.cs b/src/GraphicObjects/Wrapper.cs index 4fff17ff..a7f5f73b 100644 --- a/src/GraphicObjects/Wrapper.cs +++ b/src/GraphicObjects/Wrapper.cs @@ -104,7 +104,7 @@ namespace Crow this.RegisterForLayouting (LayoutingType.Width); break; case LayoutingType.Height: - if (Orientation == Orientation.Vertical && go.Height.Units == Unit.Percent) { + if (Orientation == Orientation.Vertical && go.Height.IsRelativeToParent) { go.Height = Measure.Fit; return; } @@ -137,7 +137,7 @@ namespace Crow foreach (GraphicObject c in Children) { if (!c.Visible) continue; - if (c.Height.Units == Unit.Percent && + if (c.Height.IsRelativeToParent && c.RegisteredLayoutings.HasFlag (LayoutingType.Height)) { childrenRWLock.ExitReadLock(); return -1; @@ -172,7 +172,7 @@ namespace Crow foreach (GraphicObject c in Children) { if (!c.Visible) continue; - if (c.Width.Units == Unit.Percent && + if (c.Width.IsRelativeToParent && c.RegisteredLayoutings.HasFlag (LayoutingType.Width)) { childrenRWLock.ExitReadLock(); return -1; @@ -207,7 +207,7 @@ namespace Crow //if no layouting remains in queue for item, registre for redraw if (RegisteredLayoutings == LayoutingType.None && IsDirty) - CurrentInterface.EnqueueForRepaint (this); + IFace.EnqueueForRepaint (this); return true; } @@ -217,13 +217,13 @@ namespace Crow public override void OnLayoutChanges (LayoutingType layoutType) { #if DEBUG_LAYOUTING - CurrentInterface.currentLQI.Slot = LastSlots; - CurrentInterface.currentLQI.Slot = Slot; + IFace.currentLQI.Slot = LastSlots; + IFace.currentLQI.Slot = Slot; #endif switch (layoutType) { case LayoutingType.Width: foreach (GraphicObject c in Children) { - if (c.Width.Units == Unit.Percent) + if (c.Width.IsRelativeToParent) c.RegisterForLayouting (LayoutingType.Width); } if (Height == Measure.Fit) @@ -232,7 +232,7 @@ namespace Crow break; case LayoutingType.Height: foreach (GraphicObject c in Children) { - if (c.Height.Units == Unit.Percent) + if (c.Height.IsRelativeToParent) c.RegisterForLayouting (LayoutingType.Height); } if (Width == Measure.Fit) diff --git a/src/IML/IMLContext.cs b/src/IML/IMLContext.cs index c8527087..aa4dee2f 100644 --- a/src/IML/IMLContext.cs +++ b/src/IML/IMLContext.cs @@ -42,7 +42,8 @@ namespace Crow.IML /// </summary> public class IMLContext { - public XmlTextReader reader = null; + public XmlReader reader = null; + public int curLine = 0; public Type RootType = null; public DynamicMethod dm = null; @@ -182,23 +183,48 @@ namespace Crow.IML /// <param name="bd">Bd.</param> /// <param name="evt">passed as arg to prevent refetching it for the 3rd time</param> public void emitHandlerMethodAddition(EventBinding bd){ + //fetch source instance with address for handler addition (as 1st arg of handler.add) il.Emit (OpCodes.Ldloc_0);//push root CompilerServices.emitGetInstance (il, bd.SourceNA); + il.Emit (OpCodes.Ldloc_0); + CompilerServices.emitGetInstance (il, bd.TargetNA); + + string[] membs = bd.TargetMember.Split ('.'); + for (int i = 0; i < membs.Length - 1; i++) { + il.Emit (OpCodes.Dup); + il.Emit (OpCodes.Ldstr, membs[i]); + il.Emit (OpCodes.Call, CompilerServices.miGetMembIinfoWithRefx); + il.Emit (OpCodes.Call, CompilerServices.miGetValWithRefx); + } + //load handlerType of sourceEvent to create handler delegate (1st arg) il.Emit (OpCodes.Ldtoken, bd.SourceEvent.EventHandlerType); il.Emit (OpCodes.Call, CompilerServices.miGetTypeFromHandle); - //load target the where the method is defined (2nd arg) - il.Emit (OpCodes.Ldloc_0); - CompilerServices.emitGetInstance (il, bd.TargetNA); //load methodInfo (3rd arg) - il.Emit (OpCodes.Ldstr, bd.TargetMember); - + il.Emit (OpCodes.Ldstr, membs[membs.Length-1]); il.Emit (OpCodes.Callvirt, CompilerServices.miCreateDel); - il.Emit (OpCodes.Callvirt, bd.SourceEvent.AddMethod);//call add event } - +// public void emitHandlerMethodAddition(EventBinding bd){ +// //fetch source instance with address for handler addition (as 1st arg of handler.add) +// il.Emit (OpCodes.Ldloc_0);//push root +// CompilerServices.emitGetInstance (il, bd.SourceNA); +// +// //load handlerType of sourceEvent to create handler delegate (1st arg) +// il.Emit (OpCodes.Ldtoken, bd.SourceEvent.EventHandlerType); +// il.Emit (OpCodes.Call, CompilerServices.miGetTypeFromHandle); +// //load target the where the method is defined (2nd arg) +// il.Emit (OpCodes.Ldloc_0); +// CompilerServices.emitGetInstance (il, bd.TargetNA); +// //load methodInfo (3rd arg) +// il.Emit (OpCodes.Ldstr, bd.TargetMember); +// +// il.Emit (OpCodes.Callvirt, CompilerServices.miCreateDel); +// +// il.Emit (OpCodes.Callvirt, bd.SourceEvent.AddMethod);//call add event +// } +// } }
\ No newline at end of file diff --git a/src/GraphicObjects/MDIContainer.cs b/src/IMLAttributes.cs index d8ce4647..929fd4f8 100644 --- a/src/GraphicObjects/MDIContainer.cs +++ b/src/IMLAttributes.cs @@ -1,5 +1,5 @@ // -// MDIContainer.cs +// IMLAttributes.cs // // Author: // Jean-Philippe Bruyère <jp_bruyere@hotmail.com> @@ -27,14 +27,18 @@ using System; namespace Crow { - public class MDIContainer : Group + public class DesignIgnore : Attribute + { + } + + public class DesignCategory : Attribute { - #region CTOR - public MDIContainer () : base() + public string Name { get; set; } + + public DesignCategory (string name) { + Name = name; } - #endregion - } } diff --git a/src/Instantiator.cs b/src/Instantiator.cs index 14e33bf0..001832b1 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -41,7 +41,7 @@ namespace Crow.IML public class InstantiatorException : Exception { public string Path; public InstantiatorException (string path, Exception innerException) - : base ("ITor exception in " + path, innerException){ + : base ("ITor error:" + path, innerException){ Path = path; } } @@ -70,21 +70,33 @@ namespace Crow.IML public Type RootType; InstanciatorInvoker loader; + protected Interface iface; internal string sourcePath; + #if DESIGN_MODE + public static int NextInstantiatorID = 0; + public int currentInstantiatorID = 0; + int currentDesignID = 0; + internal string NextDesignID { get { return string.Format ("{0}_{1}",currentInstantiatorID, currentDesignID++); }} + #endif + #region CTOR /// <summary> /// Initializes a new instance of the Instantiator class. /// </summary> - public Instantiator (string path) : this (Interface.GetStreamFromPath(path), path) { + public Instantiator (Interface _iface, string path) : this (_iface, _iface.GetStreamFromPath(path), path) { } /// <summary> /// Initializes a new instance of the Instantiator class. /// </summary> - public Instantiator (Stream stream, string srcPath = null) + public Instantiator (Interface _iface, Stream stream, string srcPath = null) { + #if DESIGN_MODE + currentInstantiatorID = NextInstantiatorID++; + #endif + iface = _iface; sourcePath = srcPath; #if DEBUG_LOAD Stopwatch loadingTime = new Stopwatch (); @@ -109,12 +121,20 @@ namespace Crow.IML /// Initializes a new instance of the Instantiator class with an already openned xml reader /// positionned on the start tag inside the itemTemplate /// </summary> - public Instantiator (XmlReader itr){ + public Instantiator (Interface _iface, XmlReader itr){ + #if DESIGN_MODE + currentInstantiatorID = NextInstantiatorID++; + #endif + iface = _iface; parseIML (itr); } //TODO:check if still used - public Instantiator (Type _root, InstanciatorInvoker _loader) + public Instantiator (Interface _iface, Type _root, InstanciatorInvoker _loader) { + #if DESIGN_MODE + currentInstantiatorID = NextInstantiatorID++; + #endif + iface = _iface; RootType = _root; loader = _loader; } @@ -123,14 +143,10 @@ namespace Crow.IML /// </summary> /// <returns>A new instantiator</returns> /// <param name="fragment">IML string</param> - public static Instantiator CreateFromImlFragment (string fragment) + public static Instantiator CreateFromImlFragment (Interface _iface, string fragment) { - try { - using (Stream s = new MemoryStream (Encoding.UTF8.GetBytes (fragment))) { - return new Instantiator (s); - } - } catch (Exception ex) { - throw new Exception ("Error loading IML fragment:\n" + fragment + "\n", ex); + using (Stream s = new MemoryStream (Encoding.UTF8.GetBytes (fragment))) { + return new Instantiator (_iface, s); } } #endregion @@ -141,7 +157,7 @@ namespace Crow.IML /// </summary> /// <returns>The new graphic object instance</returns> /// <param name="iface">The interface to bind to</param> - public GraphicObject CreateInstance(Interface iface){ + public GraphicObject CreateInstance(){ return loader (iface) as GraphicObject; } /// <summary> @@ -150,7 +166,7 @@ namespace Crow.IML /// </summary> /// <returns>The new T instance</returns> /// <param name="iface">The interface to bind to</param> - public T CreateInstance<T>(Interface iface){ + public T CreateInstance<T>(){ return (T)loader (iface); } List<DynamicMethod> dsValueChangedDynMeths = new List<DynamicMethod>(); @@ -209,6 +225,13 @@ namespace Crow.IML /// </summary> void emitLoader (XmlReader reader, IMLContext ctx) { + int curLine = ctx.curLine; + + #if DESIGN_MODE + IXmlLineInfo li = (IXmlLineInfo)reader; + ctx.curLine += li.LineNumber - 1; + #endif + string tmpXml = reader.ReadOuterXml (); if (ctx.nodesStack.Peek().HasTemplate) @@ -216,6 +239,7 @@ namespace Crow.IML emitGOLoad (ctx, tmpXml); + ctx.curLine = curLine; //emitCheckAndBindValueChanged (ctx); } /// <summary> @@ -242,16 +266,16 @@ namespace Crow.IML if (string.IsNullOrEmpty (path)) { itemTmpID += Guid.NewGuid ().ToString (); - Interface.Instantiators [itemTmpID] = - new ItemTemplate (new MemoryStream (Encoding.UTF8.GetBytes (reader.ReadInnerXml ())), dataTest, dataType, datas); + iface.Instantiators [itemTmpID] = + new ItemTemplate (iface, new MemoryStream (Encoding.UTF8.GetBytes (reader.ReadInnerXml ())), dataTest, dataType, datas); } else { if (!reader.IsEmptyElement) throw new Exception ("ItemTemplate with Path attribute set may not include sub nodes"); itemTmpID += path+dataType+datas; - if (!Interface.Instantiators.ContainsKey (itemTmpID)) - Interface.Instantiators [itemTmpID] = - new ItemTemplate (Interface.GetStreamFromPath (path), dataTest, dataType, datas); + if (!iface.Instantiators.ContainsKey (itemTmpID)) + iface.Instantiators [itemTmpID] = + new ItemTemplate (iface, path, dataTest, dataType, datas); } return new string [] { dataType, itemTmpID, datas, dataTest }; } @@ -277,6 +301,11 @@ namespace Crow.IML continue; if (reader.Name == "Template") { inlineTemplate = true; + #if DESIGN_MODE + ctx.il.Emit (OpCodes.Ldloc_0); + ctx.il.Emit (OpCodes.Ldc_I4_1); + ctx.il.Emit (OpCodes.Stfld, typeof(TemplatedControl).GetField("design_inlineTemplate")); + #endif reader.Read (); readChildren (reader, ctx, -1); } else if (reader.Name == "ItemTemplate") @@ -299,10 +328,10 @@ namespace Crow.IML //try to load ItemTemplate(s) from ItemTemplate attribute of TemplatedGroup if (!string.IsNullOrEmpty (itemTemplatePath)) { //check if it is already loaded in cache as a single itemTemplate instantiator - if (Interface.Instantiators.ContainsKey (itemTemplatePath)) { + if (iface.Instantiators.ContainsKey (itemTemplatePath)) { itemTemplateIds.Add (new string [] { "default", itemTemplatePath, "" }); } else { - using (Stream stream = Interface.GetStreamFromPath (itemTemplatePath)) { + using (Stream stream = iface.GetStreamFromPath (itemTemplatePath)) { //itemtemplate files may have multiple root nodes XmlReaderSettings itrSettings = new XmlReaderSettings { ConformanceLevel = ConformanceLevel.Fragment }; using (XmlReader itr = XmlReader.Create (stream, itrSettings)) { @@ -312,8 +341,8 @@ namespace Crow.IML if (itr.NodeType == XmlNodeType.Element) { if (itr.Name != "ItemTemplate") { //the file contains a single template to use as default - Interface.Instantiators [itemTemplatePath] = - new ItemTemplate (itr); + iface.Instantiators [itemTemplatePath] = + new ItemTemplate (iface, itr); itemTemplateIds.Add (new string [] { "default", itemTemplatePath, "", "TypeOf" }); break;//we should be at the end of the file } @@ -330,12 +359,16 @@ namespace Crow.IML //add the default item template if no default is defined if (!itemTemplateIds.Any(ids=>ids[0] == "default")) itemTemplateIds.Add (new string [] { "default", "#Crow.DefaultItem.template", "", "TypeOf"}); - //copy item templates (review this) + //get item templates foreach (string [] iTempId in itemTemplateIds) { ctx.il.Emit (OpCodes.Ldloc_0);//load TempControl ref ctx.il.Emit (OpCodes.Ldfld, CompilerServices.fldItemTemplates);//load ItemTemplates dic field + + //prepare argument to add itemTemplate to templated group dic of ItemTemplates ctx.il.Emit (OpCodes.Ldstr, iTempId [0]);//load key - ctx.il.Emit (OpCodes.Ldstr, iTempId [1]);//load value + //load itemTemplate + ctx.il.Emit (OpCodes.Ldarg_1);//load currentInterface + ctx.il.Emit (OpCodes.Ldstr, iTempId [1]);//load path ctx.il.Emit (OpCodes.Callvirt, CompilerServices.miGetITemp); ctx.il.Emit (OpCodes.Callvirt, CompilerServices.miAddITemp); @@ -351,6 +384,21 @@ namespace Crow.IML } } } + + #if DESIGN_MODE + void emitSetDesignAttribute (IMLContext ctx, string name, string value){ + //store member value in iml + ctx.il.Emit (OpCodes.Ldloc_0); + ctx.il.Emit (OpCodes.Ldfld, typeof(GraphicObject).GetField("design_iml_values")); + ctx.il.Emit (OpCodes.Ldstr, name); + if (string.IsNullOrEmpty (value)) + ctx.il.Emit (OpCodes.Ldnull); + else + ctx.il.Emit (OpCodes.Ldstr, value); + ctx.il.Emit (OpCodes.Call, CompilerServices.miDicStrStrAdd); + } + #endif + /// <summary> /// process styling, attributes and children loading. /// </summary> @@ -360,12 +408,34 @@ namespace Crow.IML using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) { reader.Read (); + #if DESIGN_MODE + IXmlLineInfo li = (IXmlLineInfo)reader; + ctx.il.Emit (OpCodes.Ldloc_0); + ctx.il.Emit (OpCodes.Ldstr, this.NextDesignID); + ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_id")); + ctx.il.Emit (OpCodes.Ldloc_0); + ctx.il.Emit (OpCodes.Ldc_I4, ctx.curLine + li.LineNumber); + ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_line")); + ctx.il.Emit (OpCodes.Ldloc_0); + ctx.il.Emit (OpCodes.Ldc_I4, li.LinePosition); + ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_column")); + if (!string.IsNullOrEmpty (sourcePath)) { + ctx.il.Emit (OpCodes.Ldloc_0); + ctx.il.Emit (OpCodes.Ldstr, sourcePath); + ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_imlPath")); + } + #endif + #region Styling and default values loading //first check for Style attribute then trigger default value loading if (reader.HasAttributes) { string style = reader.GetAttribute ("Style"); - if (!string.IsNullOrEmpty (style)) + if (!string.IsNullOrEmpty (style)){ CompilerServices.EmitSetValue (ctx.il, CompilerServices.piStyle, style); + #if DESIGN_MODE + emitSetDesignAttribute (ctx, "Style", style); + #endif + } } ctx.il.Emit (OpCodes.Ldloc_0); ctx.il.Emit (OpCodes.Callvirt, CompilerServices.miLoadDefaultVals); @@ -378,6 +448,10 @@ namespace Crow.IML if (reader.Name == "Style") continue; + #if DESIGN_MODE + emitSetDesignAttribute (ctx, reader.Name, reader.Value); + #endif + MemberInfo mi = ctx.CurrentNodeType.GetMember (reader.Name).FirstOrDefault (); if (mi == null) throw new Exception ("Member '" + reader.Name + "' not found in " + ctx.CurrentNodeType.Name); diff --git a/src/Interface.cs b/src/Interface.cs index 8c3792d5..cc62a1aa 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -67,6 +67,10 @@ namespace Crow { #region CTOR static Interface(){ + if (Type.GetType ("Mono.Runtime") == null) { + throw new Exception (@"C.R.O.W. run only on Mono, download latest version at: http://www.mono-project.com/download/stable/"); + } + CrowConfigRoot = System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @@ -84,9 +88,6 @@ namespace Crow } } - loadCursors (); - findAvailableTemplates (); - FontRenderingOptions = new FontOptions (); FontRenderingOptions.Antialias = Antialias.Subpixel; FontRenderingOptions.HintMetrics = HintMetrics.On; @@ -94,13 +95,18 @@ namespace Crow FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb; } public Interface(){ - CurrentInterface = this; CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + } + #endregion + + public void Init () { + CurrentInterface = this; + loadCursors (); loadStyling (); + findAvailableTemplates (); initTooltip (); initContextMenus (); } - #endregion #region Static and constants /// <summary> @@ -121,7 +127,7 @@ namespace Crow public static int DeviceRepeatInterval = 40; /// <summary>Tabulation size in Text controls</summary> public static int TabSize = 4; - public static string LineBreak = "\r\n"; + public static string LineBreak = "\n"; /// <summary> Allow rendering of interface in development environment </summary> public static bool DesignerMode = false; /// <summary> Disable caching for a widget if this threshold is reached </summary> @@ -206,10 +212,19 @@ namespace Crow /// <summary>each IML and fragments (such as inline Templates) are compiled as a Dynamic Method stored here /// on the first instance creation of a IML item. /// </summary> - public static Dictionary<String, Instantiator> Instantiators = new Dictionary<string, Instantiator>(); + public Dictionary<String, Instantiator> Instantiators = new Dictionary<string, Instantiator>(); public List<CrowThread> CrowThreads = new List<CrowThread>();//used to monitor thread finished public DragDropEventArgs DragAndDropOperation = null; + public Surface DragImage = null; + public int DragImageWidth, DragImageHeight, DragImageX, DragImageY; + public void ClearDragImage () { + lock (UpdateMutex) { + clipping.UnionRectangle(new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight)); + DragImage.Dispose(); + DragImage = null; + } + } #endregion #region Private Fields @@ -250,22 +265,22 @@ namespace Crow .GetManifestResourceNames () .Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) { using (Stream stream = assembly.GetManifestResourceStream (s)) { - new StyleReader (this, stream, s); + new StyleReader (this.Styling, stream, s); } } } - static void loadCursors(){ + void loadCursors(){ //Load cursors - XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[0]; - XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[0]; - XCursor.NW = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0]; - XCursor.NE = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0]; - XCursor.SW = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0]; - XCursor.SE = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0]; - XCursor.H = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0]; - XCursor.V = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0]; - XCursor.Text = XCursorFile.Load("#Crow.Images.Icons.Cursors.ibeam").Cursors[0]; + XCursor.Cross = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.cross").Cursors[0]; + XCursor.Default = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.arrow").Cursors[0]; + XCursor.NW = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0]; + XCursor.NE = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0]; + XCursor.SW = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0]; + XCursor.SE = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0]; + XCursor.H = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0]; + XCursor.V = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0]; + XCursor.Text = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.ibeam").Cursors[0]; } #endregion @@ -274,16 +289,17 @@ namespace Crow /// Resource ID must be 'fullClassName.template' (not case sensitive) /// Those found in application assembly have priority to the default Crow's one /// </summary> - public static Dictionary<string, string> DefaultTemplates = new Dictionary<string, string>(); + public Dictionary<string, string> DefaultTemplates; /// <summary>Finds available default templates at startup</summary> - static void findAvailableTemplates(){ + void findAvailableTemplates(){ + DefaultTemplates = new Dictionary<string, string>(); searchTemplatesOnDisk ("./"); string defTemplatePath = System.IO.Path.Combine (CrowConfigRoot, "defaultTemplates"); searchTemplatesOnDisk (defTemplatePath); searchTemplatesIn (Assembly.GetEntryAssembly ()); searchTemplatesIn (Assembly.GetExecutingAssembly ()); } - static void searchTemplatesOnDisk (string templatePath){ + void searchTemplatesOnDisk (string templatePath){ if (!Directory.Exists (templatePath)) return; foreach (string f in Directory.GetFiles(templatePath, "*.template",SearchOption.AllDirectories)) { @@ -293,7 +309,7 @@ namespace Crow DefaultTemplates [clsName] = f; } } - static void searchTemplatesIn(Assembly assembly){ + void searchTemplatesIn(Assembly assembly){ if (assembly == null) return; foreach (string resId in assembly @@ -312,7 +328,28 @@ namespace Crow /// <returns>A file or resource stream</returns> /// <param name="path">This could be a normal file path, or an embedded ressource ID /// Resource ID's must be prefixed with '#' character</param> - public static Stream GetStreamFromPath (string path) + public virtual Stream GetStreamFromPath (string path) + { + Stream stream = null; + + if (path.StartsWith ("#")) { + string resId = path.Substring (1); + //try/catch added to prevent nunit error + try { + stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); + } catch{} + if (stream == null)//try to find ressource in Crow assembly + stream = System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId); + if (stream == null) + throw new Exception ("Resource not found: " + path); + } else { + if (!File.Exists (path)) + throw new FileNotFoundException ("File not found: ", path); + stream = new FileStream (path, FileMode.Open, FileAccess.Read); + } + return stream; + } + public static Stream StaticGetStreamFromPath (string path) { Stream stream = null; @@ -340,12 +377,20 @@ namespace Crow /// <param name="imlFragment">a valid IML string</param> public GraphicObject LoadIMLFragment (string imlFragment) { lock (UpdateMutex) { - GraphicObject tmp = Instantiator.CreateFromImlFragment (imlFragment).CreateInstance(this); + GraphicObject tmp = CreateITorFromIMLFragment (imlFragment).CreateInstance(); AddWidget (tmp); return tmp; } } /// <summary> + /// Add the content of the IML fragment to the graphic tree of this interface + /// </summary> + /// <returns>return the new instance for convenience, may be ignored</returns> + /// <param name="imlFragment">a valid IML string</param> + public Instantiator CreateITorFromIMLFragment (string imlFragment) { + return Instantiator.CreateFromImlFragment (this, imlFragment); + } + /// <summary> /// Create an instance of a GraphicObject and add it to the GraphicTree of this Interface /// </summary> /// <returns>new instance of graphic object created</returns> @@ -363,45 +408,33 @@ namespace Crow /// </summary> /// <returns>new instance of graphic object created</returns> /// <param name="path">path of the iml file to load</param> - public GraphicObject Load (string path) + public virtual GraphicObject Load (string path) { - //try { - return GetInstantiator (path).CreateInstance (this); - //} catch (Exception ex) { - // throw new Exception ("Error loading <" + path + ">:", ex); - //} + try { + return GetInstantiator (path).CreateInstance (); + } catch (Exception ex) { + throw new Exception ("Error loading <" + path + ">:", ex); + } } /// <summary> /// Fetch instantiator from cache or create it. /// </summary> /// <returns>new Instantiator</returns> /// <param name="path">path of the iml file to load</param> - public static Instantiator GetInstantiator(string path){ + public Instantiator GetInstantiator(string path){ if (!Instantiators.ContainsKey(path)) - Instantiators [path] = new Instantiator(path); + Instantiators [path] = new Instantiator(this, path); return Instantiators [path]; } /// <summary>Item templates are derived from instantiator, this function /// try to fetch the requested one in the cache or create it. /// They have additional properties for recursivity and /// custom display per item type</summary> - public static ItemTemplate GetItemTemplate(string path){ + public virtual ItemTemplate GetItemTemplate(string path){ if (!Instantiators.ContainsKey(path)) - Instantiators [path] = new ItemTemplate(path); + Instantiators [path] = new ItemTemplate(this, path); return Instantiators [path] as ItemTemplate; } - //TODO: .Net xml serialisation is no longer used, it has been replaced with instantiators - public static void Save<T> (string file, T graphicObject) - { - XmlSerializerNamespaces xn = new XmlSerializerNamespaces (); - xn.Add ("", ""); - XmlSerializer xs = new XmlSerializer (typeof(T)); - - xs = new XmlSerializer (typeof(T)); - using (Stream s = new FileStream (file, FileMode.Create)) { - xs.Serialize (s, graphicObject, xn); - } - } #endregion #region focus @@ -443,13 +476,22 @@ namespace Crow set { if (_hoverWidget == value) return; + + if (_hoverWidget != null) + _hoverWidget.IsHover = false; + _hoverWidget = value; - #if DEBUG_FOCUS + if (_hoverWidget != null) - Debug.WriteLine("Hover => " + _hoverWidget.ToString()); - else - Debug.WriteLine("Hover => null"); - #endif + { + _hoverWidget.IsHover = true; + #if DEBUG_FOCUS + Debug.WriteLine("Hover => " + _hoverWidget.ToString()); + }else + Debug.WriteLine("Hover => null"); + #else + } + #endif } } /// <summary>Widget has the keyboard or mouse focus</summary> @@ -508,15 +550,7 @@ namespace Crow } } } - if (keyboardRepeatCount > 0) { - int mc = keyboardRepeatCount; - keyboardRepeatCount -= mc; - if (_focusedWidget != null) { - for (int i = 0; i < mc; i++) { - _focusedWidget.onKeyDown (this, lastKeyDownEvt); - } - } - } + CrowThread[] tmpThreads; lock (CrowThreads) { tmpThreads = new CrowThread[CrowThreads.Count]; @@ -556,7 +590,7 @@ namespace Crow /// <summary>Layouting loop, this is the first step of the udpate and process registered /// Layouting queue items. Failing LQI's are requeued in this cycle until MaxTry is reached which /// trigger an enqueue for the next Update Cycle</summary> - void processLayouting(){ + protected virtual void processLayouting(){ #if MEASURE_TIME layoutingMeasure.StartCycle(); #endif @@ -608,12 +642,15 @@ namespace Crow #if MEASURE_TIME drawingMeasure.StartCycle(); #endif + if (DragImage != null) + clipping.UnionRectangle(new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight)); using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) { using (ctx = new Context (surf)){ if (!clipping.IsEmpty) { for (int i = 0; i < clipping.NumRectangles; i++) ctx.Rectangle(clipping.GetRectangle(i)); + ctx.ClipPreserve(); ctx.Operator = Operator.Clear; ctx.Fill(); @@ -631,6 +668,22 @@ namespace Crow ctx.Restore (); } + if (DragAndDropOperation != null) { + if (DragImage != null) { + DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); + DragImageX = Mouse.X - DragImageWidth / 2; + DragImageY = Mouse.Y - DragImageHeight / 2; + ctx.Save (); + ctx.ResetClip (); + ctx.SetSourceSurface (DragImage, DragImageX, DragImageY); + ctx.PaintWithAlpha (0.8); + ctx.Restore (); + DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); + IsDirty = true; + //Console.WriteLine ("dragimage drawn: {0},{1}", DragImageX, DragImageY); + } + } + #if DEBUG_CLIP_RECTANGLE clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5)); #endif @@ -829,13 +882,16 @@ namespace Crow MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY); e.Mouse = Mouse; - if (ActiveWidget != null&& DragAndDropOperation == null) { + if (ActiveWidget != null && DragAndDropOperation == null) { //TODO, ensure object is still in the graphic tree //send move evt even if mouse move outside bounds ActiveWidget.onMouseMove (this, e); return true; } + if (DragAndDropOperation != null)//drag source cant have hover event, so move has to be handle here + DragAndDropOperation.DragSource.onMouseMove (this, e); + if (HoverWidget != null) { resetTooltip (); //check topmost graphicobject first @@ -843,7 +899,7 @@ namespace Crow GraphicObject topc = null; while (tmp is GraphicObject) { topc = tmp; - tmp = tmp.LogicalParent as GraphicObject; + tmp = tmp.focusParent; } int idxhw = GraphicTree.IndexOf (topc); if (idxhw != 0) { @@ -995,9 +1051,9 @@ namespace Crow lastKeyDownEvt.IsRepeat = true; _focusedWidget.onKeyDown (this, e); - keyboardRepeatThread = new Thread (keyboardRepeatThreadFunc); - keyboardRepeatThread.IsBackground = true; - keyboardRepeatThread.Start (); +// keyboardRepeatThread = new Thread (keyboardRepeatThreadFunc); +// keyboardRepeatThread.IsBackground = true; +// keyboardRepeatThread.Start (); return true; } @@ -1014,11 +1070,11 @@ namespace Crow _focusedWidget.onKeyUp (this, e); - if (keyboardRepeatThread != null) { - keyboardRepeatOn = false; - keyboardRepeatThread.Abort(); - keyboardRepeatThread.Join (); - } +// if (keyboardRepeatThread != null) { +// keyboardRepeatOn = false; +// keyboardRepeatThread.Abort(); +// keyboardRepeatThread.Join (); +// } return true; } /// <summary> @@ -1040,7 +1096,7 @@ namespace Crow GraphicObject ToolTipContainer = null; volatile bool tooltipVisible = false; - void initTooltip () { + protected void initTooltip () { ToolTipContainer = Load ("#Crow.Tooltip.template"); Thread t = new Thread (toolTipThreadFunc); t.IsBackground = true; @@ -1081,22 +1137,38 @@ namespace Crow #region Contextual menu MenuItem ctxMenuContainer; - void initContextMenus (){ + protected void initContextMenus (){ ctxMenuContainer = Load ("#Crow.ContextMenu.template") as MenuItem; + ctxMenuContainer.LayoutChanged += CtxMenuContainer_LayoutChanged; + } + + void CtxMenuContainer_LayoutChanged (object sender, LayoutingEventArgs e) + { + Rectangle r = ctxMenuContainer.ScreenCoordinates (ctxMenuContainer.Slot); + if (e.LayoutType == LayoutingType.Width || e.LayoutType == LayoutingType.X) { + if (r.Right > this.clientRectangle.Right) + ctxMenuContainer.Left = this.clientRectangle.Right - ctxMenuContainer.Slot.Width; + }else if (e.LayoutType == LayoutingType.Width || e.LayoutType == LayoutingType.Y) { + if (r.Bottom > this.clientRectangle.Bottom) + ctxMenuContainer.Top = this.clientRectangle.Bottom - ctxMenuContainer.Slot.Height; + } + } public void ShowContextMenu (GraphicObject go) { - if (ctxMenuContainer.Parent == null) - this.AddWidget (ctxMenuContainer); - else - ctxMenuContainer.IsOpened = true; + lock (UpdateMutex) { + if (ctxMenuContainer.Parent == null) + this.AddWidget (ctxMenuContainer); + else + ctxMenuContainer.IsOpened = true; - ctxMenuContainer.isPopup = true; - ctxMenuContainer.LogicalParent = go; - ctxMenuContainer.DataSource = go; + ctxMenuContainer.isPopup = true; + ctxMenuContainer.LogicalParent = go; + ctxMenuContainer.DataSource = go; - PutOnTop (ctxMenuContainer, true); + PutOnTop (ctxMenuContainer, true); + } ctxMenuContainer.Left = Mouse.X - 5; ctxMenuContainer.Top = Mouse.Y - 5; diff --git a/src/ItemTemplate.cs b/src/ItemTemplate.cs index 5ede1d94..dda9d152 100644 --- a/src/ItemTemplate.cs +++ b/src/ItemTemplate.cs @@ -48,6 +48,48 @@ namespace Crow /// /// </summary> public class ItemTemplate : Instantiator { + #if DESIGN_MODE + public void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem){ + if (sourcePath == "#Crow.DefaultItem.template") + return; + + XmlElement xe = doc.CreateElement("ItemTemplate"); + XmlAttribute xa = null; + + if (string.IsNullOrEmpty (sourcePath)) { + //inline item template + using (GraphicObject go = this.CreateInstance()) + go.getIML (doc, xe); + } else { + xa = doc.CreateAttribute ("Path"); + xa.Value = sourcePath; + xe.Attributes.Append (xa); + } + + if (strDataType != "default") { + xa = doc.CreateAttribute ("DataType"); + xa.Value = strDataType; + xe.Attributes.Append (xa); + + if (dataTest != "TypeOf"){ + xa = doc.CreateAttribute ("DataTest"); + xa.Value = dataTest; + xe.Attributes.Append (xa); + } + } + + if (!string.IsNullOrEmpty(fetchMethodName)){ + xa = doc.CreateAttribute ("Data"); + xa.Value = fetchMethodName; + xe.Attributes.Append (xa); + } + + parentElem.AppendChild (xe); + + + } + #endif + public EventHandler Expand; public BooleanTestOnInstance HasSubItems; string strDataType; @@ -61,8 +103,8 @@ namespace Crow /// <param name="path">IML file to parse</param> /// <param name="_dataType">type this item will be choosen for, or member of the data item</param> /// <param name="_fetchDataMethod">for hierarchical data, method to call for children fetching</param> - public ItemTemplate(string path, string _dataTest = "TypeOf", string _dataType = null, string _fetchDataMethod = null) - : base(path) { + public ItemTemplate(Interface _iface, string path, string _dataTest = "TypeOf", string _dataType = "default", string _fetchDataMethod = null) + : base(_iface, path) { strDataType = _dataType; fetchMethodName = _fetchDataMethod; dataTest = _dataTest; @@ -74,8 +116,8 @@ namespace Crow /// <param name="path">IML fragment to parse</param> /// <param name="_dataType">type this item will be choosen for, or member of the data item</param> /// <param name="_fetchDataMethod">for hierarchical data, method to call for children fetching</param> - public ItemTemplate (Stream ImlFragment, string _dataTest, string _dataType, string _fetchDataMethod) - :base(ImlFragment) + public ItemTemplate (Interface _iface, Stream ImlFragment, string _dataTest, string _dataType, string _fetchDataMethod) + :base(_iface, ImlFragment) { strDataType = _dataType; fetchMethodName = _fetchDataMethod; @@ -87,8 +129,8 @@ namespace Crow /// <param name="path">XML reader positionned before or at the root node</param> /// <param name="_dataType">type this item will be choosen for, or member of the data item</param> /// <param name="_fetchDataMethod">for hierarchical data, method to call for children fetching</param> - public ItemTemplate (XmlReader reader, string _dataTest = "TypeOf" , string _dataType = null, string _fetchDataMethod = null) - :base(reader) + public ItemTemplate (Interface _iface, XmlReader reader, string _dataTest = "TypeOf" , string _dataType = null, string _fetchDataMethod = null) + :base(_iface, reader) { strDataType = _dataType; fetchMethodName = _fetchDataMethod; @@ -251,6 +293,9 @@ namespace Crow il.Emit (OpCodes.Callvirt, miGetDatas); } + + + } } diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs index ba2f95af..7efdf1bc 100644 --- a/src/LayoutingQueueItem.cs +++ b/src/LayoutingQueueItem.cs @@ -98,10 +98,10 @@ namespace Crow public void ProcessLayouting() { GraphicObject go = Layoutable as GraphicObject; - if (go == null) { - Debug.WriteLine ("ERROR: processLayouting on something else than a graphic object: " + this.ToString ()); - return; - } +// if (go == null) { +// Debug.WriteLine ("ERROR: processLayouting on something else than a graphic object: " + this.ToString ()); +// return; +// } go.parentRWLock.EnterReadLock (); @@ -125,7 +125,7 @@ namespace Crow #endif if (LayoutingTries < Interface.MaxLayoutingTries) { Layoutable.RegisteredLayoutings |= LayoutType; - (Layoutable as GraphicObject).CurrentInterface.LayoutingQueue.Enqueue (this); + (Layoutable as GraphicObject).IFace.LayoutingQueue.Enqueue (this); } else if (DiscardCount < Interface.MaxDiscardCount) { #if DEBUG_LAYOUTING Debug.WriteLine ("\t\tDiscarded"); @@ -133,18 +133,18 @@ namespace Crow LayoutingTries = 0; DiscardCount++; Layoutable.RegisteredLayoutings |= LayoutType; - (Layoutable as GraphicObject).CurrentInterface.DiscardQueue.Enqueue (this); + (Layoutable as GraphicObject).IFace.DiscardQueue.Enqueue (this); } - #if DEBUG_LAYOUTING +// #if DEBUG_LAYOUTING else Debug.WriteLine ("\tDELETED => " + this.ToString ()); - #endif +// #endif } - #if DEBUG_LAYOUTING else{ if (LayoutingTries > 2 || DiscardCount > 0) Debug.WriteLine (this.ToString ()); } + #if DEBUG_LAYOUTING LQITime.Stop(); #endif go.parentRWLock.ExitReadLock (); diff --git a/src/Measure.cs b/src/Measure.cs index c88038c6..0374f5d9 100644 --- a/src/Measure.cs +++ b/src/Measure.cs @@ -69,6 +69,7 @@ namespace Crow /// </summary> public bool IsFixed { get { return Units == Unit.Pixel; }} public bool IsFit { get { return Value == -1 && Units == Unit.Percent; }} + public bool IsRelativeToParent { get { return Value >= 0 && Units == Unit.Percent; }} #region Operators public static implicit operator int(Measure m){ return m.Value; diff --git a/src/ObservableList.cs b/src/ObservableList.cs index c3d49e23..96bfccc9 100644 --- a/src/ObservableList.cs +++ b/src/ObservableList.cs @@ -37,6 +37,7 @@ namespace Crow ListAdd.Raise (this, new ListChangedEventArg (this.Count - 1, elem)); } public void RemoveElement (T elem) { + System.Diagnostics.Debug.WriteLine ("remove elem:" + elem); int idx = this.IndexOf (elem); this.RemoveAt (idx); ListRemove.Raise (this, new ListChangedEventArg (idx, elem)); diff --git a/src/ParsingException.cs b/src/ParsingException.cs new file mode 100644 index 00000000..1b596981 --- /dev/null +++ b/src/ParsingException.cs @@ -0,0 +1,30 @@ +using System; + +namespace Crow.Coding +{ + public class ParserException : Exception + { + public int Line; + public int Column; + public string Source; + public ParserException(int line, int column, string txt, string source = null) + : base(txt) + { + Line = line; + Column = column; + Source = source; + } + public ParserException(int line, int column, string txt, Exception innerException, string source = null) + : base(txt, innerException) + { + Line = line; + Column = column; + Source = source; + } + public override string ToString () + { + return string.Format("{3}:({0},{1}): {2}", Line, Column, Message, Source); + } + } +} + diff --git a/src/Picture.cs b/src/Picture.cs index fe7007c7..3784780b 100644 --- a/src/Picture.cs +++ b/src/Picture.cs @@ -87,7 +87,7 @@ namespace Crow /// <param name="path">image path, may be embedded</param> public Picture (string path) { - Load (path); + Path = path; } #endregion @@ -96,7 +96,7 @@ namespace Crow /// load the image for rendering from the stream given as argument /// </summary> /// <param name="stream">picture stream</param> - public abstract void Load(string path); + public abstract void Load(Interface iface, string path); #endregion /// <summary> @@ -117,11 +117,9 @@ namespace Crow Picture _pic = null; if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture)) - _pic = new SvgPicture (); + _pic = new SvgPicture (path); else - _pic = new BmpPicture (); - - _pic.Load (path); + _pic = new BmpPicture (path); return _pic; } @@ -139,11 +137,9 @@ namespace Crow Picture _pic = null; if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture)) - _pic = new SvgPicture (); + _pic = new SvgPicture (path); else - _pic = new BmpPicture (); - - _pic.Load (path); + _pic = new BmpPicture (path); return _pic; } diff --git a/src/Rectangle.cs b/src/Rectangle.cs index 8f48d06d..56e4148f 100644 --- a/src/Rectangle.cs +++ b/src/Rectangle.cs @@ -124,6 +124,14 @@ namespace Crow { Inflate (delta, delta); } + public Rectangle Inflated (int delta) { + return Inflated (delta,delta); + } + public Rectangle Inflated (int deltaX, int deltaY) { + Rectangle r = this; + r.Inflate (deltaX, deltaY); + return r; + } public bool ContainsOrIsEqual(Point p) { return (p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height) ? diff --git a/src/Size.cs b/src/Size.cs index ccd1ab31..891c1fb5 100644 --- a/src/Size.cs +++ b/src/Size.cs @@ -163,6 +163,14 @@ namespace Crow { return new Size(s.Width + i, s.Height + i); } + public static Size operator *(Size s, int i) + { + return new Size(s.Width * i, s.Height * i); + } + public static Size operator /(Size s, int i) + { + return new Size(s.Width / i, s.Height / i); + } #endregion public override int GetHashCode () diff --git a/src/Style.cs b/src/Style.cs index fded0503..58f09f33 100644 --- a/src/Style.cs +++ b/src/Style.cs @@ -29,12 +29,31 @@ using System.Collections.Generic; namespace Crow { + public struct FileLocation { + public string FilePath; + public int Line; + public int Column; + + public FileLocation(string filePath, int line, int column){ + FilePath = filePath; + Line = line; + Column = column; + } + public override string ToString () + { + return string.Format ("{0} ({1},{2})", FilePath, Line, Column); + } + } public class Style : Dictionary<string, object> { - public Dictionary<string, Style> SubStyles;//TODO:implement substyles for all tags inside a style + #if DESIGN_MODE + public Dictionary<string, FileLocation> Locations = new Dictionary<string, FileLocation>(); + #endif + //public Dictionary<string, Style> SubStyles;//TODO:implement substyles for all tags inside a style public Style () : base() { } + } } diff --git a/src/StyleReader.cs b/src/StyleReader.cs index 26037091..458b7856 100644 --- a/src/StyleReader.cs +++ b/src/StyleReader.cs @@ -28,6 +28,8 @@ using System; using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Text.RegularExpressions; +using Crow.Coding; namespace Crow { @@ -37,150 +39,162 @@ namespace Crow //TODO: style key shared by different class may use only first encouneter class setter, which can cause bug. public class StyleReader : StreamReader { - enum readerState { classNames, propertyName, expression } - readerState state = readerState.classNames; - string resourceId; + enum States { init, classNames, members, value, endOfStatement } + + States curState = States.init; + int column = 1; int line = 1; - public StyleReader (Interface iface, Stream stream, string resId) - : base(stream) + #region Character ValidityCheck + static Regex rxValidChar = new Regex(@"\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\p{Cf}"); + static Regex rxNameStartChar = new Regex(@"_|\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}"); + static Regex rxNameChar = new Regex(@"\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\p{Cf}"); + static Regex rxDecimal = new Regex(@"[0-9]+"); + static Regex rxHexadecimal = new Regex(@"[0-9a-fA-F]+"); + + public bool nextCharIsValidCharStartName { - resourceId = resId; + get { return rxNameStartChar.IsMatch(new string(new char[]{PeekChar()})); } + } + public bool nextCharIsValidCharName + { + get { return rxNameChar.IsMatch(new string(new char[]{PeekChar()})); } + } + #endregion + + char ReadChar () { + column++; + return (Char)Read(); + } + char PeekChar () { + return (Char)Peek(); + } + void SkipWhiteSpaceAndLineBreak (){ + while (!EndOfStream){ + if (!PeekChar ().IsWhiteSpaceOrNewLine ()) + break; + if (ReadChar () == '\n') { + line++; + column = 0; + } + } + } + + public StyleReader (Dictionary<string, Style> styling, Stream stream, string resId) + : base(stream) + { string styleKey = resId.Substring (0, resId.Length - 6); string token = ""; List<string> targetsClasses = new List<string> (); string currentProperty = ""; - int curlyBracketCount = 0; - while (!EndOfStream) { - char c = (Char)Read (); - if (c == '/' && !EndOfStream) { - if ((char)Peek () == '/') {//process comment, skip until newline - ReadLine (); - continue; - } - } - switch (state) { - case readerState.classNames: - if (c.IsWhiteSpaceOrNewLine () || c == ',' || c == '{') { - if (!string.IsNullOrEmpty (token)) - targetsClasses.Add (token); - if (c == '{') - state = readerState.propertyName; - token = ""; - }else if (c=='='){ - //this file contains only properties, - //resource Id (minus .style extention) will determine the single target class - if (targetsClasses.Count > 1) - throwParserException ("Unexpected token '='"); - else if (targetsClasses.Count == 1) { - if (!string.IsNullOrEmpty (token)) - throwParserException ("Unexpected token '='"); - currentProperty = targetsClasses [0]; - targetsClasses [0] = styleKey; - }else{ - if (string.IsNullOrEmpty (token)) - throwParserException ("Unexpected token '='"); - targetsClasses.Add (styleKey); - currentProperty = token; - token = ""; - } - state = readerState.expression; - }else - token += c; + SkipWhiteSpaceAndLineBreak (); + if (EndOfStream) break; - case readerState.propertyName: - if (c.IsWhiteSpaceOrNewLine () || c == '=') { - if (!string.IsNullOrEmpty (token)) - currentProperty = token; - if (c == '=') - state = readerState.expression; - token = ""; - }else if (c == '}'){ - if (!string.IsNullOrEmpty (token)) - throwParserException ("Unexpected token '" + c + "'"); - targetsClasses = new List<string> (); - currentProperty = ""; - state = readerState.classNames; - } else - token += c; + switch (Peek()) { + case '/': + ReadChar (); + if (PeekChar () != '/') + throw new ParserException (line, column, "Unexpected char '/'", resId); + ReadLine (); + break; + case ',': + ReadChar (); + if (!(curState == States.init || curState == States.classNames) || string.IsNullOrEmpty (token)) + throw new ParserException (line, column, "Unexpected char ','", resId); + targetsClasses.Add (token); + token = ""; + curState = States.classNames; + break; + case '{': + ReadChar (); + if (!(curState == States.init || curState == States.classNames) || string.IsNullOrEmpty (token)) + throw new ParserException (line, column, "Unexpected char '{'", resId); + targetsClasses.Add (token); + token = ""; + curState = States.members; break; - case readerState.expression: - bool expressionIsFinished = false; - if (curlyBracketCount == 0) { - if (c == '{'){ - if (!string.IsNullOrEmpty(token.Trim())) - throwParserException ("Unexpected token '{'"); - curlyBracketCount++; - token = "{"; - }else if (c == '}') - throwParserException ("Unexpected token '{'"); - else if (c == ';') { - expressionIsFinished = true; - } else - token += c; - } else { - if (c == '{') - curlyBracketCount++; - else if (c == '}') { - curlyBracketCount--; - if (curlyBracketCount == 0) - expressionIsFinished = true; + case '}': + ReadChar (); + if (curState != States.members) + throw new ParserException (line, column, "Unexpected char '}'", resId); + curState = States.classNames; + targetsClasses.Clear (); + break; + case '=': + ReadChar (); + if (!(curState == States.init || curState == States.members)) + throw new ParserException (line, column, "Unexpected char '='", resId); + currentProperty = token; + token = ""; + curState = States.value; + break; + case '"': + if (curState != States.value) + throw new ParserException (line, column, "Unexpected char '\"'", resId); + ReadChar (); + + while (!EndOfStream) { + char c = PeekChar(); + if (c == '\"') { + ReadChar (); + break; } - token += c; + token += ReadChar(); + if (c == '\\' && !EndOfStream) + token += ReadChar(); + } + curState = States.endOfStatement; + break; + case ';': + if (curState != States.endOfStatement) + throw new ParserException (line, column, "Unexpected end of statement", resId); + ReadChar (); + foreach (string tc in targetsClasses) { + if (!styling.ContainsKey (tc)) + styling [tc] = new Style (); + else if (styling [tc].ContainsKey (currentProperty)) + continue; + styling [tc] [currentProperty] = token; + #if DESIGN_MODE + styling [tc].Locations[currentProperty] = new FileLocation(resId, line,column); + #endif + //System.Diagnostics.Debug.WriteLine ("Style: {3} : {0}.{1} = {2}", tc, currentProperty, token, resId); } - if (expressionIsFinished) { - if (!string.IsNullOrEmpty (token)) { - string expression = token.Trim (); + token = ""; + curState = States.members; + break; + default: + if (curState == States.value) + throw new ParserException (line, column, "expecting value enclosed in '\"'", resId); + if (curState == States.endOfStatement) + throw new ParserException (line, column, "expecting end of statement", resId); - foreach (string tc in targetsClasses) { - if (!iface.Styling.ContainsKey (tc)) - iface.Styling [tc] = new Style (); - else if (iface.Styling [tc].ContainsKey (currentProperty)) - continue; - iface.Styling [tc] [currentProperty] = expression; - } - token = ""; - } - //allow omiting ';' if curly bracket close expression - while (!EndOfStream) { - if (Char.IsWhiteSpace((char)Peek())) - Read(); - else - break; - } - if (this.Peek () == ';') - this.Read (); - state = readerState.propertyName; + if (nextCharIsValidCharStartName) { + token += ReadChar(); + while (nextCharIsValidCharName) + token += ReadChar(); } break; } } - - if (curlyBracketCount > 0) - throwParserException ("Unexpected end of file"); } - public override int Read () - { - int tmp = base.Read (); - char c = (char)tmp; - if (c == '\n') { - line++; - column = 1; - } else if (c == '\t') - column += Interface.TabSize; - else if (c != '\r') - column++; - return tmp; - } - - void throwParserException(string message){ - throw new Exception (string.Format ("Style Reader Exception ({0},{1}): {2} in {3}.", - line, column, message, resourceId)); - } +// public override int Read () +// { +// int tmp = base.Read (); +// char c = (char)tmp; +// if (c == '\n') { +// line++; +// column = 1; +// } else if (c == '\t') +// column += Interface.TabSize; +// else if (c != '\r') +// column++; +// return tmp; +// } } } diff --git a/src/SvgPicture.cs b/src/SvgPicture.cs index 01aaeb5f..f676a497 100644 --- a/src/SvgPicture.cs +++ b/src/SvgPicture.cs @@ -51,7 +51,7 @@ namespace Crow {} #endregion - public override void Load (string path) + public override void Load (Interface iface, string path) { Path = path; if (sharedResources.ContainsKey (path)) { @@ -60,7 +60,7 @@ namespace Crow Dimensions = sp.Dims; return; } - using (Stream stream = Interface.GetStreamFromPath (path)) { + using (Stream stream = iface.GetStreamFromPath (path)) { using (MemoryStream ms = new MemoryStream ()) { stream.CopyTo (ms); @@ -71,6 +71,11 @@ namespace Crow sharedResources [path] = new sharedPicture (hSVG, Dimensions); } + public void LoadSvgFragment (string fragment) { + hSVG = new Rsvg.Handle (System.Text.Encoding.Unicode.GetBytes(fragment)); + Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height); + } + #region implemented abstract members of Fill public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle)) @@ -112,6 +117,8 @@ namespace Crow /// <param name="subPart">limit rendering to svg part named 'subPart'</param> public override void Paint (Context gr, Rectangle rect, string subPart = "") { + if (hSVG == null) + return; float widthRatio = 1f; float heightRatio = 1f; diff --git a/src/XCursor.cs b/src/XCursor.cs index 627e2afd..1cca510e 100644 --- a/src/XCursor.cs +++ b/src/XCursor.cs @@ -86,9 +86,9 @@ namespace Crow return tmp; } - public static XCursorFile Load(string path) + public static XCursorFile Load(Interface iface, string path) { - return loadFromStream (Interface.GetStreamFromPath (path)); + return loadFromStream (iface.GetStreamFromPath (path)); } static XCursor imageLoad(BinaryReader sr) |