Code Bye

C#-CorelDraw开发-枚举群组中的形状并更改颜色-无需取消群组

C#CorelDraw开发-使用递归枚举群组中的形状并更改颜色-无需取消群组C#示例
Use a recursivity method to enumerate your shapes in your groups and change the colors. ungroup no need

public void A()
        {
           
            Color searchColor = app.ActivePalette.Color[2];
            Color replaceColor = app.ActivePalette.Color[20];
            simpe(app.ActiveSelectionRange,searchColor,replaceColor);
        }
        private void simpe(ShapeRange sr,Color searchColor,Color replaceColor)
        {
            
            foreach (Shape item in sr)
            {
                if(item.Type == cdrShapeType.cdrGroupShape)
                {
                    ShapeRange tempSR = item.Shapes.All();
                    simpe(tempSR,searchColor,replaceColor);
                }
                else
                {
                    
                    if (item.Fill.UniformColor.Name == searchColor.Name)
                    {
                        item.Fill.ApplyUniformFill(replaceColor);
                        
                    }
                }
            }
        }

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明C#-CorelDraw开发-枚举群组中的形状并更改颜色-无需取消群组