override public void InvokedURL(WTArchitectView architectView, NSUrl url)
        {
            if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
            {
                NSDictionary info = new NSDictionary();

                architectView.CaptureScreenWithMode(WTScreenshotCaptureMode._CamAndWebView, WTScreenshotSaveMode._Delegate, WTScreenshotSaveOptions.None, info);
            }
            else
            {
                NSDictionary info = new NSDictionary();
                architectView.CaptureScreenWithMode(WTScreenshotCaptureMode._CamAndWebView, WTScreenshotSaveMode._PhotoLibrary, WTScreenshotSaveOptions.CallDelegateOnSuccess, info);
            }
        }
コード例 #2
0
 public static void Tweet(string text)
 {
     Thread.UI.Run(() =>
     {
         if (UIApplication.SharedApplication.CanOpenUrl(NSUrl.FromString("twitter://")))
         {
             var twitter = SLComposeViewController.FromService(SLServiceType.Twitter);
             twitter.SetInitialText(text);
             UIRuntime.Window.RootViewController.PresentViewController(twitter, true, null);
         }
         else
         {
             UIApplication.SharedApplication.OpenUrl(NSUrl.FromString($"https://twitter.com/intent/tweet?text={text}"));
         }
     });
 }
コード例 #3
0
ファイル: PostItController.cs プロジェクト: 2ndscreen/Post-It
        public void SendSocial(SLServiceKind framework)
        {
            var slComposer = SLComposeViewController.FromService(framework);

            if (slComposer == null)
            {
                new UIAlertView("Unavailable", "This social network is not available.", null, "OK").Show();
                return;
            }

            slComposer.CompletionHandler += (result) => {
                InvokeOnMainThread(() => DismissViewController(true, null));
            };
            PresentViewControllerAsync(slComposer, true);

            CreateAllNotifcations();
        }
コード例 #4
0
 public static void TweetPhoto(string text, byte[] photo)
 {
     Thread.UI.Run(() =>
     {
         if (UIApplication.SharedApplication.CanOpenUrl(NSUrl.FromString("twitter://")))
         {
             var twitter = SLComposeViewController.FromService(SLServiceType.Twitter);
             twitter.SetInitialText(text);
             twitter.AddImage(UIImage.LoadFromData(NSData.FromArray(photo)));
             UIRuntime.Window.RootViewController.PresentViewController(twitter, true, null);
         }
         else
         {
             throw new ArgumentOutOfRangeException("For posting photos you need to install Twitter on your device");
         }
     });
 }
コード例 #5
0
        public void shareFaceobook()
        {
            if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
            {
                var slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);
                slComposer.SetInitialText("Bust your stress with this new iOS Game!");

                slComposer.CompletionHandler += (result) => {
                    InvokeOnMainThread(() => {
                        slComposer.DismissViewController(true, null);
                    });
                };


                View.Window.RootViewController.PresentModalViewController(slComposer, true);
            }
        }
コード例 #6
0
        public void SendTweet(string msg)
        {
            if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
            {
                var window          = UIApplication.SharedApplication.KeyWindow;
                UIViewController vc = window.RootViewController;

                slComposer = SLComposeViewController.FromService(SLServiceKind.Twitter);
                slComposer.SetInitialText(msg);
                slComposer.CompletionHandler += (result) =>
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        vc.DismissModalViewController(true);
                    });
                };
                vc.PresentViewController(slComposer, true, null);
            }
        }
コード例 #7
0
        private void ShareOnService(SLServiceKind service, string title, string status, string link, Action onShareDone)
        {
            if (SLComposeViewController.IsAvailable(service))
            {
                var slComposer = SLComposeViewController.FromService(service);
                slComposer.Title = title;
                slComposer.SetInitialText(status);
                slComposer.AddUrl(new NSUrl(link));

                slComposer.CompletionHandler += (result) => {
                    if (result == SLComposeViewControllerResult.Done && onShareDone != null)
                    {
                        onShareDone.Invoke();
                    }
                };

                ViewController.PresentViewController(slComposer, true, null);
            }
        }
コード例 #8
0
        public void Facebook()
        {
            var _facebookComposer = SLComposeViewController.FromService(SLServiceType.Facebook);

            if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
            {
                _facebookComposer.SetInitialText(ConstantsClass.sharingText);
                //  FacebookComposer.AddImage(UIImage.FromFile("Icon.png"));
                _facebookComposer.CompletionHandler += (result) => {
                    InvokeOnMainThread(() => {
                        DismissViewController(true, null);
                        Console.WriteLine("Results: {0}", result);
                    });
                };

                // Display controller
                PresentViewController(_facebookComposer, true, null);
            }
        }
コード例 #9
0
        private void ShareOnService(SLServiceKind service, string title, string status, string link)
        {
            var slComposer = SLComposeViewController.FromService(service);

            if (SLComposeViewController.IsAvailable(service))
            {
                slComposer = SLComposeViewController.FromService(service);
                slComposer.SetInitialText(status);
                slComposer.SetInitialText(title != null ? String.Format("{0} {1}", title, status) : status);
                if (link != null)
                {
                    slComposer.AddUrl(new NSUrl(link));
                }
                slComposer.CompletionHandler += result =>
                {
                    UIApplication.SharedApplication.KeyWindow.RootViewController.InvokeOnMainThread(() =>
                    {
                        UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null);
                    });
                };
                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(slComposer, true, null);
            }
        }
コード例 #10
0
        public void Twitter()
        {
            Console.WriteLine("............. CALLING FROM TABLE SOURCE");

            var slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);

            if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
            {
                Console.WriteLine("....................................................");

                // Set initial message
                slComposer.SetInitialText(ConstantsClass.sharingText);
                // slComposer.AddImage(UIImage.FromFile("Icon.png"));
                slComposer.CompletionHandler += (result) => {
                    InvokeOnMainThread(() => {
                        DismissViewController(true, null);
                        Console.WriteLine("Results: {0}", result);
                    });
                };

                // Display controller
                PresentViewController(slComposer, true, null);
            }
        }
コード例 #11
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TweetButton.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);

                if (Screenshot.Image != null)
                {
                    slComposer.AddImage(Screenshot.Image);
                }

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };

            PostButton.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);

                if (Screenshot.Image != null)
                {
                    slComposer.AddImage(Screenshot.Image);
                }

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };

            #region Menu Buttons
            CloseButton.TouchUpInside += delegate {
                UIApplication.SharedApplication.SetStatusBarHidden(false, UIStatusBarAnimation.Fade);
                DismissViewController(true, null);
            };

            PrevBtn.TouchUpInside += delegate {
                SwipeImage("Right");
            };

            NextBtn.TouchUpInside += delegate {
                SwipeImage("Left");
            };
            #endregion

            #region Gesture Recognizers
            UITapGestureRecognizer tapGesture = new UITapGestureRecognizer();
            tapGesture.NumberOfTapsRequired = 1;
            tapGesture.AddTarget(this, new Selector("MenuDisplay"));
            Screenshot.AddGestureRecognizer(tapGesture);

            UISwipeGestureRecognizer swipeLeftGesture = new UISwipeGestureRecognizer();
            swipeLeftGesture.AddTarget(this, new Selector("SwipeLeftGesture"));
            swipeLeftGesture.Direction = UISwipeGestureRecognizerDirection.Left;
            View.AddGestureRecognizer(swipeLeftGesture);

            UISwipeGestureRecognizer swipeRightGesture = new UISwipeGestureRecognizer();
            swipeRightGesture.AddTarget(this, new Selector("SwipeRightGesture"));
            swipeRightGesture.Direction = UISwipeGestureRecognizerDirection.Right;
            View.AddGestureRecognizer(swipeRightGesture);

            UISwipeGestureRecognizer swipeDownGesture = new UISwipeGestureRecognizer();
            swipeDownGesture.AddTarget(this, new Selector("SwipeDownGesture"));
            swipeDownGesture.Direction = UISwipeGestureRecognizerDirection.Down;
            View.AddGestureRecognizer(swipeDownGesture);
            #endregion
        }
コード例 #12
0
ファイル: AppDelegate.cs プロジェクト: Peruzal/app-evolve
        public bool HandleShortcutItem(UIApplicationShortcutItem shortcutItem)
        {
            Console.WriteLine("HandleShortcutItem ");
            var handled = false;

            // Anything to process?
            if (shortcutItem == null)
            {
                return(false);
            }

            // Take action based on the shortcut type
            switch (shortcutItem.Type)
            {
            case ShortcutIdentifier.Tweet:
                Console.WriteLine("QUICKACTION: Tweet");
                var slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);
                if (slComposer == null)
                {
                    new UIAlertView("Unavailable", "Twitter is not available, please sign in on your devices settings screen.", null, "OK").Show();
                }
                else
                {
                    slComposer.SetInitialText(EventInfo.HashTag);
                    if (slComposer.EditButtonItem != null)
                    {
                        slComposer.EditButtonItem.TintColor = PrimaryColor;
                    }
                    slComposer.CompletionHandler += (result) =>
                    {
                        InvokeOnMainThread(() => UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null));
                    };

                    UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewControllerAsync(slComposer, true);
                }
                handled = true;
                break;

            case ShortcutIdentifier.Announcements:
                Console.WriteLine("QUICKACTION: Accouncements");
                ContinueNavigation(AppPage.Notification);
                handled = true;
                break;

            case ShortcutIdentifier.MiniHacks:
                Console.WriteLine("QUICKACTION: MiniHacks");
                ContinueNavigation(AppPage.MiniHacks);
                handled = true;
                break;

            case ShortcutIdentifier.Events:
                Console.WriteLine("QUICKACTION: Events");
                ContinueNavigation(AppPage.Events);
                handled = true;
                break;
            }

            Console.Write(handled);
            // Return results
            return(handled);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            twitterButton.TouchUpInside += delegate {

                if (SLComposeViewController.IsAvailable (SLServiceKind.Twitter)) {

                    slComposer = SLComposeViewController.FromService (SLServiceType.Twitter);

                    slComposer.SetInitialText ("test");
                    slComposer.AddImage (UIImage.FromFile ("monkey.png"));

                    slComposer.CompletionHandler += (result) => {
                        InvokeOnMainThread (() => {
                            DismissViewController (true, null);
                            resultsTextView.Text = result.ToString ();
                        });
                    };

                    PresentViewController (slComposer, true, null);
                } else {
                    resultsTextView.Text = "Twitter Account not added";
                }
            };

            facebookButton.TouchUpInside += delegate {

                if (SLComposeViewController.IsAvailable (SLServiceKind.Facebook)) {

                    slComposer = SLComposeViewController.FromService (SLServiceType.Facebook);

                    slComposer.SetInitialText ("test2");
                    slComposer.AddImage (UIImage.FromFile ("monkey.png"));
                    slComposer.AddUrl (new NSUrl ("http://xamarin.com"));

                    slComposer.CompletionHandler += (result) => {
                        InvokeOnMainThread (() => {
                            DismissViewController (true, null);
                            resultsTextView.Text = result.ToString ();
                        });
                    };

                    PresentViewController (slComposer, true, null);
                } else {
                    resultsTextView.Text = "Facebook Account not added";
                }
            };

            twitterRequestButton.TouchUpInside += delegate {

                if (SLComposeViewController.IsAvailable (SLServiceKind.Twitter)) {

                    var parameters = new NSDictionary ();
                    var request = SLRequest.Create (SLServiceKind.Twitter,
                                                    SLRequestMethod.Get,
                                                    new NSUrl ("http://api.twitter.com/1/statuses/public_timeline.json"),
                                                    parameters);

                    request.PerformRequest ((data, response, error) => {

                        if (response.StatusCode == 200) {
                            InvokeOnMainThread (() => {
                                resultsTextView.Text = data.ToString (); });

                        } else {
                            InvokeOnMainThread (() => {
                                resultsTextView.Text = "Error: " + response.StatusCode.ToString (); });
                        }
                    });
                } else {
                    resultsTextView.Text = "Twitter Account not added";
                }
            };

            facebookRequestButton.TouchUpInside += delegate {

                if (SLComposeViewController.IsAvailable (SLServiceKind.Facebook)) {

                    var parameters = new NSDictionary ();
                    var request = SLRequest.Create (SLServiceKind.Facebook,
                                                    SLRequestMethod.Get,
                                                    new NSUrl ("https://graph.facebook.com/283148898401104"),
                                                    parameters);

                    request.PerformRequest ((data, response, error) => {

                        if (response.StatusCode == 200) {
                            InvokeOnMainThread (() => {
                                resultsTextView.Text = data.ToString (); });

                        } else {
                            InvokeOnMainThread (() => {
                                resultsTextView.Text = "Error: " + response.StatusCode.ToString (); });
                        }
                    });
                } else {
                    resultsTextView.Text = "Facebook Account not added";
                }

            };
        }
コード例 #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavBackBtn.TouchUpInside += delegate {
                this.NavigationController.PopViewControllerAnimated(true);
            };

            WebShowSocialNetworksBtn.TouchUpInside += delegate {
                WebNavCloseBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                WebTweetBtn.Transform    = CGAffineTransform.MakeScale(0f, 0f);
                WebPostBtn.Transform     = CGAffineTransform.MakeScale(0f, 0f);
                WebNavCloseBtn.Hidden    = false;
                WebTweetBtn.Hidden       = false;
                WebPostBtn.Hidden        = false;
                UIView.AnimateNotify(0.4, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    WebTitle.Transform = CGAffineTransform.MakeScale(0f, 0f);
                    WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                    NavBackBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);

                    WebNavCloseBtn.Transform = CGAffineTransform.MakeScale(1f, 1f);
                    WebTweetBtn.Transform    = CGAffineTransform.MakeScale(1f, 1f);
                    WebPostBtn.Transform     = CGAffineTransform.MakeScale(1f, 1f);
                }, null);
            };

            WebNavCloseBtn.TouchUpInside += delegate {
                UIView.AnimateNotify(0.4, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    WebNavCloseBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                    WebTweetBtn.Transform    = CGAffineTransform.MakeScale(0f, 0f);
                    WebPostBtn.Transform     = CGAffineTransform.MakeScale(0f, 0f);

                    WebTitle.Transform = CGAffineTransform.MakeScale(1f, 1f);
                    WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(1f, 1f);
                    NavBackBtn.Transform = CGAffineTransform.MakeScale(1f, 1f);
                }, null);
            };

            WebTweetBtn.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);
                slComposer.AddUrl(new NSUrl(_url));

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };

            WebPostBtn.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);
                slComposer.AddUrl(new NSUrl(_url));

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };

            WebBackBtn.TouchUpInside += delegate {
                WebView.GoBack();
            };

            WebForwardBtn.TouchUpInside += delegate {
                WebView.GoForward();
            };

            WebToolBarRefreshBtn.TouchUpInside += delegate {
                if (WebTweetBtn.Hidden == false)
                {
                    UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                        WebNavCloseBtn.Transform    = CGAffineTransform.MakeScale(0f, 0f);
                        WebTweetBtn.Transform       = CGAffineTransform.MakeScale(0f, 0f);
                        WebPostBtn.Transform        = CGAffineTransform.MakeScale(0f, 0f);
                        WebTitle.Transform          = CGAffineTransform.MakeScale(1f, 1f);
                        NavBackBtn.Transform        = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.Transform = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.StartAnimating();
                    }, null);
                }
                else
                {
                    UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                        WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                        WebLoadingSpinner.Transform        = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.StartAnimating();
                    }, null);
                }

                WebView.Reload();
                if (!isLoaded)
                {
                    LoadWebUrl(_url);
                }
            };

            WebView.LoadStarted += delegate {
                if (WebTweetBtn.Hidden == false)
                {
                    UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                        WebNavCloseBtn.Transform    = CGAffineTransform.MakeScale(0f, 0f);
                        WebTweetBtn.Transform       = CGAffineTransform.MakeScale(0f, 0f);
                        WebPostBtn.Transform        = CGAffineTransform.MakeScale(0f, 0f);
                        WebTitle.Transform          = CGAffineTransform.MakeScale(1f, 1f);
                        NavBackBtn.Transform        = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.Transform = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.StartAnimating();
                    }, null);
                }
                else
                {
                    UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                        WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                        WebLoadingSpinner.Transform        = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.StartAnimating();
                    }, null);
                }
            };

            WebView.LoadFinished += delegate {
                WebShowSocialNetworksBtn.Hidden    = false;
                WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(1f, 1f);
                    WebLoadingSpinner.Transform        = CGAffineTransform.MakeScale(0f, 0f);
                }, delegate {
                    WebLoadingSpinner.StopAnimating();
                    isLoaded = true;
                });
            };

            WebView.LoadError += delegate(object sender, UIWebErrorArgs e) {
                if (!e.Error.ToString().Contains("NSURLErrorDomain"))
                {
                    WebLoadingSpinner.StopAnimating();
                    WebShowSocialNetworksBtn.Alpha = 1;
                    UIAlertView alert = new UIAlertView("Error", "Problem connecting.\n" +
                                                        "Please check your connection and try again.", null, "OK", null);
                    alert.Show();
                }
            };
        }
コード例 #15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            BackButton.TouchUpInside += delegate {
                this.NavigationController.PopViewControllerAnimated(true);
            };

            DetailsShowSocialNetworkViewBtn.TouchUpInside += delegate {
                DetailsNavReminderBtn.Transform        = Utilities.Hide;
                DetailsSocialNetworkCloseBtn.Transform = Utilities.Hide;
                TweetBtn.Transform = Utilities.Hide;
                PostBtn.Transform  = Utilities.Hide;
                DetailsNavReminderBtn.Transform = Utilities.Hide;
                UIView.AnimateNotify(0.4, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    DetailsShowSocialNetworkViewBtn.Transform = Utilities.Hide;
                    DetailsNavTitleLbl.Transform = Utilities.Hide;
                    DetailsShowSocialNetworkViewBtn.Transform = Utilities.Hide;
                    BackButton.Transform = Utilities.Hide;

                    DetailsSocialNetworkCloseBtn.Hidden = false;
                    TweetBtn.Hidden = false;
                    PostBtn.Hidden  = false;
                    if (Convert.ToDateTime(_item.release_date) > DateTime.Now)
                    {
                        DetailsNavReminderBtn.Hidden    = false;
                        DetailsNavReminderBtn.Transform = Utilities.Show;
                    }
                    DetailsSocialNetworkCloseBtn.Transform = Utilities.Show;
                    TweetBtn.Transform = Utilities.Show;
                    PostBtn.Transform  = Utilities.Show;
                }, null);
            };

            DetailsSocialNetworkCloseBtn.TouchUpInside += delegate {
                UIView.AnimateNotify(0.4, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    DetailsShowSocialNetworkViewBtn.Transform = Utilities.Show;
                    DetailsNavTitleLbl.Transform = Utilities.Show;
                    DetailsShowSocialNetworkViewBtn.Transform = Utilities.Show;
                    BackButton.Transform = Utilities.Show;
                    if (Convert.ToDateTime(_item.release_date) > DateTime.Now)
                    {
                        DetailsNavReminderBtn.Transform = Utilities.Hide;
                    }
                    DetailsSocialNetworkCloseBtn.Transform = Utilities.Hide;
                    TweetBtn.Transform = Utilities.Hide;
                    PostBtn.Transform  = Utilities.Hide;
                }, delegate { DetailsNavReminderBtn.Hidden = true; });
            };

            TweetBtn.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);

                if (!String.IsNullOrEmpty(game.hashtag))
                {
                    slComposer.SetInitialText("#" + game.hashtag);
                }

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };

            PostBtn.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);
                if (!String.IsNullOrEmpty(game.title))
                {
                    slComposer.SetInitialText(game.title);
                }

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            twitterButton.TouchUpInside += delegate {
                if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
                {
                    slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);

                    slComposer.SetInitialText("test");
                    slComposer.AddImage(UIImage.FromFile("monkey.png"));

                    slComposer.CompletionHandler += (result) => {
                        InvokeOnMainThread(() => {
                            DismissViewController(true, null);
                            resultsTextView.Text = result.ToString();
                        });
                    };

                    PresentViewController(slComposer, true, null);
                }
                else
                {
                    resultsTextView.Text = "Twitter Account not added";
                }
            };

            facebookButton.TouchUpInside += delegate {
                if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
                {
                    slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);

                    slComposer.SetInitialText("test2");
                    slComposer.AddImage(UIImage.FromFile("monkey.png"));
                    slComposer.AddUrl(new NSUrl("http://xamarin.com"));

                    slComposer.CompletionHandler += (result) => {
                        InvokeOnMainThread(() => {
                            DismissViewController(true, null);
                            resultsTextView.Text = result.ToString();
                        });
                    };

                    PresentViewController(slComposer, true, null);
                }
                else
                {
                    resultsTextView.Text = "Facebook Account not added";
                }
            };

            twitterRequestButton.TouchUpInside += delegate {
                if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
                {
                    var parameters = new NSDictionary();
                    var request    = SLRequest.Create(SLServiceKind.Twitter,
                                                      SLRequestMethod.Get,
                                                      new NSUrl("http://api.twitter.com/1/statuses/public_timeline.json"),
                                                      parameters);

                    request.PerformRequest((data, response, error) => {
                        if (response.StatusCode == 200)
                        {
                            InvokeOnMainThread(() => {
                                resultsTextView.Text = data.ToString();
                            });
                        }
                        else
                        {
                            InvokeOnMainThread(() => {
                                resultsTextView.Text = "Error: " + response.StatusCode.ToString();
                            });
                        }
                    });
                }
                else
                {
                    resultsTextView.Text = "Twitter Account not added";
                }
            };

            facebookRequestButton.TouchUpInside += delegate {
                if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
                {
                    var parameters = new NSDictionary();
                    var request    = SLRequest.Create(SLServiceKind.Facebook,
                                                      SLRequestMethod.Get,
                                                      new NSUrl("https://graph.facebook.com/283148898401104"),
                                                      parameters);

                    request.PerformRequest((data, response, error) => {
                        if (response.StatusCode == 200)
                        {
                            InvokeOnMainThread(() => {
                                resultsTextView.Text = data.ToString();
                            });
                        }
                        else
                        {
                            InvokeOnMainThread(() => {
                                resultsTextView.Text = "Error: " + response.StatusCode.ToString();
                            });
                        }
                    });
                }
                else
                {
                    resultsTextView.Text = "Facebook Account not added";
                }
            };
        }
コード例 #17
0
        public void donecomboShare()
        {
            hidecomboShare();
            string key = shareList [UpdatecurrenShareOpt];

            Console.WriteLine(key + " Llave: " + UpdatecurrenShareOpt);

            switch (key)
            {
            case "facebook":
            {
                SLComposeViewController slComposer;

                if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
                {
                    slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);
                    slComposer.SetInitialText("Condiviso tramite iPortogruaro. Scaricala da iTunes! " + System.Web.HttpUtility.HtmlDecode(dataPos.title));


                    foreach (UIView v in sramdom)
                    {
                        if (v.Tag == positionImg)
                        {
                            if (v is UIImageView)
                            {
                                UIImageView imgs = v as UIImageView;
                                slComposer.AddImage(imgs.Image);
                            }
                            break;
                        }
                    }

                    slComposer.CompletionHandler += (result) => {
                        InvokeOnMainThread(() => {
                                DismissViewController(true, null);
                                if (result == SLComposeViewControllerResult.Done)
                                {
                                    var alert = new UIAlertView("Esito", "messaggio mandato", null, "Ok");

                                    alert.Show();
                                }
                            });
                    };
                    PresentViewController(slComposer, true, null);
                }

                else
                {
                    InvokeOnMainThread(() => {
                            var alert = new UIAlertView("Facebook", "Entrare nei settaggi per configurare l'account facebook", null, "Ok");

                            alert.Show();
                        });
                }
            }
            break;

            case "twitter":
            {
                SLComposeViewController slComposer;

                if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
                {
                    slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);
                    slComposer.SetInitialText("Condiviso tramite iPortogruaro. Scaricala da iTunes! " + System.Web.HttpUtility.HtmlDecode(dataPos.title));
                    foreach (UIView v in sramdom)
                    {
                        if (v.Tag == positionImg)
                        {
                            if (v is UIImageView)
                            {
                                UIImageView imgs = v as UIImageView;
                                slComposer.AddImage(imgs.Image);
                            }
                            break;
                        }
                    }
                    slComposer.CompletionHandler += (result) => {
                        InvokeOnMainThread(() => {
                                DismissViewController(true, null);
                                if (result == SLComposeViewControllerResult.Done)
                                {
                                    var alert = new UIAlertView("Esito", "messaggio mandato", null, "Ok");

                                    alert.Show();
                                }
                            });
                    };
                    PresentViewController(slComposer, true, null);
                }
                else
                {
                    InvokeOnMainThread(() => {
                            var alert = new UIAlertView("Twitter", "Entrare nei settaggi per configurare l'account Twitter", null, "Ok");

                            alert.Show();
                        });
                }
                break;
            }

            case "mail":
            {
                MFMailComposeViewController _mail;

                if (MFMailComposeViewController.CanSendMail)
                {
                    _mail = new MFMailComposeViewController();
                    _mail.SetMessageBody("Condiviso tramite iPortogruaro. Scaricala da iTunes! " + System.Web.HttpUtility.HtmlDecode(dataPos.title),
                                         false);
                    _mail.SetSubject(System.Web.HttpUtility.HtmlDecode(dataPos.title));
                    _mail.Finished += HandleMailFinished;

                    foreach (UIView v in sramdom)
                    {
                        if (v.Tag == positionImg)
                        {
                            if (v is UIImageView)
                            {
                                UIImageView imgs = v as UIImageView;
                                NSData      dat  = imgs.Image.AsJPEG(0);
                                _mail.AddAttachmentData(dat, "image/png", System.Web.HttpUtility.HtmlDecode(dataPos.title));
                            }
                            break;
                        }
                    }

                    this.PresentModalViewController(_mail, true);
                }
                else
                {
                    // handle not being able to send mail
                }
                break;
            }
            }
        }
コード例 #18
0
ファイル: ViewController.cs プロジェクト: kappajbeta/Bloons
        void ComposeSocialMessage()
        {
            string socialMessage     = string.Empty;
            string currentBestTime   = userDefaults.StringForKey(PREVIOUS_BEST_TIME_KEY);
            string connectedServices = (String.IsNullOrWhiteSpace(userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED)) == true ?
                                        string.Empty : userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED));

            if (String.IsNullOrWhiteSpace(currentBestTime) == true)
            {
                socialMessage = "Got #" + APP_NAME + "?";
            }
            else
            {
                socialMessage = "I survived for " + (currentBestTime.Split(':')[0] == "00" ? string.Empty : int.Parse(currentBestTime.Split(':')[0]) + " hrs ")
                                + (currentBestTime.Split(':')[0] == "00" && currentBestTime.Split(':')[1] == "00" ? string.Empty : int.Parse(currentBestTime.Split(':')[1]) + " mins and ")
                                + int.Parse(currentBestTime.Split(':')[2]) + " secs. Enough said. Booyah. Mic drop. All that. #" + APP_NAME;
            }

            if ((connectedServices.Contains("Twitter") == true) &&
                (SLComposeViewController.IsAvailable(SLServiceKind.Twitter) == true))
            {
                SLComposeViewController twitterViewController = SLComposeViewController.FromService(SLServiceKind.Twitter);

                twitterViewController.SetInitialText(socialMessage);
                twitterViewController.AddUrl(new NSUrl(APP_LINK));

                twitterViewController.CompletionHandler += (twitterobj) =>
                {
                    InvokeOnMainThread(() =>
                    {
                        DismissViewController(true, null);

                        if ((connectedServices.Contains("Facebook") == true) &&
                            (SLComposeViewController.IsAvailable(SLServiceKind.Facebook) == true))
                        {
                            SLComposeViewController facebookViewController = SLComposeViewController.FromService(SLServiceKind.Facebook);

                            facebookViewController.SetInitialText(socialMessage);
                            facebookViewController.AddUrl(new NSUrl(APP_LINK));

                            facebookViewController.CompletionHandler += (facebookobj) =>
                            {
                                InvokeOnMainThread(() =>
                                {
                                    DismissViewController(true, null);
                                    ControlMenu("Show");
                                });
                            };

                            PresentViewController(facebookViewController, true, null);
                        }
                        else
                        {
                            ControlMenu("Show");
                        }
                    });
                };

                PresentViewController(twitterViewController, true, null);
            }
            else if ((connectedServices.Contains("Facebook") == true) &&
                     (SLComposeViewController.IsAvailable(SLServiceKind.Facebook) == true))
            {
                SLComposeViewController facebookViewController = SLComposeViewController.FromService(SLServiceKind.Facebook);

                facebookViewController.SetInitialText(socialMessage);
                facebookViewController.AddUrl(new NSUrl(APP_LINK));

                facebookViewController.CompletionHandler += (facebookobj) =>
                {
                    InvokeOnMainThread(() =>
                    {
                        DismissViewController(true, null);
                        ControlMenu("Show");
                    });
                };

                PresentViewController(facebookViewController, true, null);
            }
            else
            {
                ControlMenu("Show");
            }
        }
コード例 #19
0
ファイル: ViewController.cs プロジェクト: kappajbeta/Bloons
        void AddMenu()
        {
            SatelliteMenuButtonItem[] menuItems;
            string connectedServices = (String.IsNullOrWhiteSpace(userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED)) ? string.Empty : userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED));
            var    menuImage         = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "Menu.png");
            var    philipsHueImage   = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "HueOff.png");
            var    soundImage        = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "SoundOn.png");
            var    facebookImage     = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "Facebook" + ((SLComposeViewController.IsAvailable(SLServiceKind.Twitter) == true) &&
                                                                                                         (connectedServices.Contains("Facebook") == true) ?
                                                                                                         "Connected" : "Disconnected") + ".png");
            var twitterImage = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "Twitter" + ((SLComposeViewController.IsAvailable(SLServiceKind.Twitter) == true) &&
                                                                                                (connectedServices.Contains("Twitter") == true) ?
                                                                                                "Connected" : "Disconnected") + ".png");
            var menuFrame = new RectangleF(2, (float)View.Window.Frame.Height - 50, 48, 48);

            if (String.IsNullOrWhiteSpace(userDefaults.StringForKey(SOUND_STATUS_KEY)) == false)
            {
                gameLayer.SoundOn = (userDefaults.StringForKey(SOUND_STATUS_KEY) == "On");

                if ((gameLayer.SoundOn == true) &&
                    (ambientAudioWasPlaying == false))
                {
                    soundImage = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "SoundOn.png");
                    AVAudioSession.SharedInstance().SetActive(true, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation);
                    AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.SoloAmbient);
                }
                else
                {
                    gameLayer.SoundOn = false;

                    userDefaults.SetString("Off", SOUND_STATUS_KEY);
                    soundImage = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "SoundOff.png");
                    AVAudioSession.SharedInstance().SetActive(false, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation);
                    AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.Ambient, AVAudioSessionCategoryOptions.MixWithOthers);
                }
            }

            if (String.IsNullOrWhiteSpace(userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED)) == true)
            {
                userDefaults.SetString(connectedServices, SOCIAL_NETWORKS_CONNECTED);
            }

            menuImage       = menuImage.Scale(new CGSize(96, 96));
            philipsHueImage = philipsHueImage.Scale(new CGSize(96, 96));
            soundImage      = soundImage.Scale(new CGSize(96, 96));
            facebookImage   = facebookImage.Scale(new CGSize(96, 96));
            twitterImage    = twitterImage.Scale(new CGSize(96, 96));
            menuItems       = new[] {
                new SatelliteMenuButtonItem(philipsHueImage, 1, "Philips Hue Off"),
                new SatelliteMenuButtonItem(soundImage, 2, "Sound " + (String.IsNullOrWhiteSpace(userDefaults.StringForKey(SOUND_STATUS_KEY)) ? "On"
                                                                       : userDefaults.StringForKey(SOUND_STATUS_KEY))),
                new SatelliteMenuButtonItem(facebookImage, 3, "Facebook " + ((SLComposeViewController.IsAvailable(SLServiceKind.Twitter) == true) &&
                                                                             (connectedServices.Contains("Facebook") == true) ? "Connected" : "Disconnected")),
                new SatelliteMenuButtonItem(twitterImage, 4, "Twitter " + ((SLComposeViewController.IsAvailable(SLServiceKind.Facebook) == true) &&
                                                                           (connectedServices.Contains("Twitter") == true) ? "Connected" : "Disconnected"))
            };

            satelliteMenu                   = new SatelliteMenuButton(View, menuImage, menuItems, menuFrame);
            satelliteMenu.Alpha             = 0.85f;
            satelliteMenu.CloseItemsOnClick = true;
            satelliteMenu.TouchUpInside    += (sender, e) =>
            {
                if (gameLayer.GamePaused == false)
                {
                    gameLayer.GamePaused = true;
                }
                else
                {
                    gameLayer.GamePaused = false;
                }
            };
            satelliteMenu.MenuItemClick += (sender, args) =>
            {
                if (args.MenuItem.Name == "Philips Hue On")
                {
                    ControlMenu("Hide");

                    selectorTableView.Hidden = false;
                }
                else if (args.MenuItem.Name == "Philips Hue Off")
                {
                    ControlMenu("Hide");
                    ChangePhilipsHueStatus();
                }
                else if (args.MenuItem.Name == "Sound On")
                {
                    gameLayer.SoundOn       = false;
                    args.MenuItem.Name      = "Sound Off";
                    args.MenuItem.ItemImage = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "SoundOff.png");

                    userDefaults.SetString("Off", SOUND_STATUS_KEY);

                    if (ambientAudioWasPlaying == true)
                    {
                        UIAlertController gameAudioAlert = UIAlertController.Create("Game Audio",
                                                                                    "Would you like to resume the audio that was playing before you started the game?",
                                                                                    UIAlertControllerStyle.Alert);

                        gameAudioAlert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (connectionOK) =>
                        {
                            AVAudioSession.SharedInstance().SetActive(false, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation);
                            AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.Ambient, AVAudioSessionCategoryOptions.MixWithOthers);
                        }));

                        gameAudioAlert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Default, (connectionCancel) =>
                        {
                            AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.Ambient, AVAudioSessionCategoryOptions.MixWithOthers);
                        }));

                        PresentViewController(gameAudioAlert, true, null);
                    }
                    else
                    {
                        AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.Ambient, AVAudioSessionCategoryOptions.MixWithOthers);
                    }
                }
                else if (args.MenuItem.Name == "Sound Off")
                {
                    gameLayer.SoundOn       = true;
                    args.MenuItem.Name      = "Sound On";
                    args.MenuItem.ItemImage = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "SoundOn.png");

                    userDefaults.SetString("On", SOUND_STATUS_KEY);
                    AVAudioSession.SharedInstance().SetActive(true, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation);
                    AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.SoloAmbient);
                }
                else if (args.MenuItem.Name == "Twitter Disconnected")
                {
                    if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter) == false)
                    {
                        if (UIApplication.SharedApplication.CanOpenUrl(new NSUrl("prefs:root=General&path=TWITTER")) == true)
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("prefs:root=General&path=TWITTER"));
                        }
                        else
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("App-Prefs:root=TWITTER"));
                        }
                    }
                    else
                    {
                        args.MenuItem.Name      = "Twitter Connected";
                        args.MenuItem.ItemImage = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "TwitterConnected.png");

                        userDefaults.SetString(userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED) + ",Twitter", SOCIAL_NETWORKS_CONNECTED);
                    }
                }
                else if (args.MenuItem.Name == "Twitter Connected")
                {
                    args.MenuItem.Name      = "Twitter Disconnected";
                    args.MenuItem.ItemImage = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "TwitterDisconnected.png");

                    userDefaults.SetString(userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED).Replace("Twitter", string.Empty).Trim(','), SOCIAL_NETWORKS_CONNECTED);
                }
                else if (args.MenuItem.Name == "Facebook Disconnected")
                {
                    if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter) == false)
                    {
                        if (UIApplication.SharedApplication.CanOpenUrl(new NSUrl("prefs:root=General&path=FACEBOOK")) == true)
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("prefs:root=General&path=FACEBOOK"));
                        }
                        else
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("App-Prefs:root=FACEBOOK"));
                        }
                    }
                    else
                    {
                        args.MenuItem.Name      = "Facebook Connected";
                        args.MenuItem.ItemImage = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "FacebookConnected.png");

                        userDefaults.SetString(userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED) + ",Facebook", SOCIAL_NETWORKS_CONNECTED);
                    }
                }
                else if (args.MenuItem.Name == "Facebook Connected")
                {
                    args.MenuItem.Name      = "Facebook Disconnected";
                    args.MenuItem.ItemImage = UIImage.FromFile(IMAGES_FOLDER + currentMod + "/" + "FacebookDisconnected.png");

                    userDefaults.SetString(userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED).Replace("Facebook", string.Empty).Trim(','), SOCIAL_NETWORKS_CONNECTED);
                }
            };

            View.AddSubview(satelliteMenu);
        }