public static void UpdateFileImage(this FileImage fileImage, FileImageViewModel fileImageVm) { fileImage.ID = fileImageVm.ID; fileImage.FileName = fileImageVm.FileName; fileImage.Extension = fileImageVm.Extension; fileImage.ProductImageID = fileImageVm.ProductImageID; }
public void UploadImage_Student_Success() { string expectedLastName = "Wood"; string previousLastName = "Dubois"; string previousFirstName = "George"; EntityGenerator generator = new EntityGenerator(dbContext); Student student = generator.CreateStudentForUploadImage(previousLastName, previousFirstName); student.LastName = expectedLastName; FormDataHelper.PopulateFormData(controllerToTest, student); var stream = new MemoryStream(Encoding.UTF8.GetBytes("whatever")); MyTestPostedFileBase test = new MyTestPostedFileBase(stream, "whatever", "testImage.png"); var result = controllerToTest.EditPost(student.ID, test) as ViewResult; Student savedStudent = dbContext.Students.Find(student.ID); FileImage savedImage = dbContext.FileImages.Find(student.ID); Assert.That(result, Is.Not.Null); Assert.That(savedStudent, Is.Not.Null); Assert.That(savedImage, Is.Not.Null); }
public frmLedgerEdit(int id) { InitializeComponent(); City city = new City(); cmbCity.DataSource = city.Select().Tables[0]; cmbCity.DisplayMember = "name"; cmbCity.ValueMember = "id"; //cmbCity.SelectedValue = -1; ledger.Id = id; if (ledger.SelectById()) { txtName.Text = ledger.Name; txtContact.Text = ledger.Contact; txtEmail.Text = ledger.Email; txtPassword.Text = ledger.Password; cmbGender.Text = ledger.Gender; txtAddress.Text = ledger.Address; cmbCity.SelectedValue = ledger.CityId; //dtpDateOfBirth = ledger.DateOfBirth; cmbType.Text = ledger.Type; pbImage.Image = FileImage.ImageFromByte(ledger.Image); } }
public void AssignIcon() { if (icon != null) { icon.Dispose(); icon = null; } string fileCustomIcon = FileImage.CustomFileIcon(FileOperations.ExtractFileNameFromShellLink(FullPath)); if (string.IsNullOrEmpty(fileCustomIcon)) { icon = (Bitmap)FileImage.FileNameImage(FullPath); if (icon == null) { if (FileOperations.DirectoryExists(FullPath)) { icon = NativeThemeManager.LoadBitmap("Folder.png"); } else { icon = NativeThemeManager.LoadBitmap("UnknownFile.png"); } } } else { icon = FastBitmap.FromFile(fileCustomIcon); } }
public override async Task <ImageBase> CacheAppIcon() { ImageBase image; if (string.IsNullOrEmpty(Model.ImageUrl)) { if (!string.IsNullOrEmpty(Model.TileGlyph)) { image = new TextImage { Text = Model.TileGlyph, ImageType = ImageType.Tile, }; } else { image = TextImage.CreateFromName(Title, ImageType.Tile); } } else { image = new FileImage { Url = Model.ImageUrl, ImageType = ImageType.Logo, }; } return(image); }
private const string MagicalWord = " ."; // 解决底层跨平台傻吊bug的方案 public override CoolQRouteMessage OnMessageReceived(CoolQScopeEventArgs scope) { var routeMsg = scope.RouteMessage; FontFamily font = GetRandFont(GetFonts()); var pandas = GetPandas(); if (UseAll) { List <Bitmap> bmps = pandas.Select(item => GenerateOne(font, item.FullName)).ToList(); int maxWidthP = bmps.Max(item => item.Width); int maxHeight = bmps.Sum(item => item.Height); const int addWidth = 50; int maxWidth = maxWidthP + addWidth; Bitmap bitmap = new Bitmap(maxWidth, maxHeight); using (Graphics g = Graphics.FromImage(bitmap)) using (Brush b = new SolidBrush(Color.Black)) using (Pen p = new Pen(Color.Black)) using (Font f = new Font("等线", 30, FontStyle.Bold)) { g.Clear(Color.White); int y = 0; for (var i = 0; i < bmps.Count; i++) { var item = bmps[i]; g.TextRenderingHint = TextRenderingHint.AntiAlias; g.DrawImage(item, addWidth + maxWidthP / 2f - item.Width / 2f, y); string numStr = (i + 1).ToString(); var size = g.MeasureString(numStr, f); g.DrawString(numStr, f, b, addWidth / 2f - size.Width / 2f, y + item.Height / 2f - size.Height / 2f); g.DrawRectangle(p, new Rectangle(0, y, addWidth, item.Height)); g.DrawRectangle(p, new Rectangle(addWidth, y, maxWidthP, item.Height)); y += item.Height; } } var cqImg2 = new FileImage(bitmap, 75).ToString(); return(routeMsg.ToSource(cqImg2)); } string pandaPath; if (PandaNum >= 1) { int trueNum = PandaNum - 1; if (PandaNum > pandas.Length) { return(routeMsg.ToSource($"超过了范围哦,一共有{pandas.Length}张表情", true)); } pandaPath = pandas[trueNum].FullName; } else { pandaPath = GetRandPanda(pandas); } Bitmap bmp = GenerateOne(font, pandaPath); var cqImg = new FileImage(bmp, 65).ToString(); return(routeMsg.ToSource(cqImg)); }
public static Image file( string file, Key key = null, float scale = 1.0f, float?width = null, float?height = null, Color color = null, BlendMode colorBlendMode = BlendMode.srcIn, BoxFit?fit = null, Alignment alignment = null, ImageRepeat repeat = ImageRepeat.noRepeat, Rect centerSlice = null, bool gaplessPlayback = false, FilterMode filterMode = FilterMode.Point ) { var fileImage = new FileImage(file, scale); return(new Image( key, fileImage, width, height, color, colorBlendMode, fit, alignment, repeat, centerSlice, gaplessPlayback, filterMode )); }
public override CoolQRouteMessage OnMessageReceived(CoolQScopeEventArgs scope) { var routeMsg = scope.RouteMessage; if (routeMsg.MessageType == MessageType.Private) { return(null); } string[] ids = CoolQCode.GetAt(routeMsg.RawMessage); if (ids == null || !ids.Contains(routeMsg.ReportMeta.SelfId)) { return(null); } if (StaticRandom.NextDouble() < 0.9) { return(routeMsg .ToSource("", true) .RandomDelaySeconds(5)); } else { var cqImg = new FileImage(Path.Combine(PandaDir, "at.jpg")); return(routeMsg.ToSource(cqImg.ToString())); } }
protected void ButtonAdd_Click2(object sender, EventArgs e) { string CS = ConfigurationManager.ConnectionStrings["CustomerInfoConnectionString"].ConnectionString; if (FileImage.HasFile) { SavePath = Server.MapPath("~/Images/ProductImage/") + PID; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } Extention = Path.GetExtension(FileImage.PostedFile.FileName); FileImage.SaveAs(SavePath + "\\" + TextBoxCarName.Text.ToString().Trim() + TextBoxCarModel.Text + Extention); } using (SqlConnection con = new SqlConnection(CS)) { SqlCommand command = new SqlCommand("insert into CarRent values('" + TextBoxCarName.Text + "', '" + TextBoxCarModel.Text + "', '" + TextBoxCarPrice.Text + "', '" + TextBoxCarName.Text + TextBoxCarModel.Text.ToString().Trim() + "', '" + Extention + "', '" + TextBoxDescription.Text + "', '" + TextBoxReviewLink.Text + "' , '" + TextBoxAvailable.Text + "')", con); con.Open(); command.ExecuteNonQuery(); LabelAdd.Text = "Successfully Added ! "; TextBoxCarName.Text = ""; TextBoxCarPrice.Text = ""; TextBoxCarModel.Text = ""; TextBoxAvailable.Text = ""; TextBoxReviewLink.Text = ""; TextBoxDescription.Text = ""; } }
public void ConvertToSikuliScript_ReturnRightSikuliScript(double number, string text) { var pathToTestPic = Path.GetFullPath(@"..\..\..\Utils\vs.png"); var actualResult = new FileImage(Path.GetFullPath(pathToTestPic), number).GeneratePatternString(); actualResult.Should().Be($@"Pattern(""{pathToTestPic}"").similar({text})"); }
private void DelayScan(object groupIdObj) { string groupId = (string)groupIdObj; while (true) { Thread.Sleep(5000); if (_groupDic[groupId].LastSentIsMe) { continue; } if ((DateTime.Now - _groupDic[groupId].LastSent).TotalSeconds < _groupDic[groupId].TrigTime) { continue; } _groupDic[groupId].LastSentIsMe = true; _groupDic[groupId].StartCd = DateTime.Now; try { var cqImg = new FileImage(Path.Combine(PandaDir, "quiet.jpg")).ToString(); SendMessage(new CommonMessageResponse(cqImg, _groupDic[groupId].MessageObj)); SaveSettings(_groupDic); } catch (Exception ex) { Logger.Exception(ex); } } }
private async Task SaveFiles(FileImage file, Image img) { // save thumb SaveToFolder(img, new Size(160, 160), file.ThumbPath); // save image of size max 600 x 600 ou 600 x 708 SaveToFolder(img, new Size(600, 600), file.ImagePath); }
public void CreateOffsetPattern_WithPattern_ShouldPass() { var pattern = new FileImage(Path.GetFullPath(@"..\..\..\Utils\vs.png"), 0.3); var point = new Point(5, 5); Action action = () => new OffsetImage(pattern, point); action.Should().NotThrow(); }
public ActionResult Create([Bind(Include = "LastName, FirstMidName, EnrollmentDate")] Student student, HttpPostedFileBase upload) { try { if (ModelState.IsValid) { if (upload != null && upload.ContentLength > 0) { //getting the image string fileName = System.IO.Path.GetExtension(upload.FileName); //call of the verification class CheckImage CheckImage check = new CheckImage(); //call of the verification Extension method bool extensionIsTrue = check.checkExtension(fileName); if (extensionIsTrue == false) { ViewBag.ErrorExtension = ErrorMessages.ErrorExtension(); return(View()); } //call of the verfication Size method bool sizeIsCorrect = check.checkSize(upload.ContentLength); if (sizeIsCorrect == false) { ViewBag.ErrorSize = ErrorMessages.ErrorSize(); return(View()); } var avatar = new FileImage { FileName = Path.GetFileName(upload.FileName), FileType = FileType.Avatar, ContentType = upload.ContentType }; using (var reader = new System.IO.BinaryReader(upload.InputStream)) { avatar.Content = reader.ReadBytes(upload.ContentLength); } student.Files = new List <FileImage> { avatar }; } db.Students.Add(student); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(student)); }
internal override void Write(FileImage output) { //Console.WriteLine("Writing instruction " + instr + " with size " + size); if (twoByteInstr) { output.Write(leadByte); } output.Write((byte)instr); }
public void GenerateImage_WithValidFile_ReturnFilePattern() { var pathToTestPic = Path.GetFullPath(@"..\..\..\Utils\vs.png"); var actualResult = ImageFactory.FromFile(pathToTestPic); var expectedResult = new FileImage(pathToTestPic, 0.7); actualResult.Should().BeEquivalentTo(expectedResult); }
private string save() { string root = Server.MapPath("~"); string savePath = root + "\\Images\\"; string filename = TextCode.Text + ".jpg"; FileImage.SaveAs(savePath + filename); return("\\Images\\" + filename); }
internal sealed override void Write(FileImage output) { base.Write(output); output.Write(numCases); for (int i = 0; i < numCases; i++) { int target = (int)cases[i].GetLabelOffset() - (int)(offset + size); output.Write(target); } }
public void ToSikuliScript_WithValidPositiveSimilarity_ShouldReturnRightString() { var pathToRealFile = Directory.GetCurrentDirectory() + "\\SikuliWrapper.dll"; var pattern = new FileImage(pathToRealFile, 0.7); var actualResult = pattern.ToSikuliScript("click", 0.7); actualResult.Should() .Be($"print \"SIKULI#: YES\" if click({pattern.GeneratePatternString()}, 0.7) else \"SIKULI#: NO\""); }
/// 取得数据存放目录 /* * public static string DataPath { * get { * string game = Const.AppName.ToLower(); * string dataPath = Application.dataPath; * * if (Application.platform == RuntimePlatform.IPhonePlayer) { * string path = Path.GetDirectoryName(Path.GetDirectoryName(dataPath)); * return Path.Combine(path, "Documents/" + game + "/"); * } else if (Application.platform == RuntimePlatform.Android) { * return "/sdcard/" + game + "/"; * } * if (Const.DebugMode) { * string target = string.Empty; * if (Application.platform == RuntimePlatform.OSXEditor || * Application.platform == RuntimePlatform.IPhonePlayer || * Application.platform == RuntimePlatform.OSXEditor) { * target = "iphone"; * } else { * target = "android"; * } * return dataPath + "/StreamingAssets/" + target + "/"; * } * return "c:/" + game + "/"; * } * } */ public static byte[] ReadFile(string path) { byte[] str = null; #if UNITY_IPHONE // 文档中说:WWW.isDone不能用循环的,需要用coroutines,此处的用法不合适,待修改 (lijian 20151021) path = path.Replace("file://", ""); #endif #if UNITY_EDITOR || UNITY_STANDALONE_WIN //只在windows下起作用 bool bUseFile = (EntryPoint.Instance.DebugSettingParams.LocalData && path.Contains("GameRes/Data")) || (EntryPoint.Instance.DebugSettingParams.LocalLua && path.Contains("GameRes/Lua")); if (bUseFile) { if (File.Exists(path)) { try { str = File.ReadAllBytes(path); } catch (Exception e) { str = null; Common.HobaDebuger.LogError("failed to read File with path: " + path + ": " + e); } } else { Common.HobaDebuger.Log("file: " + path + " File does not exist"); } } else //FileImage #endif { if (FileImage.IsExist(path)) { try { str = FileImage.ReadAllBytes(path); } catch (Exception e) { str = null; Common.HobaDebuger.LogWarning("failed to read FileImage with path: " + path + ": " + e); } } else { Common.HobaDebuger.Log("file: " + path + " FileImage does not exist"); } } return(str); }
internal sealed override void Write(FileImage output) { base.Write(output); if (byteNum) { output.Write((sbyte)val); } else { output.Write(val); } }
private void TransferSyntaxesViewOnItemClick(object sender, ItemClickEventArgs e) { try { FileImage.ChangeTransferSyntax(e.ClickedItem as DicomTransferSyntax); } catch { } TransferSyntaxPopup.IsOpen = false; BottomAppBar.IsOpen = false; }
internal sealed override void Write(FileImage output) { base.Write(output); if (shortVer) { output.Write((sbyte)target); } else { output.Write(target); } }
public void OffsetPatternToScript_ShouldReturnRightString() { var pathToTestPic = Path.GetFullPath(@"..\..\..\Utils\vs.png"); var pattern = new FileImage(pathToTestPic, 0.3); var point = new Point(5, 5); var offsetPattern = new OffsetImage(pattern, point); var actualResult = offsetPattern.ToSikuliScript("click", 0); actualResult.Should() .Be( $@"print ""SIKULI#: YES"" if click(Pattern({"\"" + pathToTestPic + "\""}).similar(0.3).targetOffset(5, 5)) else ""SIKULI#: NO"""); }
// Browse file private void selectfile_Click(object sender, EventArgs e) { // Browse for file if (browsefile.ShowDialog(this) == DialogResult.OK) { // Set this file as background backgroundname = browsefile.FileName; backgroundsource = GridSetup.SOURCE_FILE; ImageData img = new FileImage(Path.GetFileNameWithoutExtension(backgroundname), backgroundname, false, 1.0f, 1.0f); General.DisplayZoomedImage(backgroundimage, new Bitmap(img.GetBackgroundBitmap())); img.Dispose(); } }
// Browse file private void selectfile_Click(object sender, EventArgs e) { // Browse for file if (browsefile.ShowDialog(this) == DialogResult.OK) { // Set this file as background backgroundname = browsefile.FileName; ImageData img = new FileImage(-1, backgroundname); img.LoadImage(); General.DisplayZoomedImage(backgroundimage, new Bitmap(img.GetBitmap())); img.Dispose(); } }
public IActionResult CreateImageRequest(FileImage imageFiles) { //net core access route to folder code string outPutFolder = @"C:\Users\LENOVO\source\repos\imageEditorProject\mvcImageEditor\wwwroot\uploads"; var backFileFinalPath = Path.Combine(outPutFolder, imageFiles.BackFileUpload.FileName); using (var fileStream = new FileStream(backFileFinalPath, FileMode.Create)) { imageFiles.BackFileUpload.CopyTo(fileStream); } var frontFileFinalPath = Path.Combine(outPutFolder, imageFiles.FrontFileUpload.FileName); using (var fileStream = new FileStream(frontFileFinalPath, FileMode.Create)) { imageFiles.FrontFileUpload.CopyTo(fileStream); } string newImagePath = ""; //string scriptPath = @"C:\Users\LENOVO\source\repos\imageEditorProject\TestLibrary\Scripts\transparenceFusionImageScript.py"; string tracePythonScript = ImageProcessingMethods.ExecuteTransparenceFusionScript(frontFileFinalPath, backFileFinalPath); //string tracePythonScript = @" hsrtwte e jertyejtkjrtuy C:\Users\LENOVO\source\repos\imageEditorProject\mvcImageEditor\wwwroot\uploads\created\aaa.png"; for (int x = tracePythonScript.Count(); x > 0; x--) { try { if (tracePythonScript.Substring(x, 2) == "C:") { int traceLenght = tracePythonScript.Count(); newImagePath = tracePythonScript.Substring(x, traceLenght - x - 2); break; } } catch (Exception) { } } //downloding the imagee+ Byte[] fileBytes = System.IO.File.ReadAllBytes(@newImagePath.Replace("\\", @"\")); return(File(fileBytes, "application/x-msdownload", newImagePath)); //return the same web downloading the image in browser }
private void btnSave_Click(object sender, EventArgs e) { int er = 0; ep.Clear(); if (cmbProduct.SelectedValue == null || cmbProduct.SelectedValue == null) { er++; ep.SetError(cmbProduct, "Product Required"); } if (txtTitle.Text == "") { er++; ep.SetError(txtTitle, "Title Required"); } if (pbImage.Image == null) { er++; ep.SetError(pbImage, "Image Required"); } if (er > 0) { return; } ProductImage productImage = new ProductImage(); productImage.ProductId = Convert.ToInt32(cmbProduct.SelectedValue); productImage.Title = txtTitle.Text; productImage.Image = FileImage.ImageToByte(pbImage.Image); if (productImage.Insert()) { MessageBox.Show(@"Image Saved"); cmbProduct.SelectedValue = -1; txtTitle.Text = ""; pbImage.Image = null; cmbProduct.Focus(); } else { MessageBox.Show(productImage.Error); } }
public override async Task <ImageBase> CacheAppIcon() { ImageBase icon = null; if (Model?.IconUrl != null) { icon = new FileImage { Url = Model.IconUrl, ImageType = ImageType.Logo }; } return(icon ?? TextImage.CreateFromName(Model.Title)); }
public FileImage Upload(HttpPostedFileBase upload) { var avatar = new FileImage { FileType = FileType.Avatar, ContentType = upload.ContentType }; using (var reader = new System.IO.BinaryReader(upload.InputStream)) { avatar.Content = reader.ReadBytes(upload.ContentLength); } return(avatar); }