예제 #1
0
        //public ActionSaveScreenSelection(Photoshop.Document __docRef, Photoshop.JPEGSaveOptions __jpgSaveOptions)
        public ActionSaveScreenSelection(Photoshop.Document __docRef)
        {
            __doc = __docRef;

            __saveOptions = new Photoshop.PNGSaveOptions();

            countSelections(__doc);
        }
        //public ActionSaveScreenSelection(Photoshop.Document __docRef, Photoshop.JPEGSaveOptions __jpgSaveOptions)
        public ActionSaveScreenSelection(Photoshop.Document __docRef)
        {
            __doc = __docRef;

            __saveOptions = new Photoshop.PNGSaveOptions();

            countSelections(__doc);
        }
예제 #3
0
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         Photoshop.Document pDocument = pApplication.ActiveDocument;
         pDocument.ArtLayers.Add();
     }
     catch (Exception err)
     {
         MessageBox.Show(this, err.Message, "运行出现异常", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return;
     }
 }
예제 #4
0
        private void saveSelection(Photoshop.Document __duppedDocument, int __count, int __idx, int __subindex)
        {
            string __fileNameBody;
            string __sidx = string.Empty;

            if (__subindex > 0)
            {
                __sidx = "." + __subindex;
            }
            __fileNameBody  = (__doc.Name.LastIndexOf(".") > -1) ? __doc.Name.Substring(0, __doc.Name.LastIndexOf(".")) : __doc.Name;
            __fileNameBody += (__count <= 1) ? "" : "." + __idx + __sidx + "";
            __fileNameBody += ".png";
            if (!Directory.Exists(__doc.Path + "/+ Screens/"))
            {
                Directory.CreateDirectory(__doc.Path + "/+ Screens/");
            }

            __duppedDocument.SaveAs(__doc.Path + "/+ Screens/" + __fileNameBody, __saveOptions, true, null);
        }
예제 #5
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         Photoshop.Document pDocument  = pApplication.ActiveDocument;
         Photoshop.Layers   pLayers    = pDocument.Layers;
         string             layersText = "";
         foreach (Photoshop.ArtLayer artLayer in pLayers)
         {
             layersText += artLayer.Name + Environment.NewLine;
         }
         textBox1.Text = layersText;
     }
     catch (Exception err)
     {
         MessageBox.Show(this, err.Message, "运行出现异常", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return;
     }
 }
예제 #6
0
        private void countSelections(Photoshop.Document __doc)
        {
            Photoshop.ArtLayer __layer;

            __countTotal    = 0;
            __countChannels = 0;
            __countBounds   = 0;

            foreach (Photoshop.Channel __channel in __doc.Channels)
            {
                if (__channel.Name.Contains("screen"))
                {
                    __countChannels++;
                    addToCompList(__channel.Name, __channelsSelectionList);
                }
            }

            for (int __j = 0; __j < __doc.Layers.Count; __j++)
            {
                try
                {
                    __layer = (Photoshop.ArtLayer)__doc.Layers[__j];
                    if (__layer.Name.Contains("@screen"))
                    {
                        __countBounds++;
                        if (__layer.Visible)                         // Hide bounds before saving
                        {
                            __layer.Visible = false;
                        }
                        addToCompList(__layer.Name, __boundsSelectionList);
                    }
                }
                catch
                {
                }
            }

            __countTotal = __countChannels + __countBounds;
        }
예제 #7
0
 private void saveSelection(Photoshop.Document __duppedDocument, int __count, int __idx)
 {
     saveSelection(__duppedDocument, __count, __idx, 0);
 }
예제 #8
0
        public void saveAll(int __count, int __index)
        {
            Photoshop.Document __duppedDocument = null;
            Photoshop.ArtLayer __layer;
            object             __selBounds;
            int __idx = 0;


            if (__countChannels > 0)
            {
                foreach (Photoshop.Channel __channel in __doc.Channels)
                {
                    if (__channel.Name.Contains("screen"))
                    {
                        __idx++;
                        try
                        {
                            __duppedDocument = __doc.Duplicate(null, null);
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Essayez de redémarrer UTC FMCore");
                        }

                        __duppedDocument.Selection.Load(__channel, null, null);
                        __selBounds = __duppedDocument.Selection.Bounds;
                        __duppedDocument.Crop(__selBounds, null, null, null);

                        if (__count > 0)
                        {
                            // check if index is to be captured
                            if (__channelsSelectionList[__idx - 1].Count > 0)
                            {
                                if (__channelsSelectionList[__idx - 1].Contains(__index.ToString()))
                                {
                                    if (__countTotal > 1)
                                    {
                                        saveSelection(__duppedDocument, __count, __index, __idx);
                                    }
                                    else
                                    {
                                        saveSelection(__duppedDocument, __count, __index, 0);
                                    }
                                }
                            }
                            else
                            {
                                if (__countTotal > 1)
                                {
                                    saveSelection(__duppedDocument, __count, __index, __idx);
                                }
                                else
                                {
                                    saveSelection(__duppedDocument, __count, __index, 0);
                                }
                            }
                        }
                        else
                        {
                            saveSelection(__duppedDocument, __countTotal, __idx, 0);
                        }
                        __duppedDocument.Close(2);
                    }
                }
            }

            int __idx2 = -1;

            if (__countBounds > 0)
            {
                for (int __j = 1; __j <= __doc.Layers.Count; __j++)
                {
                    try
                    {
                        __layer = (Photoshop.ArtLayer)__doc.Layers[__j];

                        if (__layer.Name.Contains("@screen"))
                        {
                            __idx++;
                            __idx2++;
                            try
                            {
                                //System.Threading.Thread.Sleep(1000);
                                __duppedDocument = __doc.Duplicate(null, null);
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Essayez de redémarrer UTC FMCore");
                            }

                            __selBounds = __layer.Bounds;
                            __duppedDocument.Crop(__selBounds, null, null, null);

                            if (__count > 0)
                            {
                                //MessageBox.Show("Layer comp " + __index + ":" + __boundsSelectionList[__idx2].Count);
                                // check if index is to be captured
                                //MessageBox.Show("array " + __idx2 + ":" + __boundsSelectionList[__idx2].Count);
                                if (__boundsSelectionList[__idx2].Count > 0)
                                {
                                    //MessageBox.Show("array " + __idx2 + ":" + __boundsSelectionList[__idx2].Count);
                                    if (__boundsSelectionList[__idx2].Contains(__index.ToString()))
                                    {
                                        if (__countTotal > 1)
                                        {
                                            saveSelection(__duppedDocument, __count, __index, __idx);
                                        }
                                        else
                                        {
                                            saveSelection(__duppedDocument, __count, __index, 0);
                                        }
                                    }
                                }
                                else
                                {
                                    if (__countTotal > 1)
                                    {
                                        saveSelection(__duppedDocument, __count, __index, __idx);
                                    }
                                    else
                                    {
                                        saveSelection(__duppedDocument, __count, __index, 0);
                                    }
                                }
                            }
                            else
                            {
                                saveSelection(__duppedDocument, __countTotal, __idx, 0);
                            }

                            __duppedDocument.Close(2);
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
예제 #9
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);
        }