internal void OnFontInfoReceived(Events.FontInfo fontInfo) { TextStyleCreatedArgs args = new TextStyleCreatedArgs(new TextStyleInfo( fontInfo.Ascent, fontInfo.Descent, fontInfo.Height, fontInfo.LineGap, fontInfo.GlyphInfo)); EventHandler <TextStyleCreatedArgs> callback = null; object context = null; lock (_fontCreated) { foreach (KeyValuePair <Resource, Delegate> createdCallback in _fontCreated) { // TODO: fix this in case two threads ask for a callback on the same font if (fontInfo.FontId == GetResourceId(createdCallback.Key)) { context = _fontCreatedObject[createdCallback.Key]; callback = (EventHandler <TextStyleCreatedArgs>)createdCallback.Value; _fontCreated.Remove(createdCallback.Key); _fontCreatedObject.Remove(createdCallback.Key); break; } } } if (callback != null) { try { callback(context, args); } catch (Exception ex) { StatusLog.Write(System.Diagnostics.TraceEventType.Warning, ex); } } EventHandler <TextStyleCreatedArgs> handler = TextStyleCreated; if (handler != null) { try { handler(this, args); } catch (Exception ex) { StatusLog.Write(System.Diagnostics.TraceEventType.Warning, ex); } } }
public ApplicationIconAttribute(Type resourceSource, string resourceName) { System.Resources.ResourceManager resMan = new System.Resources.ResourceManager(resourceSource); Icon = resMan.GetObject(resourceName) as byte[]; if (Icon == null) { StatusLog.Write(System.Diagnostics.TraceEventType.Error, string.Format("Unable to load resource {0} from resourceSet {1}.", resourceName, resMan.BaseName)); } }