/// <summary> /// 加载ToolTip子元素属性 /// </summary> /// <param name="result"></param> private void LoadToolTipProperty(List<t_Element> elements) { var target = _associatedElement as MonitorControl; if (null != target) { target.IsToolTipLoaded = true; var toolTipControlElement = elements.FirstOrDefault(t => t.ControlID == -9999); if (null != toolTipControlElement) { var toolTipControl = new ToolTipControl(target); toolTipControl.ListAllElement = new List<t_Element>(); toolTipControl.Width = toolTipControlElement.Width.HasValue ? toolTipControlElement.Width.Value : 300d; toolTipControl.Height = toolTipControlElement.Height.HasValue ? toolTipControlElement.Height.Value : 200d; toolTipControl.SetValue(Canvas.ZIndexProperty, 10000); toolTipControl.ScreenElement = toolTipControlElement; toolTipControl.ListElementProp = new ElementPropertyDA().SelectBy(toolTipControlElement.ElementID); toolTipControl.ElementState = ElementSate.Save; toolTipControl.SetPropertyValue(); toolTipControl.SetCommonPropertyValue(); _parent.Children.Add(toolTipControl); toolTipControl.DesignMode(); toolTipControl.SetPosition(); target.ToolTipControl = toolTipControl; if (null != CurrenttoolTipControl) { CurrenttoolTipControl.IsOpen = false; Adorner.RemoveMutiSelected(CurrenttoolTipControl.AdornerLayer); } CurrenttoolTipControl = toolTipControl; toolTipControl.IsOpen = true; var childElements = elements.Where(t => t.ControlID != -9999); foreach (var childElement in childElements) { var poperties = new ElementPropertyDA().SelectBy(childElement.ElementID); var monitor = target.OnLoadElement(toolTipControl.ToolTipCanvas, childElement, ElementSate.Save, poperties); if (null != monitor) { monitor.ParentControl = toolTipControl; monitor.DesignMode(); monitor.AllowToolTip = false; monitor.ClearValue(Canvas.ZIndexProperty); if (null != monitor.AdornerLayer) { monitor.AdornerLayer.AllToolTip = false; } } toolTipControl.ListAllElement.Add(childElement); } } } }
//private void LoadControlsByTypeCallback(LoadOperation<t_Control> result) //{ // if (!result.HasError) // { // _t_toolTipControl = result.Entities.FirstOrDefault(); // CreateToolTip(_t_toolTipControl); // } //} private void CreateToolTip(t_Control t_control) { var target = _associatedElement as MonitorControl; if (null != target) { if (t_control != null) { target.IsToolTipLoaded = true; var toolTipControl = new ToolTipControl(target); toolTipControl.SetValue(Canvas.ZIndexProperty, 10000); var listElementProperties = new List<t_ElementProperty>(); var toolTipControlElement = MonitorControl.OnInitControl(t_control); toolTipControlElement.Transparent = 100; toolTipControlElement.ControlID = -9999; toolTipControlElement.ElementType = "ToolTip"; toolTipControlElement.ElementName = t_control.ControlName; toolTipControl.ScreenElement = toolTipControlElement; toolTipControlElement.Width = 300; toolTipControlElement.Height = 200; var elementProperties = new ControlPropertyDA().SelectByControlId(t_control.ControlID); foreach (t_ControlProperty property in elementProperties) { t_ElementProperty tt = new t_ElementProperty(); tt.Caption = property.Caption; tt.ElementID = toolTipControlElement.ElementID; tt.PropertyNo = property.PropertyNo; tt.PropertyValue = property.DefaultValue; tt.PropertyName = property.PropertyName; listElementProperties.Add(tt); } toolTipControl.ScreenElement = toolTipControlElement; toolTipControl.ListElementProp = listElementProperties; toolTipControl.ElementState = ElementSate.New; toolTipControl.SetPropertyValue(); toolTipControl.SetCommonPropertyValue(); _parent.Children.Add(toolTipControl); toolTipControl.DesignMode(); toolTipControl.SetPosition(); target.ToolTipControl = toolTipControl; if (null != CurrenttoolTipControl) { CurrenttoolTipControl.IsOpen = false; Adorner.RemoveMutiSelected(CurrenttoolTipControl.AdornerLayer); } CurrenttoolTipControl = toolTipControl; toolTipControl.IsOpen = true; } } }