/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters. //Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are being GPU accelerated with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; } // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Here we initialize our Login UI and hook it up to the frame. // var loginView = new FacebookLoginView(); loginView.Complete += (s, e) => { // when the loginView tells us that that a login is completed, // then tell the LoginModel that it needs to go process it. // // this forms the bridge between the oauth process and what AgFx // understands. // if (!FacebookLoginModel.Current.IsLoggedIn) { FacebookLoginModel.Login(e.AccessToken, e.Expiration); } }; // Here we set up the frame binding. // // the below says: // "When the FacebookLoginModel.Current.IsLoggedIn property is FALSE, // set the PhoneApplicationFrameEx.IsPopupVisible to true. Or vice-versa." // RootFrame.PopupContent = loginView; Binding b = new Binding("IsLoggedIn"); b.Source = FacebookLoginModel.Current; b.Converter = new NotConverter(); RootFrame.SetBinding(PhoneApplicationFrameEx.IsPopupVisibleProperty, b); }
/// <summary> /// invoke a logout. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Logout_Click(object sender, RoutedEventArgs e) { if (FacebookLoginModel.Current.IsLoggedIn) { DataManager.Current.Clear <FacebookUserModel>("me"); FacebookLoginView.LogoutMode = true; FacebookLoginModel.Logout(); } }
public object Deserialize(FacebookLoginLoadContext loadContext, Type objectType, System.IO.Stream stream) { // just pick the values back out of the stream. // StreamReader sr = new StreamReader(stream); string access_token = sr.ReadLine(); DateTime expiration_time = DateTime.Parse(sr.ReadLine()); // build our loginmodel. // FacebookLoginModel flm = new FacebookLoginModel(); flm.LoadContext = loadContext; flm.Token = access_token; flm.ExpirationTimeUtc = expiration_time.ToUniversalTime(); return(flm); }