示例#1
0
        public grafexe.HMIObject RetrieveObjectProperties(string pdlName, string objName, grafexe.Application g, grafexe.HMIOpenDocumentType openType = grafexe.HMIOpenDocumentType.hmiOpenDocumentTypeInvisible)
        {
            string seldocfullname = Path.Combine(g.ApplicationDataPath, pdlName + ".pdl");

            Console.WriteLine("Opening... " + seldocfullname);

            grafexe.HMIObject go = null;

            grafexe.Document   seldoc = g.Documents.Open(seldocfullname, openType);
            grafexe.HMIObjects selos  = seldoc.HMIObjects;

            go = selos.Find(ObjectName: objName).Count > 0 ? selos.Find(ObjectName: objName)[1] : null;

            if (go != null)
            {
                if (go.Visible.value == false && go.Visible.DynamicStateType == HMIDynamicStateType.hmiDynamicStateTypeNoDynamic)
                {
                    go = null;
                }
            }

            if (go != null)
            {
                Console.WriteLine(go.ObjectName.value);
            }

            return(go);
        }
示例#2
0
        public List <ObjectData> GetObjectsInfo(string type, string nameContains, List <IHMIScreen> filteredScreens, List <WindowData> windowData)
        {
            var g        = new grafexe.Application();
            var dataList = new List <ObjectData>();

            foreach (var s in filteredScreens)
            {
                var mainScreen = GetMainScreen();

                var screenData = windowData.FirstOrDefault(c => c.Name == s.Parent.ObjectName);
                var left       = screenData.ScreenLeft;
                var top        = screenData.ScreenTop;

                var screenItems = s.ScreenItems.Cast <IHMIScreenItem>();
                var query       = screenItems.Where(o => o.ObjectName.Contains(nameContains) && o.Type == type).ToList();

                foreach (IHMIScreenItem o in query) //screenitems is rt objects
                {
                    var obj = RetrieveObjectProperties(s.ObjectName, o.ObjectName, g);

                    if (obj != null)
                    {
                        Console.WriteLine(obj.ObjectName.value + "," + obj.Left.value + "," + obj.Top.value);

                        Console.WriteLine(o.Parent.ObjectName + "," + obj.ObjectName.value + "," + obj.Left.value + "," + obj.Top.value, "\\Screen.log", false);
                        Console.WriteLine(o.Parent.ObjectName + "," + obj.ObjectName.value + "," +
                                          (left + obj.Left.value) + "," +
                                          (top + obj.Top.value) + "," +
                                          (left + obj.Left.value + obj.Width.value) + "," +
                                          (top + obj.Top.value + obj.Height.value), "\\Screen.log", false);

                        dataList.Add(new ObjectData()
                        {
                            RealLeft   = left + obj.Left.value,
                            RealRight  = left + obj.Left.value + obj.Width.value,
                            RealTop    = top + obj.Top.value,
                            RealBottom = top + obj.Top.value + obj.Height.value,

                            OffsetLeft = left,
                            OffsetTop  = top,
                            ObjectName = obj.ObjectName.value,
                            Page       = s.ObjectName,
                            CallsPdl   = ""
                        });

                        var      events = obj.Events.Cast <HMIEvent>();
                        HMIEvent evs    = events.FirstOrDefault(e => e.EventName == "OnLButtonUp" && e.Actions.Count > 0);

                        if (evs == null)
                        {
                            break;
                        }

                        HMIActions acts = evs.Actions;

                        string pdl = "";
                        foreach (HMIScriptInfo act in acts)
                        {
                            if (pdl == "")
                            {
                                var vb = act.SourceCode;

                                var callingRow = vb.Split("\r\n".ToCharArray()).FirstOrDefault(c => c.Contains("pdlName = "));
                                pdl = callingRow?.Split("\"".ToCharArray())?.ElementAtOrDefault(1);

                                var embeddedRow = vb.Split("\r\n".ToCharArray()).FirstOrDefault(c => c.Contains(".PictureName = "));
                                if (embeddedRow != null)
                                {
                                    pdl = embeddedRow?.Split("\"".ToCharArray())?.ElementAtOrDefault(1);
                                }
                                if (pdl != "")
                                {
                                    break;
                                }
                            }
                        }

                        pdl = pdl != null?pdl.Replace(".pdl", "") : "";

                        dataList.FirstOrDefault(c => c.ObjectName == o.ObjectName).CallsPdl = pdl != null ? pdl : "";

                        Console.WriteLine(obj.ObjectName.value + " calls " + dataList.Last().CallsPdl, "\\PdlCalls.log", false);
                    }
                }
            }

            dataList = dataList.Where(c => c.CallsPdl != "" && c.CallsPdl != null && !navigatedPages.Contains(c.CallsPdl)).ToList();
            return(dataList);
        }