public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { SVBitmap bitmap = value as SVBitmap; if (bitmap == null) { return(value); } IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SVWpfControl picDialog = new SVWpfControl(); picDialog.Width = 240; picDialog.Height = 260; SVWPfIconPic iconPicture = new SVWPfIconPic(); iconPicture.image.DataContext = bitmap.ShowName; picDialog.addContent(iconPicture); edSvc.DropDownControl(picDialog); value = iconPicture.resultBitmap(); return(value); } return(value); }
public SVIconProperties() { _rect = new Rectangle(0, 0, 100, 100); _iconData = new SVBitmap(); _controlType = "静态图"; _isLock = false; }
public override void refreshPropertyToPanel() { this.Id = _attrib.ID; this.Width = _attrib.Rect.Width; this.Height = _attrib.Rect.Height; this.Location = new Point(_attrib.Rect.X, _attrib.Rect.Y); this.BackColor = Color.Green; this.IsMoved = !_attrib.Lock; if (_attrib.VarName.Count != 0) { _attrib.VarList = String.Join(",", _attrib.VarName); } else { _attrib.VarList = "未设置变量"; } if (_attrib.Pic.BitmapArray.Count > 0) { SVBitmap svbitMap = _attrib.Pic.BitmapArray[0]; this.BackgroundImage = svbitMap.bitmap(); } else { this.BackgroundImage = _defaultBackGround; } }
/// <summary> /// 根据当前按钮属性对象中的值,更新按钮外观显示 /// </summary> public override void refreshPropertyToPanel() { this.Id = _attrib.ID; this.Width = _attrib.Rect.Width; this.Height = _attrib.Rect.Height; this.IsMoved = !_attrib.Lock; this.Location = new Point(_attrib.Rect.X, _attrib.Rect.Y); ///保证心跳控件必须至少设置了一副图片 if (_attrib.BitMapArray.BitmapArray.Count > 0) { SVBitmap svbitMap = _attrib.BitMapArray.BitmapArray[0]; ///判断文件是否已经被删除,如果删除控件不在显示图片 String file = Path.Combine(SVProData.IconPath, svbitMap.ImageFileName); if (!File.Exists(file)) { return; } SVPixmapFile pixmapFile = new SVPixmapFile(); pixmapFile.readPixmapFile(file); this.BackgroundImage = pixmapFile.getBitmapFromData(); } else { this.BackgroundImage = null; } }
/// <summary> /// 从xml文件中加载当前按钮对象内容 /// </summary> /// <param Name="xml">xml对象</param> /// <param Name="isCreate">true-创建新的ID号,false-表示使用文件中的ID</param> public override void loadXML(SVXml xml, Boolean isCreate = false) { XmlElement button = xml.CurrentElement; if (isCreate) { newID(); } else { _attrib.ID = UInt16.Parse(button.GetAttribute("id")); } int x = int.Parse(button.GetAttribute("x")); int y = int.Parse(button.GetAttribute("y")); int width = int.Parse(button.GetAttribute("width")); int height = int.Parse(button.GetAttribute("height")); _attrib.Rect = new Rectangle(x, y, width, height); ///遍历节点,循环读取图片文件数据 XmlNodeList nls = button.ChildNodes; foreach (var tmp in nls) { XmlElement vElement = (XmlElement)tmp; SVBitmap svBitmap = new SVBitmap(); svBitmap.ShowName = vElement.GetAttribute("Name"); svBitmap.ImageFileName = vElement.GetAttribute("File"); _attrib.BitMapArray.BitmapArray.Add(svBitmap); } }
public SVGifProperties() { _rect = new Rectangle(0, 0, 100, 100); _controlType = "动态图"; _picError = new SVBitmap(); _pic = new SVBitmapArray(); _var = new List <String>(); _varType = new List <Byte>(); _isLock = false; }
override public void loadXML(SVXml xml, Boolean isCreate = false) { XmlElement gif = xml.CurrentElement; if (isCreate) { newID(); } else { _attrib.ID = UInt16.Parse(gif.GetAttribute("ID")); } int x = int.Parse(gif.GetAttribute("X")); int y = int.Parse(gif.GetAttribute("Y")); int width = int.Parse(gif.GetAttribute("Width")); int height = int.Parse(gif.GetAttribute("Height")); _attrib.Rect = new Rectangle(x, y, width, height); ///读取错误图片数据 _attrib.PicError.ImageFileName = gif.GetAttribute("ErrorFile"); _attrib.PicError.ShowName = gif.GetAttribute("ErrorShowName"); XmlDocument docment = gif.OwnerDocument; ///读取背景图片数组 XmlNodeList nls = gif.GetElementsByTagName("PIC"); foreach (var tmp in nls) { XmlElement vElement = (XmlElement)tmp; SVBitmap svBitmap = new SVBitmap(); svBitmap.ShowName = vElement.GetAttribute("Name"); svBitmap.ImageFileName = vElement.GetAttribute("File"); _attrib.Pic.BitmapArray.Add(svBitmap); } ///读取变量名列表 nls = gif.GetElementsByTagName("VarName"); foreach (var tmp in nls) { XmlElement vElement = (XmlElement)tmp; String vName = vElement.GetAttribute("VName"); Byte vType = Byte.Parse(vElement.GetAttribute("VType")); _attrib.VarName.Add(vName); _attrib.VarType.Add(vType); } }
private void resultListView_Drop(object sender, DragEventArgs e) { String dataString = e.Data.GetData(typeof(String)) as String; if (dataString == null) { return; } List <SVBitmap> result = this.resultListView.ItemsSource as List <SVBitmap>; SVBitmap svBitmap = new SVBitmap(); svBitmap.ShowName = dataString; svBitmap.ImageFileName = _picManager.getFilePathFromName(dataString); result.Add(svBitmap); this.resultListView.Items.Refresh(); }
public SVButtonProperties() { _font = new Font("华文细黑", 12); _rect = new Rectangle(0, 0, 120, 60); _text = "Button"; _fText = "None"; _fMemo = ""; _bgcolor = Color.FromArgb(236, 236, 236); _fgcolor = Color.Black; _bgDownColor = _bgcolor; _btnType = new SVBtnChoicePage(); _controlType = "按钮"; _enVarText = new SVVarDefine(); _btnVarText = new SVVarDefine(); _btnDownPic = new SVBitmap(); _btnUpPic = new SVBitmap(); _isShowPic = false; _isLock = false; }
public SVBinaryProperties() { _font = new Font("华文细黑", 12); _rect = new Rectangle(0, 0, 120, 40); _trueColor = Color.Green; _trueBgColor = Color.Moccasin; _falseColor = Color.Blue; _falseBgColor = Color.White; _exceptionColor = Color.Red; _exceptionBgColor = Color.White; _type = 0; _customTrueText = "True"; _customFlaseText = "False"; _controlType = "开关量"; _isLock = false; _var = new SVVarDefine(); _truePicture = new SVBitmap(); _flasePicture = new SVBitmap(); _exPicture = new SVBitmap(); }
/// <summary> /// 初始化构造函数 /// </summary> /// <param Name="array">初始化图片数组</param> /// <param Name="count">最大图片个数</param> public SVBitmapArrayWindow(SVBitmapArray array, Int32 count = 8) { InitializeComponent(); ///相关事件注册 this.dataGridView.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView.AllowUserToAddRows = false; this.dataGridView.RowPostPaint += new DataGridViewRowPostPaintEventHandler(dataGridView_RowPostPaint); this.dataGridView.Click += new EventHandler(dataGridView_Click); this.propertyGrid1.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid1_PropertyValueChanged); _bitArray = array; ///在表格中,添加最大行 for (int i = 0; i < count; i++) { DataGridViewRowChild v = new DataGridViewRowChild(); dataGridView.Rows.Add(v); } if (array.BitmapArray == null) { return; } Int32 minValue = Math.Min(count, array.BitmapArray.Count); for (int i = 0; i < minValue; i++) { SVBitmap vTmp = array.BitmapArray[i]; if (vTmp == null) { continue; } DataGridViewRowChild vv = dataGridView.Rows[i] as DataGridViewRowChild; vv.Attrib.Bitmap = vTmp; dataGridView.Rows[i].SetValues(vTmp.ShowName); } }
private void btnIn_Click(object sender, RoutedEventArgs e) { if (this.resultListView.Items.Count >= 8) { return; } String dataString = this.listListView.SelectedValue as String; if (dataString == null) { return; } List <SVBitmap> result = this.resultListView.ItemsSource as List <SVBitmap>; SVBitmap svBitmap = new SVBitmap(); svBitmap.ShowName = dataString; svBitmap.ImageFileName = _picManager.getFilePathFromName(dataString); result.Add(svBitmap); this.resultListView.Items.Refresh(); }
public override void PaintValue(PaintValueEventArgs e) { SVBitmap bitmap = e.Value as SVBitmap; if (bitmap == null) { return; } if (bitmap.ImageFileName == null || bitmap.ShowName == null) { return; } Rectangle rect = new Rectangle(1, 1, 19, 17); var bitMap = bitmap.bitmap(); if (bitMap == null) { return; } e.Graphics.DrawImage(bitMap, rect); }
public SVPageProperties() { _bitMap = new SVBitmap(); }