コード例 #1
0
        static public PhotoshopBrush GetBrushSettings()
        {
            if (!IsActive())
            {
                return(null);
            }

            try
            {
                var currentToolOptions = AppDescriptor.GetObjectValue(App.StringIDToTypeID("currentToolOptions"));
                var currentBrush       = currentToolOptions.GetObjectValue(App.StringIDToTypeID("brush"));

                var brushData = new PhotoshopBrush();

                if (currentBrush.HasKey(App.StringIDToTypeID("diameter")))
                {
                    brushData.Diameter = currentBrush.GetDouble(App.StringIDToTypeID("diameter"));
                }

                if (currentBrush.HasKey(App.StringIDToTypeID("hardness")))
                {
                    brushData.Hardness = currentBrush.GetDouble(App.StringIDToTypeID("hardness"));
                }

                if (currentToolOptions.HasKey(App.StringIDToTypeID("flow")))
                {
                    brushData.Flow = currentToolOptions.GetInteger(App.StringIDToTypeID("flow"));
                }

                if (currentToolOptions.HasKey(App.StringIDToTypeID("opacity")))
                {
                    brushData.Opacity = currentToolOptions.GetDouble(App.StringIDToTypeID("opacity"));
                }

                Trace.WriteLine(brushData.Opacity);

                return(brushData);
            }
            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;
                }
            }

            return(null);
        }
コード例 #2
0
 static public void SetBrushSettings(PhotoshopBrush brush)
 {
     SetBrushSettings(brush.Diameter, brush.Hardness, brush.Flow, brush.Opacity);
 }