public bool LoadData(SqlConnection cn) { ParticipantDataTableAdapter ta = new ParticipantDataTableAdapter(); ta.Connection = cn; DsListShow.ParticipantDataDataTable t = ta.GetData(Iid); if (t.Rows.Count < 1) { Loaded = false; return(false); } DsListShow.ParticipantDataRow row = (DsListShow.ParticipantDataRow)t.Rows[0]; this.Name = row.surname.ToUpper(); if (!row.IsnameNull()) { if (row.name.Length > 0) { this.Name += " " + row.name; } } this.Qf = (row.IsqfNull() ? "" : row.qf); this.Age = (row.IsageNull() ? 0 : row.age); this.Photo = (row.IsphotoNull() ? null : ImageWorker.GetFromBytes(row.photo)); this.Team = row.team; this.Group = row.grp; LoadResults(cn); this.Loaded = true; return(true); }
private void ReloadMinigCrystals(string asteroidType) { if (asteroidType == "empty") { return; } var point = new Point(_areas[Constants.Areas.FirstMiningLaser].Top.X + 10, _areas[Constants.Areas.FirstMiningLaser].Top.Y + 10); _clicker.DoRightMouseClick(point); var crystals = GetAvailableCrystals(point); int crystalNumber; try { var neededCrystal = _crystalImages.First(z => z.Key == asteroidType).Value; crystalNumber = crystals.First(z => ImageWorker.AreBitmapsSameEquals(z.Value, neededCrystal)).Key; } catch { InitialCLick(); return; } _clicker.OpenMenuAndClick(_areas[Constants.Areas.FirstMiningLaser], crystalNumber); _clicker.OpenMenuAndClick(_areas[Constants.Areas.SecondMiningLaser], crystalNumber); }
void Compress() { newW = (int)(data.archive.Res[IMKey].W * (Slider_Size.Value / 100)); newH = (int)(data.archive.Res[IMKey].H * (Slider_Size.Value / 100)); IMG_After.Source = ImageWorker.ReduceQualityJPG(data.archive.GetImage(IMKey) as BitmapSource, (int)Slider_Quality.Value, out imageAR, (int)(data.archive.Res[IMKey].W * (Slider_Size.Value / 100)), (int)(data.archive.Res[IMKey].H * (Slider_Size.Value / 100))); Run_AfterSize.Text = "" + FileWorker.GetBytesReadable(imageAR.LongLength); }
private void Save_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveFile = new SaveFileDialog(); saveFile.FileName = "image.png"; saveFile.Filter = "PNG " + Strings.ResStrings.Image + " (.png)|*.png|" + "JPG " + Strings.ResStrings.Image + " (.jpg)|*.jpg|" + Strings.ResStrings.AllFiles + "|*.*"; if (saveFile.ShowDialog() == true) { if (((Control)sender).Tag != null) { if (System.IO.Path.GetExtension(saveFile.FileName) == ".jpg") { Debug.WriteLine("Saving as JPG"); ImageWorker.SaveImageToFileJPG((BitmapSource)datastore.archive.GetImage(((Control)sender).Tag.ToString()), saveFile.FileName); } else { Debug.WriteLine("Saving as PNG"); ImageWorker.SaveImageToFilePNG((BitmapSource)datastore.archive.GetImage(((Control)sender).Tag.ToString()), saveFile.FileName); } } MessageBox.Show(Strings.ResStrings.SavedTo + ": " + saveFile.FileName, Strings.ResStrings.Success); } }
public async Task <ActionResult> Create(PatientViewModel patientViewModel) { if (ModelState.IsValid) { var checkingUser = UserManager.FindByEmail(patientViewModel.Email); if (checkingUser == null) { Patient patient = PatientViewModel.ToPatient(patientViewModel); patient.Doctors.AddRange(db.Doctors.ToList().Where (doctor => patientViewModel.DoctorsIds.Contains(doctor.Id))); await CreateUser(patientViewModel); ImageWorker imagePathGetter = new ImageWorker(); patient.ImageUrl = imagePathGetter.GetImageStringPath(patientViewModel.UserImage); SaveImage(patientViewModel, patient); db.Patients.Add(patient); db.SaveChanges(); return(RedirectToAction("Index")); } } patientViewModel.Doctors = db.Doctors.ToList(); patientViewModel.AttendingDoctorId = 1; return(View(patientViewModel)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Name, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { Patient patient = new Patient() { Name = model.Name, Email = user.Email, Status = Status.Arrived, DayOfBirth = model.DayOfBirth, TaxCode = model.TaxCode, }; ImageWorker imagePathGetter = new ImageWorker(); patient.ImageUrl = imagePathGetter.GetImageStringPath(model.UserImage); SaveImage(model, patient); db.Patients.Add(patient); db.SaveChanges(); await UserManager.AddToRoleAsync(user.Id, "Patient"); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToAction("Details", "Patients", new { id = patient.Id })); } AddErrors(result); } return(View(model)); }
public override bool Process(ImageWI iwi) { // what to do? switch (this.WorkingStyle) { case TASKWORKINGSTYLE.STRAIGHT: // destroy fib (will be reloaded by next task) iwi.CleanUp(); // save to temp file FileInfo tmpFI; if (iwi.ImageHandleWeak != null) { // when we hav a image handle save that to disk tmpFI = new FileInfo(Path.Combine(iwi.CurrentFile.DirectoryName ?? "./", DateTime.Now.Millisecond.ToString())); ImageWorker.SaveJPGImageHandle(iwi.ImageHandle, tmpFI); } else { // if we dont have a image handle use currentfileinfo tmpFI = iwi.CurrentFile; } // transform temp file ImageWorker.AutoRotateImageFI(tmpFI, this.nameExtension); // load into fib FIBITMAP?fibitmap = ImageWorker.GetJPGImageHandle(tmpFI); if (fibitmap != null) { iwi.ImageHandle = (FIBITMAP)fibitmap; } else { // tell anyone? } // remove tempfile tmpFI.Delete(); break; case TASKWORKINGSTYLE.COPYOUTPUT: // leave fib alone // save current version, if necessary if (iwi.ImageHandleWeak != null) { ImageWorker.SaveJPGImageHandle(iwi.ImageHandle, iwi.CurrentFile); } // transform current version to new name ImageWorker.AutoRotateImageFI(iwi.CurrentFile, this.nameExtension); break; case TASKWORKINGSTYLE.COPYINPUT: // destroy fib (will be reloaded by next task) // save current file // transform file to new name break; default: throw new ArgumentOutOfRangeException(); } ImageWorker.AutoRotateImageFI(iwi.CurrentFile, string.Empty); return(true); }
public async Task <ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl, HttpPostedFileBase ImgFile) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Manage")); } if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await AuthenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return(View("ExternalLoginFailure")); } var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user); if (result.Succeeded) { result = await UserManager.AddLoginAsync(user.Id, info.Login); if (result.Succeeded) { string fileName = Guid.NewGuid().ToString() + ".jpg"; string image = Server.MapPath(UniversityManager.Helpers.Constants.ImagePath) + "//" + fileName; using (Bitmap img = new Bitmap(ImgFile.InputStream)) { Bitmap saveImg = ImageWorker.CreateImage(img, 400, 400); if (saveImg != null) { saveImg.Save(image, ImageFormat.Jpeg); _context.userAdditionalInfos.Add(new Models.EF.UserAdditionalInfo() { FullName = model.FullName, Address = model.Address, Image = fileName, GroupId = int.Parse(model.GroupId), Id = user.Id }); _context.SaveChanges(); } } UserManager.AddToRole(user.Id, "Student"); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToLocal(returnUrl)); } } AddErrors(result); } ViewBag.ReturnUrl = returnUrl; return(View(model)); }
public static void TypeText(MagickImage inputPlace, string text) { using (MagickImage screen = new MagickImage("screenshot:")) { using (inputPlace) { try { if (ImageWorker.IsSubImageExist(screen, inputPlace)) { MouseMethods.LMBClick(ImageWorker.FindSubImageCoordinate(screen, inputPlace)); new InputSimulator().Keyboard.TextEntry(text); } else { throw new Exception("Such element not found"); } } catch (Exception e) { Console.WriteLine(e); throw; } } } }
void RenderPreview(int i) { SPanel.Children.Clear(); Canvas can = CanvasSaveLoad.LoadSpecificCanvas(data, i); CanvasSaveLoad.ToPresentationMode(can); CanvasSaveLoad.SimulateCanvas(can); can.UpdateLayout(); Size size = new Size(); can.Measure(size); can.Arrange(new Rect(size)); ImageSource bs = ImageWorker.ByteDataToImage(CanvasWriter.SaveCanvasToImgSimulateFullPng(can)); Border pageP = new Border(); pageP.Background = new ImageBrush(bs); pageP.BorderBrush = new SolidColorBrush(Color.FromRgb(44, 62, 80)); pageP.BorderThickness = new Thickness(3); pageP.Width = data.CanvasW; pageP.Height = data.CanvasH; pageP.Margin = new Thickness(10, 10, 10, 15); SPanel.Children.Add(pageP); L_Page.Content = (i + 1) + "/" + data.pages.Count; }
public JsonResult UploadImageDecription(HttpPostedFileBase file) { string link = string.Empty; string filename = Guid.NewGuid().ToString() + ".jpg"; string image = Server.MapPath(Constants.ProductDescriptionPath) + filename; try { // The Complete method commits the transaction. If an exception has been thrown, // Complete is not called and the transaction is rolled back. Bitmap imgCropped = new Bitmap(file.InputStream); var saveImage = ImageWorker.CreateImage(imgCropped, 450, 450); if (saveImage == null) { throw new Exception("Error save image"); } saveImage.Save(image, ImageFormat.Jpeg); link = Url.Content(Constants.ProductDescriptionPath) + filename; ProductDescriptionImage pImage = new ProductDescriptionImage() { Name = filename }; _context.ProductDescriptionImages.Add(pImage); _context.SaveChanges(); } catch (Exception) { if (System.IO.File.Exists(image)) { System.IO.File.Delete(image); } } return(Json(new { link, filename })); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { string imagePath = "asdfasdf"; string dir = imagePath; int widthBig = 2560; // Імя фалу із зображенням string filePhoto = string.Empty; filePhoto = Guid.NewGuid().ToString() + ImageWorker.GetImageType(model.Image); byte[] bytesPhoto = ImageWorker.GetImageBytesFromBase64(model.Image); string imageType = ImageWorker.GetImageType(model.Image); Bitmap imageBig = ImageWorker.SaveImageFromBytesTry(bytesPhoto, widthBig); if (imageBig != null) { string fileName = widthBig + "_" + filePhoto; string pathSaveFile = Path.Combine(dir, fileName); imageBig.Save(pathSaveFile, ImageWorker.GetImageFormat(imageType)); } var result = await _accountProvider.RegisterAsync(model); if (result) { // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } //AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public void CLoseChrome(string desktopPath, string chromeClosePath, string leavePath) { MouseMethods.LMBClick(ImageWorker.FindSubImageCoordinate(desktopPath, chromeClosePath)); System.Threading.SpinWait.SpinUntil(() => ImageWorker.IsSubImageExist(leavePath), TimeSpan.FromSeconds(int.Parse(SikuliTestData.DefaultWait))); MouseMethods.LMBClick(ImageWorker.FindSubImageCoordinate(desktopPath, leavePath)); }
private static void MetaDataTest() { FileInfo fi = new FileInfo(@"..\..\..\testdata\pixrotate\IMG_4222.jpg"); FIBITMAP dib = (FIBITMAP)ImageWorker.GetJPGImageHandle(fi); ImageWorker.SaveJPGImageHandle(dib, fi.AugmentFileInfo("_meta")); }
public void FindAndOpenChrome(string desktopPath, string chromePath) { System.Threading.SpinWait.SpinUntil(() => ImageWorker.IsSubImageExist(chromePath), TimeSpan.FromSeconds(int.Parse(SikuliTestData.DefaultWait))); subImageCoordinate = ImageWorker.FindSubImageCoordinate(desktopPath, chromePath); MouseMethods.LMBClick(subImageCoordinate); }
public ResultDTO Uploadfile([FromRoute] string id, [FromForm(Name = "file")] IFormFile image) { string Filename = Guid.NewGuid().ToString() + ".jpg"; string path = _appEnvironment.WebRootPath + @"\Images"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = path + @"\" + Filename; if (image == null) { return(new ResultErrorDTO { Message = "File is null", Status = 405, Errors = null }); } if (image.Length == 0) { return(new ResultErrorDTO { Message = "File is empty", Status = 405, Errors = null }); } using (Bitmap b = new Bitmap(image.OpenReadStream())) { Bitmap SaveImage = ImageWorker.CreateImage(b, 400, 300); if (SaveImage != null) { SaveImage.Save(path, ImageFormat.Jpeg); Game game = _context.Games.Find(id); if (game.ImageURL != null) { System.IO.File.Delete(_appEnvironment.WebRootPath + @"\Images" + game.ImageURL); } _context.Games.Find(id).ImageURL = Filename; _context.SaveChanges(); return(new ResultDTO { Message = "File is saved", Status = 200 }); } else { return(new ResultErrorDTO { Message = "File is not saved", Status = 405, Errors = null }); } } }
public void KeyboardMethodsTest() { _clickPoint = ImageWorker.FindSubImageCoordinate(DesktopPath, ExplorerPath); KeyboardMethods.TypeText("V"); KeyboardMethods.PressEnter(); MouseMethods.MoveToElemment(0, 0); }
void ResolveSeeTheFeuture() { MakeFeatureUnvisible(true); ImageWorker.LoadImageFromCard(ExploadingDeck.Top, pictureBox15); ImageWorker.LoadImageFromCard(ExploadingDeck[1], pictureBox14); ImageWorker.LoadImageFromCard(ExploadingDeck[2], pictureBox13); }
public async Task <ActionResult> Create(DoctorViewModel doctorViewModel) { if (ModelState.IsValid) { var user = UserManager.FindByEmail(doctorViewModel.Email); if (user == null) { Doctor doctor = DoctorViewModel.ToDoctor(doctorViewModel); user = await AddUser(doctorViewModel); ImageWorker imagePathGetter = new ImageWorker(); doctor.ImageUrl = imagePathGetter.GetImageStringPath(doctorViewModel.DoctorImage); if (doctorViewModel.DoctorImage != null) { doctorViewModel.DoctorImage.SaveAs(Path.Combine( Server.MapPath("~/AppFile/DoctorPictures"), doctor.ImageUrl)); } db.Doctors.Add(doctor); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(doctorViewModel)); }
public ActionResult Edit(StudentViewModel el, HttpPostedFileBase file) { Student st = _context.Students.Find(el.Id); st.ApplicationUser.Email = el.Email; st.Age = el.Age; st.Phone = el.Phone; st.Id = el.Id; st.Image = el.Image; if (file != null) { string filename = Guid.NewGuid().ToString() + ".jpg"; string image = Server.MapPath(Constants.ImagePath) + "\\" + filename; using (Bitmap bmp = new Bitmap(file.InputStream)) { Bitmap saveImage = ImageWorker.CreateImage(bmp, 200, 120); if (saveImage != null) { saveImage.Save(image); st.Image = filename; } } } _context.SaveChanges(); return(RedirectToAction("Index")); }
public void CreateGame(string[] names, DeckType decktype, Form f) { welcomeform = f; howmanydudes = (byte)names.Length; expl_kittens = (byte)(howmanydudes - 1); // Create Deck ExploadingDeck = new Deck(decktype, howmanydudes); ExploadingDeck.Shuffle(); Player.D = ExploadingDeck; // Create Players for (int i = 0; i < howmanydudes; i++) { Player new_plr = new Player(names[i]); new_plr.TakeFirstCards(); new_plr.TakeDefuse((byte)i); AllPlayers.Add(new_plr); } ExploadingDeck.AddExKittens(); if (decktype == DeckType.Impladings) { ExploadingDeck.AddImplKitten(); DisplayVector(); if (howmanydudes == 2) { expl_kittens += 1; } } ExploadingDeck.Shuffle(); // First player AllPlayers.SetWhoIsFirst(); ImageWorker.LoadPlayerCards(CurrentPlayer); label1.Text = "Хід граця " + CurrentPlayer.Name; DisplayExploadingInfo(); }
public ActionResult CreateGame(CreateGameViewModel model, HttpPostedFileBase imageFile) { string fileName = Guid.NewGuid().ToString() + ".jpg"; string image = Server.MapPath(Constants.ImagePath) + "\\" + fileName; using (Bitmap img = new Bitmap(imageFile.InputStream)) { Bitmap saveImage = ImageWorker.CreateImage(img, 400, 400); if (saveImage != null) { saveImage.Save(image, ImageFormat.Jpeg); // Save game with name image in Db _context.Games.Add(new Game { Developer = model.Developer, Image = fileName, Name = model.Name, Price = model.Price }); _context.SaveChanges(); } } return(RedirectToAction("Index", "Home")); }
public IActionResult Create([FromBody] CountryAddViewModel model) { var country = _context.Countries .SingleOrDefault(c => c.Name == model.Name); if (country != null) { return(BadRequest(new { invalid = "Така країна уже є в БД!" })); } string fileDestDir = _env.ContentRootPath; fileDestDir = Path.Combine(fileDestDir, "Bigimot"); string imageName = Path.GetRandomFileName() + ".jpg"; var bitmap = model.Image.Split(',')[1].FromBase64StringToImage(); var outbtmp = ImageWorker.CreateImage(bitmap, 100, 100); outbtmp.Save(Path.Combine(fileDestDir, imageName), ImageFormat.Jpeg); //bitmap.Save(Path.Combine(fileDestDir,imageName), ImageFormat.Jpeg); country = new Country { Name = model.Name, FlagImage = model.FlagImage }; _context.Countries.Add(country); _context.SaveChanges(); return(Ok(new CountryViewModel { Id = country.Id, Name = country.Name })); }
public ResultDTO UploadImage([FromForm(Name = "file")] IFormFile uploadedImage) { string fileName = Guid.NewGuid().ToString() + ".jpg"; string path = _appEnvironment.WebRootPath + @"\Images\" + fileName; if (uploadedImage == null) { return new ResultDTO { Status = 400, Errors = new List <string> { "Не вдалося завантажити файл" } } } ; if (uploadedImage.Length == 0) { return new ResultDTO { Status = 400, Errors = new List <string> { "Файл порожній" } } } ; try { using (Bitmap bmp = new Bitmap(uploadedImage.OpenReadStream())) { var saveImage = ImageWorker.CreateImage(bmp, 400, 365); int idProduct = (from v in _context.Products orderby v.Id descending select v).FirstOrDefault().Id; if (saveImage != null) { saveImage.Save(path, ImageFormat.Jpeg); var product = _context.Products.Find(idProduct); _context.Products.Find(idProduct).Image = fileName; _context.SaveChanges(); } } } catch (Exception ex) { return(new ResultDTO { Status = 400, Errors = new List <string> { "Не вдалося завантажити файл" }, Message = ex.InnerException.Message }); } return(new ResultDTO { Status = 200 }); }
public BaseGame(ImageWorker imageWorker, UserActivityHook actHook, WinApiClass apiClass, SaveData saveData, FrameForm frame) { _imageWorker = imageWorker; _actHook = actHook; _apiClass = apiClass; _saveData = saveData; _frame = frame; }
public void MoveCheirOnWorkspace(string desktopPath, string cheirPath) { System.Threading.SpinWait.SpinUntil(() => ImageWorker.IsSubImageExist(cheirPath), TimeSpan.FromSeconds(int.Parse(SikuliTestData.DefaultWait))); Point point = ImageWorker.FindSubImageCoordinate(desktopPath, cheirPath); MouseMethods.DragAndDrop(point, new Point(point.X + 500, point.Y)); }
public IActionResult Add(CategoryViewModel model, IFormFile file) { //if (!ModelState.IsValid) // return View(model); //if (this.categoryRepository.All().Any(c => c.EnName == model.EnName)) //{ // ShowNotification(Messages.ObjectAlreadyExists, ToastrSeverity.Error); // return View(); //} //if (this.categoryRepository.All().Any(c => c.DeName == model.DeName)) //{ // ShowNotification(Messages.ObjectAlreadyExists, ToastrSeverity.Error); // return View(); //} //if (this.categoryRepository.All().Any(c => c.BgName == model.BgName)) //{ // ShowNotification(Messages.ObjectAlreadyExists, ToastrSeverity.Error); // return View(); //} base.InitMainLabels(); string img = string.Empty; if (file != null && file.Length > 0) { using (var ms = new MemoryStream()) { file.CopyTo(ms); img = ImageWorker.ResizeImage(ms); } } var category = this.categoryRepository.FindOrCreate(model.Id); category.EnName = model.EnName; category.DeName = model.DeName; category.BgName = model.BgName; category.EnDescription = model.EnDescription; category.DeDescription = model.DeDescription; category.BgDescription = model.BgDescription; category.Thumbnail = Base64ToByteArray(img); try { this.categoryRepository.Save(category); ShowNotification(Messages.SuccessAdd, ToastrSeverity.Success); } catch (Exception) { string error = string.Join(Environment.NewLine, ModelState.SelectMany(e => e.Value.Errors.Select(er => er.ErrorMessage))); ShowNotification(error, ToastrSeverity.Error); } return(View()); }
public void FindSearchFieldAndGoToTheTestSite(string desktopPath, string searchPath) { System.Threading.SpinWait.SpinUntil(() => ImageWorker.IsSubImageExist(searchPath), TimeSpan.FromSeconds(int.Parse(SikuliTestData.DefaultWait))); subImageCoordinate = ImageWorker.FindSubImageCoordinate(desktopPath, searchPath); MouseMethods.LMBClick(subImageCoordinate.X + 100, subImageCoordinate.Y); KeyboardMethods.TypeText(SikuliTestData.TestSite); KeyboardMethods.PressEnter(); }
public void MouseMethodsTest() { Assert.IsTrue(ImageWorker.IsSubImageExist(DesktopPath, ExplorerPath)); _clickPoint = ImageWorker.FindSubImageCoordinate(DesktopPath, ExplorerPath); MouseMethods.MoveToElemment(_clickPoint); MouseMethods.RMBClick(_clickPoint); MouseMethods.LMBClick(_clickPoint); MouseMethods.MoveToElemment(0, 0); }
private void Game_MouseMove(object sender, MouseEventArgs e) { if (ImageWorker.OnTopBox == null) { return; } timer1.Stop(); ImageWorker.BackImage(); }
public ActionResult Threads(string Id) { string pickType = Id; DateTime start = DateTime.Now; int X=(int)Session["X"]; int Y = (int)Session["Y"]; Dictionary<Color, List<ImageWorker.Point>> imageDict=new Dictionary<Color,List<ImageWorker.Point>>(); imageDict = (Dictionary<Color, List<ImageWorker.Point>>)Session["imageDic"]; double Smooth = 0.001; double XYSmooth = X * Y * Smooth; ImageWorker worker = new ImageWorker(); List<ImageWorker.ColorMul> MulNab = worker.GetColors(pickType); MyProject.ImageWorker.Picture picture = new MyProject.ImageWorker.Picture((int)Session["Y"],(int)Session["X"]); int h1 = ((Dictionary<Color, List<ImageWorker.Point>>)Session["imageDic"]).Values.Sum(x => x.Count); Session.Remove("imageDic"); Session.Add("imageDic", imageDict); int h = imageDict.Values.Sum(x => x.Count); foreach (Color c in imageDict.Keys) { MyProject.ImageWorker.ColorMul cm = worker.FindColor(c, ref MulNab); List<ImageWorker.ColorArray> t=picture.Color_array.FindAll(x => ImageWorker.CountDifferenceBetweenColors(x.color.color, cm.color) < 15); if (t.Count > 0) { picture.AddPoint(t.First().color, imageDict[c].AsReadOnly()); } else { picture.AddPoint(cm, imageDict[c].AsReadOnly()); } } DateTime findColors = DateTime.Now; string size = Session["Size"] as string; int kk = 0; switch (size) { case "Small": kk = 50; break; case "Large": kk = 100; break; case "Normal": kk = 80; break; } while (picture.Color_array.Count > kk) { ImageWorker.ColorMul reduceColor = (from x in picture.Color_array from y in picture.Color_array where x!=y orderby ImageWorker.CountDifferenceBetweenColors(x.color.color, y.color.color) select x.color).First(); List<MyProject.ImageWorker.ColorMul> cmtemp = (from x in picture.Color_array where x.color != reduceColor select x.color).ToList(); MyProject.ImageWorker.ColorMul c3 = worker.FindColor(reduceColor.color, ref cmtemp); if (c3 != null) { picture.ReduceColor(reduceColor, c3); } } List<ImageWorker.ColorMul> colorsForReduce = (from x in picture.Color_array where x.points.Count < XYSmooth select x.color).ToList(); List<MyProject.ImageWorker.ColorMul> cmtemp2 = (from x in picture.Color_array where x.points.Count >= XYSmooth select x.color).ToList(); foreach (MyProject.ImageWorker.ColorMul cc in colorsForReduce) { MyProject.ImageWorker.ColorMul c3 = worker.FindColor(cc.color, ref cmtemp2); if (c3 != null) { picture.ReduceColor(cc, c3); } } DateTime ReducingColors = DateTime.Now; ViewData["mess"] = string.Format("DictPOints:{2}FindColors: {0} ReduceColors:{1}", findColors-start, ReducingColors-findColors,h); ViewData["imageSmooth"] = picture; Session.Remove("imageSmooth"); Session.Add("imageSmooth", picture); ViewData["X"] = X; ViewData["Y"] = Y; return View(); }