public override void Do(ActionArgs e)
        {
            Begin(e);
            ActionFacebookLoginArgs arg = e as ActionFacebookLoginArgs;

            if (precheckToDo(e))
            {
                if (!FacebookClient.Instance.IsUserLogedin())
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() => {
                        LoginFacebookDialog dialog = new LoginFacebookDialog(arg.AppInfo);
                        dialog.OnComplete         += dialog_OnComplete;
                        arg.ParentLayout.Children.Add(dialog.Dialog);
                        dialog.show(0, 0);
                        _waiting.Add(dialog, arg);
                    });
                }
                else
                {
                    arg.IsCancelByLogedin = true;
                    Done(arg);
                }
            }
            else
            {
                Cancel(e);
            }
        }
Esempio n. 2
0
 static private void action_fblogin_stream_OnDone(object sender, Actions.ActionArgs e)
 {
     try {
         Actions.ActionFacebookLoginArgs fbarg = e as Actions.ActionFacebookLoginArgs;
         ActionFacebookLoginArgs         arg   = e as ActionFacebookLoginArgs;
         foreach (ActionArgLinker link in AppObject.PopupOfAction)
         {
             if (link.AttachArg == arg)
             {
                 AppObject.PopupOfAction.Remove(link);
                 break;
             }
         }
         if (fbarg != null && (fbarg.IsCancelByLogedin || (fbarg.Result != null && fbarg.Result.IsSuccess)))
         {
             if (fbarg.IsCancelByLogedin)
             {
                 ServerStream svstream = _stream_wating[(Actions.Action)sender];
                 svstream.Status = (int)ServerStreamStatus.STREAM_STATUS_RESPONSED;
                 ApplicationInfomation.onPopupOff();
             }
             else
             {
                 FacebookClient.Instance.Token        = fbarg.Result.Token;
                 FacebookClient.Instance.TokenExprite = fbarg.Result.TokenExprite;
                 FacebookClient.Instance.SaveUserData();
                 ServerStream svstream = _stream_wating[(Actions.Action)sender];
                 action_fbinfo_stream_do(svstream);
             }
         }
         else
         {
             ServerStream svstream = _stream_wating[(Actions.Action)sender];
             svstream.Status = (int)ServerStreamStatus.STREAM_STATUS_ERROR;
             _stream_wating.Remove((Actions.Action)sender);
             ApplicationInfomation.onPopupOff();
         }
     } catch (Exception ex) {
         Debug.WriteLine(ex.Message);
     }
 }
        public override void Cancel(ActionArgs e)
        {
            ActionFacebookLoginArgs arg = e as ActionFacebookLoginArgs;

            if (arg != null)
            {
                try {
                    LoginFacebookDialog dialog = _waiting.FirstOrDefault(x => x.Value == arg).Key;
                    arg.ParentLayout.Children.Remove(dialog.Dialog);
                    arg.Result = null;
                } catch (Exception ex) {
                    //throw ex;
                }
            }
            else
            {
                Exception ex = new Exception("Facebook login dialog error");
                //throw ex;
            }
            base.Cancel(e);
        }
        void dialog_OnComplete(object sender, LoginFacebookDialogCompleteArgs e)
        {
            LoginFacebookDialog dialog = sender as LoginFacebookDialog;

            if (dialog != null)
            {
                try {
                    ActionFacebookLoginArgs arg = _waiting[dialog];
                    arg.ParentLayout.Children.Remove(dialog.Dialog);
                    arg.Result = e;
                    Done(arg);
                } catch (Exception ex) {
                    //throw ex;
                }
            }
            else
            {
                Exception ex = new Exception("Facebook login dialog error");
                //throw ex;
            }
        }
Esempio n. 5
0
 static public void login(FacebookAppInfomation appinfo, ServerStream stream, Actions.DelegateBegin onBegin, Actions.DelegateDone onDone, Actions.DelegateCancel onCancel)
 {
     Actions.ActionFacebookLoginArgs arg = new Actions.ActionFacebookLoginArgs(AppObject.RootLayout)
     {
         AppInfo = appinfo
     };
     Actions.ActionFacebookLogin action_fblogin = new Actions.ActionFacebookLogin();
     _stream_wating.Add(action_fblogin, stream);
     try {
         action_fblogin.OnBegin  += onBegin;
         action_fblogin.OnDone   += action_fblogin_stream_OnDone;
         action_fblogin.OnDone   += onDone;
         action_fblogin.OnCancel += action_fblogin_stream_OnCancel;
         action_fblogin.OnCancel += onCancel;
         stream.Status            = (int)ServerStreamStatus.STREAM_STATUS_REQUESTING;
         AppObject.PopupOfAction.Add(new Actions.ActionArgLinker(action_fblogin, arg));
         ApplicationInfomation.onPopupOn();
         action_fblogin.Do(arg);
     } catch (Exception ex) {
         stream.Status = (int)ServerStreamStatus.STREAM_STATUS_ERROR;
     }
 }
        public override bool precheckToDo(ActionArgs e)
        {
            ActionFacebookLoginArgs arg = e as ActionFacebookLoginArgs;

            return(arg.ParentLayout != null);
        }