/// <summary> /// 重载EditValue,编辑按钮动作属性的弹出窗口 /// </summary> /// <param Name="context"></param> /// <param Name="provider"></param> /// <param Name="value"></param> /// <returns></returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { try { //从当前对象中获取按钮控件对象 SVButton button = context.Instance as SVButton; if (button == null) { return(null); } IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SVBtnBackGroundWindow win = new SVBtnBackGroundWindow(button); edSvc.ShowDialog(win); if (button.Attrib.IsShowPic) { return("图片"); } else { return("颜色"); } } } catch (Exception ex) { SVLog.TextLog.Exception(ex); } return(value); }
/// <summary> /// 进入编辑按钮备注的对话框 /// </summary> /// <param oldName="context"></param> /// <param oldName="provider"></param> /// <param oldName="value"></param> /// <returns></returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { ///确保操作的对象为按钮控件,其他对象不能使用该类进行包装 SVButton svButton = context.Instance as SVButton; if (svButton == null) { return(value); } IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SVWpfControl textDialog = new SVWpfControl(); textDialog.Width = 200; textDialog.Height = 120; SVWPFBtnMemoEdit edit = new SVWPFBtnMemoEdit(); edit.textBox.DataContext = svButton.Attrib; textDialog.addContent(edit); edSvc.DropDownControl(textDialog); return(value); } return(value); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { SVButton svPanel = context.Instance as SVButton; if (svPanel == null) { return(value); } ///获取当前页面中的所以趋势图 List <SVCurveProperties> attribList = new List <SVCurveProperties>(); foreach (var sv in svPanel.Parent.Controls) { SVCurve curve = sv as SVCurve; if (curve != null) { attribList.Add(curve.Attrib); } } IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SVWpfControl variableDialog = new SVWpfControl(); variableDialog.Width = 100; variableDialog.Height = 100; SVWPFCurveSelect curveDialog = new SVWPFCurveSelect(); curveDialog.listView.ItemsSource = attribList; variableDialog.addContent(curveDialog); edSvc.DropDownControl(variableDialog); SVCurveProperties obj = curveDialog.listView.SelectedItem as SVCurveProperties; if (obj != null) { switch (svPanel.Attrib.ButtonType) { case 6: svPanel.Attrib.BtnVarText = obj.ForwardControl; break; case 7: svPanel.Attrib.BtnVarText = obj.CurControl; break; case 8: svPanel.Attrib.BtnVarText = obj.BackwardControl; break; } return(obj.ID.ToString()); } } return(value); }
/// <summary> /// 通过序列化的机制来克隆一个当前对象并返回 /// </summary> /// <returns>一个新的按钮对象</returns> override public object cloneObject() { MemoryStream stream = new MemoryStream(); BinaryFormatter binFormat = new BinaryFormatter(); binFormat.Serialize(stream, this); stream.Position = 0; SVButton result = (SVButton)binFormat.Deserialize(stream); result.refreshPropertyToPanel(); return(result); }
/// <summary> /// 自定义构造函数 /// </summary> /// <param Name="button">按钮对象</param> public SVBtnBackGroundWindow(SVButton button) { InitializeComponent(); _button = button; ///设置颜色checkbox this.colorGroupBox.init(); this.colorGroupBox.setEnabledText("颜色"); ///设置图片checkbox this.picGroupBox.init(); this.picGroupBox.setEnabledText("图片"); if (_button.Attrib.IsShowPic) { this.colorGroupBox.setChecked(false); this.picGroupBox.setChecked(true); } else { this.colorGroupBox.setChecked(true); this.picGroupBox.setChecked(false); } if (_button.Attrib.BtnDownPic.ImageFileName != null) { String file = Path.Combine(SVProData.IconPath, _button.Attrib.BtnDownPic.ImageFileName); setButtonBackGd(picBtnDown, file); } if (_button.Attrib.BtnUpPic.ImageFileName != null) { String file = Path.Combine(SVProData.IconPath, _button.Attrib.BtnUpPic.ImageFileName); setButtonBackGd(picBtnUp, file); } colorBtnDown.BackColor = _button.Attrib.BackColorgroundDown; colorBtnUp.BackColor = _button.Attrib.BackColorground; ///颜色发生改变 colorGroupBox.EnabledChanged += new System.EventHandler(colorGroupBox_EnabledChanged); ///图片发生改变 picGroupBox.EnabledChanged += new System.EventHandler(picGroupBox_EnabledChanged); }