Example #1
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);
 }
Example #2
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);
        }
Example #3
0
        /// <summary>
        /// Deselects the layer.
        /// </summary>
        /// <param name="__name">Name</param>
        private void deselectLayer(string __name)
        {
            Photoshop.ActionDescriptor __desc = new Photoshop.ActionDescriptor();
            Photoshop.ActionReference __ref = new Photoshop.ActionReference();

            __ref.PutName(__appRef.CharIDToTypeID("Lyr "), __name);
            __desc.PutReference(__appRef.CharIDToTypeID("null"), __ref);
            __desc.PutEnumerated(__appRef.StringIDToTypeID("selectionModifier"), __appRef.StringIDToTypeID("selectionModifierType"), __appRef.StringIDToTypeID("removeFromSelection"));
            __desc.PutBoolean(__appRef.CharIDToTypeID("MkVs"), false);
            __appRef.ExecuteAction(__appRef.CharIDToTypeID("slct"), __desc, Photoshop.PsDialogModes.psDisplayNoDialogs);
        }
Example #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);
        }
Example #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);
        }
Example #6
0
        /// <summary>
        /// Determines whether [has screen selection] [the specified __doc].
        /// </summary>
        /// <param name="__doc">The __doc.</param>
        /// <returns>
        ///   <c>true</c> if [has screen selection] [the specified __doc]; otherwise, <c>false</c>.
        /// </returns>
        private bool hasScreenSelection(Photoshop.Document __doc)
        {
            bool __value;
            Photoshop.ActionDescriptor __desc = new Photoshop.ActionDescriptor();
            Photoshop.ActionReference __ref = new Photoshop.ActionReference();

            __value = (getScreenSelectionChannel(__doc) != null) ? true : false;

            /*try
            {
                __selChannel = __doc.Channels["screen"];
                __value = true;
            }
            catch (Exception)
            {
                __value = false;
            }*/

            if (!__value)
            {
                try
                {
                    __ref.PutName(__appRef.CharIDToTypeID("Lyr "), "@screen");
                    __desc.PutReference(__appRef.CharIDToTypeID("null"), __ref);
                    __desc.PutEnumerated(__appRef.StringIDToTypeID("selectionModifier"), __appRef.StringIDToTypeID("selectionModifierType"), __appRef.StringIDToTypeID("removeFromSelection"));
                    __desc.PutBoolean(__appRef.CharIDToTypeID("MkVs"), true);
                    __appRef.ExecuteAction(__appRef.CharIDToTypeID("slct"), __desc, Photoshop.PsDialogModes.psDisplayNoDialogs);
                    __value = true;
                }
                catch (Exception)
                {
                    __value = false;
                }
            }

            return __value;
        }