예제 #1
0
 static private void GetSolidFillColor()
 {
     Photoshop.ActionReference reference = new Photoshop.ActionReference();
     reference.PutEnumerated(PhotoshopApplication.StringIDToTypeID("contentLayer"), PhotoshopApplication.CharIDToTypeID("Ordn"), PhotoshopApplication.CharIDToTypeID("Trgt"));
     Photoshop.ActionDescriptor descriptor      = PhotoshopApplication.ExecuteActionGet(reference);
     Photoshop.ActionList       actionList      = descriptor.GetList(PhotoshopApplication.CharIDToTypeID("Adjs"));
     Photoshop.ActionDescriptor solidColorLayer = actionList.GetObjectValue(0);
     Photoshop.ActionDescriptor color           = solidColorLayer.GetObjectValue(PhotoshopApplication.CharIDToTypeID("Clr "));
     double red   = color.GetDouble(PhotoshopApplication.CharIDToTypeID("Rd  "));
     double green = color.GetDouble(PhotoshopApplication.CharIDToTypeID("Grn "));
     double blue  = color.GetDouble(PhotoshopApplication.CharIDToTypeID("Bl  "));
 }
예제 #2
0
 static private void UpdateSolidFillColor(Color color)
 {
     Photoshop.ActionDescriptor descriptor = new Photoshop.ActionDescriptor();
     Photoshop.ActionReference  reference  = new Photoshop.ActionReference();
     reference.PutEnumerated(PhotoshopApplication.StringIDToTypeID("contentLayer"), PhotoshopApplication.CharIDToTypeID("Ordn"), PhotoshopApplication.CharIDToTypeID("Trgt"));
     descriptor.PutReference(PhotoshopApplication.CharIDToTypeID("null"), reference);
     Photoshop.ActionDescriptor fillDescriptor  = new Photoshop.ActionDescriptor();
     Photoshop.ActionDescriptor colorDescriptor = new Photoshop.ActionDescriptor();
     colorDescriptor.PutDouble(PhotoshopApplication.CharIDToTypeID("Rd  "), color.R);
     colorDescriptor.PutDouble(PhotoshopApplication.CharIDToTypeID("Grn "), color.G);
     colorDescriptor.PutDouble(PhotoshopApplication.CharIDToTypeID("Bl  "), color.B);
     fillDescriptor.PutObject(PhotoshopApplication.CharIDToTypeID("Clr "), PhotoshopApplication.CharIDToTypeID("RGBC"), colorDescriptor);
     descriptor.PutObject(PhotoshopApplication.CharIDToTypeID("T   "), PhotoshopApplication.StringIDToTypeID("solidColorLayer"), fillDescriptor);
     PhotoshopApplication.ExecuteAction(PhotoshopApplication.CharIDToTypeID("setd"), descriptor);
 }
예제 #3
0
        /// <summary>
        /// Deselects the layers.
        /// </summary>
        private void deselectLayers()
        {
            Photoshop.ActionDescriptor __desc = new Photoshop.ActionDescriptor();
            Photoshop.ActionReference __ref = new Photoshop.ActionReference();

            __ref.PutEnumerated(__appRef.CharIDToTypeID("Lyr "), __appRef.CharIDToTypeID("Ordn"), __appRef.CharIDToTypeID("Trgt"));
            __desc.PutReference(__appRef.CharIDToTypeID("null"), __ref);
            __appRef.ExecuteAction(__appRef.StringIDToTypeID("selectNoLayers"), __desc, Photoshop.PsDialogModes.psDisplayNoDialogs);
        }
예제 #4
0
        /// <summary>
        /// Changes the layer colour.
        /// </summary>
        /// <param name="__col">Color</param>
        private void ChangeLayerColour(Colors __col)
        {
            string __colour;
            Photoshop.ActionDescriptor __desc;
            Photoshop.ActionReference __ref;
            Photoshop.ActionDescriptor __desc2;

            switch (__col)
            {
                case Colors.RED:
                    __colour = "Rd  ";
                    break;
                case Colors.ORANGE:
                    __colour = "Orng";
                    break;
                case Colors.YELLOW:
                    __colour = "Ylw ";
                    break;
                case Colors.GREEN:
                    __colour = "Grn ";
                    break;
                case Colors.BLUE:
                    __colour = "Bl  ";
                    break;
                case Colors.VIOLET:
                    __colour = "Vlt ";
                    break;
                case Colors.GRAY:
                    __colour = "Gry ";
                    break;
                case Colors.NONE:
                    __colour = "None";
                    break;
                default:
                    __colour = "None";
                    break;
            }

            __desc = new Photoshop.ActionDescriptor();
            __ref = new Photoshop.ActionReference();
            __ref.PutEnumerated(__appRef.CharIDToTypeID("Lyr "), __appRef.CharIDToTypeID("Ordn"), __appRef.CharIDToTypeID("Trgt"));
            __desc.PutReference(__appRef.CharIDToTypeID("null"), __ref);

            __desc2 = new Photoshop.ActionDescriptor();
            __desc2.PutEnumerated(__appRef.CharIDToTypeID("Clr "), __appRef.CharIDToTypeID("Clr "), __appRef.CharIDToTypeID(__colour));
            __desc.PutObject(__appRef.CharIDToTypeID("T   "), __appRef.CharIDToTypeID("Lyr "), __desc2);
            __appRef.ExecuteAction(__appRef.CharIDToTypeID("setd"), __desc, Photoshop.PsDialogModes.psDisplayNoDialogs);
        }
예제 #5
0
        /// <summary>
        /// Moves the layer.
        /// </summary>
        /// <param name="__name">Name</param>
        private void moveLayer(string __name)
        {
            Photoshop.ActionReference __ref = new Photoshop.ActionReference();
            Photoshop.ActionDescriptor __desc = new Photoshop.ActionDescriptor();
            __ref.PutProperty( __appRef.CharIDToTypeID("Prpr") , __appRef.CharIDToTypeID("NmbL"));
            __ref.PutEnumerated(__appRef.CharIDToTypeID("Dcmn"), __appRef.CharIDToTypeID("Ordn"), __appRef.CharIDToTypeID("Trgt"));
            int __nblayers = __appRef.ExecuteActionGet(__ref).GetInteger(__appRef.CharIDToTypeID("NmbL"));

            Photoshop.ActionDescriptor __desc1 = new Photoshop.ActionDescriptor();
            Photoshop.ActionReference __ref1 = new Photoshop.ActionReference();
            Photoshop.ActionReference __ref2 = new Photoshop.ActionReference();

            __ref1.PutEnumerated(__appRef.CharIDToTypeID("Lyr "), __appRef.CharIDToTypeID("Ordn"), __appRef.CharIDToTypeID("Trgt"));
            __desc1.PutReference(__appRef.CharIDToTypeID("null"), __ref1);

            __ref2.PutIndex(__appRef.CharIDToTypeID("Lyr "), __nblayers);
            __desc1.PutReference(__appRef.CharIDToTypeID("T   "), __ref2);

            __desc1.PutBoolean(__appRef.CharIDToTypeID("Adjs"), false);
            __desc1.PutInteger(__appRef.CharIDToTypeID("Vrsn"), 5);
            __appRef.ExecuteAction(__appRef.CharIDToTypeID("move"), __desc1, Photoshop.PsDialogModes.psDisplayNoDialogs);
        }
예제 #6
0
        private void listFonts(Photoshop.Document __docRef, string __filename, bool __messageWhenDone)
        {
            //MessageBox.Show(__filename);

            Photoshop.ActionReference __ref = new Photoshop.ActionReference();
            Photoshop.ActionDescriptor __desc = new Photoshop.ActionDescriptor();
            Regex __RegexObj = new Regex("^</Layer group");
            List<string> __fonts = new List<string>();

            __ref.PutEnumerated(__appRef.CharIDToTypeID("Dcmn"), __appRef.CharIDToTypeID("Ordn"), __appRef.CharIDToTypeID("Trgt") );
            int __count = __appRef.ExecuteActionGet(__ref).GetInteger(__appRef.CharIDToTypeID("NmbL")) + 1;
            //MessageBox.Show(__count.ToString());
            for(int i = 1; i < __count; i++)
            {
                __ref = new Photoshop.ActionReference();
                __ref.PutIndex( __appRef.CharIDToTypeID("Lyr "), i);
                __desc = __appRef.ExecuteActionGet(__ref);
                string __layerName = __desc.GetString(__appRef.CharIDToTypeID("Nm  "));
                string __layerType = __appRef.TypeIDToStringID(__desc.GetEnumerationValue( __appRef.StringIDToTypeID("layerSection")));

                if (__RegexObj.IsMatch(__layerName))
                    continue;

                if( __desc.HasKey(__appRef.StringIDToTypeID("textKey")))
                {
                    Photoshop.ActionDescriptor __list = __desc.GetObjectValue(__appRef.CharIDToTypeID("Txt "));
                    Photoshop.ActionList __tsr = __list.GetList(__appRef.CharIDToTypeID("Txtt"));
                    //MessageBox.Show(__tsr.Count.ToString());
                    for(var j = 0; j < __tsr.Count; j++)
                    {
                        //MessageBox.Show("ok");
                        Photoshop.ActionDescriptor __tsr0 = __tsr.GetObjectValue(j);
                        Photoshop.ActionDescriptor __textStyle = __tsr0.GetObjectValue(__appRef.CharIDToTypeID("TxtS"));
                        string __font = __textStyle.GetString(__appRef.CharIDToTypeID("FntN"));
                        string __style = __textStyle.GetString(__appRef.CharIDToTypeID("FntS"));
                        //MessageBox.Show(__font + "-" + __style);
                        if (!__fonts.Contains(__font + "-" + __style))
                            __fonts.Add(__font + "-" + __style);
                    }
                }
            }
            //MessageBox.Show(__fonts.Count.ToString());
            addFont(__docRef, __fonts, __filename, __messageWhenDone);
        }
예제 #7
0
 /// <summary>
 /// Hides all layers.
 /// </summary>
 private void hideAllLayers()
 {
     Photoshop.ActionReference __ref = new Photoshop.ActionReference();
     __ref.PutEnumerated(__appRef.CharIDToTypeID("Lyr "), __appRef.CharIDToTypeID("Ordn"), __appRef.CharIDToTypeID("Trgt"));
     Photoshop.ActionList __list = new Photoshop.ActionList();
     __list.PutReference(__ref);
     Photoshop.ActionDescriptor __desc = new Photoshop.ActionDescriptor();
     __desc.PutList(__appRef.CharIDToTypeID("null"), __list);
     __appRef.ExecuteAction(__appRef.CharIDToTypeID("Hd  "), __desc, Photoshop.PsDialogModes.psDisplayNoDialogs);
 }
예제 #8
0
        /// <summary>
        /// Gets the type of the smart object.
        /// </summary>
        /// <param name="__appRef">Application Reference</param>
        /// <returns></returns>
        private string getSmartObjectType(Photoshop.Application __appRef)
        {
            string __value;
            Photoshop.ActionReference __aRef = new Photoshop.ActionReference();
            __aRef.PutEnumerated(__appRef.CharIDToTypeID("Lyr "), __appRef.CharIDToTypeID("Ordn"), __appRef.CharIDToTypeID("Trgt"));

            Photoshop.ActionDescriptor __desc;
            __desc = __appRef.ExecuteActionGet(__aRef);

            if (__desc.HasKey(__appRef.StringIDToTypeID("smartObject")))
            {
                int __desc2 = __appRef.ExecuteActionGet(__aRef).GetObjectValue(__appRef.StringIDToTypeID("smartObject")).GetEnumerationValue(__appRef.StringIDToTypeID("placed"));

                if ((string)(__appRef.TypeIDToStringID(__desc2)) == "vectorData")
                {
                    __value = ".ai";
                }
                else if ((string)(__appRef.TypeIDToStringID(__desc2)) == "rasterizeContent")
                {
                    __value = ".psd";
                }
                else
                {
                    __value = "";
                }
            }
            else
            {
                __value = "";
            }
            return __value;
        }