コード例 #1
0
            private static ScriptsType GetScripts(FrameType frame, bool createOnNull)
            {
                ScriptsType result = null;

                if (frame.Scripts.Count == 0)
                {
                    if (createOnNull)
                    {
                        result = new ScriptsType();
                        frame.Scripts.Add(result);
                    }
                }
                else
                {
                    for (int index = frame.Scripts.Count - 1; index >= 0; index--)
                    {
                        ScriptsType scripts = frame.Scripts[index];

                        if (MergeScripts(scripts, result, EventChoice.OnMouseDown) ||
                            MergeScripts(scripts, result, EventChoice.OnMouseUp))
                        {
                            frame.Scripts.Remove(scripts);
                        }
                    }

                    if (result == null)
                    {
                        result = frame.Scripts[0];
                    }
                }

                return(result);
            }
コード例 #2
0
            private static bool MergeScripts(ScriptsType from, ScriptsType to, EventChoice eventChoice)
            {
                if (from.Events.ContainsKey(eventChoice))
                {
                    if (to == null)
                    {
                        to = from;
                        return(false);
                    }
                    else
                    {
                        // Retrieve current event handler script
                        string currentScript = to.Events.ContainsKey(eventChoice) && to.Events[eventChoice] != null ? to.Events[eventChoice] : String.Empty;

                        // Append script to be merged
                        currentScript += from.Events[eventChoice] ?? String.Empty;

                        // Update event handler script
                        to.Events[eventChoice] = currentScript;

                        return(true);
                    }
                }

                return(false);
            }
コード例 #3
0
            private bool IsMovingEnabled()
            {
                FrameType frame = control.SerializationObject as FrameType;

                if (frame == null)
                {
                    return(false);
                }

                ScriptsType scripts = GetScripts(frame, false);

                return(frame.movable && scripts != null && scripts.Events.ContainsKey(EventChoice.OnMouseDown) &&
                       scripts.Events.ContainsKey(EventChoice.OnMouseUp));
            }
コード例 #4
0
        private void ClearEvent(IList <ScriptsType> allScripts)
        {
            ScriptsType scripts = this.FindContainingScripts(allScripts);

            if (scripts != null)
            {
                scripts.Events.Remove(this.eventName);

                if (scripts.Events.Count == 0)
                {
                    allScripts.Remove(scripts);
                }
            }
        }
コード例 #5
0
        public override object GetValue(object component)
        {
            IFrameControl frameControl = (component as IFrameControl);

            if (frameControl == null)
            {
                return(string.Empty);
            }

            FrameType   frame   = (FrameType)frameControl.SerializationObject;
            ScriptsType scripts = this.FindContainingScripts(frame.Scripts);

            return(((scripts == null) || (!scripts.Events.ContainsKey(this.eventName))) ?
                   string.Empty : scripts.Events[this.eventName]);
        }
コード例 #6
0
 /// <summary>
 /// 脚本解释器
 /// 构造函数
 /// </summary>
 /// <param name="scriptsType">tcs文件中所有的子节点</param>
 public ScriptEntrance(ScriptsType scriptsType)
 {
     try
     {
         //TODO 正式开始执行各个对象的实际对应操作
         AnnotationEvents  annotationEvents  = new AnnotationEvents(new AnnotationNodes(scriptsType.AnnXEle).Annotation_Info);
         TestConfigEvents  testConfigEvents  = new TestConfigEvents(new TestConfigNodes(scriptsType.ConfXEle).TestConfig_Info);
         StartAppEvents    startAppEvents    = new StartAppEvents(new StartAppNodes(scriptsType.StartXEle).StartApp_Info);
         TestsEvents       testsEvents       = new TestsEvents(new TestsNodes(scriptsType.TestsXEle).TestsType_Info);
         CloseAppEvents    closeAppEvents    = new CloseAppEvents(new CloseAppNodes(scriptsType.CloseXEle).CloseApp_Info);
         LogFunctionEvents logFunctionEvents = new LogFunctionEvents(new LogFunctionNodes(scriptsType.LogFuncXEle).LogFunction_Info);
     }
     catch (Exception e)
     {
         ComArgs.RoLog.WriteLog(LogStatus.LExpt, "脚本解析核心类发生异常", e.ToString());
     }
 }
コード例 #7
0
            /// <summary>
            /// Makes the frame movable.
            /// </summary>
            public void EnableMoving()
            {
                FrameType frameType = control.SerializationObject as FrameType;

                if (frameType != null)
                {
                    //frameType.movable = true;

                    ScriptsType scripts = GetScripts(frameType, true);

                    if (scripts != null)
                    {
                        // Retrieve current OnMouseDown event
                        string currentOnDown = (scripts.Events.ContainsKey(EventChoice.OnMouseDown)) ? scripts.Events[EventChoice.OnMouseDown] : String.Empty;

                        // Append start move script, if not found
                        if (!currentOnDown.Contains(FrameDesigner.startMoveScript))
                        {
                            currentOnDown += FrameDesigner.startMoveScript;
                        }

                        // Set the event handler
                        scripts.Events[EventChoice.OnMouseDown] = currentOnDown;

                        // Retrieve current OnMouseUp event
                        string currentOnUp = (scripts.Events.ContainsKey(EventChoice.OnMouseUp)) ? scripts.Events[EventChoice.OnMouseUp] : String.Empty;

                        // APpend stop move script, if not found
                        if (!currentOnUp.Contains(FrameDesigner.stopMoveScript))
                        {
                            currentOnUp += FrameDesigner.stopMoveScript;
                        }

                        // Set the event handler
                        scripts.Events[EventChoice.OnMouseUp] = currentOnUp;
                    }

                    // Raise ComponentChangedEvent
                    this.OnComponentChanged(EventArgs.Empty);

                    // Refresh the Designer Action UI
                    designerActionUIService.Refresh(this.Component);
                }
            }
コード例 #8
0
ファイル: APIWindwos.cs プロジェクト: lixioabai/GameEngine
    /// <summary>
    /// 绘制界面
    /// </summary>
    void OnGUI()
    {
        scriptsType = (ScriptsType)EditorGUILayout.EnumPopup("类别", scriptsType);

        if (scriptsType == ScriptsType.None)
        {
            GUILayout.BeginVertical("Box");



            GUILayout.EndVertical();
        }

        if (scriptsType == ScriptsType.PanelBase)
        {
            GUILayout.BeginVertical("Box");

            if (GUILayout.Button("PanelBase"))
            {
                PanelBaseWindows.ShowAPIWindwos();
            }

            GUILayout.EndVertical();
        }
        if (scriptsType == ScriptsType.PanelMgr)
        {
            GUILayout.BeginVertical("Box");

            GUILayout.Button("PanelBase");

            GUILayout.EndVertical();
        }

        if (scriptsType == ScriptsType.Other)
        {
            GUILayout.BeginVertical("Box");

            GUILayout.Button("PanelBase");

            GUILayout.EndVertical();
        }
    }
コード例 #9
0
ファイル: MainEntrance.cs プロジェクト: duanbi/RoWarlock
        /// <summary>
        /// 脚本解释器入口
        /// 初始化整个测试脚本,并且能反馈部分有效信息
        /// 构造函数
        /// </summary>
        /// <param name="rospath">单个ros文件路径</param>
        public MainEntrance(string rospath)
        {
            //前置:初始化整个测试脚本,初始化可能应用的方法
            ScriptsType scriptsType = new ScriptsType();

            try
            {
                //1.解析tcs文件

                //读取tcs文件
                XDocument tcsDocument = XDocument.Load(rospath, LoadOptions.SetLineInfo);

                //提取根节点
                XElement rootElement = tcsDocument.Element(XName.Get("TestDefinition", ComArgs.RosStr));

                //提取各个分类节点
                if (rootElement != null)
                {
                    scriptsType.AnnXEle     = rootElement.Element(XName.Get("Annotation", ComArgs.RosStr));
                    scriptsType.ConfXEle    = rootElement.Element(XName.Get("TestConfig", ComArgs.RosStr));
                    scriptsType.StartXEle   = rootElement.Element(XName.Get("StartApp", ComArgs.RosStr));
                    scriptsType.TestsXEle   = rootElement.Element(XName.Get("Tests", ComArgs.RosStr));
                    scriptsType.CloseXEle   = rootElement.Element(XName.Get("CloseApp", ComArgs.RosStr));
                    scriptsType.LogFuncXEle = rootElement.Element(XName.Get("LogFunction", ComArgs.RosStr));
                }


                TotalSteps = scriptsType.TestsXEle.Elements().Count();                                              //提取步骤数量
                UseTciNums = scriptsType.ConfXEle.Element(XName.Get("Imports", ComArgs.RosStr)).Elements().Count(); //提取使用的roi文件数量

                //2.执行步骤
                ScriptEntrance scriptsEntrance = new ScriptEntrance(scriptsType);
                //3.返回结果
                FinalResult = scriptsEntrance.Result; //最终结果
            }
            catch (Exception e)
            {
                ComArgs.RoLog.WriteLog(LogStatus.LExpt, "脚本解析器入口发生异常", e.ToString());
            }
        }
コード例 #10
0
        public override void SetValue(object component, object value)
        {
            IFrameControl frameControl = (component as IFrameControl);

            if (frameControl == null)
            {
                return;
            }

            FrameType frame = (FrameType)frameControl.SerializationObject;

            string valueAsString = (value as string);

            if (string.IsNullOrEmpty(valueAsString))
            {
                this.ClearEvent(frame.Scripts);
            }
            else
            {
                ScriptsType scripts = this.FindContainingScripts(frame.Scripts);

                if (scripts == null)
                {
                    if (frame.Scripts.Count > 0)
                    {
                        scripts = frame.Scripts[0];
                    }
                    else
                    {
                        scripts = new ScriptsType();
                        frame.Scripts.Add(scripts);
                    }
                }

                scripts.Events[this.eventName] = valueAsString;
            }
        }
コード例 #11
0
            /// <summary>
            /// Makes the frame fixed.
            /// </summary>
            public void DisableMoving()
            {
                FrameType frameType = control.SerializationObject as FrameType;

                if (frameType != null)
                {
                    //frameType.movable = false;

                    ScriptsType scripts = FrameDesigner.FrameDesignerActionList.GetScripts(frameType, false);

                    if (scripts != null)
                    {
                        if (scripts.Events.ContainsKey(EventChoice.OnMouseDown))
                        {
                            // Retrieve current OnMouseDown event
                            string currentDown = scripts.Events[EventChoice.OnMouseDown] ?? String.Empty;

                            // Remove the start move snippet from the event handler script
                            currentDown = currentDown.Replace(FrameDesigner.startMoveScript, String.Empty);

                            // If there is no code left, remove the event handler script altogether, update otherwise
                            if (String.IsNullOrEmpty(currentDown))
                            {
                                scripts.Events.Remove(EventChoice.OnMouseDown);
                            }
                            else
                            {
                                scripts.Events[EventChoice.OnMouseDown] = currentDown;
                            }
                        }

                        if (scripts.Events.ContainsKey(EventChoice.OnMouseUp))
                        {
                            // Retrieve current OnMouseUp event
                            string currentUp = (scripts.Events[EventChoice.OnMouseUp] ?? String.Empty);

                            // Remvoe the stop move snippet from the event handler sciprt
                            currentUp = currentUp.Replace(FrameDesigner.stopMoveScript, String.Empty);

                            // If there is no code left, remove the event handler script altogether, update otherwise
                            if (String.IsNullOrEmpty(currentUp))
                            {
                                scripts.Events.Remove(EventChoice.OnMouseUp);
                            }
                            else
                            {
                                scripts.Events[EventChoice.OnMouseUp] = currentUp;
                            }
                        }

                        // Remove the <Scripts> element if no events have handlers now
                        if (scripts.Events.Count == 0)
                        {
                            frameType.Scripts.Remove(scripts);
                        }
                    }

                    // Raise ComponentChangedEvent
                    this.OnComponentChanged(EventArgs.Empty);

                    // Refresh the Designer Action UI
                    designerActionUIService.Refresh(this.Component);
                }
            }
コード例 #12
0
            private static bool MergeScripts(ScriptsType from, ScriptsType to, EventChoice eventChoice)
            {
                if (from.Events.ContainsKey(eventChoice))
                {
                    if (to == null)
                    {
                        to = from;
                        return false;
                    }
                    else
                    {
                        // Retrieve current event handler script
                        string currentScript = to.Events.ContainsKey(eventChoice) && to.Events[eventChoice] != null ? to.Events[eventChoice] : String.Empty;

                        // Append script to be merged
                        currentScript += from.Events[eventChoice] ?? String.Empty;

                        // Update event handler script
                        to.Events[eventChoice] = currentScript;

                        return true;
                    }
                }

                return false;
            }
コード例 #13
0
            private static ScriptsType GetScripts(FrameType frame, bool createOnNull)
            {
                ScriptsType result = null;

                if (frame.Scripts.Count == 0)
                {
                    if (createOnNull)
                    {
                        result = new ScriptsType();
                        frame.Scripts.Add(result);
                    }
                }
                else
                {
                    for (int index = frame.Scripts.Count - 1; index >= 0; index--)
                    {
                        ScriptsType scripts = frame.Scripts[index];

                        if (MergeScripts(scripts, result, EventChoice.OnMouseDown) ||
                            MergeScripts(scripts, result, EventChoice.OnMouseUp))
                        {
                            frame.Scripts.Remove(scripts);
                        }

                    }

                    if (result == null)
                        result = frame.Scripts[0];
                }

                return result;
            }
コード例 #14
0
        public override void SetValue(object component, object value)
        {
            IFrameControl frameControl = (component as IFrameControl);
            if (frameControl == null)
            {
                return;
            }

            FrameType frame = (FrameType)frameControl.SerializationObject;

            string valueAsString = (value as string);

            if (string.IsNullOrEmpty(valueAsString))
            {
                this.ClearEvent(frame.Scripts);
            }
            else
            {
                ScriptsType scripts = this.FindContainingScripts(frame.Scripts);

                if (scripts == null)
                {
                    if (frame.Scripts.Count > 0)
                    {
                        scripts = frame.Scripts[0];
                    }
                    else
                    {
                        scripts = new ScriptsType();
                        frame.Scripts.Add(scripts);
                    }
                }

                scripts.Events[this.eventName] = valueAsString;
            }
        }