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

            if (precheckToDo(e))
            {
                if (!TwitterUtils.TwitterClient.isAlreadyLoggedIn())
                {
                    var dispatcher = ActionHelper.getCurrentUIThread();
                    dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        LoginTwitterDialog dialog = new LoginTwitterDialog();
                        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);
            }
        }
Example #2
0
 public static void login(ServerStream stream, Actions.DelegateBegin onBegin, Actions.DelegateDone onDone, Actions.DelegateCancel onCancel)
 {
     Actions.ActionTwitterLoginArgs arg            = new Actions.ActionTwitterLoginArgs(AppObject.RootLayout);
     Actions.ActionTwitterLogin     action_twlogin = new Actions.ActionTwitterLogin();
     _stream_wating.Add(action_twlogin, stream);
     try {
         if (onBegin != null)
         {
             action_twlogin.OnBegin += onBegin;
         }
         action_twlogin.OnDone += action_twitter_login_OnDone;
         if (onDone != null)
         {
             action_twlogin.OnDone += onDone;
         }
         action_twlogin.OnCancel += action_twitter_login_OnCancel;
         if (onCancel != null)
         {
             action_twlogin.OnCancel += onCancel;
         }
         stream.Status = (int)ServerStreamStatus.STREAM_STATUS_REQUESTING;
         ////ApplicationInfomation.onPopupOn();
         AppObject.PopupOfAction.Add(new Actions.ActionArgLinker(action_twlogin, arg));
         action_twlogin.Do(arg);
     } catch (Exception ex) {
         stream.Status = (int)ServerStreamStatus.STREAM_STATUS_ERROR;
     }
 }
Example #3
0
 static private void action_twitter_login_OnCancel(object sender, Actions.ActionArgs e)
 {
     try {
         Actions.ActionTwitterLoginArgs twarg = e as Actions.ActionTwitterLoginArgs;
         foreach (ActionArgLinker link in AppObject.PopupOfAction)
         {
             if (link.AttachArg == twarg)
             {
                 AppObject.PopupOfAction.Remove(link);
                 break;
             }
         }
         ServerStream svstream = _stream_wating[(Actions.Action)sender];
         svstream.Status = (int)ServerStreamStatus.STREAM_STATUS_ERROR;
         _stream_wating.Remove((Actions.Action)sender);
         ////ApplicationInfomation.onPopupOff();
         AppObject.PopupOfAction.Clear();
     } catch (Exception ex) {
     }
 }
        public override void Cancel(ActionArgs e)
        {
            ActionTwitterLoginArgs arg = e as ActionTwitterLoginArgs;

            if (arg != null)
            {
                try {
                    LoginTwitterDialog 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, LoginTwitterDialogCompleteArgs e)
        {
            LoginTwitterDialog dialog = sender as LoginTwitterDialog;

            if (dialog != null)
            {
                try {
                    ActionTwitterLoginArgs arg = _waiting[dialog];
                    arg.ParentLayout.Children.Remove(dialog.Dialog);
                    arg.Result = e;
                    Done(arg);
                } catch (Exception ex) {
                    //throw ex;
                }
            }
            else
            {
                Exception ex = new Exception("Twitter login dialog error");
                //throw ex;
            }
        }
Example #6
0
 static private void action_twitter_login_OnDone(object sender, Actions.ActionArgs e)
 {
     try {
         Actions.ActionTwitterLoginArgs twarg = e as Actions.ActionTwitterLoginArgs;
         foreach (ActionArgLinker link in AppObject.PopupOfAction)
         {
             if (link.AttachArg == twarg)
             {
                 AppObject.PopupOfAction.Remove(link);
                 break;
             }
         }
         if (twarg != null && (twarg.IsCancelByLogedin || (twarg.Result != null && twarg.Result.IsSuccess)))
         {
             if (twarg.IsCancelByLogedin)
             {
                 ServerStream svstream = _stream_wating[(Actions.Action)sender];
                 svstream.Status = (int)ServerStreamStatus.STREAM_STATUS_RESPONSED;
                 _stream_wating.Remove((Actions.Action)sender);
                 ////ApplicationInfomation.onPopupOff();
             }
             else
             {
                 ServerStream svstream = _stream_wating[(Actions.Action)sender];
                 svstream.Status = (int)ServerStreamStatus.STREAM_STATUS_RESPONSED;
                 _stream_wating.Remove((Actions.Action)sender);
                 ////ApplicationInfomation.onPopupOff();
             }
         }
         else
         {
             ServerStream svstream = _stream_wating[(Actions.Action)sender];
             svstream.Status = (int)ServerStreamStatus.STREAM_STATUS_ERROR;
             _stream_wating.Remove((Actions.Action)sender);
             //// ApplicationInfomation.onPopupOff();
         }
         AppObject.PopupOfAction.Clear();
     } catch (Exception ex) {
     }
 }
        public override bool precheckToDo(ActionArgs e)
        {
            ActionTwitterLoginArgs arg = e as ActionTwitterLoginArgs;

            return(arg.ParentLayout != null);
        }