Пример #1
0
        public void Save(ref ps.Document doc, FileInfo file)
        {
            ps.ExportOptionsIllustratorClass SaveOpts = new ps.ExportOptionsIllustratorClass();
            SaveOpts.Path = _path;

            doc.Export(file.FullName, ps.PsExportType.psIllustratorPaths, SaveOpts);
        }
        //public ActionSaveScreenSelection(Photoshop.Document __docRef, Photoshop.JPEGSaveOptions __jpgSaveOptions)
        public ActionSaveScreenSelection(Photoshop.Document __docRef)
        {
            __doc = __docRef;

            __saveOptions = new Photoshop.PNGSaveOptions();

            countSelections(__doc);
        }
Пример #3
0
 public void WaitForRedraw(ps.ApplicationClass app)
 {
     var eventWait = app.CharIDToTypeID("Wait");
     var enumRedrawComplete = app.CharIDToTypeID("RdCm");
     var typeState = app.CharIDToTypeID("Stte");
     var keyState = app.CharIDToTypeID("Stte");
     var desc = new ps.ActionDescriptor();
     desc.PutEnumerated(keyState, typeState, enumRedrawComplete);
     app.ExecuteAction(eventWait, desc, ps.PsDialogModes.psDisplayNoDialogs);
 }
Пример #4
0
 public void FillKnowledge(CandidateViewModel candidate)
 {
     _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
     Ionic.EnterText(candidate.Ionic.ToString());
     Android.EnterText(candidate.Android.ToString());
     Angular.EnterText(candidate.Angular.ToString());
     Asp.EnterText(candidate.Asp.ToString());
     Others.EnterText(candidate.Others);
     Photoshop.EnterText(candidate.Photoshop.ToString());
     Illustrator.EnterText(candidate.Illustrator.ToString());
     Html.EnterText(candidate.Html.ToString());
     Jquery.EnterText(candidate.Jquery.ToString());
 }
        public async Task <ActionResult> Edit(string shortcut)
        {
            if (shortcut == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Photoshop photoshop = await _context.Photoshops.SingleOrDefaultAsync(x => x.Shortcut == shortcut);

            if (photoshop == null)
            {
                return(HttpNotFound());
            }
            return(View(photoshop.As <PhotoshopEditModel>()));
        }
Пример #6
0
        protected virtual ActionResult View(Photoshop model)
        {
            var vmodel = ObjectExtension.As <PhotoshopViewModel.Details>(model);
            var data   = new ViewData.Photoshop.DetailsViewData
            {
                RouteDetails = vmodel,
                Technics     = _phototechnicsService.GetPhotoshopTechnics(vmodel, new PageRequest <PricePosition>()
                {
                    Where = x => x.PhotoshopID == vmodel.ID
                }),
                Categorieses = ObjectExtension.As <IList <CategoryViewModel> >(Context.Categories.Include(x => x.Brands).ToList())
            };

            return(View("Details", data));
        }
        public async Task <ActionResult> ProductDetails(string shortcut)
        {
            if (shortcut == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Photoshop photoshop = await _context.Photoshops.SingleOrDefaultAsync(x => x.Shortcut == shortcut);

            if (photoshop == null)
            {
                return(HttpNotFound());
            }
            this.SetTheme(photoshop);
            var model = photoshop.As <PhotoshopViewModel.Summary>();

            //       model.Categorieses = _context.Categories.ToList().As<IList<CategoryViewModel>>();
            return(View(model));
        }
        public async Task <ActionResult> Contact(string shortcut)
        {
            if (shortcut == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Photoshop photoshop = await _context.Photoshops.SingleOrDefaultAsync(x => x.Shortcut == shortcut);

            if (photoshop == null)
            {
                return(HttpNotFound());
            }

            var model = new ContactViewData
            {
                Item = Mapper.Map <PhotoshopViewModel.Summary>(photoshop)
            };

            //     model.Categorieses = _context.Categories.ToList().As<IList<CategoryViewModel>>();
            return(View(model));
        }
 public void Close(ref ps.Document doc)
 {
     _def.Close(ref doc);
 }
Пример #10
0
 public void SetUnits(ref ps.ApplicationClass app, ref ps.Document doc)
 {
     app.Preferences.RulerUnits = _rulerUnits;
         app.Preferences.TypeUnits = _typeUnits;
 }
Пример #11
0
        public void ResizeImageWithConstraints(ref ps.Document doc, double width, double height)
        {
            if (doc.Width/doc.Height<=width/height)
            {
                doc.ResizeImage(Height: height, ResampleMethod: ps.PsPDFResampleType.psPDFBicubic);

            }
            else
            {
                doc.ResizeImage(Width: width, ResampleMethod: ps.PsPDFResampleType.psPDFBicubic);
            }
        }
Пример #12
0
 public void ExtendCanvas(ref ps.Document doc, double width, double height)
 {
     doc.ResizeCanvas(width, height, ps.PsAnchorPosition.psMiddleCenter);
 }
Пример #13
0
        public void OpenWithConstraints(ref ps.ApplicationClass app, ref ps.Document doc, FileInfo file, double width, double height)
        {
            //Width Constraint
            ps.PDFOpenOptionsClass PdfOpenOptsWidth = new ps.PDFOpenOptionsClass();
            PdfOpenOptsWidth.AntiAlias = _antiAlias;
            PdfOpenOptsWidth.BitsPerChannel = _bitsPerChannel;
            PdfOpenOptsWidth.ConstrainProportions = _constrainProportions;
            PdfOpenOptsWidth.SuppressWarnings = _suppressWarnings;
            PdfOpenOptsWidth.CropPage = _cropPage;
            PdfOpenOptsWidth.Mode = _mode;
            PdfOpenOptsWidth.Page = _page;
            PdfOpenOptsWidth.UsePageNumber=_usePageNumber;
            PdfOpenOptsWidth.Resolution = _resolution;
            PdfOpenOptsWidth.Width = PsTools.GetPixelUnit(width, _resolution);

            //Height Constraint
            ps.PDFOpenOptionsClass PdfOpenOptsHeight = new ps.PDFOpenOptionsClass();
            PdfOpenOptsHeight.AntiAlias = _antiAlias;
            PdfOpenOptsHeight.BitsPerChannel = _bitsPerChannel;
            PdfOpenOptsHeight.ConstrainProportions = _constrainProportions;
            PdfOpenOptsHeight.SuppressWarnings = _suppressWarnings;
            PdfOpenOptsHeight.CropPage = _cropPage;
            PdfOpenOptsHeight.Mode = _mode;
            PdfOpenOptsWidth.UsePageNumber = _usePageNumber;
            PdfOpenOptsHeight.Page = _page;
            PdfOpenOptsHeight.Resolution = _resolution;
            PdfOpenOptsHeight.Height = PsTools.GetPixelUnit(height, _resolution);

            //Open the file

            doc = app.Open(file.FullName, PdfOpenOptsWidth);

            if (doc.Height > height)
            {
                Close(ref doc);
                //Open the file
                doc = app.Open(file.FullName, PdfOpenOptsHeight);
            }
        }
Пример #14
0
        /// <summary>
        /// Exports the smart objects.
        /// </summary>
        /// <param name="__docRef">Document refrence</param>
        /// <param name="_layers">Layers</param>
        /// <returns></returns>
        private bool exportSmartObjects(Photoshop.Document __docRef, object _layers)
        {
            Photoshop.Layers __layers;
            Photoshop.ArtLayer __alayer = null;
            Photoshop.LayerSet __slayer;
            bool __isArtLayer = false;
            object __layer;
            int __j;
            string __soType;

            __layers = (Photoshop.Layers)_layers;

            for (__j = 1; __j <= __layers.Count; __j++)
            {
                __layer = __layers[__j];

                try
                {
                    __alayer = (Photoshop.ArtLayer)__layer;
                    __isArtLayer = true;
                }
                catch
                {
                    __isArtLayer = false;
                }

                if (__isArtLayer) // Everything as Layer goes here
                {
                    __appRef.ActiveDocument.ActiveLayer = __layer;

                    if (__alayer.Kind == Photoshop.PsLayerKind.psSmartObjectLayer)
                    {

                        int __idplacedLayerExportContents;
                        __idplacedLayerExportContents = __appRef.StringIDToTypeID("placedLayerExportContents");

                        Photoshop.ActionDescriptor __desc4;
                        __desc4 = new Photoshop.ActionDescriptor();

                        int __idnull;
                        __idnull = __appRef.CharIDToTypeID("null");

                        if (!Directory.Exists(__docRef.Path + "+ SmartObjects\\"))
                        {
                            Directory.CreateDirectory(__docRef.Path + "+ SmartObjects\\");
                        }

                        __soType = getSmartObjectType(__appRef);
                        if (__soType != "")
                        {
                            __desc4.PutPath(__idnull, __docRef.Path + "+ SmartObjects\\" + wipeName(__alayer.Name) + __soType);
                            __appRef.ExecuteAction(__idplacedLayerExportContents, __desc4, Photoshop.PsDialogModes.psDisplayNoDialogs);
                        }
                    }
                }
                else // Everything as LayerSet goes here
                {
                    __slayer = (Photoshop.LayerSet)__layer;
                    __appRef.ActiveDocument.ActiveLayer = __layer;

                    if (__slayer.LayerType == Photoshop.PsLayerType.psLayerSet)
                    {
                        bool __test = exportSmartObjects(__docRef, __slayer.Layers);
                    }
                }
            }
            return true;
        }
Пример #15
0
 public void OpenWithConstraints(ref ps.ApplicationClass app, ref ps.Document doc, FileInfo file, double width, double height)
 {
     _def.OpenWithConstraints(ref app, ref doc, file, width, height);
 }
Пример #16
0
 public void SetBackGroundTransparent(ref ps.ApplicationClass app, ref ps.Document doc)
 {
     _def.SetBackGroundTransparent(ref app, ref doc);
 }
Пример #17
0
 /// <summary>
 /// Saves the asset.
 /// </summary>
 /// <param name="__docRef">Document reference</param>
 /// <param name="__name">Name</param>
 private void saveAsset(Photoshop.Document __docRef, string __name)
 {
     saveAsset(__docRef, __name, null);
 }
Пример #18
0
        /// <summary>
        /// Exports the images rights.
        /// </summary>
        /// <param name="__docRef">Document</param>
        /// <param name="_layers">Layers</param>
        /// <returns></returns>
        private bool exportImagesRights(Photoshop.Document __docRef, object _layers)
        {
            Photoshop.Layers __layers;
            Photoshop.ArtLayer __alayer = null;
            Photoshop.LayerSet __slayer;
            bool __isArtLayer = false;
            object __layer;
            int __j;
            string __soType;
            ImageRight __ir;

            __ir = new ImageRight();

            __layers = (Photoshop.Layers)_layers;

            for (__j = 1; __j <= __layers.Count; __j++)
            {
                __layer = __layers[__j];

                try
                {
                    __alayer = (Photoshop.ArtLayer)__layer;
                    __isArtLayer = true;
                }
                catch
                {
                    __isArtLayer = false;
                }

                if (__isArtLayer) // Everything as Layer goes here
                {
                    __appRef.ActiveDocument.ActiveLayer = __layer;

                    if (__alayer.Kind == Photoshop.PsLayerKind.psNormalLayer)
                    {
                        __ir.parse(__alayer.Name);
                        if (__ir.isValidURL)
                        {
                            __ir.createLink(__docRef.Path);
                        }
                    }
                    else if (__alayer.Kind == Photoshop.PsLayerKind.psSmartObjectLayer)
                    {
                        __ir.parse(__alayer.Name);
                        if (__ir.Code != null)
                        {
                            if (__ir.isValidURL)
                            {
                                __ir.createLink(__docRef.Path);
                            }
                        }
                        else
                        {
                            __soType = getSmartObjectType(__appRef);
                            if (__soType == ".psd")
                            {

                                int __opn;
                                __opn = __appRef.StringIDToTypeID("placedLayerEditContents");

                                Photoshop.ActionDescriptor __desc4;
                                __desc4 = new Photoshop.ActionDescriptor();

                                try
                                {
                                    __appRef.ExecuteAction(__opn, __desc4, Photoshop.PsDialogModes.psDisplayNoDialogs);
                                }
                                catch (InvalidOperationException ex)
                                {
                                    MessageBox.Show(ex.Message);
                                }
                                bool __test = exportImagesRights(__docRef, __appRef.ActiveDocument.Layers);
                                __appRef.ActiveDocument.Close(2);
                            }
                        }
                    }

                }
                else // Everything as LayerSet goes here
                {
                    __slayer = (Photoshop.LayerSet)__layer;
                    __appRef.ActiveDocument.ActiveLayer = __layer;

                    if (__slayer.LayerType == Photoshop.PsLayerType.psLayerSet)
                    {
                        bool __test = exportImagesRights(__docRef, __slayer.Layers);
                    }
                }
            }
            return true;
        }
Пример #19
0
        /// <summary>
        /// Saves the asset.
        /// </summary>
        /// <param name="__docRef">Document reference</param>
        /// <param name="__name">Name</param>
        /// <param name="__layers">Layers</param>
        private void saveAsset(Photoshop.Document __docRef, string __name, object __layers)
        {
            Photoshop.Document __duppedDocument;
            object __bounds = null;

            Photoshop.ExportOptionsSaveForWeb __pngExportOptionsSaveForWeb = new Photoshop.ExportOptionsSaveForWeb();
            __pngExportOptionsSaveForWeb.Format = Photoshop.PsSaveDocumentType.psPNGSave; // 13;
            __pngExportOptionsSaveForWeb.PNG8 = false;
            __pngExportOptionsSaveForWeb.Transparency = true;

            if (!Directory.Exists(__docRef.Path + "+ Assets\\"))
            {
                Directory.CreateDirectory(__docRef.Path + "+ Assets\\");
            }

            if (__layers != null)
                __bounds = checkBounds(__layers);

            Photoshop.ActionDescriptor __desc = __appRef.ExecuteAction(__appRef.StringIDToTypeID("newPlacedLayer"), null, Photoshop.PsDialogModes.psDisplayNoDialogs);

            __duppedDocument = __docRef.Duplicate(__name, null);

            __appRef.ActiveDocument = __duppedDocument;

            moveLayer(__name);
            selectAllLayers();
            deselectLayer(__name);
            hideAllLayers();
            deselectLayers();
            //System.Threading.Thread.Sleep(2000);
            if (__bounds == null)
            {
                __duppedDocument.Trim(Photoshop.PsTrimType.psTransparentPixels, true, true, true, true);
            }
            else
            {
                __duppedDocument.Crop(__bounds, null, null, null);
            }

            string __tempName = (__name.IndexOf("@1x") > -1) ? Regex.Replace(__name, "@1x", "") : __name;
            __tempName = Regex.Replace(__tempName, "(\\+)+\\s", "");
            __duppedDocument.Export(__docRef.Path + "+ Assets\\" + __tempName, 2, __pngExportOptionsSaveForWeb);

            __name = Regex.Replace(__name, "(\\+)+\\s", "");

            if (__name.IndexOf("@2x") > -1)
            {
                //__duppedDocument.ResizeImage(__duppedDocument.Width / 2, __duppedDocument.Width / 2, null, Photoshop.PsResampleMethod.psBicubicSmoother);
                resizeImage(__duppedDocument.Width / 2);
                try
                {
                    __duppedDocument.Export(__docRef.Path + "+ Assets\\" + Regex.Replace(__name, "@2x", ""), 2, __pngExportOptionsSaveForWeb);
                }
                catch
                {
                    MessageBox.Show("Please allow to save all slices in Save For Web options");
                }
            }
            else if (__name.IndexOf("@1x") > -1)
            {
                //__duppedDocument.ResizeImage(__duppedDocument.Width * 2, __duppedDocument.Width * 2, null, Photoshop.PsResampleMethod.psBicubicSmoother);
                resizeImage(__duppedDocument.Width * 2);
                try
                {
                    __duppedDocument.Export(__docRef.Path + "+ Assets\\" + Regex.Replace(__name, "@1x", "@2x"), 2, __pngExportOptionsSaveForWeb);
                }
                catch
                {
                    MessageBox.Show("Please allow to save all slices in Save For Web options");
                }
            }
            __duppedDocument.Close(2);
        }
Пример #20
0
        private Photoshop.Channel getScreenSelectionChannel(Photoshop.Document __doc)
        {
            Photoshop.Channel __selChannel = null;

            __screenSelectionList = new List<string> { };
            foreach (Photoshop.Channel __channel in __doc.Channels)
            {
                //MessageBox.Show(__channel.Name);
                if (__channel.Name.Contains("screen"))
                {
                    __selChannel = __channel;

                    char[] __delimiters = new char[] { '=' };
                    string[] __indexes = __channel.Name.Split(__delimiters, StringSplitOptions.RemoveEmptyEntries);
                    if (__indexes.Length > 1)
                    {
                        char[] __delimitersOne = new char[] { ',' };
                        string[] __indexesOne = __indexes[1].Split(__delimitersOne, StringSplitOptions.RemoveEmptyEntries);

                        foreach (string __index in __indexesOne)
                        {
                            //MessageBox.Show(__index.ToString());
                            if (!__screenSelectionList.Contains(__index))
                                __screenSelectionList.Add(__index);
                        }
                    }
                    break;
                }
            }

            return __selChannel;
        }
Пример #21
0
 /// <summary>
 /// Saves the screen selection.
 /// </summary>
 /// <param name="__docRef">Document Refrence</param>
 /// <param name="__doc">Document</param>
 /// <param name="__options">JPEG options</param>
 private void saveScreenSelection(Photoshop.Document __docRef, Photoshop.Document __doc, Photoshop.JPEGSaveOptions __options)
 {
     saveScreenSelection(__docRef, __doc, -1, __options);
 }
Пример #22
0
 public void Close(ref ps.Document doc)
 {
     doc.Close(ps.PsSaveOptions.psDoNotSaveChanges);
 }
Пример #23
0
        /// <summary>
        /// Saves the screen selection.
        /// </summary>
        /// <param name="__docRef">Document Refrence</param>
        /// <param name="__doc">Document</param>
        /// <param name="__idx">Layer Comp Index</param>
        /// <param name="__options">JPEG options</param>
        private void saveScreenSelection(Photoshop.Document __docRef, Photoshop.Document __doc, int __idx, Photoshop.JPEGSaveOptions __options)
        {
            Photoshop.Channel __selChannel;
            object __selBounds;
            string __fileNameBody;
            bool __hasSelection = false;
            Photoshop.ActionDescriptor __desc = new Photoshop.ActionDescriptor();
            Photoshop.ActionReference __ref = new Photoshop.ActionReference();
            Photoshop.ArtLayer __layer;
            int __j;

            try
            {
                __selChannel = getScreenSelectionChannel(__doc);
                __hasSelection = true;
                //MessageBox.Show(__selChannel.Name)
                __doc.Selection.Load(__selChannel, null, null);
                __selBounds = __doc.Selection.Bounds;
                __doc.Crop(__selBounds, null, null, null);
            }
            catch (Exception)
            {
                __hasSelection = false;

            }
            if (!__hasSelection)
            {
                /*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);
                    __desc = __appRef.ExecuteActionGet(__ref);

                    //__layer = (Photoshop.ArtLayer)__docRef.ActiveLayer;
                    //__selBounds = __layer.Bounds;
                    //__doc.Crop(__selBounds, null, null, null);
                    //__hasSelection = true;

                    string __res = __desc.GetString(__appRef.CharIDToTypeID("Nm  "));

                    if (__res == "@screen")
                    {
                        //int __index = __desc.GetInteger(__appRef.CharIDToTypeID("ItmI"));
                        MessageBox.Show(__desc.GetReference(__appRef.CharIDToTypeID("ItmI")).ToString());

                        //__docRef.ActiveLayer = __docRef.ArtLayers[__index];
                        //MessageBox.Show(__index.ToString());
                        //__layer = (Photoshop.ArtLayer)__doc.ArtLayers[__index];
                        //__selBounds = __layer.Bounds;
                        //__doc.Crop(__selBounds, null, null, null);
                        __hasSelection = true;
                    }
                    else
                    {
                        __hasSelection = false;
                    }
                }
                catch (Exception __e)
                {
                    MessageBox.Show(__e.Message);
                    __hasSelection = false;
                }
                */

                for (__j = 1; __j <= __docRef.Layers.Count; __j++)
                {
                    try
                    {
                        __layer = (Photoshop.ArtLayer)__docRef.Layers[__j];
                        //MessageBox.Show(__layer.Name);
                        if (__layer.Name == "@screen")
                        {
                            __selBounds = __layer.Bounds;
                            __doc.Crop(__selBounds, null, null, null);
                            __hasSelection = true;
                            break;
                        }
                    }
                    catch
                    {
                        __hasSelection = false;
                    }
                }
            }

            if (__hasSelection)
            {
                __fileNameBody = (__docRef.Name.LastIndexOf(".") > -1) ? __docRef.Name.Substring(0, __docRef.Name.LastIndexOf(".")) : __docRef.Name;
                __fileNameBody += (__idx <= -1) ? "_screen" : "." + __idx + "_screen";
                __fileNameBody += ".jpg";
                __doc.SaveAs(__docRef.Path + __fileNameBody, __options, true, null);
            }
            else
            {
                MessageBox.Show("You have to create a selection named \"screen\" or a layer named \"@screen\"", "No selection found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Application.Exit();
            }

            if (__idx > 0)
                __doc.Close(2);
        }
Пример #24
0
 public void OpenWithConstraints(ref ps.ApplicationClass app, ref ps.Document doc, FileInfo file, double width, double height)
 {
     //Open any bitmap image
     doc = app.Open(file.FullName);
     ResizeImageWithConstraints(ref doc, width, height);
 }
Пример #25
0
 /// <summary>
 /// Saves to file.
 /// </summary>
 /// <param name="__docRef">Document</param>
 /// <param name="__args">Arguments</param>
 private void saveToFile(Photoshop.Document __docRef, string[] __args)
 {
     saveToFile(__docRef, __args, false);
 }
Пример #26
0
        public void SetBackGroundTransparent(ref ps.ApplicationClass app,ref ps.Document doc)
        {
            bool isTransparent=PsTools.IsTransparent(ref app, ref doc);

            if(!isTransparent){
                doc.ArtLayers[0].Name = "Background";
                doc.LayerComps[0].Name = "Background";
                PsTools.SetBckgTransparentAction(ref app);
            }
        }
Пример #27
0
        /// <summary>
        /// Saves to file.
        /// </summary>
        /// <param name="__docRef">Document</param>
        /// <param name="__args">Arguments</param>
        /// <param name="__selectionOnly">if set to <c>true</c> Export Selection Only</param>
        private void saveToFile(Photoshop.Document __docRef, string[] __args, bool __selectionOnly)
        {
            bool __exportLayerComps = false;
            int __compsCount;
            int __compsIndex;
            Photoshop.LayerComp __compRef;
            Photoshop.Document __duppedDocument;
            string __fileNameBody = null;
            bool __hasSelection;
            bool __exportFonts = false;
            Format __imageFormat;

            __exportLayerComps = __form.ExportLayerComps.Checked;
            //MessageBox.Show(__exportLayerComps.ToString());

            bool __isNamedLayerComp = false;

            Photoshop.JPEGSaveOptions __jpgSaveOptions = null;

            try
            {
                __jpgSaveOptions = new Photoshop.JPEGSaveOptions();
                __jpgSaveOptions.EmbedColorProfile = false;
                __jpgSaveOptions.FormatOptions = Photoshop.PsFormatOptionsType.psStandardBaseline; // 1 psStandardBaseline
                __jpgSaveOptions.Matte = Photoshop.PsMatteType.psNoMatte; // 1 psNoMatte
            }
            catch //(Exception __e)
            {
                DialogResult __dr = MessageBox.Show("Photoshop is busy with open dialog or something." + "\r\n" + "\r\n" + "Please switch to Photoshop then close open dialogs or leave editing state", "Photoshop not ready", MessageBoxButtons.OK);
                if (__dr == DialogResult.OK)
                {
                    Application.Exit();
                }
            }

            switch (__args[2 + __form.idx])
            {
                case "jpg":
                    __jpgSaveOptions.Quality = int.Parse(__args[4 + __form.idx]);
                    if (__jpgSaveOptions.Quality == 12)
                    {
                        __exportFonts = true;
                    }
                    __imageFormat = Format.JPG;
                    //__exportLayerComps = true; //force using this mode
                    break;
                case "png":
                    __imageFormat = Format.PNG;
                    //__exportLayerComps = true;
                    break;
                case "gif":
                    __imageFormat = Format.GIF;
                    break;
                case "pdf":
                    __imageFormat = Format.PDF;
                    __exportLayerComps = true;
                    break;
                case "sc":
                    __jpgSaveOptions.Quality = 12;
                    __imageFormat = Format.JPG;
                    __exportLayerComps = true; //force using this mode
                    break;
                default: // Export each layer by its name
                    __jpgSaveOptions.Quality = int.Parse(__args[4 + __form.idx]);
                    __imageFormat = Format.JPG;
                    break;
            }

            switch (__args[3 + __form.idx])
            {
                case "name":
                    __isNamedLayerComp = true;
                    break;
                case "index":
                    __isNamedLayerComp = false;
                    break;
                default:
                    __isNamedLayerComp = false;
                    break;
            }

            Photoshop.ExportOptionsSaveForWeb __gifExportOptionsSaveForWeb = new Photoshop.ExportOptionsSaveForWeb();
            //gifExportOptionsSaveForWeb.MatteColor = 255
            __gifExportOptionsSaveForWeb.Format = Photoshop.PsSaveDocumentType.psCompuServeGIFSave; // 3;
            __gifExportOptionsSaveForWeb.ColorReduction = Photoshop.PsColorReductionType.psAdaptive; //1;
            __gifExportOptionsSaveForWeb.Colors = 256;
            __gifExportOptionsSaveForWeb.Dither = Photoshop.PsDitherType.psNoise; //3;
            __gifExportOptionsSaveForWeb.DitherAmount = 100;
            __gifExportOptionsSaveForWeb.Quality = 100;
            __gifExportOptionsSaveForWeb.Transparency = true;
            __gifExportOptionsSaveForWeb.TransparencyAmount = 100;
            __gifExportOptionsSaveForWeb.TransparencyDither = Photoshop.PsDitherType.psNoDither; //2;
            __gifExportOptionsSaveForWeb.IncludeProfile = false;
            __gifExportOptionsSaveForWeb.Lossy = 0;
            __gifExportOptionsSaveForWeb.WebSnap = 0;

            Photoshop.ExportOptionsSaveForWeb __pngExportOptionsSaveForWeb = new Photoshop.ExportOptionsSaveForWeb();
            __pngExportOptionsSaveForWeb.Format = Photoshop.PsSaveDocumentType.psPNGSave; // 13;
            __pngExportOptionsSaveForWeb.PNG8 = false;
            __pngExportOptionsSaveForWeb.Transparency = true;

            Photoshop.PDFSaveOptions __pdfSaveOptions = new Photoshop.PDFSaveOptions();
            __pdfSaveOptions.AlphaChannels = false;
            __pdfSaveOptions.Annotations = false;
            __pdfSaveOptions.DowngradeColorProfile = true;
            __pdfSaveOptions.EmbedColorProfile = true;
            __pdfSaveOptions.Encoding = Photoshop.PsPDFEncodingType.psPDFJPEG;
            __pdfSaveOptions.Interpolation = false;
            __pdfSaveOptions.JPEGQuality = 9;
            __pdfSaveOptions.Layers = false;
            __pdfSaveOptions.SpotColors = false;
            __pdfSaveOptions.Transparency = false;
            __pdfSaveOptions.UseOutlines = false;
            __pdfSaveOptions.VectorData = false;

            //MessageBox.Show(__args(3))

            //MessageBox.Show(__imageType)

            __compsCount = __docRef.LayerComps.Count;

            //ActionSaveScreenSelection __asss = new ActionSaveScreenSelection(__docRef, __jpgSaveOptions);
            ActionSaveScreenSelection __asss = new ActionSaveScreenSelection(__docRef);

            __hasSelection = __asss.hasSelection;
            if (__asss.hasSelection)
                __asss.wipeOldScreens();

            // Exporting layercomps by index or name
            if (__exportLayerComps)
            {
                if (__compsCount <= 1)
                {
                    //Set textItemRef = appRef.ActiveDocument.Layers(1)

                    //textItemRef.TextItem.Contents = Args.Item(1)

                    //outFileName = Args.Item(1)
                    if (__selectionOnly) // IF screen selection then save crop
                    {
                        if (__asss.count >= 1)
                        {
                            __asss.saveAll();
                        }
                    }
                    else
                    {
                        //MessageBox.Show(__args[1]);
                        if (__imageFormat == Format.JPG)
                        {
                            __docRef.SaveAs(__args[1 + __form.idx], __jpgSaveOptions, true, null);
                        }
                        else if (__imageFormat == Format.PNG)
                        {
                            __fileNameBody = __docRef.Name.Substring(0, __docRef.Name.LastIndexOf(".")) + ".png";
                            //MessageBox.Show(__docRef.Path + __fileNameBody);
                            __docRef.Export(__docRef.Path + __fileNameBody, 2, __pngExportOptionsSaveForWeb);

                            if (__fileNameBody.Replace(" ", "-") != __fileNameBody)
                            {
                                if (File.Exists(__docRef.Path + __fileNameBody))
                                    File.Delete(__docRef.Path + __fileNameBody);
                                try
                                {
                                    //MessageBox.Show(__fileNameBody.Replace(" ", "-"));
                                    File.Move(__docRef.Path + __fileNameBody.Replace(" ", "-"), __docRef.Path + __fileNameBody);
                                }
                                catch { }
                            }
                        }
                        else if (__imageFormat == Format.PDF)
                        {
                            __fileNameBody = __docRef.Name.Substring(0, __docRef.Name.LastIndexOf(".")) + ".pdf";
                            __docRef.SaveAs(__docRef.Path + __fileNameBody, __pdfSaveOptions, false, Photoshop.PsExtensionType.psLowercase);
                        }
                        else
                        {
                            __fileNameBody = __docRef.Name.Substring(0, __docRef.Name.LastIndexOf(".")) + ".gif";
                            __docRef.Export(__docRef.Path + __fileNameBody, 2, __gifExportOptionsSaveForWeb);
                        }
                    }

                }
                else
                {
                    //msgbox("comps!")
                    for (__compsIndex = 1; __compsIndex <= __compsCount; __compsIndex++)
                    {
                        //MsgBox(docRef.LayerComps.Count)
                        //End
                        __compRef = __docRef.LayerComps[__compsIndex];
                        //if (exportInfo.selectionOnly && !compRef.selected) continue; // selected only
                        __compRef.Apply();

                        //msgbox(compRef.Name)
                        __duppedDocument = null;

                        /*if (__hasSelection)
                        {
                            try
                            {
                                __duppedDocument = __docRef.Duplicate(null, null);
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Essayez de redémarrer UTC FMCore");
                            }
                            if (__screenSelectionList.Count > 0)
                            {
                                if (__screenSelectionList.Contains(__compsIndex.ToString()))
                                    saveScreenSelection(__docRef, __duppedDocument, __compsIndex, __jpgSaveOptions);
                                else
                                    __duppedDocument.Close(2);
                            }
                            else
                            {
                                saveScreenSelection(__docRef, __duppedDocument, __compsIndex, __jpgSaveOptions);
                            }
                        }*/

                        if (__selectionOnly)
                        {
                            if (__asss.count >= 1)
                            {
                                __asss.saveAll(__compsCount, __compsIndex);
                            }
                        }
                        else
                        {

                            try
                            {
                                __duppedDocument = __docRef.Duplicate(null, null);
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Essayez de redémarrer UTC FMCore");
                            }

                            if (!__isNamedLayerComp)
                            {
                                // cleaning single JPEG file if layer comps > 1
                                if (File.Exists(__docRef.Name.Substring(0, __docRef.Name.LastIndexOf(".")) + ".jpg"))
                                {
                                    File.Delete(__docRef.Name.Substring(0, __docRef.Name.LastIndexOf(".")) + ".jpg");
                                }
                                __fileNameBody = __docRef.Name.Substring(0, __docRef.Name.LastIndexOf(".")) + "." + __compsIndex;
                            }
                            else
                            {
                                __fileNameBody = __compRef.Name;
                            }

                            if (__imageFormat == Format.JPG)
                            {
                                __fileNameBody += ".jpg";
                                __duppedDocument.SaveAs(__docRef.Path + __fileNameBody, __jpgSaveOptions, true, null);
                            }
                            else if (__imageFormat == Format.PNG)
                            {
                                __fileNameBody += ".png";
                                //MessageBox.Show(__docRef.Path + __fileNameBody);
                                __duppedDocument.Export(__docRef.Path + __fileNameBody, 2, __pngExportOptionsSaveForWeb);

                                if (__fileNameBody.Replace(" ", "-") != __fileNameBody)
                                {
                                    if (File.Exists(__docRef.Path + __fileNameBody))
                                        File.Delete(__docRef.Path + __fileNameBody);
                                    try
                                    {
                                        File.Move(__docRef.Path + __fileNameBody.Replace(" ", "-"), __docRef.Path + __fileNameBody);
                                    }
                                    catch
                                    {

                                    }
                                }
                            }
                            else if (__imageFormat == Format.PDF)
                            {
                                __fileNameBody += ".pdf";
                                //MessageBox.Show(__docRef.Path + __fileNameBody);
                                //__duppedDocument.Export(__docRef.Path + __fileNameBody, 2, __pdfExportOptionsSaveForWeb);

                                __duppedDocument.SaveAs(__docRef.Path + __fileNameBody, __pdfSaveOptions, false, Photoshop.PsExtensionType.psLowercase);
                            }
                            else
                            {
                                __fileNameBody += ".gif";
                                __duppedDocument.Export(__docRef.Path + __fileNameBody, 2, __gifExportOptionsSaveForWeb);
                            }
                            __duppedDocument.Close(2);

                        }
                    }
                    __compRef = __docRef.LayerComps[1];
                    __compRef.Apply();
                }

                //MsgBox(Me.AutoArchive.Checked)
                archiveFiles(__docRef);

                FileInfo __selectedfile = new FileInfo(__docRef.Name);
                string __selectedfileext = __selectedfile.Extension;
                //MessageBox.Show(__selectedfile.Extension);
                List<string> __allowedext = new List<string>(new string[] { ".psd", ".psb" });
                if (__allowedext.Contains(__selectedfile.Extension.ToLower()) && __exportFonts) listFonts(__docRef, __docRef.Name, true);
            }
            else //Exporting each layers by name
            {
                Photoshop.ArtLayer __layer;
                for (__compsIndex = 1; __compsIndex <= __docRef.ArtLayers.Count; __compsIndex++)
                {
                    __layer = __docRef.ArtLayers[__compsIndex];
                    //isVisible = oLayer.visible
                    __appRef.ActiveDocument.ActiveLayer = __layer;
                    //oLayer.Apply()
                    //duppedDocument = docRef.Duplicate()
                    //msgbox(compRef.Name)
                    __fileNameBody = (string)(__layer.Name + ".jpg");
                    //msgbox(fileNameBody)
                    __docRef.SaveAs(__docRef.Path + __fileNameBody, __jpgSaveOptions, true, null);

                    __layer.Visible = false;
                    __appRef.ActiveDocument.ActiveLayer = __layer;
                    //duppedDocument.Close(2)
                }
            }

            //ExportImagesRights()
            if (__compsCount > 0)
            {
                __compRef = __docRef.LayerComps[1];
                __compRef.Apply();
            }
        }
Пример #28
0
        public void OpenWithConstraints(ref ps.ApplicationClass app, ref ps.Document doc, FileInfo file, double width, double height)
        {
            // Set EPS openning options
            // Open with Width constraint
            ps.EPSOpenOptionsClass EpsOpenOptsWidth = new ps.EPSOpenOptionsClass();
            EpsOpenOptsWidth.AntiAlias = _antiAlias;
            EpsOpenOptsWidth.ConstrainProportions = _constrainProportions;
            EpsOpenOptsWidth.Mode = _mode;
            EpsOpenOptsWidth.Resolution = _resolution;
            EpsOpenOptsWidth.Width = PsTools.GetPixelUnit(width,_resolution);

            // Open with Height constraint
            ps.EPSOpenOptionsClass EpsOpenOptsHeight = new ps.EPSOpenOptionsClass();
            EpsOpenOptsHeight.AntiAlias = _antiAlias;
            EpsOpenOptsHeight.ConstrainProportions = _constrainProportions;
            EpsOpenOptsHeight.Mode = _mode;
            EpsOpenOptsHeight.Resolution = _resolution;
            EpsOpenOptsHeight.Height = PsTools.GetPixelUnit(height, _resolution);

            doc = app.Open(file.FullName, EpsOpenOptsWidth);

            if (doc.Height > height)
            {
                Close(ref doc);
                doc = app.Open(file.FullName, EpsOpenOptsHeight);
            }
        }
Пример #29
0
        private void addFont(Photoshop.Document __docRef, List<string> __fonts, string __filename, bool __messageWhenDone)
        {
            Regex __RegexObj = new Regex("_(v|V)\\d*$");
            string __shortfilename = __docRef.Name.Substring(0, __filename.LastIndexOf("."));
            __shortfilename = __RegexObj.Replace(__shortfilename, "");

            StreamWriter __sw;

            /*
            List<string> __existingFonts = new List<string>();
            string __outputFonts;

            if (File.Exists(__docRef.Path + "\\fonts.txt"))
            {
                string[] __lines = File.ReadAllLines(__docRef.Path + "\\fonts.txt");
                __existingFonts = new List<string>(__lines);

                //__sw = File.AppendText(__docRef.Path + "\\fonts.txt");
            }
            else
            {
                //__sw = File.CreateText(__docRef.Path + "\\fonts.txt");
            }

            foreach (string __item in __fonts)
            {
                if (!__existingFonts.Contains(__item))
                    __existingFonts.Add(__item);
            }

            __existingFonts.Sort();

            __outputFonts = string.Join(Environment.NewLine, __existingFonts.ToArray());

            File.WriteAllText(__docRef.Path + "\\fonts.txt", __outputFonts, System.Text.Encoding.UTF8);
            */
            //__sw.Close();

            if (!File.Exists(__docRef.Path + "\\fonts.txt"))
            {
                __sw = File.CreateText(__docRef.Path + "\\fonts.txt");
                __sw.Close();
            }

            IniParser __ini = new IniParser(__docRef.Path + "\\fonts.txt");

            foreach (string __item in __ini.EnumAllSections())
            {
                __ini.DeleteSetting(__item, __shortfilename);
            }
            __ini.DeleteSetting("Z---------------------------Z", "Total non system fonts");

            foreach (string __item in __fonts)
            {
                __ini.AddSetting(__item, __shortfilename, DateTime.Now.ToString());
            }

            int __countFont = 0;
            List<string> __addedFont = new List<string>();
            string __fontname;
            foreach (string __item in __ini.EnumAllSections())
            {
                //MessageBox.Show(__item);

                if (__item.IndexOf("-") > -1)
                    __fontname = __item.Substring(0, __item.IndexOf("-"));
                else
                    __fontname = __item;

                if (!__systemFont.Contains(__fontname) && !__addedFont.Contains(__item))
                {
                    __countFont++;
                    __addedFont.Add(__item);
                }
            }
            __ini.AddSetting("Z---------------------------Z", "Total non system fonts", __countFont.ToString());
            __ini.SaveSettings();

            /*InstalledFontCollection __fontsCollection = new InstalledFontCollection();
            FontFamily[] __fontFamilies = __fontsCollection.Families;
            List<string> __sysfonts = new List<string>();
            foreach (FontFamily __font in __fontFamilies)
            {
                __sysfonts.Add(__font.Source);
            }*/

            if (__messageWhenDone) AutoClosingMessageBox.Show("Fonts list saved !", "PSTools", 1500);
        }
Пример #30
0
 public void ExtendCanvas(ref ps.Document doc, double width, double height)
 {
     _def.ExtendCanvas(ref doc, width, height);
 }
Пример #31
0
        /// <summary>
        /// Archives the files.
        /// </summary>
        /// <param name="__docRef">The __doc ref.</param>
        private void archiveFiles(Photoshop.Document __docRef)
        {
            DirectoryInfo __di;
            try
            {
                __di = new DirectoryInfo(__docRef.Path);
            }
            catch (Exception)
            {
                goto finish;
            }

            //MsgBox(di.Name)
            if (__form.AutoArchive.Checked && !isExcludeDirectory(__di.Name))
            {

                //Dim di As DirectoryInfo
                FileInfo[] __afi;

                //MsgBox(Directory.Exists(docRef.Path & "\" & Me.ArchiveDirectory.Text & "\"))
                //If Not Directory.Exists(__docRef.Path & "\" & Me.ArchiveDirectory.Text & "\") Then
                //Directory.CreateDirectory(__docRef.Path & "\" & Me.ArchiveDirectory.Text & "\")
                //End If

                //di = New DirectoryInfo(docRef.Path)
                string __currentFileName = __docRef.Name.Substring(0, __docRef.Name.LastIndexOf("."));

                //Dim __RegexObj As Regex = New Regex("\d*$")
                Regex __RegexObj = new Regex("(\\d*)\\.*\\d*$");
                Match __myMatches;
                string __currentVersion;
                string __cleanFileName;

                if (__RegexObj.IsMatch(__currentFileName))
                {
                    __myMatches = __RegexObj.Match(__currentFileName);
                    __currentVersion = __myMatches.Value;

                    if (__currentVersion.Length < 1)
                    {
                        goto finish;
                    }

                    __cleanFileName = __RegexObj.Replace(__currentFileName, "");
                    __cleanFileName = __cleanFileName.Replace("+", "\\+");
                    __cleanFileName = __cleanFileName.Replace(" ", "\\s");
                    //MsgBox(__cleanFileName)
                    Regex __RegexObj2 = new Regex("^" + __cleanFileName + "(\\d+|\\.)");

                    __afi = __di.GetFiles("*.*");
                    //MsgBox(__currentVersion)
                    foreach (FileInfo __fi in __afi)
                    {
                        if (__RegexObj2.IsMatch(__fi.Name))
                        {
                            //MsgBox(__fi.Name)
                            if (isOldFileVersion(__fi.Name, __currentVersion.ToString())) //And Directory.Exists(__docRef.Path & "\" & Me.ArchiveDirectory.Text & "\") Then
                            {
                                //MsgBox(__fi.Name)
                                if (!Directory.Exists(__docRef.Path + "\\" + __form.ArchiveDirectory.Text + "\\"))
                                {
                                    Directory.CreateDirectory(__docRef.Path + "\\" + __form.ArchiveDirectory.Text + "\\");
                                }
                                try
                                {
                                    File.Copy(__docRef.Path + __fi.Name, __docRef.Path + "\\" + __form.ArchiveDirectory.Text + "\\" + __fi.Name, true);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                }

                                try
                                {
                                    File.Delete(__docRef.Path + __fi.Name);
                                }
                                catch { }

                            }
                        }
                    }
                }
            }

            finish:{ }
        }
Пример #32
0
 public void Save(ref ps.Document doc, IFileSaver fileSaver, FileInfo file)
 {
     _def.Save(ref doc, fileSaver, file);
 }
Пример #33
0
 /// <summary>
 /// Closes the document.
 /// </summary>
 /// <param name="__docRef">Document refrence</param>
 private void closeDocument(Photoshop.Document __docRef)
 {
     if (!__keepOpen)
     {
         __docRef.Close(2);
     }
 }
Пример #34
0
 public void SetUnits(ref ps.ApplicationClass app, ref ps.Document doc)
 {
     _def.SetUnits(ref app, ref doc);
 }
Пример #35
0
        /// <summary>
        /// Exports the assets.
        /// </summary>
        /// <param name="__docRef">Document reference</param>
        /// <param name="_layers">Layers</param>
        /// <returns></returns>
        private bool exportAssets(Photoshop.Document __docRef, object _layers)
        {
            Photoshop.Layers __layers;
            Photoshop.ArtLayer __alayer = null;
            Photoshop.LayerSet __slayer;
            bool __isArtLayer = false;
            object __layer;
            int __j;

            __layers = (Photoshop.Layers)_layers;
            for (__j = 1; __j <= __layers.Count; __j++)
            {
                __appRef.ActiveDocument = __docRef;
                __layer = __layers[__j];

                try
                {
                    __alayer = (Photoshop.ArtLayer)__layer;
                    __isArtLayer = true;
                }
                catch //(Exception __e)
                {
                    __isArtLayer = false;
                }

                if (__isArtLayer) // Everything as Layer goes here
                {
                    __appRef.ActiveDocument.ActiveLayer = __layer;
                    if (__alayer.Name.IndexOf(".png") > -1)
                    {
                        saveAsset(__docRef, __alayer.Name);
                    }
                }
                else
                {
                    try
                    {
                        __slayer = (Photoshop.LayerSet)__layer;
                        __appRef.ActiveDocument.ActiveLayer = __layer;

                        if (__slayer.LayerType == Photoshop.PsLayerType.psLayerSet)
                        {

                            if (__slayer.Name.IndexOf(".png") > -1)
                            {
                                saveAsset(__docRef, __slayer.Name, __slayer.Layers);
                            }
                            else
                            {
                                exportAssets(__docRef, __slayer.Layers);
                            }
                        }
                    }
                    catch //(Exception __e)
                    {
                        //MessageBox.Show("error>" + __e.Message);
                    }
                }
            }
            return true;
        }