Ejemplo n.º 1
0
 //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;
         }
     }
 }
Ejemplo n.º 2
0
        /// <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);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected override void OnMouseEnter(MouseEventArgs e)
        {
            if (!IsToolTip && !IsDesignMode)
            {
                if (!IsToolTipLoaded)
                {
                    if (null == ToolTipControl && null != _ScreenElement)
                    {
                        IsToolTipLoaded = true;
                        var parentID = _ScreenElement.ElementID;
                        //LoadScreen._DataContext.Load<t_Element>(LoadScreen._DataContext.GetT_ElementsByScreenIDQuery(screenID), LoadToolTipCallback, null);
                        var toolTipControlElement = new ElementDA().GetBy(-9999, parentID, "ToolTip");
                        if (null != toolTipControlElement
                            && Parent is Canvas)
                        {
                            var parent = Parent as Canvas;
                            ToolTipControl = new ToolTipControl(this);
                            ToolTipControl.Width = toolTipControlElement.Width.HasValue ? toolTipControlElement.Width.Value : 300d;
                            ToolTipControl.Height = toolTipControlElement.Height.HasValue ? toolTipControlElement.Height.Value : 200d;
                            ToolTipControl.Transparent = 100;
                            ToolTipControl.SetValue(Canvas.ZIndexProperty, 10000);
                            ToolTipControl.ScreenElement = toolTipControlElement;
                            ToolTipControl.ListElementProp = ElementPropertyDA.SelectByElementID(toolTipControlElement.ElementID);
                            ToolTipControl.ElementState = ElementSate.Save;
                            ToolTipControl.SetPropertyValue();
                            ToolTipControl.SetCommonPropertyValue();
                            parent.Children.Add(ToolTipControl);
                            SetToolTipPosition();

                            var childElements = new ElementDA().SelectByParentId(parentID);
                            if (ToolTipControl.ListAllElement == null)
                            {
                                ToolTipControl.ListAllElement = new List<t_Element>();
                            }
                            foreach (var childElement in childElements)
                            {
                                var poperties = ElementPropertyDA.SelectByElementID(childElement.ElementID);
                                OnLoadElement(ToolTipControl.ToolTipCanvas, childElement, ElementSate.Save, poperties);

                                ToolTipControl.ListAllElement.Add(childElement);
                            }
                        }
                    }
                }
                else
                {
                    SetToolTipPosition();
                }
            }
            base.OnMouseEnter(e);
        }