public void SetString(Font font, PointF location, String txt = null) { DataState = ValidData.TEXT; OriginalFormat = DataState; Txt = txt; TxtPosition = location; Font = font; ForegroundColor = Color.Crimson; }
public ZiCharacterV3(IZiFont parent, uint codepoint, byte[] bytes, byte width = 0, byte kerningL = 0, byte kerningR = 0) { Parent = parent; CodePoint = codepoint; if (_Bitmap != null && _Bitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Undefined) { _Bitmap.Dispose(); } _CharacterData = bytes; KerningRight = KerningLeft = 0; // Kerning is not supported in V3 DataState = ValidData.CHARDATA; OriginalFormat = DataState; Width = Parent.CharacterWidth; // Fixed Width set by Parent Font ForegroundColor = Color.Aqua; }
public ZiCharacterV5(IZiFont parent, uint codepoint, byte[] bytes, byte width, byte kerningL = 0, byte kerningR = 0) { Parent = parent; CodePoint = codepoint; if (_Bitmap != null && _Bitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Undefined) { _Bitmap.Dispose(); } _CharacterData = bytes; KerningLeft = kerningL; KerningRight = kerningR; DataState = ValidData.CHARDATA; OriginalFormat = DataState; Width = width; ForegroundColor = Color.Blue; }
/// <summary> /// Serves as the default hash function. /// </summary> /// <returns>A hash code for the current object.</returns> public override int GetHashCode() { var hashCode = -910965429; hashCode = (hashCode * -1521134295) + ValidData.GetHashCode(); hashCode = (hashCode * -1521134295) + SampleState.GetHashCode(); hashCode = (hashCode * -1521134295) + ViewState.GetHashCode(); hashCode = (hashCode * -1521134295) + SourceTimestamp.GetHashCode(); hashCode = (hashCode * -1521134295) + InstanceHandle.GetHashCode(); hashCode = (hashCode * -1521134295) + PublicationHandle.GetHashCode(); hashCode = (hashCode * -1521134295) + DisposedGenerationCount.GetHashCode(); hashCode = (hashCode * -1521134295) + NoWritersGenerationCount.GetHashCode(); hashCode = (hashCode * -1521134295) + SampleRank.GetHashCode(); hashCode = (hashCode * -1521134295) + GenerationRank.GetHashCode(); hashCode = (hashCode * -1521134295) + AbsoluteGenerationRank.GetHashCode(); return(hashCode); }
/* Constructors */ public ZiCharacterV3(IZiFont parent, uint codepoint, Bitmap bmp, byte kerningL = 0, byte kerningR = 0) { Parent = parent; CodePoint = codepoint; _Bitmap = new Bitmap(Parent.CharacterWidth, Parent.CharacterHeight); using (var graphics = Graphics.FromImage(_Bitmap)) { graphics.DrawImage(bmp, 0, 0); } if (_CharacterData != null) { _CharacterData = null; } KerningRight = KerningLeft = 0; // Kerning is not supported in V3 Width = Parent.CharacterWidth; // Fixed Width set by Parent Font DataState = ValidData.BITMAP; OriginalFormat = DataState; ForegroundColor = Color.Green; }
/* Constructors */ public ZiCharacterV5(IZiFont parent, uint codepoint, Bitmap bmp, byte kerningL = 0, byte kerningR = 0) { Parent = parent; CodePoint = codepoint; _Bitmap = new Bitmap(bmp.Width, bmp.Height); using (var graphics = Graphics.FromImage(_Bitmap)) { graphics.DrawImage(bmp, 0, 0); } if (_CharacterData != null) { _CharacterData = null; } KerningLeft = kerningL; KerningRight = kerningR; Width = (byte)(bmp.Width - kerningL - kerningR); DataState = ValidData.BITMAP; OriginalFormat = DataState; ForegroundColor = Color.Green; }
public void SetBitmap(Bitmap bmp) { /*if (_Bitmap != null && _Bitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Undefined) { * using (var graphics = Graphics.FromImage(_Bitmap)) { * graphics.FillRectangle(Brushes.Transparent, 0, 0, bmp.Width, _Bitmap.Height); * graphics.DrawImage(bmp, 0, 0); * } * DataState = ValidData.BITMAP; * }*/ _Bitmap = new Bitmap(Width, Parent.CharacterHeight); using (var graphics = Graphics.FromImage(_Bitmap)) { graphics.DrawImage(bmp, 0, 0); } DataState = ValidData.BITMAP; OriginalFormat = DataState; ForegroundColor = Color.Cyan; DataState = ValidData.BITMAP; }
public async Task <IActionResult> AddFavouriteWord([FromBody] LanguageItem languageItem) { if (!ValidData.isValidDatabaseEntry(languageItem)) { return(BadRequest()); } var exists = await _context.LanguageItem.Where(l => l.userId == languageItem.userId && l.languageName == languageItem.languageName && l.languageCode == languageItem.languageCode && l.word == languageItem.word ).AnyAsync(); if (exists) { return(Conflict()); } var item = await _context.LanguageItem.Where(l => l.userId == languageItem.userId && l.languageName == languageItem.languageName && l.languageCode == languageItem.languageCode ).OrderByDescending(l => l.rank).FirstOrDefaultAsync(); if (item == null) { languageItem.rank = 1; } else { languageItem.rank = item.rank + 1; } _context.LanguageItem.Add(languageItem); await _context.SaveChangesAsync(); return(CreatedAtAction("GetLanguageItem", languageItem)); }
protected void doAddButtton_Click(object sender, EventArgs e) { //图片大小 int upPhotoLength = 0; byte[] ImageContent = new Byte[upPhotoLength]; int intStatus = 0; //获取上传的文件名 string fileName = this.UpPhotos.FileName; //获取物理路径 string strImageType = string.Empty; Stream PhotoStream = null; //当包含文件时(即上传有文件) if (UpPhotos.HasFile) { //为0表示被上传的图片的类型不符合要求,1表示符合要求 int ImageType = 0; HttpPostedFile upPhoto = UpPhotos.PostedFile; upPhotoLength = upPhoto.ContentLength; if (upPhotoLength > 1024000) { this.lblMessage.Text = GetTran("004073", "产品图片的大小请限制在300K之内") + "..."; return; } //获取上传文件的扩展名 strImageType = Path.GetExtension(fileName).ToLower(); String[] Extensions = { ".gif", ".png", ".jpeg", ".jpg", ".bmp", ".pdf" }; for (int i = 0; i < Extensions.Length; i++) { if (strImageType == Extensions[i]) { //图片类型 strImageType = Extensions[i]; ImageType = 1; } } if (ImageType == 1) { try { PhotoStream = upPhoto.InputStream; ImageContent = new Byte[upPhotoLength]; intStatus = PhotoStream.Read(ImageContent, 0, upPhotoLength); } catch { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("004076", "上传图片失败,请联系管理员!"))); return; } } else { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("004079", "请检查图片类型!"))); return; } } string productType = uclProductType.SelectedValue; string typeName = txtProductType.Text.Trim(); //添加类 bool isFold = this.addClass.Checked; //大单位 int bignumber = 0; ///长、宽、高 decimal Length = 0, Width = 0, High = 0; ///重量 decimal Weight = 0; ///验证预警数量 int alertCount = 0; ///价格和积分 decimal costPrice = 0, commonPrice = 0, commonPV = 0, preferentialPrice = 0, preferentialPV = 0; ///验证产品信息 if (!isFold) { //判断产品名称是否为空 if (txtProductName.Text.Trim() == "") { this.lblMessage.Text = GetTran("004082", "名称不能为空!"); return; } ///产品编码 if (this.txtProductCode.Text.Trim() == "") { this.lblMessage.Text = GetTran("004085", "产品编码不能为空!"); return; } ///判断产品编码是否重复 else { ///添加产品 if (editingID == 0) { //获取编码的数目 int proCodeCount = AddNewProductBLL.CheckProductCodeIsExist(this.txtProductCode.Text.Trim()); if (proCodeCount > 0) { lblMessage.Text = GetTran("004088", "对不起,编码重复!"); return; } } ///修改产品 else { ///获取行数,判断编码是否存在 int proCodeCount = AddNewProductBLL.CheckProductCodeIsExistByID(this.txtProductCode.Text.Trim(), Convert.ToInt32(this.editingID)); if (proCodeCount > 0) { lblMessage.Text = GetTran("004088", "对不起,编码重复!"); return; } } } ///验证产品型号 if (this.txtProductType.Text.Trim() == "") { this.lblMessage.Text = GetTran("004091", "产品型号不能为空!"); return; } if (txtCostPrice.Text.Trim() == "") { costPrice = 0; } if (txtCommonPrice.Text.Trim() == "") { commonPrice = 0; } if (txtPreferentialPrice.Text.Trim() == "") { preferentialPrice = 0; } if (txtCommonPV.Text == "") { commonPV = 0; } if (txtPreferentialPV.Text == "") { preferentialPV = 0; } if (txtCostPrice.Text.Trim() != "" || txtCommonPrice.Text.Trim() != "" || txtCommonPV.Text.Trim() != "" || txtPreferentialPV.Text.Trim() != "" || txtPreferentialPrice.Text.Trim() != "") { try { costPrice = Convert.ToDecimal(this.txtCostPrice.Text.Trim()); commonPrice = Convert.ToDecimal(this.txtCommonPrice.Text.Trim()); commonPV = Convert.ToDecimal(this.txtCommonPV.Text.Trim()); preferentialPrice = Convert.ToDecimal(this.txtPreferentialPrice.Text.Trim()); preferentialPV = Convert.ToDecimal(this.txtPreferentialPV.Text.Trim()); } catch { this.lblMessage.Text = GetTran("004093", "请正确输入价格,积分!"); return; } if (costPrice < 0 || commonPrice < 0 || commonPV < 0 || preferentialPrice < 0 || preferentialPV < 0) { this.lblMessage.Text = GetTran("004094", "请注意,价格,积分不能为负数!"); return; } } ///验证大单位 if (uclProductBigUnit.SelectedItemText == "") { this.lblMessage.Text = GetTran("004095", "大单位名称不能为空!"); return; } ///验证小单位 if (uclProductSmallUnit.SelectedItemText == "") { this.lblMessage.Text = GetTran("004096", "小单位名称不能为空!"); return; } ///大小单位比例 if (txtBigSmallMultiple.Text.Trim() == "") { this.lblMessage.Text = GetTran("004098", "大小单位比例不能为空!"); return; } else { try { bignumber = Convert.ToInt32(txtBigSmallMultiple.Text); } catch { lblMessage.Text = GetTran("004100", "对不起,大小单位转换必须是整数!"); return; } if (bignumber <= 0) { lblMessage.Text = GetTran("004101", "对不起,大小单位转换必须是大于或等于1的整数!"); return; } } Length = 0; Width = 0; High = 0; ///验证重量 if (txtWeight.Text.Trim() == "") { this.lblMessage.Text = GetTran("004104", "对不起,重量不能为空!"); return; } else { try { Weight = Convert.ToDecimal(txtWeight.Text.Trim()); } catch { this.lblMessage.Text = GetTran("004106", "请正确输入重量!"); return; } if (Weight < 0) { this.lblMessage.Text = GetTran("004107", "对不起,重量必须大于或等于0!"); return; } } ///验证预警数量 if (txtAlertnessCount.Text.Trim() != "") { try { alertCount = Convert.ToInt32(txtAlertnessCount.Text); } catch { this.lblMessage.Text = GetTran("004108", "对不起,预警数量必须是整数!"); return; } if (alertCount < 0) { this.lblMessage.Text = GetTran("004109", "对不起,预警数量必须是大于或等于0的整数!"); return; } } } ///产品说明 if (txtDescription.Text.Length > 200) { this.lblMessage.Text = GetTran("004110", "产品说明不能超过两百字!"); return; } string productName = this.txtProductName.Text.Trim(); ///判断产品类名称是否为空 if (isFold && productName == "") { this.lblMessage.Text = GetTran("004082", "名称不能为空!"); return; } ///为了和后面的说明区别,故命名为productDescription(2009-10-22) string productDescription = ValidData.InputText(this.txtDescription.Text.Trim()); string productSpec = uclProductSpec.SelectedValue; string productColor = uclProductColor.SelectedValue; string productStatus = uclProductStatus.SelectedValue; string productSexType = uclProductSexType.SelectedValue; string productArea = ValidData.InputText(txtProductArea.Text.Trim()); string productSize = uclProductSize.SelectedValue; string productBigUnit = uclProductBigUnit.SelectedValue; string productSmallUnit = uclProductSmallUnit.SelectedValue; string strMessage; //On sale int isSell = 0; if (this.ChboxHide.Checked == true) { isSell = 0; } //No sale if (this.ChboxHide.Checked == false) { isSell = 1; } #region 产品新增部分[详细、允许销售的团队人数] xyc int detailsMaxLenth = 200000; string details_TX = Request.Form["txtDetails"] == null ? "" : Request.Form["txtDetails"].ToString(); details_TX = ValidData.RemoveScript(details_TX); //if (details_TX.Length > detailsMaxLenth) //{ // Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert("详细内容过多,请适当减少产品的详细描述内容!")); // return; //} productModel.Details_TX = details_TX; int onlyForGroup = 0; if (this.rbtnN.Checked == true) { onlyForGroup = 0; } else if (this.rbtnY.Checked == true) { onlyForGroup = 1; } productModel.OnlyForGroup_NR = onlyForGroup; Regex rx = new Regex(@"[;|;]", RegexOptions.IgnoreCase); this.txt_GroupIDS_AZ_TX.Text = rx.Replace(this.txt_GroupIDS_AZ_TX.Text, ";"); this.txt_GroupIDS_TJ_TX.Text = rx.Replace(this.txt_GroupIDS_TJ_TX.Text, ";"); string GroupIDS_AZ_TX = this.txt_GroupIDS_AZ_TX.Text; string GroupIDS_TJ_TX = this.txt_GroupIDS_TJ_TX.Text; Regex rx0 = new Regex(@"\w|;]+", RegexOptions.IgnoreCase); if (!string.IsNullOrEmpty(GroupIDS_AZ_TX) && !rx0.IsMatch(GroupIDS_AZ_TX)) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert("格式错误,多安置团队顶点编号请用分号隔开!")); return; } if (!string.IsNullOrEmpty(GroupIDS_TJ_TX) && !rx0.IsMatch(GroupIDS_TJ_TX)) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert("多推荐团队顶点编号请用分号隔开!")); return; } if (onlyForGroup == 1) { if (string.IsNullOrEmpty(GroupIDS_AZ_TX) && string.IsNullOrEmpty(GroupIDS_TJ_TX)) { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert("请填写允许销售的团队顶点编号!")); return; } else { #region 对会员编号的真实性进行验证 //验证编号是否存在 bool bhValidate = true; string notExistID = string.Empty; string[] bhsAZ = rx.Split(GroupIDS_AZ_TX); string[] bhsTJ = rx.Split(GroupIDS_TJ_TX); List <string> group_ids = new List <string>(); foreach (string s in bhsAZ) { if (!string.IsNullOrEmpty(s)) { group_ids.Add(s); } } foreach (string s in bhsTJ) { if (!group_ids.Contains(s)) { if (!string.IsNullOrEmpty(s)) { group_ids.Add(s); } } } MemberInfoModel member = null; foreach (string s in group_ids) { member = MemberInfoModifyBll.getMemberInfo(s); if (member == null) {//不存在 bhValidate = false; notExistID += s + ","; } } if (notExistID != string.Empty) { notExistID = notExistID.Substring(0, notExistID.Length - 1); ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('会员[" + notExistID + "]不存在!');</script>", false); return; } #endregion } } productModel.GroupIDS_AZ_TX = GroupIDS_AZ_TX; productModel.GroupIDS_TJ_TX = GroupIDS_TJ_TX; #endregion productModel.IsFold = Convert.ToInt32(isFold); productModel.ProductName = productName; if (!isFold) { productModel.ProductTypeID = Convert.ToInt32(productType); productModel.ProductTypeName = typeName; productModel.ProductSpecID = Convert.ToInt32(productSpec); productModel.ProductColorID = Convert.ToInt32(productColor); productModel.ProductSizeID = Convert.ToInt32(productSize); productModel.ProductSexTypeID = Convert.ToInt32(productSexType); productModel.ProductStatusID = Convert.ToInt32(productStatus); productModel.BigProductUnitID = Convert.ToInt32(productBigUnit); productModel.SmallProductUnitID = Convert.ToInt32(productSmallUnit); productModel.BigSmallMultiple = bignumber; productModel.ProductArea = productArea; productModel.CostPrice = costPrice; productModel.CommonPrice = commonPrice; productModel.CommonPV = commonPV; productModel.PreferentialPrice = preferentialPrice; productModel.PreferentialPV = preferentialPV; productModel.AlertnessCount = alertCount; productModel.Description = productDescription; productModel.Weight = Weight; if (ImageContent.Length > 0) { productModel.ProductImage = ImageContent; } else { int imageSate = Convert.ToInt32(ViewState["imageState"]); if (imageSate == 0) { productModel.ProductImage = ImageContent; } if (imageSate == 1) { productModel.ProductImage = (byte[])ViewState["image"]; } } productModel.ImageType = strImageType; productModel.CountryCode = ViewState["CountryCode"].ToString(); productModel.Currency = Convert.ToInt32(ViewState["CurrencyID"]); productModel.IsCombineProduct = (byte)(chbcombine.Checked ? 1 : 0); productModel.OperateIP = CommonDataBLL.OperateIP; productModel.OperateNum = CommonDataBLL.OperateBh; productModel.ProductCode = this.txtProductCode.Text.Trim(); productModel.IsSell = isSell; productModel.Length = Length; productModel.Width = Width; productModel.High = High; productModel.Details_TX = Request.Form["txtDetails"].ToString(); productModel.GroupIDS_AZ_TX = txt_GroupIDS_AZ_TX.Text; productModel.GroupIDS_TJ_TX = txt_GroupIDS_TJ_TX.Text; productModel.OnlyForGroup_NR = rbtnN.Checked == true ? 0 : 1; if (this.ChboxFirst.Checked && this.ChboxAgain.Checked) { productModel.Yongtu = 0; } else { if (this.ChboxFirst.Checked) { productModel.Yongtu = 1; } if (this.ChboxAgain.Checked) { productModel.Yongtu = 2; } } } else { productModel.ProductTypeID = 0; productModel.ProductTypeName = ""; productModel.ProductSpecID = 0; productModel.ProductColorID = 0; productModel.ProductSexTypeID = 0; productModel.ProductStatusID = 0; productModel.BigProductUnitID = 0; productModel.SmallProductUnitID = 0; productModel.BigSmallMultiple = 0; productModel.ProductArea = ""; productModel.CostPrice = costPrice; productModel.CommonPrice = commonPrice; productModel.CommonPV = commonPV; productModel.PreferentialPrice = preferentialPrice; productModel.PreferentialPV = preferentialPV; productModel.AlertnessCount = alertCount; productModel.Description = productDescription; productModel.ProductImage = ImageContent; productModel.ImageType = strImageType; productModel.Weight = 0; productModel.CountryCode = ViewState["CountryCode"].ToString(); productModel.Currency = Convert.ToInt32(ViewState["CurrencyID"]); productModel.OperateIP = CommonDataBLL.OperateIP; productModel.OperateNum = CommonDataBLL.OperateBh; productModel.ProductCode = ""; productModel.IsSell = isSell; } if (editingID == 0) //添加数据 { bool isEsist = AddNewProductBLL.ProductNameIsExist(productName); ///产品 if (!isFold) { if (isEsist) { this.lblMessage.Text = GetTran("004113", "此产品名称已经存在!"); return; } } ///产品类 else { if (isEsist) { this.lblMessage.Text = GetTran("004116", "此产品类名已经存在!"); return; } } productModel.PID = Convert.ToInt32(this.pID); strMessage = GetTran("000492", "添加"); string oldID = ""; string languageName = ""; string languageID = ""; using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); using (SqlTransaction tran = conn.BeginTransaction()) { try { //增加产品 AddNewProductBLL.AddProduct(tran, productModel); //---多语言产品操作 ///获取新产品信息 //DataTable dtpro = AddNewProductBLL.GetNewProductInfo(); //if(dtpro.Rows.Count>0) //{ // oldID=dtpro.Rows[0]["productid"].ToString(); // languageName=dtpro.Rows[0]["productname"].ToString(); // string description=dtpro.Rows[0]["Description"].ToString().Trim(); // //获取语言种类(ID>1) // DataTable dtlang = AddNewProductBLL.GetLanguageIDByID(); // for(int i=0;i<dtlang.Rows.Count;i++) // { // languageID=dtlang.Rows[i][0].ToString(); // //获取----获取(产品目录)是否插入 // int count = AddNewProductBLL.GetLanguageTransCountByID(Convert.ToInt32(languageID)); // if(count==0) // { // ///向产品名称等翻译表插入相关记录 // languageTrans.TableName="Product"; // languageTrans.OldID=1; // languageTrans.ColumnsName = productName; // languageTrans.LanguageName = GetTran("004117","产品目录"); // languageTrans.LanguageID =Convert.ToInt32(languageID); // AddNewProductBLL.AddLanguageTrans(tran, languageTrans); // } // if(description!="") // { // /// 向产品名称等翻译表插入相关记录 // languageTrans.TableName = "Product"; // languageTrans.OldID =Convert.ToInt32(oldID); // languageTrans.ColumnsName ="Description"; // languageTrans.LanguageName=description; // languageTrans.LanguageID=Convert.ToInt32(languageID); // AddNewProductBLL.AddLanguageTrans(tran, languageTrans); // } // ///向产品名称等翻译表插入相关记录 // languageTrans.TableName = "Product"; // languageTrans.OldID =Convert.ToInt32(oldID); // languageTrans.ColumnsName = productName; // languageTrans.LanguageName= languageName; // languageTrans.LanguageID =Convert.ToInt32(languageID); // AddNewProductBLL.AddLanguageTrans(tran, languageTrans); // } //} tran.Commit(); } catch (System.Exception ee) { tran.Rollback(); System.Diagnostics.Trace.WriteLine(ee.Message); throw; } } } } else //修改数据 { strMessage = GetTran("000259", "修改"); // before delete ChangeLogs cl = new ChangeLogs("Product", "ProductID"); cl.AddRecord(this.editingID); //--多语言产品操作(只更新产品说明) //获取产品说明 //string Description = AddNewProductBLL.GetDescriptionByID(Convert.ToInt32(this.editingID)).Trim(); //string langID=""; //if(Description=="" && productDescription.Trim()!="") //{ // //查找ID>1的所有ID // DataTable dtlang = AddNewProductBLL.GetLanguageIDByID(); // for(int i=0;i<dtlang.Rows.Count;i++) // { // langID=dtlang.Rows[i][0].ToString(); // ///插入相关记录 // languageTrans.TableName = "Product"; // languageTrans.OldID = Convert.ToInt32(this.editingID); // languageTrans.ColumnsName = Description; // languageTrans.LanguageName = productDescription; // languageTrans.LanguageID =Convert.ToInt32(langID); // AddNewProductBLL.AddLanguageTrans(languageTrans); // } //} ///注意传参产品ID productModel.ProductID = this.editingID; int updCount = AddNewProductBLL.UpdProduct(productModel); if (updCount > 0) { cl.AddRecord(this.editingID); cl.ModifiedIntoLogs(ChangeCategory.company7, Session["Company"].ToString(), ENUM_USERTYPE.objecttype1); this.lblMessage.Text = strMessage + GetTran("004124", "成功!"); } else { this.lblMessage.Text = strMessage + GetTran("004128", "失败,请联系管理员!"); } } if (this.editingID == 0) { this.lblMessage.Text += GetTran("004132", "您可以继续添加此类下的产品"); } this.lblMessage.Text += "(" + GetTran("004140", "按 关闭 后可查看新数据") + ")"; Page.ClientScript.RegisterStartupScript(GetType(), "", "<script language='javascript'>alert('" + GetTran("001401", "操作成功!") + "');reloadopener();</script>"); SetValue(); }