123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
/* * SystemPens.cs - Implementation of the * "System.Drawing.SystemPens" class. * * Copyright (C) 2003 Southern Storm Software, Pty Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ namespace System.Drawing { public sealed class SystemPens { // Internal state. private static Pen[] systemPens; // Cannot instantiate this class. private SystemPens() {} // Get a pen for a system color. public static Pen FromSystemColor(Color c) { if(c.IsSystemColor) { return GetOrCreatePen(c.ToKnownColor()); } else { throw new ArgumentException(S._("Arg_NotSystemColor")); } } // Get or create a system pen. private static Pen GetOrCreatePen(KnownColor color) { lock(typeof(SystemPens)) { if(systemPens == null) { systemPens = new Pen [((int)(KnownColor.WindowText)) - ((int)(KnownColor.ActiveBorder)) + 1]; } int index = ((int)color) - ((int)(KnownColor.ActiveBorder)); if(systemPens[index] == null) { systemPens[index] = new Pen(new Color(color)); } return systemPens[index]; } } // Standard system brush objects. public static Pen ActiveBorder { get { return GetOrCreatePen(KnownColor.ActiveBorder); } } public static Pen ActiveCaption { get { return GetOrCreatePen(KnownColor.ActiveCaption); } } public static Pen ActiveCaptionText { get { return GetOrCreatePen(KnownColor.ActiveCaptionText); } } public static Pen AppWorkspace { get { return GetOrCreatePen(KnownColor.AppWorkspace); } } public static Pen Control { get { return GetOrCreatePen(KnownColor.Control); } } public static Pen ControlDark { get { return GetOrCreatePen(KnownColor.ControlDark); } } public static Pen ControlDarkDark { get { return GetOrCreatePen(KnownColor.ControlDarkDark); } } public static Pen ControlLight { get { return GetOrCreatePen(KnownColor.ControlLight); } } public static Pen ControlLightLight { get { return GetOrCreatePen(KnownColor.ControlLightLight); } } public static Pen ControlText { get { return GetOrCreatePen(KnownColor.ControlText); } } public static Pen Desktop { get { return GetOrCreatePen(KnownColor.Desktop); } } public static Pen GrayText { get { return GetOrCreatePen(KnownColor.GrayText); } } public static Pen Highlight { get { return GetOrCreatePen(KnownColor.Highlight); } } public static Pen HighlightText { get { return GetOrCreatePen(KnownColor.HighlightText); } } public static Pen HotTrack { get { return GetOrCreatePen(KnownColor.HotTrack); } } public static Pen InactiveBorder { get { return GetOrCreatePen(KnownColor.InactiveBorder); } } public static Pen InactiveCaption { get { return GetOrCreatePen(KnownColor.InactiveCaption); } } public static Pen InactiveCaptionText { get { return GetOrCreatePen(KnownColor.InactiveCaptionText); } } public static Pen Info { get { return GetOrCreatePen(KnownColor.Info); } } public static Pen InfoText { get { return GetOrCreatePen(KnownColor.InfoText); } } public static Pen Menu { get { return GetOrCreatePen(KnownColor.Menu); } } public static Pen MenuText { get { return GetOrCreatePen(KnownColor.MenuText); } } public static Pen ScrollBar { get { return GetOrCreatePen(KnownColor.ScrollBar); } } public static Pen Window { get { return GetOrCreatePen(KnownColor.Window); } } public static Pen WindowFrame { get { return GetOrCreatePen(KnownColor.WindowFrame); } } public static Pen WindowText { get { return GetOrCreatePen(KnownColor.WindowText); } } }; // class SystemPens }; // namespace System.Drawing