void pillMode(PillMode mode, bool LayoutUpdated = false) { if ((!LayoutUpdated)&&(mode == fMode)) return; fMode = mode; if (mode == PillMode.Hide) { Opacity = 0; return; } Opacity = 1; TBitmapHolder holder; char key=tb.text[0]; Dictionary<PillMode, TBitmapHolder> cachedTm; if (!cachedTb.TryGetValue(key, out cachedTm)) { cachedTm = new Dictionary<PillMode, TBitmapHolder>(); cachedTb.Add(key, cachedTm); } if (!cachedTm.TryGetValue(mode, out holder)) { holder = new TBitmapHolder(); cachedTm.Add(mode, holder); } if(tb.Visibility==Visibility.Collapsed){ if (holder.state == TBitmapHolderState.Updating) { holder.onReady += new EventHandler(OnHolderReady); }else if((holder.state==TBitmapHolderState.Clean)||(holder.bitmap.PixelWidth < ActualWidth)){ holder.state = TBitmapHolderState.Updating; drawOutline(mode); }else{ c2++; img.Source = holder.bitmap; } }else{ if(LayoutUpdated){ holder.bitmap = new WriteableBitmap((int)ActualWidth, (int)ActualHeight); holder.bitmap.Render(tb, null); holder.bitmap.Invalidate(); holder.state = TBitmapHolderState.Ready; if(holder.onReady!=null) holder.onReady.Invoke(null, null); holder.onReady = null; tb.Visibility = Visibility.Collapsed; img.Source = holder.bitmap; } } #if DEBUG System.Diagnostics.Debugger.Log(0, "", c1.ToString() + "/" + c2.ToString() + "\n"); #endif }
void pillMode(PillMode mode, bool LayoutUpdated = false) { if ((!LayoutUpdated) && (mode == fMode)) { return; } fMode = mode; if (mode == PillMode.Hide) { Opacity = 0; return; } Opacity = 1; TBitmapHolder holder; char key = tb.text[0]; Dictionary <PillMode, TBitmapHolder> cachedTm; if (!cachedTb.TryGetValue(key, out cachedTm)) { cachedTm = new Dictionary <PillMode, TBitmapHolder>(); cachedTb.Add(key, cachedTm); } if (!cachedTm.TryGetValue(mode, out holder)) { holder = new TBitmapHolder(); cachedTm.Add(mode, holder); } if (tb.Visibility == Visibility.Collapsed) { if (holder.state == TBitmapHolderState.Updating) { holder.onReady += new EventHandler(OnHolderReady); } else if ((holder.state == TBitmapHolderState.Clean) || (holder.bitmap.PixelWidth < ActualWidth)) { holder.state = TBitmapHolderState.Updating; drawOutline(mode); } else { c2++; img.Source = holder.bitmap; } } else { if (LayoutUpdated) { holder.bitmap = new WriteableBitmap((int)ActualWidth, (int)ActualHeight); holder.bitmap.Render(tb, null); holder.bitmap.Invalidate(); holder.state = TBitmapHolderState.Ready; if (holder.onReady != null) { holder.onReady.Invoke(null, null); } holder.onReady = null; tb.Visibility = Visibility.Collapsed; img.Source = holder.bitmap; } } #if DEBUG System.Diagnostics.Debugger.Log(0, "", c1.ToString() + "/" + c2.ToString() + "\n"); #endif }