コード例 #1
0
 /// <summary>
 /// Set shape style.
 /// </summary>
 /// <param name="project">The project instance.</param>
 /// <param name="shape">The shape instance.</param>
 /// <param name="style">The style instance.</param>
 public static void ApplyStyle(this IProjectContainer project, IBaseShape shape, IShapeStyle style)
 {
     if (shape != null && style != null)
     {
         if (shape is IGroupShape group)
         {
             var shapes = ProjectContainer.GetAllShapes(group.Shapes);
             foreach (var child in shapes)
             {
                 var previous = child.Style;
                 var next     = (IShapeStyle)style.Copy(null);
                 project?.History?.Snapshot(previous, next, (p) => child.Style = p);
                 child.Style = next;
             }
         }
         else
         {
             var previous = shape.Style;
             var next     = (IShapeStyle)style.Copy(null);
             project?.History?.Snapshot(previous, next, (p) => shape.Style = p);
             shape.Style = next;
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// Set shape style.
 /// </summary>
 /// <param name="project">The project instance.</param>
 /// <param name="shape">The shape instance.</param>
 /// <param name="style">The style instance.</param>
 public static void ApplyStyle(this ProjectContainer project, BaseShape shape, ShapeStyle style)
 {
     if (shape != null && style != null)
     {
         if (shape is GroupShape)
         {
             var shapes = ProjectContainer.GetAllShapes((shape as GroupShape).Shapes);
             foreach (var child in shapes)
             {
                 var previous = child.Style;
                 var next     = style;
                 project?.History?.Snapshot(previous, next, (p) => child.Style = p);
                 child.Style = next;
             }
         }
         else
         {
             var previous = shape.Style;
             var next     = style;
             project?.History?.Snapshot(previous, next, (p) => shape.Style = p);
             shape.Style = next;
         }
     }
 }