private void ShowElements(List<t_Element> lsitElement, Canvas canvas, MonitorControl parentContol = null) { List<t_ElementProperty> _elementProperties = new ElementPropertyDA().selectByScreenID(_screen.ScreenID); foreach (t_Element el in lsitElement) { var list = _elementProperties.Where(a => a.ElementID == el.ElementID); var monitorControl = ShowElement(el, ElementSate.Save, list.ToList()); // _ScreenView.ShowElement(canvas, el, ElementSate.Save, list.ToList()); if (null != monitorControl && null != parentContol) { monitorControl.ParentControl = parentContol; monitorControl.AllowToolTip = false; monitorControl.ClearValue(Canvas.ZIndexProperty); if (null != monitorControl.AdornerLayer) { monitorControl.AdornerLayer.AllToolTip = false; } } } }
public void SetAttrByName(string name, object value) { if (null == ScreenElement || !ScreenElement.ControlID.HasValue) { return; } if (ListElementProp == null) { ListElementProp = new ElementPropertyDA().SelectBy(ScreenElement.ElementID); if (ListElementProp.Count == 0) { var elementProperties = new ControlPropertyDA().SelectByControlId(ScreenElement.ControlID.Value); foreach (t_ControlProperty elementProperty in elementProperties) { t_ElementProperty tt = new t_ElementProperty(); tt.Caption = elementProperty.Caption; tt.ElementID = ScreenElement.ElementID; tt.PropertyNo = elementProperty.PropertyNo; tt.PropertyValue = elementProperty.DefaultValue; tt.PropertyName = elementProperty.PropertyName; ListElementProp.Add(tt); } } } var property = ListElementProp.FirstOrDefault(p => string.Equals(p.PropertyName, name, StringComparison.CurrentCultureIgnoreCase)); if (null != property) { property.PropertyValue =( null == value ? string.Empty : value.ToString()); } }
/// <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); } } } }
/// <summary> /// 加载,元素属性完成 /// </summary> /// <param name="result"></param> private void LoadElementPropertiesCompleted(object state) { try { var screenId = (int)state; ScreenElement = new ElementDA().SelectBy(screenId); ; ShowLoadTimeLen("4"); //_ScreenView.Width = 200; //_ScreenView.Height = 200; //csScreen.Children.Add(_ScreenView); //如果不是组态,打开定时器 //if (CBIsztControl.IsChecked == false) ElementProperties = new ElementPropertyDA().selectByScreenID(_CurrentScreen.ScreenID); var TopElement = ScreenElement.Where(m => m.ParentID == 0).ToList();//|| m.ControlID ==-9999 Dispatcher.Invoke(new Action(() => { ShowElements(TopElement, csScreen); tbWait.IsBusy = false; })); //var ToolElement = ScreenElement.Where(m => m.ControlID == -9999); //{ //} ShowLoadTimeLen("5"); if (IsZT) { // timerRefrshValue.Start(); } } catch (Exception ex) { Dispatcher.Invoke(new Action(() => { tbWait.IsBusy = false; MessageBox.Show(ex.Message); })); } }