Beispiel #1
0
 internal static void Add(ISystemColorTracker obj)
 {
     lock (typeof(SystemColorTracker))
     {
         if (SystemColorTracker.list.Length == SystemColorTracker.count)
         {
             SystemColorTracker.GarbageCollectList();
         }
         if (!SystemColorTracker.addedTracker)
         {
             SystemColorTracker.addedTracker     = true;
             SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(SystemColorTracker.OnUserPreferenceChanged);
         }
         int local_0 = SystemColorTracker.count;
         ++SystemColorTracker.count;
         if (SystemColorTracker.list[local_0] == null)
         {
             SystemColorTracker.list[local_0] = new WeakReference((object)obj);
         }
         else
         {
             SystemColorTracker.list[local_0].Target = (object)obj;
         }
     }
 }
Beispiel #2
0
 private static void GarbageCollectList()
 {
     SystemColorTracker.CleanOutBrokenLinks();
     if ((double)SystemColorTracker.count / (double)SystemColorTracker.list.Length <= (double)SystemColorTracker.EXPAND_THRESHOLD)
     {
         return;
     }
     WeakReference[] weakReferenceArray = new WeakReference[SystemColorTracker.list.Length * SystemColorTracker.EXPAND_FACTOR];
     SystemColorTracker.list.CopyTo((Array)weakReferenceArray, 0);
     SystemColorTracker.list = weakReferenceArray;
     int length = SystemColorTracker.list.Length;
     int num    = SystemColorTracker.WARNING_SIZE;
 }
Beispiel #3
0
        public SolidBrush(Color color)
        {
            _color = color;

            IntPtr nativeBrush;
            int    status = Gdip.GdipCreateSolidFill(_color.ToArgb(), out nativeBrush);

            Gdip.CheckStatus(status);

            SetNativeBrushInternal(nativeBrush);

            if (_color.IsSystemColor)
            {
                SystemColorTracker.Add(this);
            }
        }
        public Pen(System.Drawing.Color color, float width)
        {
            this.color = color;
            IntPtr zero   = IntPtr.Zero;
            int    status = SafeNativeMethods.Gdip.GdipCreatePen1(color.ToArgb(), width, 0, out zero);

            if (status != 0)
            {
                throw SafeNativeMethods.Gdip.StatusException(status);
            }
            this.SetNativePen(zero);
            if (this.color.IsSystemColor)
            {
                SystemColorTracker.Add(this);
            }
        }
Beispiel #5
0
        public Pen(Color color, float width)
        {
            this.color = color;
            IntPtr pen  = IntPtr.Zero;
            int    pen1 = SafeNativeMethods.Gdip.GdipCreatePen1(color.ToArgb(), width, 0, out pen);

            if (pen1 != 0)
            {
                throw SafeNativeMethods.Gdip.StatusException(pen1);
            }
            this.SetNativePen(pen);
            if (!this.color.IsSystemColor)
            {
                return;
            }
            SystemColorTracker.Add((ISystemColorTracker)this);
        }
        public SolidBrush(System.Drawing.Color color)
        {
            this.color = System.Drawing.Color.Empty;
            this.color = color;
            IntPtr zero   = IntPtr.Zero;
            int    status = SafeNativeMethods.Gdip.GdipCreateSolidFill(this.color.ToArgb(), out zero);

            if (status != 0)
            {
                throw SafeNativeMethods.Gdip.StatusException(status);
            }
            base.SetNativeBrushInternal(zero);
            if (color.IsSystemColor)
            {
                SystemColorTracker.Add(this);
            }
        }
Beispiel #7
0
        public SolidBrush(Color color)
        {
            _color = color;

            IntPtr nativeBrush = IntPtr.Zero;
            int    status      = SafeNativeMethods.Gdip.GdipCreateSolidFill(_color.ToArgb(), out nativeBrush);

            SafeNativeMethods.Gdip.CheckStatus(status);

            SetNativeBrushInternal(nativeBrush);

#if FEATURE_SYSTEM_EVENTS
            if (ColorUtil.IsSystemColor(_color))
            {
                SystemColorTracker.Add(this);
            }
#endif
        }
        public SolidBrush(Color color)
        {
            this.color = color;

            IntPtr brush  = IntPtr.Zero;
            int    status = SafeNativeMethods.Gdip.GdipCreateSolidFill(this.color.ToArgb(), out brush);

            if (status != SafeNativeMethods.Gdip.Ok)
            {
                throw SafeNativeMethods.Gdip.StatusException(status);
            }

            SetNativeBrushInternal(brush);

            if (color.IsSystemColor)
            {
                SystemColorTracker.Add(this);
            }
        }
Beispiel #9
0
        private void _SetColor(Color value)
        {
            if (immutable)
            {
                throw new ArgumentException(SR.GetString(SR.CantChangeImmutableObjects, "Pen"));
            }

            Color oldColor = this.color;

            this.color = value;
            InternalSetColor(value);

            // CONSIDER: We never remove pens from the active list, so if someone is
            // changing their pen colors a lot, this could be a problem.
            if (value.IsSystemColor && !oldColor.IsSystemColor)
            {
                SystemColorTracker.Add(this);
            }
        }
Beispiel #10
0
Datei: Pen.cs Projekt: ash2005/z
        public Pen(Color color, float width)
        {
            this.color = color;

            IntPtr pen    = IntPtr.Zero;
            int    status = SafeNativeMethods.Gdip.GdipCreatePen1(color.ToArgb(),
                                                                  width,
                                                                  (int)GraphicsUnit.World,
                                                                  out pen);

            if (status != SafeNativeMethods.Gdip.Ok)
            {
                throw SafeNativeMethods.Gdip.StatusException(status);
            }

            SetNativePen(pen);

            if (this.color.IsSystemColor)
            {
                SystemColorTracker.Add(this);
            }
        }