public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the MoveNext method in Dictionary ValueCollection Enumerator");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("1", "test1");
         Dictionary<string, string>.ValueCollection.Enumerator ValEnumer1 = new Dictionary<string, string>.ValueCollection(dic).GetEnumerator();
         if (ValEnumer1.Current != null || ValEnumer1.MoveNext() != true)
         {
             TestLibrary.TestFramework.LogError("001.1", "The ExpectResult is not the ActualResult");
             retVal = false;
         }
         if (ValEnumer1.MoveNext())
         {
             TestLibrary.TestFramework.LogError("001.2", "The method MoveNext should return false but it did not");
         }
         ValEnumer1.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
     public JSONStructIterator(JSONEntry oEntry)
     {
 	    m_object = oEntry.getObject();
         m_enumStruct = m_object.GetEnumerator();
         if (m_enumStruct.MoveNext())
             m_strCurKey = m_enumStruct.Current.Key;
     }
     public JSONStructIterator(JSONEntry oEntry, String strName)
     {
 	    m_object = (Dictionary<string, object>)oEntry.getObject(strName);
         m_enumStruct = m_object.GetEnumerator();
         if (m_enumStruct.MoveNext())
             m_strCurKey = m_enumStruct.Current.Key;
     }
 public static float[] BuildBoostList(IEnumerable<string> valArray, IDictionary<string, float> boostMap)
 {
     var valArray2 = new List<string>(valArray.Count());
     // NOTE: we must loop through the list in order to make it format
     // the values so it can match the formatted values in the boostMap.
     foreach (var item in valArray)
     {
         valArray2.Add(item);
     }
     float[] boostList = new float[valArray2.Count];
     Arrays.Fill(boostList, 1.0f);
     if (boostMap != null && boostMap.Count > 0)
     {
         Dictionary<string, float>.Enumerator iter = new Dictionary<string, float>(boostMap).GetEnumerator();
         while (iter.MoveNext())
         {
             KeyValuePair<string, float> entry = iter.Current;
             int index = valArray2.IndexOf(entry.Key);
             if (index >= 0)
             {
                 float fval = entry.Value;
                 if (fval >= 0)
                 {
                     boostList[index] = fval;
                 }
             }
         }
     }
     return boostList;
 }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Return the property Current in Dictionary KeyCollection Enumerator 2");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("1", "test1");
         Dictionary<string, string>.KeyCollection.Enumerator keyEnumer = new Dictionary<string, string>.KeyCollection(dic).GetEnumerator();
         while (keyEnumer.MoveNext())
         {
             if (keyEnumer.Current != "1")
             {
                 TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
                 retVal = false;
             }
         }
         keyEnumer.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
    public static void ShowSensorSelectionWindow(Vector2 nSize, Rect nPosition, VRPNDataObject nInFront)
    {
        size = nSize;
        pos = nPosition;
        inFront = nInFront;

        sensors = VRPNEditEditor.Instance.GetSensors(inFront.dataName, inFront.originalDataTime, inFront.dataDevice);
        disabledSensors = VRPNEditEditor.Instance.GetDisabledSensors(inFront.dataName, inFront.originalDataTime, inFront.dataDevice);
        states = new bool[sensors.Count];
        sensorsE = sensors.GetEnumerator();

        //Initial sensors state
        int numSensor = 0;
        while (sensorsE.MoveNext())
        {
            int test;
            if (disabledSensors.TryGetValue(sensorsE.Current.Key, out test))
            {
                states[numSensor] = false;
            }
            else
            {
                states[numSensor] = true;
            }
            numSensor++;
        }

        VRPNSensorSelectionWindow window = VRPNSensorSelectionWindow.CreateInstance<VRPNSensorSelectionWindow>();
        window.ShowAsDropDown(pos, size);
    }
        public JSONStructIterator(String szData)
        {
            m_object = (Dictionary<string, object>)JsonParser.JsonDecode(szData);

            m_enumStruct = m_object.GetEnumerator();
            if ( m_enumStruct.MoveNext() )
                m_strCurKey = m_enumStruct.Current.Key;
        }
Example #8
0
		public void SetAllActive(bool active)
		{
			enumerator = taskDic.GetEnumerator();
			while(enumerator.MoveNext())
			{
				GameTask task = enumerator.Current.Value;
				task.Active = active;
			}
		}
Example #9
0
		public void Update(float deltaTime)
		{
			enumerator = taskDic.GetEnumerator();
			while(enumerator.MoveNext())
			{
				GameTask task = enumerator.Current.Value;
				if (task.Active)
				{
					task.Timer += deltaTime;
					if (task.Delay <= 0f)
					{
						task.Callback();
					}
					else if (task.Timer > task.Delay)
					{
						task.Timer = 0f;
						task.Callback();
					}
				}
			}
		}
 public bool NegTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("NegTest1:The collection was modified after the enumerator was created");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("1", "test1");
         Dictionary<string, string>.ValueCollection.Enumerator ValEnumer = new Dictionary<string, string>.ValueCollection(dic).GetEnumerator();
         dic.Add("2", "test2");
         bool boolVal = ValEnumer.MoveNext();
         TestLibrary.TestFramework.LogError("N001", "The collection was modified after the enumerator was created but not throw exception");
         retVal = false;
     }
     catch (InvalidOperationException) { }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("N002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Example #11
0
        public bool GetFirst(out KeyValuePair<int, string> item)
        {
            item = new KeyValuePair<int, string>();
            if (playList.Count == 0)
                return false;

            enumerator = playList.GetEnumerator();
            if (enumerator.MoveNext())
            {
                item = enumerator.Current;
                return true;
            }
            else
            {
                return false;
            }
        }
Example #12
0
 public void reset()
 {
     m_enumStruct = m_object.GetEnumerator();
     if (m_enumStruct.MoveNext())
         m_strCurKey = m_enumStruct.Current.Key;
 }
        private static void LoadBoardList()
        {
            BoardsPaths = new Dictionary<string, string>();

            DirectoryInfo di = new DirectoryInfo("Maps");
            FileInfo[] rgFiles = di.GetFiles("*.xml");

            XmlDocument document;
            foreach (FileInfo fi in rgFiles)
            {
                document = new XmlDocument();
                document.Load(fi.FullName);

                String name = document.DocumentElement.GetAttribute("name");

                BoardsPaths.Add(name, fi.FullName);

            }

            String key = String.Empty;
            if (loaded)
            {
                key = enumerator.Current.Key;
            }

            enumerator = BoardsPaths.GetEnumerator();
            enumerator.MoveNext();

            if (loaded)
            {
                bool endReached = false;
                while ((enumerator.Current.Key != key || endReached) && !(enumerator.Current.Key != key && endReached))
                {
                    endReached = !enumerator.MoveNext();
                }

                if (enumerator.Current.Key != key && endReached)
                {
                    enumerator = BoardsPaths.GetEnumerator();
                    enumerator.MoveNext();
                }
            }

            loaded = true;
        }
 static void MoveEnumerator()
 {
     if (!enumerator.MoveNext())
     {
         enumerator = BoardsPaths.GetEnumerator();
         enumerator.MoveNext();
     }
 }
        public void PlayFrame()
        {
            if (start)
            {
                keystates[Settings.controls["MoveLeft"]] = false;
                keystates[Settings.controls["MoveRight"]] = false;
                keystates[Settings.controls["Jump"]] = false;
                keystates[Settings.controls["Slide"]] = false;
                keystates[Settings.controls["Box"]] = false;

                time = 0;
                start = false;
                enumerator = events.GetEnumerator();
                enumerator.MoveNext();
            }

            if (enumerator.Current.Key == time)
            {
                foreach (string s in enumerator.Current.Value)
                {
                    string[] split = s.Split(' ');
                    Keys key = Settings.controls[split[1]];
                    keystates[key] = split[0] == "press";
                }

                enumerator.MoveNext();
            }

            if (time % 60 == 0)
            {
                if (recallibrater.Count > time / 60)
                {
                    Game1.currentRoom.Runner.position = recallibrater[time / 60].Item1;
                    Game1.currentRoom.Runner.velocity = recallibrater[time / 60].Item2;
                }
            }

            time++;
        }
Example #16
0
        public void ReadAndExecuteCommand(String InputString)
        {

            // Read and execute commend

            #region Check if valid command
            //has to be done via split, because irony doesn't recognize whitespaces,
            //so "dfgfkgdfgkfd" could be detected as the command "df" with an 
            //strange parameter

            if (!IsQuit && ValidCommandFromInputString(InputString))
            {

            #endregion

                #region Prepare Command Execution

                _Scanner = GraphCLICompiler.Scanner;

                _CompilerContext = new CompilerContext(GraphCLICompiler);

                _SourceFile = new SourceFile(InputString, "Source");

                _Scanner.Prepare(_CompilerContext, _SourceFile);

                _CompilerContext.Tokens.Clear();

                _TokenStream = _Scanner.BeginNonDetermisticScan();

                AstNode ExecutionTree = null;

                ExecutionTree = GraphCLICompiler.Parser.ParseNonDeterministic(_CompilerContext, _TokenStream);

                #region Checkt if valid command is complete

                if (ExecutionTree == null)
                {
                    MarkWrongOption(InputString, GraphCLICompiler.Parser.GetCorrectElements(_CompilerContext, _TokenStream));
                }
                else
                {
                    //Carry on, the command is valid and complete
                #endregion

                    ExtractOptionsFromTree(ExecutionTree);

                #endregion

                    if (Commands[CurrentCommand].CLI_Output == CLI_Output.Standard)
                        WriteLine();

                    #region Handle Command Execution

                    //try
                    //{

                        Stopwatch sw = new Stopwatch();
                        sw.Start();

                        // TODO: what's this doing here? 
                        //if (Parameters.Count > 0)
                        //{
                        #region Execute command...

                        if (_GraphDSSharp != null || CurrentCommand.Equals("MKFS") || CurrentCommand.Equals("MOUNT") || CurrentCommand.Equals("QUIT") || CurrentCommand.Equals("EXIT") || CurrentCommand.Equals("USEHISTORY") || CurrentCommand.Equals("SAVEHISTORY"))
                        {


                            Commands[CurrentCommand].Execute(_GraphDSSharp, ref CurrentPath, Parameters, InputString);

                            //if (CommandCategory.Equals(CLICommandCategory.CLIStandardCommand))
                            //{

                                #region Handle Quit and History

                                switch (CurrentCommand.ToUpper())
                                {

                                    case "QUIT":
                                        IsQuit = true;
                                        break;

                                    case "EXIT":
                                        IsQuit = true;
                                        break;

                                    case "USEHISTORY":
                                        //lets move to the right parameter
                                        ParameterEnum = Parameters.GetEnumerator();
                                        ParameterEnum.MoveNext();
                                        ParameterEnum.MoveNext();

                                        switch (ParameterEnum.Current.Key)
                                        {
                                            case "default":
                                                LoadStandardHistory = true;

                                                if (!HistoryFileName.Length.Equals(0))
                                                    SaveHistory(HistoryFileName, SthMountedList);

                                                break;

                                            default:
                                                LoadStandardHistory = false;

                                                HistoryFileName = ParameterEnum.Current.Key;

                                                LoadHistoryFrom(HistoryFileName);

                                                break;

                                        }

                                        break;

                                    case "SAVEHISTORY":
                                        //lets move to the right parameter
                                        ParameterEnum = Parameters.GetEnumerator();
                                        ParameterEnum.MoveNext();
                                        ParameterEnum.MoveNext();

                                        if (LoadStandardHistory)
                                            SaveHistory(ParameterEnum.Current.Key, NothingMountedList);
                                        else
                                            SaveHistory(ParameterEnum.Current.Key, SthMountedList);

                                        break;

                                }

                                #endregion

                            //}

                        }

                        else
                            WriteLine("Nothing mounted...");

                        #endregion
                        //}//CommandArray.Length > 0 ?

                        sw.Stop();

                        if (Parameters.Count > 0 && Commands[CurrentCommand].CLI_Output != CLI_Output.Short)
                        {
                            WriteLine("Command took {0}ms, {1:0.0} MB RAM, {2:0.0}% CPU", sw.ElapsedMilliseconds, _RAMCounter.NextValue() / 1024 / 1024, _CPUCounter.NextValue());
                        }
                    //}
                    //catch (Exception e)
                    //{
                    //    WriteLine("Uuups... " + e.Message);
                    //    WriteLine("StackTrace... " + e.StackTrace);
                    //}

                    Reset();

                    #endregion

                }

            }

                

        }
 public void OnGUI()
 {
     scrollPosition = GUI.BeginScrollView(new Rect(0, 0, this.position.width, this.position.height), scrollPosition, new Rect(0, 0, this.position.width - scrollSize, labelsHeigth * (states.Length + 2)));
     //Sensors Label
     GUIStyle styleLabel = new GUIStyle(GUI.skin.label);
     styleLabel.alignment = TextAnchor.MiddleCenter;
     styleLabel.fontStyle = FontStyle.Bold;
     GUI.Label(new Rect(0, 0, this.position.width - scrollSize, labelsHeigth), "Sensors", styleLabel);
     //Sensors list
     sensorsE = sensors.GetEnumerator();
     int numSensor = 0;
     while (sensorsE.MoveNext())
     {
         states[numSensor] = EditorGUI.ToggleLeft(new Rect(0, labelsHeigth * (numSensor + 1), this.position.width - scrollSize, labelsHeigth), "Sensor " + sensorsE.Current.Key + ":", states[numSensor]);
         numSensor++;
     }
     sensorsE = sensors.GetEnumerator();
     //Apply button
     if (GUI.Button(new Rect(0, labelsHeigth * (states.Length + 1), this.position.width - scrollSize, labelsHeigth), "Apply"))
     {
         numSensor = 0;
         while (sensorsE.MoveNext())
         {
             if (states[numSensor])
             {
                 VRPNEditEditor.Instance.EnableTrackerSensor(inFront.dataName, inFront.originalDataTime, inFront.dataDevice, sensorsE.Current.Key);
             }
             else
             {
                 VRPNEditEditor.Instance.DisableTrackerSensor(inFront.dataName, inFront.originalDataTime, inFront.dataDevice, sensorsE.Current.Key);
             }
             numSensor++;
         }
         this.Close();
     }
     GUI.EndScrollView();
 }
        public void setPhase(int phaseNum)
        {
            _inController = true;

            TimeSpan totalTime = TimeSpan.Zero;

            _phase = phaseNum;

            if (phases.ContainsKey(_phase))
            {

                phases[_phase].phaseStarted = DateTime.Now + phases[_phase].phaseStartDelay;

                if (phases[_phase].rotationAbilities.Any())
                {
                    nextRotationEnumerator = phases[_phase].rotationAbilitiesWarningTime.GetEnumerator();
                    nextRotationEnumerator.MoveNext();

                    nextRotationTime = phases[_phase].phaseStarted + nextRotationEnumerator.Current.Key;
                    nextRotationAbility = nextRotationEnumerator.Current.Value;


                    totalTime = phases[_phase].rotationAbilities.Last().Key;
                }

                phases[_phase].phaseLength = totalTime;

                if (phases[_phase].onPhaseStart != null)
                {
                    phases[_phase].onPhaseStart.start();
                }

            }

            _inController = false;
        }
Example #19
0
 // Constructor
 public ShaderSelector(Dictionary<string, Shader> owner)
 {
     myOwner = owner;
     myIterator = owner.GetEnumerator();
     myIterator.MoveNext();
 }
        private void processRotationAbility()
        {
            Regex rgx;

            if (phases.ContainsKey(_phase))
            {
                if (phases[_phase].rotationAbilities.Any())
                {
                    string debugOut = nextRotationAbility.warningMessage + " warning time. ";
                    if (nextRotationAbility.announceWarning)
                    {
                        string message = parseMessage(nextRotationAbility, nextRotationAbility.warningMessage);

                        tts(message);
                    }

                    RotationAbility tmpAbil = nextRotationAbility;



                    if (!nextRotationEnumerator.MoveNext())
                    {
                        nextRotationEnumerator = phases[_phase].rotationAbilitiesWarningTime.GetEnumerator();
                        nextRotationEnumerator.MoveNext();

                        phases[_phase].phaseStarted = phases[_phase].phaseStarted + phases[_phase].phaseLength;
                    }

                    nextRotationTime = phases[_phase].phaseStarted + nextRotationEnumerator.Current.Key;
                    nextRotationAbility = nextRotationEnumerator.Current.Value;

                    debugOut += "nextRotationTime: " + nextRotationTime + " nextRotationAbility: " + nextRotationAbility.warningMessage;

                    EncounterController.debug(debugOut, DBMErrorLevel.FineTimings);

                    // Need to call this after moving to the next rotation
                    // otherwise the callback may swap phases, and we'd then skip the first rotation in the next phase
                    if (tmpAbil.warningCallback != null)
                    {
                        _inController = false;
                        tmpAbil.warningCallback(tmpAbil);
                        _inController = true;
                    }

                }
            }
        }
Example #21
0
 /// <summary>
 /// Function called when a key is pressed
 /// </summary>
 static void OnKeyPressed(object sender, KeyEventArgs e)
 {
     RenderWindow window = (RenderWindow)sender;
     if (e.Code == KeyCode.Escape)
     {
         // Close the window
         window.Close();
     }
     else if (e.Code == KeyCode.Add)
     {
         // Advance to the next effect
         if (CurrentEffect.MoveNext() == false)
         {
             CurrentEffect = Effects.GetEnumerator();
             CurrentEffect.MoveNext();
         }
         CurFXStr.Text = "Current effect is \"" + CurrentEffect.Current.Key + "\"";
     }
 }
Example #22
0
 // Select the next shader
 public void GotoNext()
 {
     if (myIterator.MoveNext() == false)
     {
         myIterator = myOwner.GetEnumerator();
         myIterator.MoveNext();
     }
 }
Example #23
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Create the main window
            RenderWindow App = new RenderWindow(new VideoMode(800, 600), "SFML.Net PostFX");

            // Setup event handlers
            App.Closed     += new EventHandler(OnClosed);
            App.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);

            // Check that the system can use post effects
            if (PostFx.CanUsePostFX == false)
            {
                DisplayError(App);
                return;
            }

            // Load a cute background image to display :)
            Sprite Background = new Sprite(new Image("datas/post-fx/background.jpg"));

            // Load the text font
            Font Cheeseburger = new Font("datas/post-fx/cheeseburger.ttf");

            // Load the image needed for the wave effect
            Image WaveImage = new Image("datas/post-fx/wave.jpg");

            // Load all effects
            Effects = new Dictionary<string, PostFx>();
            Effects["nothing"]  = new PostFx("datas/post-fx/nothing.sfx");
            Effects["blur"]     = new PostFx("datas/post-fx/blur.sfx");
            Effects["colorize"] = new PostFx("datas/post-fx/colorize.sfx");
            Effects["fisheye"]  = new PostFx("datas/post-fx/fisheye.sfx");
            Effects["wave"]     = new PostFx("datas/post-fx/wave.sfx");
            CurrentEffect = Effects.GetEnumerator();
            CurrentEffect.MoveNext();

            // Do specific initializations
            Effects["nothing"].SetTexture("framebuffer", null);
            Effects["blur"].SetTexture("framebuffer", null);
            Effects["blur"].SetParameter("offset", 0.0F);
            Effects["colorize"].SetTexture("framebuffer", null);
            Effects["colorize"].SetParameter("color", 1.0F, 1.0F, 1.0F);
            Effects["fisheye"].SetTexture("framebuffer", null);
            Effects["wave"].SetTexture("framebuffer", null);
            Effects["wave"].SetTexture("wave", WaveImage);

            // Define a string for displaying current effect description
            CurFXStr = new String2D();
            CurFXStr.Text = "Current effect is \"" + CurrentEffect.Current.Key + "\"";
            CurFXStr.Font = Cheeseburger;
            CurFXStr.Position = new Vector2(20.0F, 0.0F);

            // Define a string for displaying help
            String2D InfoStr = new String2D();
            InfoStr.Text = "Move your mouse to change the effect parameters\nPress numpad + to change effect\nWarning : some effects may not work\ndepending on your graphics card";
            InfoStr.Font = Cheeseburger;
            InfoStr.Position = new Vector2(20.0F, 460.0F);
            InfoStr.Color = new Color(200, 100, 150);

            // Start the game loop
            while (App.IsOpened())
            {
                // Process events
                App.DispatchEvents();

                // Get the mouse position in the range [0, 1]
                float X = App.Input.GetMouseX() / (float)App.Width;
                float Y = App.Input.GetMouseY() / (float)App.Height;

                // Update the current effect
                if      (CurrentEffect.Current.Key == "blur")     CurrentEffect.Current.Value.SetParameter("offset", X * Y * 0.1f);
                else if (CurrentEffect.Current.Key == "colorize") CurrentEffect.Current.Value.SetParameter("color", 0.3f, X, Y);
                else if (CurrentEffect.Current.Key == "fisheye")  CurrentEffect.Current.Value.SetParameter("mouse", X, 1.0F - Y);
                else if (CurrentEffect.Current.Key == "wave")     CurrentEffect.Current.Value.SetParameter("offset", X, Y);

                // Clear the window
                App.Clear();

                // Draw background and apply the post-fx
                App.Draw(Background);
                App.Draw(CurrentEffect.Current.Value);

                // Draw interface strings
                App.Draw(CurFXStr);
                App.Draw(InfoStr);

                // Finally, display the rendered frame on screen
                App.Display();
            }
        }
Example #24
0
        private static void AddCustomAttributes(XmlNode parentNode, Dictionary<string, IPolicyLanguageItem>.Enumerator attributesEnumerator)
        {
            while (attributesEnumerator.MoveNext())
            {
                KeyValuePair<string, IPolicyLanguageItem> attribute = attributesEnumerator.Current;

                if (attribute.Value is NonTranslateableLanguageItem)
                {
                    AddAttribute(parentNode, attribute.Key, attribute.Value.Value);
                }
                else
                {
                    AddAttribute(parentNode, attribute.Key, attribute.Value.Identifier);
                }
            }
        }
        private void WriteMatrixCells(XmlNode xmlRoutingNode, Dictionary<KeyValuePair<Guid, Guid>, IRoutingMatrixCell>.Enumerator cellEnumer)
        {
            XmlNode xmlMatrixCellsNode = m_xmlDocument.CreateElement("RoutingMatrixCells");
            xmlRoutingNode.AppendChild(xmlMatrixCellsNode);

            while (cellEnumer.MoveNext())
            {
                WriteMatrixCell(xmlMatrixCellsNode, cellEnumer.Current);
            }
        }