using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; namespace Kingo.Mobile.Shape2KOTool.SymbolSetting { public partial class UCSymbolItemConfig : UserControl { public UCSymbolItemConfig() { InitializeComponent(); } private void rbtnImage_CheckedChanged(object sender, EventArgs e) { this.label4.Enabled = this.rbtnImage.Checked; this.btnLoadImage.Enabled = this.rbtnImage.Checked; this.label1.Enabled = !this.rbtnImage.Checked; this.ucFillColor.Enabled = !this.rbtnImage.Checked; this.label5.Enabled = !this.rbtnImage.Checked; this.numFillOpacity.Enabled = !this.rbtnImage.Checked; this.ucSymbolItem1.FillImage = this.rbtnImage.Checked ? this.btnLoadImage.Tag as Image : null; } private void numBorderWidth_ValueChanged(object sender, EventArgs e) { this.ucSymbolItem1.BoderWidth =(double) numBorderWidth.Value; } private void ucFillColor_BackColorChanged(object sender, EventArgs e) { this.ucSymbolItem1.FillColor = Color.FromArgb((int)(this.numFillOpacity.Value * 255), ucFillColor.Color); //this.ucSymbolItem1.FillColor } private void ucBorderColor_BackColorChanged(object sender, EventArgs e) { this.ucSymbolItem1.BorderColor = Color.FromArgb((int)(this.numBorderOpacity.Value * 255), ucBorderColor.Color); } private void numFillOpacity_ValueChanged(object sender, EventArgs e) { this.ucSymbolItem1.FillColor = Color.FromArgb((int)(this.numFillOpacity.Value * 255), ucFillColor.Color); } private void numBorderOpacity_ValueChanged(object sender, EventArgs e) { this.ucSymbolItem1.BorderColor = Color.FromArgb((int)(this.numBorderOpacity.Value * 255), ucBorderColor.Color); } private void btnLoadImage_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog(this) == DialogResult.OK) { Image img = Image.FromFile(openFileDialog1.FileName); SetbtnLoadImage(img); this.ucSymbolItem1.FillImage = img; } } private void SetbtnLoadImage(Image img) { if (btnLoadImage.Tag != null) { Image tagImage = btnLoadImage.Tag as Image; if (tagImage != null) tagImage.Dispose(); btnLoadImage.Tag = null; } btnLoadImage.Tag = img; } //private void rbtnColor_CheckedChanged(object sender, EventArgs e) //{ // this.label4.Enabled = !this.rbtnColor.Checked; // this.btnLoadImage.Enabled = !this.rbtnColor.Checked; // this.label1.Enabled = this.rbtnColor.Checked; // this.ucFillColor.Enabled = this.rbtnColor.Checked; //} public XSDClass.FSymbol FSymbol { get { return this.ucSymbolItem1.FSymbol; } set { if(value==null) return; //this.ucSymbolItem1.FSymbol = value; //设置本身的样式 XSDClass.FSymbol pFSymbol = value; if (value is XSDClass.SFSymbol) { XSDClass.SFSymbol pSFSymbol = value as XSDClass.SFSymbol; this.rbtnColor.Checked = true; this.ucFillColor.Color = XSDClass.CommonMethod.GetColorFromInt4Color(pSFSymbol.Color); this.numFillOpacity.Value = (decimal)(pSFSymbol.Color[3] / 255.0); SetbtnLoadImage(null); } else if (value is XSDClass.PFSymbol) { XSDClass.PFSymbol pPFSymbol = value as XSDClass.PFSymbol; this.rbtnImage.Checked = true; Image img = XSDClass.CommonMethod.GetImageFromBase64(pPFSymbol.ImageData); SetbtnLoadImage(img); this.ucSymbolItem1.FillImage = img; } this.ucBorderColor.Color = XSDClass.CommonMethod.GetColorFromInt4Color(pFSymbol.Outline.Color); this.numBorderWidth.Value = (decimal)pFSymbol.Outline.Width; this.numBorderOpacity.Value = (decimal)(pFSymbol.Outline.Color[3] / 255.0); } } } }