string title = project.Variables["text_centr_left"].Value;
string url_logo = project.Variables["url_logo_center_top"].Value;
string url_product = project.Variables["url_product_center_center"].Value;
string title_one=project.Variables["text_top_center"].Value;
string title_two=project.Variables["text_center_center"].Value;
string title_category=project.Variables["text_center_bottom"].Value;
string price=project.Variables["text_bottom_left"].Value;
string currency=project.Variables["text_bottom_right"].Value;
string base64_product_temp=project.Variables["temp_img"].Value;
string code_html = String.Empty;
string base64_logo = String.Empty;
string base64_product = String.Empty;
var font = new List<string>();
var rand = new Random();
#region Шрифты
font.Add("font-family: 'Roboto', sans-serif;");
font.Add("font-family: 'Open Sans', sans-serif;");
font.Add("font-family: 'Roboto Condensed', sans-serif;");
font.Add("font-family: 'Oswald', sans-serif;");
font.Add("font-family: 'PT Sans', sans-serif;");
font.Add("font-family: 'Merriweather', serif;");
font.Add("font-family: 'Roboto Slab', serif;");
font.Add("font-family: 'Lora', serif;");
font.Add("font-family: 'Ubuntu', sans-serif;");
font.Add("font-family: 'Playfair Display', serif;");
font.Add("font-family: 'Arimo', sans-serif;");
font.Add("font-family: 'PT Serif', serif;");
font.Add("font-family: 'Noto Sans', sans-serif;");
font.Add("font-family: 'Noto Serif', serif;");
font.Add("font-family: 'Yanone Kaffeesatz', sans-serif;");
font.Add("font-family: 'Fira Sans', sans-serif;");
font.Add("font-family: 'Roboto Mono', monospace;");
font.Add("font-family: 'Exo 2', sans-serif;");
font.Add("font-family: 'Rubik', sans-serif;");
font.Add("font-family: 'Cuprum', sans-serif;");
font.Add("font-family: 'Cormorant Garamond', serif;");
font.Add("font-family: 'Istok Web', sans-serif;");
font.Add("font-family: 'Philosopher', sans-serif;");
font.Add("font-family: 'Playfair Display SC', serif;");
font.Add("font-family: 'Tinos', serif;");
font.Add("font-family: 'Jura', sans-serif;");
font.Add("font-family: 'Scada', sans-serif;");
font.Add("font-family: 'Arsenal', sans-serif;");
font.Add("font-family: 'Cousine', monospace;");
font.Add("font-family: 'Fira Sans Condensed', sans-serif;");
font.Add("font-family: 'Fira Sans Extra Condensed', sans-serif;");
font.Add("font-family: 'Ubuntu Mono', monospace;");
font.Add("font-family: 'Anonymous Pro', monospace;");
font.Add("font-family: 'Cormorant', serif;");
font.Add("font-family: 'Podkova', serif;");
font.Add("font-family: 'Cormorant Infant', serif;");
font.Add("font-family: 'Cormorant SC', serif;");
font.Add("font-family: 'Cormorant Unicase', serif;");
font.Add("font-family: 'El Messiri', sans-serif;");
font.Shuffle();
#endregion
title = Regex.Replace(title.Trim(), @"(\s+|\s)", " ");
base64_logo = CommonCode.base64_img(url_logo);
base64_product = CommonCode.base64_img(url_product);
string base64_fon = CommonCode.base64_img(@"http://bgrepeat.com/load-new.php?p=128-"+rand.Next(0,218).ToString());
base64_fon="data:image/jpg;base64,"+base64_fon;
string base64_body = CommonCode.base64_img(@"http://bgrepeat.com/load-new.php?p=128-"+rand.Next(0,218).ToString());
base64_body="data:image/jpg;base64,"+base64_body;
if (string.IsNullOrEmpty(base64_logo)) {
base64_logo=String.Empty;}
else {
base64_logo = @"<span style=""display:block; background: white; width:100%;"" ><img class=""logo"" src=""data:image/jpg;base64,"+base64_logo+@""" /></span>";
}
if (string.IsNullOrEmpty(base64_product)) {
base64_product=String.Empty;
base64_product = CommonCode.base64_img(base64_product_temp);
if (string.IsNullOrEmpty(base64_product)) {
base64_product=String.Empty;}
else {
base64_product = @"<img class=""product"" style=""transform: rotate("+rand.Next(rand.Next(-25, 1), rand.Next(1, 25)).ToString()+@"""deg); src=""data:image/jpg;base64,"+base64_product+@""" alt="""" />";
}
}
else {
base64_product = @"<img class=""product"" style=""border: 5px solid rgba(0,0,0,0.5); box-shadow: -5px 5px -20px rgba(0,0,0,0.5);""src=""data:image/jpg;base64,"+base64_product+@""" alt="""" />";
}
if (string.IsNullOrEmpty(title_one)||title_one=="0") {
title_one = String.Empty;
} else {
title_one = @"<div class=""title"">"+title_one.ToUpper()+"</div>";
}
if (string.IsNullOrEmpty(title_two)||title_two=="0") {
title_two = String.Empty;
} else {
title_two = @"<div class=""title"">"+title_two.ToUpper()+"</div>";
}
if (string.IsNullOrEmpty(title_category)||title_category.ToUpper()=="0") {
title_category = String.Empty; }
else {
title_category = @"<div class=""title"">"+title_category.ToUpper()+"</div>";
}
string prices = @"<span style=""display:block; background: Yellow; width:95%; padding:10px; box-shadow: -15px 15px -30px rgba(0,0,0,0.5); border-radius: 0px 100px 100px 0px; z-index:1"">"+price.ToUpper()+" "+currency+"</span>";
string font_head=@"<link href=""https://fonts.googleapis.com/css?family=Roboto|Open+Sans|Roboto+Condensed|Oswald|PT+Sans|Merriweather|Roboto+Slab|Lora|Ubuntu|Playfair+Display|Arimo|PT+Serif|Noto+Sans|Noto+Serif|Yanone+Kaffeesatz|Fira+Sans|Roboto+Mono|Exo+2|Rubik|Cuprum|Cormorant+Garamond|Istok+Web|Philosopher|Playfair+Display+SC|Tinos|Jura|Scada|Arsenal|Cousine|Fira+Sans+Condensed|Fira+Sans+Extra+Condensed|Ubuntu+Mono|Anonymous+Pro|Cormorant|Podkova|Cormorant+Infant|Cormorant+SC|Cormorant+Unicase|El+Messiri|"" rel=""stylesheet"">";
code_html = @"<html><head>"+font_head+"<style>body { background-image:url("+base64_body+@");background-repeat:repeat; } #captcha{ width:735px; height:1102px;} .logo {display:block; height:80px; margin:0 auto; } .body {margin:10px auto; width:735px; height:1102px; }.title {text-align: center; color: white; font-weight: 900; font-size: 35pt;"+font[rand.Next(0, font.Count)].ToString()+"}.center {background:radial-gradient(circle farthest-side at 50px 20px, #FF6412, #E3440A); width:735px; height:75%; border-radius: 0 0 100% 0; border-bottom: 10px solid black; border-right: 10px solid black; position: relative;}.left{float:left; position: relative; padding: 30px 30px 30px 30px; top: 0; width: 450px; padding: 20px; font-size: 45pt; color: white; "+font[rand.Next(0, font.Count)].ToString()+"}.right{position: relative; float:right; margin-right:0px 0px 0px 0px; width:100%; top:-20%; text-align:center; color:green; padding:10px; font-size: 5em;"+font[rand.Next(0, font.Count)].ToString()+" font-weight: 900; }.product { display:block; position:relative; float:left; width:400px; top:-25%; left:40%; border-radius: 10px 100px 0px 100px; transform: rotate(-15deg); z-index:2; margin-top:10px; margin-bottom:10px; }</style></head>"
+@"<body><div id=""captcha""><div class=""body"" id=""layer2"">"+base64_logo+@"<div class=""center"">"+title_one + title_two + title_category + @"<div class=""left"">"+title+"</div></div>"+base64_product+@"<div class=""right"">"+prices+"</div></div><div></body></html>";
Tab tabs = instance.ActiveTab;
if (tabs.IsBusy) tabs.WaitDownloading();
tabs.SetSourceText(code_html);
System.Threading.Thread.Sleep(3000);
string temp_file = project.Directory + rand.Next(0,999).ToString() + rand.Next(50,700).ToString() + ".jpg";
//project.SendInfoToLog("Идем дальше", true);
HtmlElement img = instance.GetTabByAddress("page").FindElementById("captcha");
string recognition = ZennoPoster.CaptchaRecognition("CaptchaSaver.dll", img.DrawToBitmap(false), temp_file);
byte[] imageArray = System.IO.File.ReadAllBytes(@temp_file);
string base64ImageRepresentation = Convert.ToBase64String(imageArray);
long size = new System.IO.FileInfo(@temp_file).Length;
if(size>0) System.IO.File.Delete(@temp_file);
return base64ImageRepresentation;