Пример #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);
    }
Пример #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);
    }
Пример #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);
        }
Пример #4
0
        public void Add(ActionReference actionRef)
        {
            // Check for default afterCloneValue
            if (!actionRef.AfterClone.HasValue)
            {
                actionRef.AfterClone = _defaultAfterClone;
            }

            // Check for default afterUncloneValue
            if (!actionRef.AfterUnclone.HasValue)
            {
                actionRef.AfterUnclone = _defaultAfterUnclone;
            }

            // Check for default handsfreeValue
            if (!actionRef.Handsfree.HasValue)
            {
                actionRef.Handsfree = _defaultHandsfree;
            }

            // Add action to table
            _table.Add(actionRef.Action, actionRef);
        }
Пример #5
0
        static public void Initialize()
        {
            if (Process.GetProcessesByName("Photoshop").Length > 0)
            {
                App = new Photoshop.Application();

                var refApp = new ActionReference();
                refApp.PutProperty(App.StringIDToTypeID("property"), App.StringIDToTypeID("tool"));
                refApp.PutEnumerated(App.StringIDToTypeID("application"), App.StringIDToTypeID("ordinal"), App.StringIDToTypeID("targetEnum"));

                AppDescriptor = App.ExecuteActionGet(refApp);

                var refDoc = new ActionReference();

                refDoc.PutProperty(App.StringIDToTypeID("property"), App.StringIDToTypeID("zoom"));
                refDoc.PutEnumerated(App.StringIDToTypeID("document"), App.StringIDToTypeID("ordinal"), App.StringIDToTypeID("targetEnum"));

                DocumentDescriptor = App.ExecuteActionGet(refDoc);
            }
            else
            {
                App = null;
            }
        }
Пример #6
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);
    }
Пример #7
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;
                    }
                }
            }
        }