Beispiel #1
0
    private void SelectToolPreset(string toolName)
    {
        ActionDescriptor actionDesc = new ActionDescriptor();
        ActionReference  actionRef  = new ActionReference();
        int idslct       = psApp.CharIDToTypeID("slct");
        int idnull       = psApp.CharIDToTypeID("null");
        int idtoolPreset = psApp.StringIDToTypeID("toolPreset");

        actionRef.PutName(idtoolPreset, toolName);
        actionDesc.PutReference(idnull, actionRef);
        psApp.ExecuteAction(idslct, actionDesc, PsDialogModes.psDisplayNoDialogs);
    }
Beispiel #2
0
    private void SelectTool(string charID)
    {
        int idslct = psApp.CharIDToTypeID("slct");
        int idnull = psApp.CharIDToTypeID("null");
        int idtool = psApp.CharIDToTypeID(charID);
        ActionDescriptor actionDesc = new ActionDescriptor();
        ActionReference  actionRef  = new ActionReference();

        actionRef.PutClass(idtool);
        actionDesc.PutReference(idnull, actionRef);
        psApp.ExecuteAction(idslct, actionDesc, PsDialogModes.psDisplayNoDialogs);
    }
Beispiel #3
0
        public void ResetColor()
        {
            if (Application == null)
            {
                throw new ArgumentNullException(nameof(Application));
            }
            var desc49 = new ActionDescriptor();
            var ref22  = new ActionReference();

            ref22.PutProperty(Application.CharIDToTypeID("Clr "), Application.CharIDToTypeID("Clrs"));
            desc49.PutReference(Application.CharIDToTypeID("null"), ref22);
            Application.ExecuteAction(Application.CharIDToTypeID("Rset"), desc49, 3);
        }
Beispiel #4
0
    private void LoadToolPresets(string toolsPath)
    {
        ActionDescriptor actionDesc = new ActionDescriptor();
        ActionReference  actionRef  = new ActionReference();
        int idsetd       = psApp.CharIDToTypeID("setd");
        int idnull       = psApp.CharIDToTypeID("null");
        int idPrpr       = psApp.CharIDToTypeID("Prpr");
        int idtoolPreset = psApp.StringIDToTypeID("toolPreset");

        actionRef.PutProperty(idPrpr, idtoolPreset);
        int idcapp = psApp.CharIDToTypeID("capp");
        int idOrdn = psApp.CharIDToTypeID("Ordn");
        int idTrgt = psApp.CharIDToTypeID("Trgt");

        actionRef.PutEnumerated(idcapp, idOrdn, idTrgt);
        actionDesc.PutReference(idnull, actionRef);
        int idT = psApp.CharIDToTypeID("T   ");

        actionDesc.PutPath(idT, toolsPath);
        int idAppe = psApp.CharIDToTypeID("Appe");

        actionDesc.PutBoolean(idAppe, true);
        psApp.ExecuteAction(idsetd, actionDesc, PsDialogModes.psDisplayNoDialogs);
    }
Beispiel #5
0
        static public void SetBrushSettings(double diameter, double hardness, int flow, double opacity)
        {
            if (!IsActive())
            {
                return;
            }

            for (int i = 0; i < 1; i++)
            {
                try
                {
                    var currentToolOptions = AppDescriptor.GetObjectValue(App.StringIDToTypeID("currentToolOptions"));
                    var currentTool        = AppDescriptor.GetEnumerationType(App.StringIDToTypeID("tool"));
                    var currentBrush       = currentToolOptions.GetObjectValue(App.StringIDToTypeID("brush"));

                    var toolRef = new ActionReference();
                    toolRef.PutClass(currentTool);

                    if (currentBrush.HasKey(App.StringIDToTypeID("diameter")) && diameter != -1)
                    {
                        currentBrush.PutDouble(App.StringIDToTypeID("diameter"), diameter);
                    }

                    if (currentBrush.HasKey(App.StringIDToTypeID("hardness")) && hardness != -1)
                    {
                        currentBrush.PutDouble(App.StringIDToTypeID("hardness"), hardness);
                    }

                    if (currentToolOptions.HasKey(App.StringIDToTypeID("flow")) && flow != -1)
                    {
                        currentToolOptions.PutInteger(App.StringIDToTypeID("flow"), flow);
                    }

                    if (currentToolOptions.HasKey(App.StringIDToTypeID("opacity")) && opacity != -1)
                    {
                        currentToolOptions.PutDouble(App.StringIDToTypeID("opacity"), opacity);
                    }

                    currentToolOptions.PutObject(App.StringIDToTypeID("brush"), App.StringIDToTypeID("null"), currentBrush);

                    var setBrush = new ActionDescriptor();
                    setBrush.PutReference(App.StringIDToTypeID("null"), toolRef);
                    setBrush.PutObject(App.StringIDToTypeID("to"), App.StringIDToTypeID("null"), currentToolOptions);

                    App.ExecuteAction(App.StringIDToTypeID("set"), setBrush, PsDialogModes.psDisplayNoDialogs);

                    return;
                }
                catch (COMException ex)
                {
                    switch ((PhotoshopExceptionResult)ex.ErrorCode)
                    {
                    case PhotoshopExceptionResult.RPCERR:
                        Trace.WriteLine("Photoshop handle is outdated.");
                        Trace.WriteLine(ex.ErrorCode);
                        Trace.WriteLine(ex.Message);

                        break;

                    case PhotoshopExceptionResult.NOTAVAIL:
                        Trace.WriteLine("Tool does not have brush settings.");
                        break;
                    }
                }
            }
        }