Пример #1
0
        public void DrawByName(string name, string exportPath, string logoName,
                               string splitString, string exportSplitString, bool isScaleAll)
        {
            if (!Directory.Exists(exportPath))
            {
                Directory.CreateDirectory(exportPath);
            }

            // get list logo order behind main logo
            ScriptConfig        config   = props.ScriptConfig;
            List <ScriptObject> logoList = config.LogoList.OrderBy(p => p.Order).ToList();

            string[] names      = name.Trim().Split(new string[] { splitString }, StringSplitOptions.None);
            string   exportName = name.Replace(splitString, exportSplitString);

            for (int i = 0; i < names.Length; i++)
            {
                ScriptObject obj      = logoList[i];
                string       fontPath = props.LogoRootPath + obj.FontName;
                Font         ff       = GetCustomFont(fontPath, obj.FontSize);
                {
                    Layer layer = new Layer(new LayerText(names[i], ff, obj.FontSize, LogoUtil.ConvertStringToColor(obj.TextColor)
                                                          , (int)obj.OutlineSize, LogoUtil.ConvertStringToColor(obj.OutlineColorHex)
                                                          , (LineJoin)obj.LineJoin));

                    layer.UpdateLayer(obj.LogoPosition, obj.LogoScale, obj.LogoRotation, obj.LogoContainer);
                    layerManager.AddTextLayer(layer);
                }
            }
            if (logoList.Count > 0)
            {
                layerManager.ExportImage(exportPath + exportName + ".png", new Size(2400, 3200), isScaleAll);
            }
        }
Пример #2
0
 public void ConvertToScriptConfig(string savePath)
 {
     if (Layers.Count > 0)
     {
         ScriptConfig config = new ScriptConfig();
         for (int i = 0; i < Layers.Count; i++)
         {
             Layer layer = Layers[i];
             if (layer.LayerName.ToLower().StartsWith("textlayer"))
             {
                 ScriptObject obj = new ScriptObject();
                 obj.LineJoin        = (int)layer.LayerText.OutlineStyle;
                 obj.LogoContainer   = layer.Transform.Size;
                 obj.LogoPosition    = layer.Transform.Position;
                 obj.LogoRotation    = layer.Transform.Rotation;
                 obj.LogoScale       = layer.Transform.Scale;
                 obj.Order           = layer.Order;
                 obj.OutlineColorHex = LogoUtil.ColorToHex(layer.LayerText.OutlineColor);
                 obj.OutlineSize     = layer.LayerText.OutlineSize;
                 obj.TextColor       = LogoUtil.ColorToHex(layer.LayerText.TextColor);
                 obj.FontSize        = layer.LayerText.FontSize;
                 obj.FontName        = "font.ttf";
                 config.LogoList.Add(obj);
             }
         }
         config.AutoScaleAll = this.AutoScaleAll;
         FileUtil.WriteConfig <ScriptConfig>(config, savePath);
     }
 }
Пример #3
0
        public void DrawByName(string name, string exportPath, string logoName)
        {
            try
            {
                if (!Directory.Exists(exportPath))
                {
                    Directory.CreateDirectory(exportPath);
                }

                // get list logo order behind main logo
                ScriptConfig        config   = props.ScriptConfig;
                List <ScriptObject> logoList = config.LogoList.OrderBy(p => p.Order).ToList();
                string[]            names    = name.Trim().Split(new string[] { Settings.Default.SplitString }, StringSplitOptions.None);
                string exportName            = name.Replace(Settings.Default.SplitString, Settings.Default.ExportSplitString);
                for (int i = 0; i < names.Length; i++)
                {
                    ScriptObject obj      = logoList[i];
                    string       fontPath = props.LogoRootPath + obj.FontName;
                    Font         ff       = GetCustomFont(fontPath, obj.FontSize);
                    {
                        AutoArtist.Model.Layer layer = new AutoArtist.Model.Layer(new AutoArtist.Model.LayerText(names[i], ff, obj.FontSize, LogoUtil.ConvertStringToColor(obj.TextColor)
                                                                                                                 , (int)obj.OutlineSize, LogoUtil.ConvertStringToColor(obj.OutlineColorHex)
                                                                                                                 , (LineJoin)obj.LineJoin));

                        layer.UpdateLayer(obj.LogoPosition, obj.LogoScale, obj.LogoRotation, obj.LogoContainer);
                        layerManager.AddTextLayer(layer);
                    }
                }
                if (logoList.Count > 0)
                {
                    layerManager.ExportImage(exportPath + exportName + ".png", new Size(2400, 3200), config.AutoScaleAll);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Cannot found any logo info!");
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Error: " + ex.Message);
            }
        }
Пример #4
0
        private string CreateNewSunfrogData(string names, string logoPath, ref string refTitle, bool isFast)
        {
            string exportName = names.Replace(Settings.Default.SplitString, Settings.Default.ExportSplitString);

            //string[] temp = name.Split(new string[] { Settings.Default.SplitString }, StringSplitOptions.None);

            string[] temp     = names.Split(new string[] { Settings.Default.SplitString }, StringSplitOptions.None);
            string   realName = names;

            if (temp != null)
            {
                realName = temp[0];
            }
            UploadModel model = new UploadModel();

            model.ArtOwnerID  = SunfrogController.Instance.AM;
            model.Category    = ContentConfig.Category;
            model.IAgree      = true;
            model.Description = ContentConfig.Description.Replace("{NAME}", realName);
            string[] titleArr  = ContentConfig.Title.Split(';');
            Random   rand      = new Random();
            int      randIndex = rand.Next(0, titleArr.Length);

            if (temp != null && temp.Length > 0)
            {
                //model.Title = UploadContent.Title;
                model.Title = titleArr[randIndex];
                for (int i = 0; i < temp.Length; i++)
                {
                    model.Title = model.Title.Replace("{" + i + "}", temp[i]);
                    // model.Keywords.Add(temp[i]);
                }
                model.Keywords.Add(string.Format(ContentConfig.SiteTags, realName));
            }
            else
            {
                model.Title = string.Format(titleArr[randIndex], realName);
                model.Keywords.Add(string.Format(ContentConfig.SiteTags, realName));
            }

            refTitle = model.Title;

            model.imageFront = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"2400px\" height=\"3200px\" " +
                               "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" +
                               "<g id=\"SvgjsG1048\" transform=\"rotate(0 1200 1600) translate({0}) scale({1}) \">" +
                               "<image id=\"SvgjsImage1049\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" " +
                               "xlink:href=\"__dataURI:0__\" width=\"2400\" height=\"3200\"></image></g></svg>";
            //model.imageFront = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http:/www.w3.org/1999/xlink\" "
            //    + "id=\"SvgjsSvg1000\" version=\"1.1\" width=\"2400\" height=\"3200\" " +
            //    "viewBox=\"311.00000000008 230 387.99999999984004 517.33333333312\"><g id=\"SvgjsG1048\" transform=\"scale(0.15749999999993336 0.15749999999993336) translate({0})\">" +
            //    "<image id=\"SvgjsImage1049\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:href=\"__dataURI:0__\" width=\"2400\" height=\"3200\">" +
            //    "</image></g><defs id=\"SvgjsDefs1001\"></defs></svg>";
            model.imageFront = string.Format(model.imageFront, LogoConfig.MockupPosition, LogoConfig.MockupScale);
            ////   model.imageFront = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"2400\" height=\"3200\" viewBox=\"311.00000000008 230 387.99999999984004 517.33333333312\" "+
            ////  "xmlns:xlink=\"http://www.w3.org/1999/xlink\">" +
            ////  "<g id=\"SvgjsG1048\" transform=\"rotate(0 1200 1600) translate({0}) scale({1}) \">" +
            ////  "<image id=\"SvgjsImage1049\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" " +
            ////  "xlink:href=\"__dataURI:0__\" width=\"2400\" height=\"3200\"></image></g></svg>";

            ////   model.imageFront = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" id=\"SvgjsSvg1000\" version=\"1.1\" width=\"2400\" height=\"3200\" viewBox=\"311.00000000008 230 387.99999999984004 517.33333333312\"><g id=\"SvgjsG1048\" transform=\"scale(0.15749999999993336 0.15749999999993336) translate(2006.349206350563 1502.645502646138)\"><image id=\"SvgjsImage1049\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:href=\"__dataURI:0__\" width=\"2400\" height=\"3200\"></image></g><defs id=\"SvgjsDefs1001\"></defs></svg>";
            model.imageBack = "";
            ImageLink imgLink = new ImageLink();

            imgLink.id  = "__dataURI:0__";
            imgLink.uri = "data:image/png;base64," +
                          LogoUtil.ImageToBase64(Image.FromFile(logoPath),
                                                 System.Drawing.Imaging.ImageFormat.Png);

            ShirtType guys = new ShirtType();

            guys.id    = "8";
            guys.name  = "Guys Tee";
            guys.price = ContentConfig.GuysPrice.ToString();
            guys.price = guys.price.Replace(',', '.');
            // guys.colors.AddRange(LogoScript.GuysColor.Split(','));
            guys.colors.Add(LogoConfig.GuysColor.Split(',')[0]);

            ShirtType ladies = new ShirtType();

            ladies.id    = "34";
            ladies.name  = "Ladies Tee";
            ladies.price = ContentConfig.LadiesPrice.ToString();
            ladies.price = ladies.price.Replace(',', '.');
            //ladies.colors.AddRange(LogoScript.LadiesColor.Split(','));
            ladies.colors.Add(LogoConfig.LadiesColor.Split(',')[0]);

            ShirtType sweatShirt = new ShirtType();

            sweatShirt.id    = "27";
            sweatShirt.name  = "Sweat Shirt";
            sweatShirt.price = ContentConfig.SweatShirtPrice.ToString();
            sweatShirt.price = sweatShirt.price.Replace(',', '.');
            //sweatShirt.colors.AddRange(LogoScript.SweatShirtColor.Split(','));
            sweatShirt.colors.Add(LogoConfig.SweatShirtColor.Split(',')[0]);

            ShirtType youthTee = new ShirtType();

            youthTee.id    = "35";
            youthTee.name  = "Youth Tee";
            youthTee.price = ContentConfig.YouthTeePrice.ToString();
            youthTee.price = youthTee.price.Replace(',', '.');
            //sweatShirt.colors.AddRange(LogoScript.SweatShirtColor.Split(','));
            youthTee.colors.Add(LogoConfig.YouthTeeColor.Split(',')[0]);

            ShirtType guysVNeck = new ShirtType();

            guysVNeck.id    = "50";
            guysVNeck.name  = "Guys V-Neck";
            guysVNeck.price = ContentConfig.GuysVNeckPrice.ToString();
            guysVNeck.price = guysVNeck.price.Replace(',', '.');
            //guysVNeck.colors.AddRange(LogoScript.GuysVNeck.Split(','));
            guysVNeck.colors.Add(LogoConfig.GuysVNeck.Split(',')[0]);

            ShirtType ladiesVNeck = new ShirtType();

            ladiesVNeck.id    = "116";
            ladiesVNeck.name  = "Ladies V-Neck";
            ladiesVNeck.price = ContentConfig.LadiesVNeckPrice.ToString();
            ladiesVNeck.price = ladiesVNeck.price.Replace(',', '.');
            // ladiesVNeck.colors.AddRange(LogoScript.LadiesVNeck.Split(','));
            ladiesVNeck.colors.Add(LogoConfig.LadiesVNeck.Split(',')[0]);

            ShirtType unisexTankTop = new ShirtType();

            unisexTankTop.id    = "118";
            unisexTankTop.name  = "Unisex Tank Top";
            unisexTankTop.price = ContentConfig.UnisexTankTopPrice.ToString();
            unisexTankTop.price = unisexTankTop.price.Replace(',', '.');
            //unisexTankTop.colors.AddRange(LogoScript.UnisexTankTop.Split(','));
            unisexTankTop.colors.Add(LogoConfig.UnisexTankTop.Split(',')[0]);

            ShirtType unisexLongSleeve = new ShirtType();

            unisexLongSleeve.id    = "119";
            unisexLongSleeve.name  = "Unisex Long Sleeve";
            unisexLongSleeve.price = ContentConfig.UnisexLongSleeve.ToString();
            unisexLongSleeve.price = unisexLongSleeve.price.Replace(',', '.');
            //unisexLongSleeve.colors.AddRange(LogoScript.UnisexLongSleeve.Split(','));
            unisexLongSleeve.colors.Add(LogoConfig.UnisexLongSleeve.Split(',')[0]);


            ShirtType hoodie = new ShirtType();

            hoodie.id    = "19";
            hoodie.name  = "Hoodie";
            hoodie.price = ContentConfig.HoodiesPrice.ToString();
            hoodie.price = hoodie.price.Replace(',', '.');
            //hoodie.colors.AddRange(LogoScript.HoodieColor.Split(','));
            hoodie.colors.Add(LogoConfig.HoodieColor.Split(',')[0]);

            model.images.Add(imgLink);

            if (LogoConfig.PrimaryMockupName.ToLower().StartsWith("hoodie"))
            {
                //hoodie.colors.RemoveRange(1, hoodie.colors.Count - 1);
                model.types.Add(hoodie);
                model.types.Add(guys);
                model.types.Add(ladies);
                if (!isFast)
                {
                    model.types.Add(guysVNeck);
                    model.types.Add(ladiesVNeck);
                    model.types.Add(unisexLongSleeve);
                    model.types.Add(unisexTankTop);
                    model.types.Add(sweatShirt);
                    model.types.Add(youthTee);
                }
            }
            else if (LogoConfig.PrimaryMockupName.ToLower().StartsWith("guys"))
            {
                //guys.colors.RemoveRange(1, guys.colors.Count - 1);
                model.types.Add(guys);
                model.types.Add(ladies);
                model.types.Add(hoodie);
                if (!isFast)
                {
                    model.types.Add(guysVNeck);
                    model.types.Add(ladiesVNeck);
                    model.types.Add(unisexLongSleeve);
                    model.types.Add(unisexTankTop);
                    model.types.Add(sweatShirt);
                    model.types.Add(youthTee);
                }
            }
            else if (LogoConfig.PrimaryMockupName.ToLower().StartsWith("ladies"))
            {
                //ladies.colors.RemoveRange(1, ladies.colors.Count - 1);
                model.types.Add(ladies);
                model.types.Add(guys);
                model.types.Add(hoodie);
                if (!isFast)
                {
                    model.types.Add(guysVNeck);
                    model.types.Add(ladiesVNeck);
                    model.types.Add(unisexLongSleeve);
                    model.types.Add(unisexTankTop);
                    model.types.Add(sweatShirt);
                    model.types.Add(youthTee);
                }
            }


            return(Newtonsoft.Json.JsonConvert.SerializeObject(model));
        }