Beispiel #1
0
 private void button7_Click(object sender, EventArgs e)
 {
     try
     {
         Photoshop.ArtLayer artLayer = pApplication.ActiveDocument.ActiveLayer;
         artLayer.FillOpacity = 50;
     }
     catch (Exception err)
     {
         MessageBox.Show(this, err.Message, "运行出现异常", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return;
     }
 }
Beispiel #2
0
        static private void UpdatePsd(FileInfo fileInfo, Dictionary <string, Color> convertMap, string saveFolder)
        {
            Console.Out.WriteLine("Start Convert " + fileInfo.FullName);

            Photoshop.Document  psdDocument = PhotoshopApplication.Open(fileInfo.FullName);
            Photoshop.ArtLayers layers      = psdDocument.ArtLayers;
            for (int index = 0; index < layers.Count; ++index)
            {
                try
                {
                    Photoshop.ArtLayer layer = layers[index + 1];
                    var layName = layer.Name.ToUpper();
                    var findKey = convertMap.Single(x => layName.Contains(x.Key));
                    var color   = findKey.Value;

                    switch (layer.LayerType)
                    {
                    case Photoshop.PsLayerType.psArtLayer:
                    {
                        switch (layer.Kind)
                        {
                        case Photoshop.PsLayerKind.psSolidFillLayer:
                        {
                            PhotoshopApplication.ActiveDocument.ActiveLayer = layer;
                            UpdateSolidFillColor(color);
                        }
                        break;

                        case Photoshop.PsLayerKind.psTextLayer:
                        {
                            PhotoshopApplication.ActiveDocument.ActiveLayer = layer;
                            Photoshop.TextItem text = layer.TextItem;
                            text.Color.RGB.HexValue = color.R.ToString("X2").ToLower() + color.G.ToString("X2").ToLower() + color.B.ToString("X2").ToLower();
                            break;
                        }

                        default:
                        {
                            ConsoleColor oldColor = Console.ForegroundColor;
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Out.WriteLine("Convert Error : Layer Name - " + layName + "   LayerKind - " + layer.Kind);
                            Console.ForegroundColor = oldColor;
                            break;
                        }
                        }
                    }
                    break;

                    default:
                    {
                        throw new Exception();
                    }
                    }
                }
                catch
                {
                }
            }

            psdDocument.SaveAs(saveFolder + "\\" + fileInfo.Name);
            psdDocument.Close();
            Console.Out.WriteLine("Convert Finished, Save to " + saveFolder + "\\" + fileInfo.Name);
        }