alielie
2025-08-25 c4a3f8db90530a727ffab77c3bb5bb7d782792bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using HMI.UI.MDI;
using System;
using System.Windows;
using System.Windows.Media;
 
namespace HMI.UI.DpUtil
{
    public class CanvasPosition
    {
        public double Top { get; set; }
        public double Left { get; set; }
        public double Width { get; set; }
        public double Height { get; set; }
 
        public double LimitWidth { get; set; }
        public double LimitHeight { get; set; }
    }
 
    public class CanvasHelper
    {
        public static void SetTopZIndex(InnerWindow element, DependencyObject parent, Type targetClass)
        {
            int max = 0;
            int zindex = element.Zindex;
 
            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
            {
                InnerWindow child = VisualTreeHelper.GetChild(parent, i) as InnerWindow;
                if (child != null && targetClass == child.GetType())
                {
                    if (element != child && child.Zindex >= zindex)
                    {
                        child.Zindex = child.Zindex-1;
                    }
                   
                }
                max++;
            }
            element.Zindex = max;
        }
    }
}