예제 #1
0
        internal static GoBrushInfo GetBrushInfo(System.Drawing.Brush b)
        {
            GoBrushInfo info3;

            if (b == null)
            {
                return(null);
            }
            lock (DiagramGraph.myDrawers)
            {
                WeakHashRef   ref1       = new WeakHashRef(b);
                WeakReference reference1 = (WeakReference)DiagramGraph.myDrawers[ref1];
                GoBrushInfo   info1      = null;
                if (reference1 != null)
                {
                    if (reference1.IsAlive)
                    {
                        info1 = reference1.Target as GoBrushInfo;
                    }
                    else
                    {
                        DiagramGraph.myDrawers.Remove(ref1);
                    }
                }
                if (info1 == null)
                {
                    info1 = new GoBrushInfo();
                    if (!info1.SetBrush(b))
                    {
                        return(info1);
                    }
                    WeakHashRef ref2 = new WeakHashRef(info1);
                    reference1 = (WeakHashRef)DiagramGraph.myInfos[ref2];
                    if (reference1 != null)
                    {
                        if (reference1.IsAlive)
                        {
                            GoBrushInfo info2 = reference1.Target as GoBrushInfo;
                            if (info2 != null)
                            {
                                return(info2);
                            }
                        }
                        else
                        {
                            DiagramGraph.myInfos.Remove(ref2);
                        }
                    }
                    DiagramGraph.myDrawers[ref1] = new WeakReference(info1);
                    DiagramGraph.myInfos[ref2]   = ref2;
                    DiagramGraph.CleanInfos();
                }
                info3 = info1;
            }
            return(info3);
        }
예제 #2
0
 internal static GoBrushInfo GetBrushInfo(System.Drawing.Brush b)
 {
     GoBrushInfo info3;
     if (b == null)
     {
         return null;
     }
     lock (DiagramGraph.myDrawers)
     {
         WeakHashRef ref1 = new WeakHashRef(b);
         WeakReference reference1 = (WeakReference)DiagramGraph.myDrawers[ref1];
         GoBrushInfo info1 = null;
         if (reference1 != null)
         {
             if (reference1.IsAlive)
             {
                 info1 = reference1.Target as GoBrushInfo;
             }
             else
             {
                 DiagramGraph.myDrawers.Remove(ref1);
             }
         }
         if (info1 == null)
         {
             info1 = new GoBrushInfo();
             if (!info1.SetBrush(b))
             {
                 return info1;
             }
             WeakHashRef ref2 = new WeakHashRef(info1);
             reference1 = (WeakHashRef)DiagramGraph.myInfos[ref2];
             if (reference1 != null)
             {
                 if (reference1.IsAlive)
                 {
                     GoBrushInfo info2 = reference1.Target as GoBrushInfo;
                     if (info2 != null)
                     {
                         return info2;
                     }
                 }
                 else
                 {
                     DiagramGraph.myInfos.Remove(ref2);
                 }
             }
             DiagramGraph.myDrawers[ref1] = new WeakReference(info1);
             DiagramGraph.myInfos[ref2] = ref2;
             DiagramGraph.CleanInfos();
         }
         info3 = info1;
     }
     return info3;
 }