public static IEnumerable <DrawObject> GetAllVisibleDrawObjects(this ICanvasDataContext canvasDataContext) { if (canvasDataContext == null) { throw new ArgumentNullException(nameof(canvasDataContext)); } return(canvasDataContext.GetAllDrawObjects()?.Where(p => p.IsVisible)); }
/// <summary> /// 获取所有指定类型的绘制对象; /// </summary> /// <typeparam name="TDrawObject"></typeparam> /// <param name="canvasDataContext"></param> /// <returns></returns> public static IEnumerable <TDrawObject> GetAllDrawObjects <TDrawObject>(this ICanvasDataContext canvasDataContext) where TDrawObject : DrawObject { if (canvasDataContext == null) { throw new ArgumentNullException(nameof(canvasDataContext)); } return(canvasDataContext.GetAllDrawObjects()?.OfType <TDrawObject>()); }