Ejemplo n.º 1
0
        ///<summary>
        /// Given an XmlElement node that contains the transition, this populate the modelTranstion
        /// that is passed as parameter
        ///</summary>
        void convertToModelTransition(ModelTransition modelTransition, XmlElement action)
        {
            string name = action.GetAttribute("Name");


            if (name == "KeyDown")
            {
                modelTransition.ActionName = "KeyDown";

                getKeyState(modelTransition, action);
            }
            else if (name == "KeyUp")
            {
                getKeyState(modelTransition, action);
                modelTransition.ActionName = "KeyUp";
            }
            else if (name == "GotKeyboardFocus")
            {
                modelTransition.ActionName = "GotKeyboardFocus";
                modelTransition.EndState.Add("NewFocus", action.GetAttribute("NewFocus"));
                modelTransition.EndState.Add("OldFocus", action.GetAttribute("OldFocus"));
            }
            else if (name == "LostKeyboardFocus")
            {
                modelTransition.ActionName = "LostKeyboardFocus";
                modelTransition.EndState.Add("NewFocus", action.GetAttribute("NewFocus"));
                modelTransition.EndState.Add("OldFocus", action.GetAttribute("OldFocus"));
            }
            else if (name == "MouseDown")
            {
                modelTransition.ActionName = "MouseDown";
                modelTransition.InParams.Add("Source", action.GetAttribute("Source"));
            }
        }
Ejemplo n.º 2
0
        ///<summary>
        /// This is been used to convert XmlElement to a modeltestcase. This method also populate the
        /// ModelTransitions
        ///</summary>
        ModelTestCase convertXmlElementToModelTestCase(Model model, XmlElement xmlElement)
        {
            ModelTestCase modelTestCase = new ModelTestCase();

            //This will call BeginCase, this is a pattern for State-based Modeling
            ModelTransition modelTransition = new ModelTransition(model);

            modelTransition.ActionName = "";
            modelTestCase.AddTransition(modelTransition);

            modelTransition            = new ModelTransition(model);
            modelTransition.ActionName = "LoadEnvironment";
            modelTransition.InParams.Add("Filename", "KeyboardTestEnvironment.xml");
            modelTestCase.AddTransition(modelTransition);

            for (int i = 0; i < xmlElement.ChildNodes.Count; i++)
            {
                modelTransition = new ModelTransition(model);
                modelTestCase.AddTransition(modelTransition);
                convertToModelTransition(modelTransition, (XmlElement)xmlElement.ChildNodes[i]);
            }

            modelTestCase.AddTransition(new ModelEndTransition(model, new State()));

            return(modelTestCase);
        }
Ejemplo n.º 3
0
 ///<summary>
 /// This is called on KeyDown or KeyUp to get the state of the KeyDown and populate
 /// the modeltransition InParams that will be used on the Model.
 ///</summary>
 void getKeyState(ModelTransition modelTransition, XmlElement action)
 {
     modelTransition.InParams.Add("Key", action.GetAttribute("Key"));
     modelTransition.InParams.Add("ShiftDown", action.GetAttribute("ShiftDown"));
     modelTransition.InParams.Add("ControlDown", action.GetAttribute("ControlDown"));
     modelTransition.InParams.Add("AltDown", action.GetAttribute("AltDown"));
     modelTransition.InParams.Add("TextInputKey", action.GetAttribute("TextInputKey"));
     modelTransition.InParams.Add("ImeProcessedKey", action.GetAttribute("ImeProcessedKey"));
 }