public static void restoreSyncedBoards(Firebase boardsRef)
		{
			SharedPreferences preferences = mContext.getSharedPreferences(PREFS_NAME, 0);
			ISet<string> syncedBoards = preferences.getStringSet(PREF_NAME, new HashSet<string>());
			foreach (string key in syncedBoards)
			{
				Log.i(TAG, "Keeping board " + key + " synced");
				boardsRef.child(key).keepSynced(true);
			}
		}
			public override void onComplete(FirebaseError firebaseError, Firebase @ref)
			{
				if (firebaseError != null)
				{
					Log.e(TAG, firebaseError.ToString());
					throw firebaseError.toException();
				}
				else
				{
					// once the board is created, start a DrawingActivity on it
					openBoard(newBoardRef.Key);
				}
			}
		/// <summary>
		/// Called when the activity is first created.
		/// </summary>
		public override void onCreate(Bundle savedInstanceState)
		{
			base.onCreate(savedInstanceState);
			Intent intent = Intent;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String url = intent.getStringExtra("FIREBASE_URL");
			string url = intent.getStringExtra("FIREBASE_URL");
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String boardId = intent.getStringExtra("BOARD_ID");
			string boardId = intent.getStringExtra("BOARD_ID");
			Log.i(TAG, "Adding DrawingView on " + url + " for boardId " + boardId);
			mFirebaseRef = new Firebase(url);
			mBoardId = boardId;
			mMetadataRef = mFirebaseRef.child("boardmetas").child(boardId);
			mSegmentsRef = mFirebaseRef.child("boardsegments").child(mBoardId);
			mMetadataRef.addValueEventListener(new ValueEventListenerAnonymousInnerClassHelper(this, boardId));
		}
		public static void toggle(Firebase boardsRef, string boardId)
		{
			SharedPreferences preferences = mContext.getSharedPreferences(PREFS_NAME, 0);
			ISet<string> syncedBoards = new HashSet<string>(preferences.getStringSet(PREF_NAME, new HashSet<string>()));
			if (syncedBoards.Contains(boardId))
			{
				syncedBoards.Remove(boardId);
				boardsRef.child(boardId).keepSynced(false);
			}
			else
			{
				syncedBoards.Add(boardId);
				boardsRef.child(boardId).keepSynced(true);
			}
			preferences.edit().putStringSet(PREF_NAME, syncedBoards).commit();
			Log.i(TAG, "Board " + boardId + " is now " + (syncedBoards.Contains(boardId) ? "" : "not ") + "synced");
		}
		public DrawingView(Context context, Firebase @ref, float scale) : base(context)
		{

			mOutstandingSegments = new HashSet<string>();
			mPath = new Path();
			this.mFirebaseRef = @ref;
			this.mScale = scale;

			mListener = @ref.addChildEventListener(new ChildEventListenerAnonymousInnerClassHelper(this));


			mPaint = new Paint();
			mPaint.AntiAlias = true;
			mPaint.Dither = true;
			mPaint.Color = 0xFFFF0000;
			mPaint.Style = Paint.Style.STROKE;

			mBitmapPaint = new Paint(Paint.DITHER_FLAG);
		}
		protected internal override void onCreate(Bundle savedInstanceState)
		{
			base.onCreate(savedInstanceState);
			ContentView = R.layout.activity_main;

			// Make sure we have a mUsername
			setupUsername();

			Title = "Chatting as " + mUsername;

			// Setup our Firebase mFirebaseRef
			mFirebaseRef = (new Firebase(FIREBASE_URL)).child("chat");

			// Setup our input methods. Enter key on the keyboard or pushing the send button
			EditText inputText = (EditText) findViewById(R.id.messageInput);
			inputText.OnEditorActionListener = new OnEditorActionListenerAnonymousInnerClassHelper(this);

			findViewById(R.id.sendButton).OnClickListener = new OnClickListenerAnonymousInnerClassHelper(this);

		}
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			// Perform any additional setup after loading the view, typically from a nib.

			var firebase = new Firebase("https://boiling-torch-6531.firebaseio.com");
			//var nsObject = new NSString ("Wow");

			var values = NSDictionary.FromObjectsAndKeys (new NSObject[] {
				new NSString ("KeyValue")
			},
				             new NSObject[] {
					new NSString ("KeyName")
				});

			var rootNode = NSDictionary.FromObjectAndKey (values, new NSString("root"));

			firebase.SetValue(rootNode);

			this.TextKeyName.Text = "KeyName";
			this.TextKeyValue.Text = "KeyValue";


//			firebase.ObserveEventType(FEventType.ChildChanged, snapshot =>
//				{
//					var key = snapshot.Key;
//					var value = snapshot.Value;
//					this.TextKeyName.Text = snapshot.Key;
//					this.TextKeyValue.Text = snapshot.Value.ToString();
//				});

			firebase.ChildByAppendingPath("root/KeyName").ObserveEventType(FEventType.Value, snapshot =>
				{
					var key = snapshot.Key;
					var value = snapshot.Value;
					this.TextKeyName.Text = snapshot.Key;
					this.TextKeyValue.Text = snapshot.Value.ToString();
				});

		}
示例#8
0
 void FailHandler(Firebase sender, FirebaseError err)
 {
     DevLogger.Error("Firebase.FailHandler " + err.Message);
 }
示例#9
0
 void PushOKHandler(Firebase sender, DataSnapshot snapshot)
 {
     DevLogger.Log("Firebase.PushOKHandler");
 }
示例#10
0
 public void setFirebaseNull()
 {
     firebase = null;
 }
				public override void onComplete(FirebaseError firebaseError, Firebase firebase)
				{
					if (firebaseError != null)
					{
						Log.e(TAG, "Error updating thumbnail", firebaseError.toException());
					}
				}
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public static void updateThumbnail(int boardWidth, int boardHeight, com.firebase.client.Firebase segmentsRef, final com.firebase.client.Firebase metadataRef)
		public static void updateThumbnail(int boardWidth, int boardHeight, Firebase segmentsRef, Firebase metadataRef)
		{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final float scale = Math.min(1.0f * THUMBNAIL_SIZE / boardWidth, 1.0f * THUMBNAIL_SIZE / boardHeight);
			float scale = Math.Min(1.0f * THUMBNAIL_SIZE / boardWidth, 1.0f * THUMBNAIL_SIZE / boardHeight);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.graphics.Bitmap b = android.graphics.Bitmap.createBitmap(Math.round(boardWidth * scale), Math.round(boardHeight * scale), android.graphics.Bitmap.Config.ARGB_8888);
			Bitmap b = Bitmap.createBitmap(Math.Round(boardWidth * scale), Math.Round(boardHeight * scale), Bitmap.Config.ARGB_8888);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.graphics.Canvas buffer = new android.graphics.Canvas(b);
			Canvas buffer = new Canvas(b);

			buffer.drawRect(0, 0, b.Width, b.Height, DrawingView.paintFromColor(Color.WHITE, Paint.Style.FILL_AND_STROKE));
			Log.i(TAG, "Generating thumbnail of " + b.Width + "x" + b.Height);

			segmentsRef.addListenerForSingleValueEvent(new ValueEventListenerAnonymousInnerClassHelper3(metadataRef, scale, b, buffer));
		}
		protected internal override void onCreate(Bundle savedInstanceState)
		{
			base.onCreate(savedInstanceState);

			ContentView = R.layout.activity_office_mover;

			// Initialize Firebase
			mFirebaseRef = new Firebase(FIREBASE);

			// Process authentication
			Bundle extras = Intent.Extras;
			string authToken;
			if (extras != null)
			{
				authToken = extras.getString(LoginActivity.AUTH_TOKEN_EXTRA);
			}
			else
			{
				Log.w(TAG, "Users must be authenticated to do this activity. Redirecting to login activity.");
				Intent loginIntent = new Intent(ApplicationContext, typeof(LoginActivity));
				loginIntent.Flags = Intent.FLAG_ACTIVITY_CLEAR_TOP;
				startActivity(loginIntent);
				finish();
				return;
			}

			mFirebaseRef.authWithOAuthToken("google", authToken, new AuthResultHandlerAnonymousInnerClassHelper(this));

			// Initialize the view stuff
			mOfficeLayout = new OfficeLayout();
			mOfficeCanvasView = (OfficeCanvasView) findViewById(R.id.office_canvas);
			mOfficeCanvasView.OfficeLayout = mOfficeLayout;
			mOfficeFloorView = (FrameLayout) findViewById(R.id.office_floor);

			// Listen for floor changes
			mFirebaseRef.child("background").addValueEventListener(new ValueEventListenerAnonymousInnerClassHelper(this));

			// Listen for furniture changes
			mFirebaseRef.child("furniture").addChildEventListener(new ChildEventListenerAnonymousInnerClassHelper(this));

			// Handles menu changes that happen when an office thing is selected or de-selected
			mOfficeCanvasView.ThingFocusChangeListener = new SelectedThingChangeListenerAnonymousInnerClassHelper(this);

			// Triggers whenever an office thing changes on the screen. This binds the
			// user interface to the scheduler that throttles updates to Firebase
			mOfficeCanvasView.ThingChangedListener = new ThingChangeListenerAnonymousInnerClassHelper(this);

			// A scheduled executor that throttles updates to Firebase to about 40ms each.
			// This prevents the high frequency change events from swamping Firebase.
			ScheduledExecutorService firebaseUpdateScheduler = Executors.newScheduledThreadPool(1);
			firebaseUpdateScheduler.scheduleAtFixedRate(() =>
			{
				if (mStuffToUpdate != null && mStuffToUpdate.Count > 0)
				{
					foreach (OfficeThing officeThing in mStuffToUpdate.Values)
					{
						updateOfficeThing(officeThing.Key, officeThing);
						mStuffToUpdate.Remove(officeThing.Key);
					}
				}
			}, UPDATE_THROTTLE_DELAY, UPDATE_THROTTLE_DELAY, TimeUnit.MILLISECONDS);
		}
示例#14
0
 void PushOKHandler(Firebase sender, DataSnapshot snapshot)
 {
     // Dans le cas où la requête a fonctionné
     Debug.Log("[OK] Push from key: " + sender.FullKey);
     DisplayRanking();
 }
示例#15
0
 public void Delete(Firebase firebasePos)
 {
     firebaseQueue.AddQueueDelete(firebasePos);
 }
示例#16
0
 public void Push(String json, Firebase firebasePos)
 {
     firebaseQueue.AddQueuePush(firebasePos, json, true);
 }
示例#17
0
 public void Request(Firebase firebasePos)
 {
     firebasePos.OnGetSuccess += OnGet;
     firebaseQueue.AddQueueGet(firebasePos);
 }
示例#18
0
 private void GetRulesFailHandler(Firebase sender, FirebaseError err)
 {
 }
示例#19
0
 private void GetRulesOKHandler(Firebase sender, DataSnapshot snapshot)
 {
 }
示例#20
0
 private void OnVarmistaKayttaja(Firebase fb, DataSnapshot snapshot)
 {
 }
示例#21
0
 protected EventContract(Firebase reference, EventType supportedEventType)
 {
     Reference = reference;
     SupportedEventType = supportedEventType;
 }
示例#22
0
		public DrawingView(Context context, Firebase @ref) : this(context, @ref, 1.0f)
		{
		}
示例#23
0
 void Start()
 {
     firebase = Firebase.CreateNew("https://whg-ai.firebaseio.com/");
 }
示例#24
0
 public Result(Firebase reference)
 {
     Reference = reference;
 }
示例#25
0
 void UpdateFailedHandler(Firebase sender, FirebaseError err)
 {
     Debug.Log(err);
 }
示例#26
0
 private void OnVarmistaKayttajaFail(Firebase arg1, FirebaseError arg2)
 {
 }
示例#27
0
 void GetRulesOKHandler(Firebase sender, DataSnapshot snapshot)
 {
     DoDebug("[OK] GetRules");
     DoDebug("[OK] Raw Json: " + snapshot.RawJson);
 }
			public ValueEventListenerAnonymousInnerClassHelper3(Firebase metadataRef, float scale, Bitmap b, Canvas buffer)
			{
				this.metadataRef = metadataRef;
				this.scale = scale;
				this.b = b;
				this.buffer = buffer;
			}
示例#29
0
 void GetRulesFailHandler(Firebase sender, FirebaseError err)
 {
     DoDebug("[ERR] GetRules,  " + err.Message + " (" + (int)err.Status + ")");
 }
示例#30
0
 void PushFailHandler(Firebase sender, FirebaseError err)
 {
     // S'il y a eut un problème de connexion ou de validation
     Debug.Log("[ERR] Push from key: " + sender.FullKey + ", " + err.Message
               + " (" + (int)err.Status + ")");
 }
示例#31
0
 void UpdateOKHandler(Firebase sender, DataSnapshot snapshot)
 {
     DoDebug("[OK] Update from key: <" + sender.FullKey + ">");
 }
示例#32
0
		public void initialize(string url) {
			firebase = Firebase.CreateNew(base_url);
			this.base_url = url;
		}
示例#33
0
 void DelFailHandler(Firebase sender, FirebaseError err)
 {
     DoDebug("[ERR] Del from key: <" + sender.FullKey + ">, " + err.Message + " (" + (int)err.Status + ")");
 }
示例#34
0
 void DeleteOKHandler(Firebase sender, DataSnapshot snapshot)
 {
     DevLogger.Log("Firebase.DeleteOKHandler");
 }
示例#35
0
 void PushOKHandler(Firebase sender, DataSnapshot snapshot)
 {
     DoDebug("[OK] Push from key: <" + sender.FullKey + ">");
 }
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>();
            var user        = await userManager.FindAsync(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("invalid_grant", "incorrect_user_pass");
                return;
            }

            if (!user.SmsSent)
            {
                context.SetError("invalid_grant", "please register first.");
                return;
            }

            user.IsLogin = true;
            var isLoginUpdated = await userManager.UpdateAsync(user);

            if (!isLoginUpdated.Succeeded)
            {
                context.SetError("internal_error", "An error has occurred.");
                return;
            }
            try
            {
                var data = await context.Request.ReadFormAsync();

                if (data["deviceId"] != null)
                {
                    var deviceId        = data["deviceId"].ToString();
                    var registerationId = data["registerationId"].ToString();

                    if (string.IsNullOrEmpty(user.NotificationKey))
                    {
                        var notificationKey = Firebase.CreateFirebaseGroup("U-" + user.Id, registerationId);

                        user.NotificationKey = notificationKey;
                        var notificationKeyUpdated = await userManager.UpdateAsync(user);

                        if (!notificationKeyUpdated.Succeeded)
                        {
                            context.SetError("internal_error", "An error has occurred.");
                            return;
                        }
                    }
                    else
                    {
                        Firebase.AddToFirebaseGroup("U-" + user.Id, user.NotificationKey, registerationId);
                    }


                    var oldRegisterId = SetLoginRegisterationId(user.Id, deviceId, registerationId);

                    if (!string.IsNullOrEmpty(oldRegisterId) && oldRegisterId != registerationId)
                    {
                        Firebase.RemoveFromFireBase("U-" + user.Id, user.NotificationKey, new string[] { oldRegisterId });
                    }
                }
                else
                {
                    context.SetError("internal_error", "call setDevice before login.");
                    return;
                }
            }
            catch (Exception ex)
            {
                context.SetError("firebase_error", ex.Message);
            }



            var oAuthIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                     OAuthDefaults.AuthenticationType);

            var cookiesIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                       CookieAuthenticationDefaults.AuthenticationType);

            var properties = CreateProperties(user.Id);
            var ticket     = new AuthenticationTicket(oAuthIdentity, properties);

            context.Validated(ticket);
            context.Request.Context.Authentication.SignIn(cookiesIdentity);
        }
示例#37
0
        protected internal override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);
            /* Load the view and display it */
            ContentView = R.layout.activity_main;

            /* *************************************
            *              FACEBOOK               *
            ***************************************/
            /* Load the Facebook login button and set up the tracker to monitor access token changes */
            mFacebookCallbackManager    = CallbackManager.Factory.create();
            mFacebookLoginButton        = (LoginButton)findViewById(R.id.login_with_facebook);
            mFacebookAccessTokenTracker = new AccessTokenTrackerAnonymousInnerClassHelper(this);

            /* *************************************
            *               GOOGLE                *
            ***************************************/
            /* Load the Google login button */
            mGoogleLoginButton = (SignInButton)findViewById(R.id.login_with_google);
            mGoogleLoginButton.OnClickListener = new OnClickListenerAnonymousInnerClassHelper(this);
            /* Setup the Google API object to allow Google+ logins */
            mGoogleApiClient = (new GoogleApiClient.Builder(this)).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN).build();

            /* *************************************
            *                TWITTER              *
            ***************************************/
            mTwitterLoginButton = (Button)findViewById(R.id.login_with_twitter);
            mTwitterLoginButton.OnClickListener = new OnClickListenerAnonymousInnerClassHelper2(this);

            /* *************************************
            *               PASSWORD              *
            ***************************************/
            mPasswordLoginButton = (Button)findViewById(R.id.login_with_password);
            mPasswordLoginButton.OnClickListener = new OnClickListenerAnonymousInnerClassHelper3(this);

            /* *************************************
            *              ANONYMOUSLY            *
            ***************************************/
            /* Load and setup the anonymous login button */
            mAnonymousLoginButton = (Button)findViewById(R.id.login_anonymously);
            mAnonymousLoginButton.OnClickListener = new OnClickListenerAnonymousInnerClassHelper4(this);

            /* *************************************
            *               GENERAL               *
            ***************************************/
            mLoggedInStatusTextView = (TextView)findViewById(R.id.login_status);

            /* Create the Firebase ref that is used for all authentication with Firebase */
            mFirebaseRef = new Firebase(Resources.getString([email protected]_url));

            /* Setup the progress dialog that is displayed later when authenticating with Firebase */
            mAuthProgressDialog            = new ProgressDialog(this);
            mAuthProgressDialog.Title      = "Loading";
            mAuthProgressDialog.Message    = "Authenticating with Firebase...";
            mAuthProgressDialog.Cancelable = false;
            mAuthProgressDialog.show();

            mAuthStateListener = new AuthStateListenerAnonymousInnerClassHelper(this);

            /* Check if the user is authenticated with Firebase already. If this is the case we can set the authenticated
             * user and hide hide any login buttons */
            mFirebaseRef.addAuthStateListener(mAuthStateListener);
        }
示例#38
0
			public override void onComplete(FirebaseError error, Firebase firebaseRef)
			{
				if (error != null)
				{
					Log.e("AndroidDrawing", error.ToString());
					throw error.toException();
				}
				outerInstance.mOutstandingSegments.Remove(segmentName);
			}
 // Use this for initialization
 void Start()
 {
     firebase = Firebase.CreateNew("ctrlplust-33926.firebaseio.com");
     firebase.OnGetSuccess += GetOkHandler;
 }
示例#40
0
		public DrawingView(Context context, Firebase @ref, int width, int height) : this(context, @ref)
		{
			this.BackgroundColor = Color.DKGRAY;
			mCanvasWidth = width;
			mCanvasHeight = height;
		}
示例#41
0
 public Result(Firebase reference)
 {
     Reference = reference;
 }
示例#42
0
 public TestController(IConfiguration config)
 {
     _config = config;
     _fbObj  = new Firebase(_config);
 }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public static void updateThumbnail(int boardWidth, int boardHeight, com.firebase.client.Firebase segmentsRef, final com.firebase.client.Firebase metadataRef)
        public static void updateThumbnail(int boardWidth, int boardHeight, Firebase segmentsRef, Firebase metadataRef)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final float scale = Math.min(1.0f * THUMBNAIL_SIZE / boardWidth, 1.0f * THUMBNAIL_SIZE / boardHeight);
            float scale = Math.Min(1.0f * THUMBNAIL_SIZE / boardWidth, 1.0f * THUMBNAIL_SIZE / boardHeight);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.graphics.Bitmap b = android.graphics.Bitmap.createBitmap(Math.round(boardWidth * scale), Math.round(boardHeight * scale), android.graphics.Bitmap.Config.ARGB_8888);
            Bitmap b = Bitmap.createBitmap(Math.Round(boardWidth * scale), Math.Round(boardHeight * scale), Bitmap.Config.ARGB_8888);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.graphics.Canvas buffer = new android.graphics.Canvas(b);
            Canvas buffer = new Canvas(b);

            buffer.drawRect(0, 0, b.Width, b.Height, DrawingView.paintFromColor(Color.WHITE, Paint.Style.FILL_AND_STROKE));
            Log.i(TAG, "Generating thumbnail of " + b.Width + "x" + b.Height);

            segmentsRef.addListenerForSingleValueEvent(new ValueEventListenerAnonymousInnerClassHelper3(metadataRef, scale, b, buffer));
        }
			public override void onComplete(FirebaseError firebaseError, Firebase firebase)
			{
				if (firebaseError != null)
				{
					Log.w(TAG, "Update failed! " + firebaseError.Message);
				}
			}
			public override void onComplete(FirebaseError firebaseError, Firebase firebase)
			{
				if (firebaseError != null)
				{
					throw firebaseError.toException();
				}
				outerInstance.mDrawingView = new DrawingView(outerInstance, outerInstance.mFirebaseRef.child("boardsegments").child(outerInstance.mBoardId), outerInstance.mBoardWidth, outerInstance.mBoardHeight);
				ContentView = outerInstance.mDrawingView;
				//mDrawingView.clear();
			}
 void GetOkHandler(Firebase firebasse, DataSnapshot snapshot)
 {
 }
示例#47
0
 void GetFailHandler(Firebase sender, FirebaseError err)
 {
     Debug.LogError("[ERR] get from key <" + sender.FullKey + ">, " + err.Message + " (" + (int)err.Status + ")");
 }
 public ValueChangedEventContract(Firebase reference, Firebase.ValueChangedEvent @event)
     : base(reference, EventType.ValueChanged)
 {
     this.@event = @event;
 }
    void GetDataHandler(Firebase sender, DataSnapshot snapshot)
    {
        Dictionary <string, object> dict = snapshot.Value <Dictionary <string, object> >();
        List <string> keys = snapshot.Keys;

        dict = (Dictionary <string, object>)dict["rooms"];
        dict = (Dictionary <string, object>)dict[roomID];

        // Get Room Name
        string roomName = dict["name"].ToString();

        startState.SetRoomTitle(roomName);

        // Get Count Keys
        foreach (string key in dict.Keys)
        {
            if (key == "finishCount")
            {
                count = int.Parse(dict[key].ToString());
            }
        }
        // Get Puzzle ID
        try
        {
            dict = (Dictionary <string, object>)dict["puzzles"];
        }
        catch
        {
            // If no puzzle is in room, use blank state
            puzzleStates.Add(blankState);
        }

        foreach (string key in dict.Keys)
        {
            State newState = new State();
            newState.SetID(key);
            newState.SetRoomTitle(startState.GetRoomTitle());
            puzzleStates.Add(newState);
        }

        Dictionary <string, object> saveDict = snapshot.Value <Dictionary <string, object> >();

        saveDict = (Dictionary <string, object>)saveDict["puzzles"];
        Dictionary <string, object> puzzleDict;
        List <string> answers     = new List <string>();
        List <string> hints       = new List <string>();
        List <string> transitions = new List <string>();
        List <State>  stateList   = new List <State>();

        for (int i = 0; i < puzzleStates.Count; i++)
        {
            puzzleDict = (Dictionary <string, object>)saveDict[puzzleStates[i].GetID()];

            // Get Questions
            puzzleStates[i].SetStoryText(puzzleDict["question"].ToString());

            // Get Answers
            dict = (Dictionary <string, object>)puzzleDict["answers"];
            puzzleStates[i].SetCorrectAnswer(dict["correct"].ToString());
            answers.Add(dict["correct"].ToString());
            if (dict.ContainsKey("wrong1"))
            {
                answers.Add(dict["wrong1"].ToString());
            }
            if (dict.ContainsKey("wrong2"))
            {
                answers.Add(dict["wrong2"].ToString());
            }
            if (dict.ContainsKey("wrong3"))
            {
                answers.Add(dict["wrong3"].ToString());
            }
            puzzleStates[i].SetAnswers(answers.ToArray());
            answers.Clear();

            // Get Hints
            foreach (string key in puzzleDict.Keys)
            {
                if (key == "hints")
                {
                    dict = (Dictionary <string, object>)puzzleDict["hints"];
                }
            }

            hints.Add("");
            if (dict.ContainsKey("hint1"))
            {
                hints.Add(dict["hint1"].ToString());
            }
            if (dict.ContainsKey("hint2"))
            {
                hints.Add(dict["hint2"].ToString());
            }
            if (dict.ContainsKey("hint3"))
            {
                hints.Add(dict["hint3"].ToString());
            }
            puzzleStates[i].SetHints(hints.ToArray());
            hints.Clear();

            //Get Transitions
            foreach (string key in puzzleDict.Keys)
            {
                if (key == "transitions")
                {
                    dict = (Dictionary <string, object>)puzzleDict["transitions"];
                }
            }

            //Correct Transition
            if (dict.ContainsKey("right"))
            {
                transitions.Add(dict["right"].ToString());
            }
            else
            {
                transitions.Add("null");
            }

            //Wrong Transition
            if (dict.ContainsKey("left"))
            {
                transitions.Add(dict["left"].ToString());
            }
            else
            {
                transitions.Add("null");
            }

            puzzleStates[i].SetNextStateID(transitions.ToArray());

            for (int k = 0; k < 2; k++)
            {
                for (int j = 0; j < puzzleStates.Count; j++)
                {
                    if (puzzleStates[i].GetNextStateID()[k] == puzzleStates[j].GetID())
                    {
                        stateList.Add(puzzleStates[j]);
                        break;
                    }
                    else if (puzzleStates[i].GetNextStateID()[k] == "null")
                    {
                        stateList.Add(puzzleStates[i]);
                        break;
                    }
                }
            }
            puzzleStates[i].SetNextState(stateList.ToArray());
            transitions.Clear();
            stateList.Clear();
        }
    }