コード例 #1
0
            public override void DidReceiveChallenge(NSUrlSession session, NSUrlSessionTask task, NSUrlAuthenticationChallenge challenge, Action <NSUrlSessionAuthChallengeDisposition, NSUrlCredential> completionHandler)
            {
                if (challenge.ProtectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodNTLM)
                {
                    NetworkCredential credentialsToUse;

                    if (This.Credentials != null)
                    {
                        if (This.Credentials is NetworkCredential)
                        {
                            credentialsToUse = (NetworkCredential)This.Credentials;
                        }
                        else
                        {
                            var uri = this.getResponseForTask(task).Request.RequestUri;
                            credentialsToUse = This.Credentials.GetCredential(uri, "NTLM");
                        }
                        var credential = new NSUrlCredential(credentialsToUse.UserName, credentialsToUse.Password, NSUrlCredentialPersistence.ForSession);
                        completionHandler(NSUrlSessionAuthChallengeDisposition.UseCredential, credential);
                    }
                    return;
                }

                if (challenge.ProtectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodClientCertificate)
                {
                    Console.WriteLine("Client Cert!");

                    var password = "******";
                    var options  = NSDictionary.FromObjectAndKey(NSObject.FromObject(password), SecImportExport.Passphrase);

                    var path     = Path.Combine(NSBundle.MainBundle.BundlePath, "Content", "client.p12");
                    var certData = File.ReadAllBytes(path);

                    NSDictionary[] importResult;

                    X509Certificate cert = new X509Certificate(certData, password);

                    SecStatusCode statusCode     = SecImportExport.ImportPkcs12(certData, options, out importResult);
                    var           identityHandle = importResult[0][SecImportExport.Identity];
                    var           identity       = new SecIdentity(identityHandle.Handle);
                    var           certificate    = new SecCertificate(cert.GetRawCertData());

                    SecCertificate[] certificates = { certificate };
                    NSUrlCredential  credential   = NSUrlCredential.FromIdentityCertificatesPersistance(identity, certificates, NSUrlCredentialPersistence.ForSession);
                    completionHandler(NSUrlSessionAuthChallengeDisposition.UseCredential, credential);

                    return;
                }

                if (!This.customSSLVerification)
                {
                    goto doDefault;
                }

                if (challenge.ProtectionSpace.AuthenticationMethod != "NSURLAuthenticationMethodServerTrust")
                {
                    goto doDefault;
                }

                if (ServicePointManager.ServerCertificateValidationCallback == null)
                {
                    goto doDefault;
                }

                // Convert Mono Certificates to .NET certificates and build cert
                // chain from root certificate
                var serverCertChain   = challenge.ProtectionSpace.ServerSecTrust;
                var chain             = new X509Chain();
                X509Certificate2 root = null;
                var errors            = SslPolicyErrors.None;

                if (serverCertChain == null || serverCertChain.Count == 0)
                {
                    errors = SslPolicyErrors.RemoteCertificateNotAvailable;
                    goto sslErrorVerify;
                }

                if (serverCertChain.Count == 1)
                {
                    errors = SslPolicyErrors.RemoteCertificateChainErrors;
                    goto sslErrorVerify;
                }

                var netCerts = Enumerable.Range(0, serverCertChain.Count)
                               .Select(x => serverCertChain[x].ToX509Certificate2())
                               .ToArray();

                for (int i = 1; i < netCerts.Length; i++)
                {
                    chain.ChainPolicy.ExtraStore.Add(netCerts[i]);
                }

                root = netCerts[0];

                chain.ChainPolicy.RevocationFlag      = X509RevocationFlag.EntireChain;
                chain.ChainPolicy.RevocationMode      = X509RevocationMode.NoCheck;
                chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 1, 0);
                chain.ChainPolicy.VerificationFlags   = X509VerificationFlags.AllowUnknownCertificateAuthority;

                if (!chain.Build(root))
                {
                    errors = SslPolicyErrors.RemoteCertificateChainErrors;
                    goto sslErrorVerify;
                }

                var subject   = root.Subject;
                var subjectCn = cnRegex.Match(subject).Groups[1].Value;

                if (String.IsNullOrWhiteSpace(subjectCn) || !Utility.MatchHostnameToPattern(task.CurrentRequest.Url.Host, subjectCn))
                {
                    errors = SslPolicyErrors.RemoteCertificateNameMismatch;
                    goto sslErrorVerify;
                }

sslErrorVerify:
                var hostname = task.CurrentRequest.Url.Host;
                bool result = ServicePointManager.ServerCertificateValidationCallback(hostname, root, chain, errors);

                if (result)
                {
                    completionHandler(
                        NSUrlSessionAuthChallengeDisposition.UseCredential,
                        NSUrlCredential.FromTrust(challenge.ProtectionSpace.ServerSecTrust));
                }
                else
                {
                    completionHandler(NSUrlSessionAuthChallengeDisposition.CancelAuthenticationChallenge, null);
                }
                return;

doDefault:
                completionHandler(NSUrlSessionAuthChallengeDisposition.PerformDefaultHandling, challenge.ProposedCredential);
                return;
            }
コード例 #2
0
 public TableSource(string[] items)
 {
     tableItems = items;
     cData      = NSDictionary.FromObjectAndKey(NSObject.FromObject("val1"), NSObject.FromObject("key1"));
 }
コード例 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            NSDictionary cData = NSDictionary.FromObjectAndKey(NSObject.FromObject("val1"), NSObject.FromObject("key1"));

            ADBMobile.CollectLifecycleDataWithAdditionalData(cData);

            table = new UITableView(View.Bounds);             // defaults to Plain style
            string[] tableItems = new string[] {
                //config
                "version",
                "privacyStatus",
                "setPrivacyStatus - in",
                "setPrivacyStatus - out",
                "setPrivacyStatus - unknown",
                "lifetimeValue",
                "userIdentifier",
                "setUserIdentifier",
                "debugLogging",
                "setDebugLogging - true",
                "setDebugLogging - false",
                "keepLifecycleSessionAlive",
                //Analytics
                "trackState",
                "trackAction",
                "trackActionFromBackground",
                "trackLocation",
                "trackBeacon",
                "trackingClearCurrentBeacon",
                "trackLifetimeValueIncrease",
                "trackTimedActionStart",
                "trackTimedActionUpdate",
                "trackTimedActionEnd",
                "trackingTimedActionExists",
                "trackingIdentifier",
                "trackingSendQueuedHits",
                "trackingClearQueue",
                "trackingGetQueueSize",
                //Media
                "mediaCreateSettingsWithName",
                "mediaAdCreateSettingsWithName",
                "mediaOpenWithSettings",
                "mediaClose",
                "mediaPlay",
                "mediaComplete",
                "mediaStop",
                "mediaClick",
                "mediaTrack",
                //Target
                "targetLoadRequest",
                "targetCreateRequestWithName",
                "targetCreateOrderConfirmRequestWithName",
                "targetClearCookies",
                //AAM
                "audienceVisitorProfile",
                "audienceDpid",
                "audienceDpuuid",
                "audienceSetDpid",
                "audienceReset",
                "visitorMarketingCloudID",
                "visitorSyncIdentifiers",
                //4.13.0 Update
                "setAdvertisingIdentifier",
                "setPushIdentifier",
                "setAppGroup",
                "setAppExtensionType",
                "registerAdobeDataCallback",
                "trackPushMessageClickthrough",
                "trackLocalNotificationClickthrough",
                "trackAdobeDeepLink",
                "acquisitionCampaignStartForApp",
                "targetLoadRequestWithRequestLocation",
                "targetThirdPartyId",
                "targetSetThirdPartyId",
                "targetPcID",
                "targetSessionID",
                "visitorSyncIdentifiers",
                "visitorSyncIdentifiersAuthState",
                "visitorSyncIdentifierWithTypeAuthState",
                "visitorGetIDs",
                "visitorAppendToURL"
            };

            table.Source = new TableSource(tableItems);
            Add(table);
            // Perform any additional setup after loading the view, typically from a nib.
        }
コード例 #4
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            //define useragent andorid like
            string userAgent = "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version /4.0 Chrome/43.0.2357.65 Mobile Safari/537.36";

            //set default useragent
            NSDictionary dictionary = NSDictionary.FromObjectAndKey(NSObject.FromObject(userAgent), NSObject.FromObject("UserAgent"));

            NSUserDefaults.StandardUserDefaults.RegisterDefaults(dictionary);

            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }
コード例 #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            btnFbLogin.Frame = new CoreGraphics.CGRect(1, 59, 132, 44);
            SidebarController.CloseMenu(true);
            txtPassword.Text   = "123456";
            txtEmail.Text      = "*****@*****.**";
            txtEmail.Font      = UIFont.FromName("OpenSans", 14);
            txtPassword.Font   = UIFont.FromName("OpenSans", 14);
            lblSignInWith.Font = UIFont.FromName("OpenSans-Bold", 14);

            var redColoe = new UIColor((nfloat)(148 / 255.0), (nfloat)(26 / 255.0), (nfloat)(33 / 255.0), (nfloat)(1));

            btnLogin.Layer.BorderColor       = redColoe.CGColor;
            btnLogin.Layer.BorderWidth       = 1;
            btnLogin.AccessibilityIdentifier = "btnLogin";
            btnLogin.Font = UIFont.FromName("OpenSans", 14);

            btnLogin.SetTitle("SIGN IN", UIControlState.Normal);
            var text = "Virtual Event";

            var attributedString = new NSMutableAttributedString(text);

            var nsKern  = new NSString("NSKern");
            var spacing = NSObject.FromObject(3.2);
            var range   = new NSRange(0, text.Length - 1);

            attributedString.AddAttribute(nsKern, spacing, range);
            lblLogo.AttributedText = attributedString;
            lblLogo.Font           = UIFont.FromName("SFUIDisplay-Regular", 24);

            btnLogin.TouchUpInside += async delegate
            {
                if (txtEmail.Text.Trim() == "" && txtPassword.Text.Trim() == "")
                {
                    CommonUtils.AlertView("Please fill email and password.");
                }
                else if (txtEmail.Text.Trim() == "")
                {
                    CommonUtils.AlertView("Please fill email.");
                }
                else if (txtPassword.Text.Trim() == "")
                {
                    CommonUtils.AlertView("Please fill password.");
                }
                else if (txtPassword.Text.Trim() != "")
                {
                    bool valid = Regex.IsMatch(txtEmail.Text, @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9_\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", RegexOptions.ECMAScript);
                    if (!valid)
                    {
                        CommonUtils.AlertView("Please enter valid email.");
                    }
                    else
                    {
                        await UserLogin();
                    }
                }
            };

            btnFbLogin.TouchUpInside += delegate
            {
                // https://developers.facebook.com/apps/
                var auth = new OAuth2Authenticator(
                    clientId: "822879767861537",
                    scope: "",
                    authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"),
                    redirectUrl: new Uri("http://www.facebook.com/connect/login_success.html"));

                var ui = auth.GetUI();

                auth.Completed += FacebookAuth_Completed;

                PresentViewController((UIKit.UIViewController)ui, true, null);
            };



            //Profile.Notifications.ObserveDidChange(async (sender, e) =>
            //{

            //	if (e.NewProfile == null)
            //		return;

            //	model = new UserSocialLoginRequest
            //	{
            //		FirstName = e.NewProfile.FirstName,
            //		LastName = e.NewProfile.LastName,
            //		Email = "",
            //		SocialId = e.NewProfile.UserID,
            //		LoginType = (int)LoginTypes.Facebook,
            //		DeviceType = (int)EnumDeviceType.IOS,
            //		DeviceToken = "ABC"// DeviceToken
            //	};

            //	string nameLabel = e.NewProfile.Name;
            //	await UserSocialLogin(model);
            //});
            //btnFbLogin.LoginBehavior = LoginBehavior.Native;
            //btnFbLogin.ReadPermissions = readPermissions.ToArray();

            //btnFbLogin.Completed += (sender, e) =>
            //			{
            //				if (e.Error != null)
            //				{
            //					// Handle if there was an error
            //					Console.WriteLine("Error");

            //				}

            //				if (e.Result.IsCancelled)
            //				{
            //					// Handle if the user cancelled the login request
            //					Console.WriteLine("Cancel ");
            //				}

            //			};

            //// Handle actions once the user is logged out
            //btnFbLogin.LoggedOut += (sender, e) =>
            //{
            //	// Handle your logout
            //};



            ////// If you have been logged into the app before, ask for the your profile name
            //if (AccessToken.CurrentAccessToken != null)
            //{
            //	var request = new GraphRequest("/me?fields=email", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
            //	request.Start((connection, result, error) =>
            //					{
            //						// Handle if something went wrong with the request
            //						if (error != null)
            //						{
            //							//new UIAlertView("Error...", error.Description, null, "Ok", null).Show();
            //							return;
            //						}

            //						// Get your profile name



            //						var userInfo = result as NSDictionary;
            //					});
            //}


            #region Gogle Login
            //// TODO(developer) Configure the sign-in button look/feel
            //SignIn.SharedInstance.UIDelegate = this;

            //SignIn.SharedInstance.SignedIn += (sender, e) =>
            //{
            //	// Perform any operations on signed in user here.
            //	if (e.User != null && e.Error == null)
            //	{
            //		//statusText.Text = string.Format("Signed in user: {0}", e.User.Profile.Name);
            //		ToggleAuthUI();
            //	}
            //};

            //SignIn.SharedInstance.Disconnected += (sender, e) =>
            //{
            //	// Perform any operations when the user disconnects from app here.
            //	//statusText.Text = "Disconnected user";
            //	ToggleAuthUI();
            //};

            //// Automatically sign in the user.
            //SignIn.SharedInstance.SignInUserSilently();
            //ToggleAuthUI();
            #endregion
        }
コード例 #6
0
        public override void ViewDidLoad()
        {
            this.AddOption("Bar Series", LoadBarSeries);
            this.AddOption("Column Series", LoadColumnSeries);
            this.AddOption("Line Series", LoadLineSeries);
            this.AddOption("Pie Series", LoadPieSeries);
            this.AddOption("Ohlc Series", LoadFinancialSeries);

            base.ViewDidLoad();

            chart = new TKChart(this.View.Bounds);
            chart.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
            chart.AllowAnimations  = true;
            chart.Delegate         = chartDelegate;
            this.View.AddSubview(chart);

            Random r = new Random();

            columnData = new List <TKChartDataPoint> ();
            barData    = new List <TKChartDataPoint> ();
            string[] categories = new string[] { "Greetings", "Perfecto", "NearBy", "Family Store", "Fresh & Green" };
            for (int i = 0; i < categories.Length; i++)
            {
                TKChartDataPoint columnPoint = new TKChartDataPoint(new NSString(categories [i]), new NSNumber(r.Next() % 100));
                TKChartDataPoint barPoint    = new TKChartDataPoint(new NSNumber(r.Next() % 100), NSObject.FromObject(categories[i]));
                columnData.Add(columnPoint);
                barData.Add(barPoint);
            }

            lineData = new List <TKChartDataPoint> ();
            int[] lineValues = new int[] { 82, 68, 83, 46, 32, 75, 8, 54, 47, 51 };
            for (int i = 0; i < lineValues.Length; i++)
            {
                TKChartDataPoint point = new TKChartDataPoint(new NSNumber(i), new NSNumber(lineValues [i]));
                lineData.Add(point);
            }

            pieDonutData = new List <TKChartDataPoint> ();
            pieDonutData.Add(new TKChartDataPoint(new NSNumber(20), null, "Google"));
            pieDonutData.Add(new TKChartDataPoint(new NSNumber(30), null, "Apple"));
            pieDonutData.Add(new TKChartDataPoint(new NSNumber(10), null, "Microsoft"));
            pieDonutData.Add(new TKChartDataPoint(new NSNumber(5), null, "IBM"));
            pieDonutData.Add(new TKChartDataPoint(new NSNumber(8), null, "Oracle"));

            int[] openPrices  = new int[] { 100, 125, 69, 99, 140, 125 };
            int[] closePrices = new int[] { 85, 65, 135, 120, 80, 136 };
            int[] lowPrices   = new int[] { 50, 60, 65, 55, 75, 90 };
            int[] highPrices  = new int[] { 129, 142, 141, 123, 150, 161 };
            ohlcData = new List <TKChartFinancialDataPoint> ();
            for (int i = 0; i < openPrices.Length; i++)
            {
                NSDate   date  = NSDate.FromTimeIntervalSinceNow(60 * 60 * 24 * i);
                NSNumber open  = new NSNumber(openPrices [i]);
                NSNumber high  = new NSNumber(highPrices [i]);
                NSNumber low   = new NSNumber(lowPrices [i]);
                NSNumber close = new NSNumber(closePrices [i]);
                TKChartFinancialDataPoint point = TKChartFinancialDataPoint.DataPoint(date, open, high, low, close);
                ohlcData.Add(point);
            }

            this.LoadBarSeries();
        }
コード例 #7
0
ファイル: ReadOnlineData.cs プロジェクト: tiffvan/Coder
        public static async Task Read()
        {
            AppData.onlineLST = new List <ChatListClass>();

            if (AppData.auth.CurrentUser == null)
            {
                return;
            }

            bool done = false;

            AppData.DataNode.GetChild(AppData.curUser.Uid).ObserveSingleEvent(DataEventType.Value, (snapshot) =>
            {
                if (!snapshot.HasChildren)
                {
                    return;
                }

                var allChatsData = snapshot.GetValue <NSDictionary>();

                if (allChatsData.Count == 0)
                {
                    return;
                }
                if (!(allChatsData.IsKindOfClass(new ObjCRuntime.Class(typeof(NSDictionary)))))
                {
                    return;
                }

                foreach (NSDictionary eachChatAllVals in allChatsData.Values)
                {
                    NSString chatName = (NSString)eachChatAllVals.ValueForKey((NSString)"chatName");

                    List <MessageClass> itemsInChat = new List <MessageClass>();

                    if (eachChatAllVals.ValueForKey((NSString)"items") != null)
                    {
                        if ((eachChatAllVals.ValueForKey((NSString)"items")).IsKindOfClass(new ObjCRuntime.Class(typeof(NSDictionary))))
                        {
                            NSDictionary itemsOfChatVals = (NSDictionary)NSObject.FromObject(eachChatAllVals.ValueForKey((NSString)"items"));

                            for (int j = 0; j < (int)itemsOfChatVals.Values.Length; j++)
                            {
                                NSDictionary eachItemVals = (NSDictionary)NSObject.FromObject(itemsOfChatVals.Values[j]);
                                var fetchedItemName       = (NSString)eachItemVals.ValueForKey((NSString)"itemName");
                                var fetchedItemTime       = (NSString)eachItemVals.ValueForKey((NSString)"itemTime");

                                itemsInChat.Add(new MessageClass
                                {
                                    ItemName = fetchedItemName,
                                    ItemTime = DateTime.Parse(fetchedItemTime)
                                });
                            }
                        }
                    }

                    AppData.onlineLST.Add(new ChatListClass
                    {
                        ChatName  = chatName,
                        ChatOwner = AppData.curUser,
                        ChatItems = itemsInChat
                    });
                }
                done = true;
            });
            while (!done)
            {
                await Task.Delay(50);
            }
        }
コード例 #8
0
 void AddDataPointsForChart(String month, Double value)
 {
     DataPoints.Add(new SFChartDataPoint(NSObject.FromObject(month), NSObject.FromObject(value)));
 }
コード例 #9
0
 void AddDataPointsForChart(String xValue, Double open, Double high, Double low, Double close)
 {
     DataPoints.Add(new SFChartDataPoint(NSObject.FromObject(xValue), NSObject.FromObject(open),
                                         NSObject.FromObject(high), NSObject.FromObject(low), NSObject.FromObject(close)));
 }
コード例 #10
0
        public NSObject GroupItemAtIndex(int index)
        {
            string itemTitle = GroupItems [index];

            return(NSObject.FromObject(itemTitle));
        }
コード例 #11
0
        private UILocalNotification createNativeNotification(LocalNotification notification)
        {
            var nativeNotification = new UILocalNotification
            {
                AlertAction = notification.Title,
                AlertBody   = notification.Text,
                    #if __UNIFIED__
                FireDate = notification.NotifyTime.DateTimeToNSDate(),
                    #else
                FireDate = notification.NotifyTime,
                    #endif
                UserInfo = NSDictionary.FromObjectAndKey(NSObject.FromObject(notification.Id), NSObject.FromObject(NotificationKey))
            };

            return(nativeNotification);
        }
コード例 #12
0
ファイル: WebView.iOS.cs プロジェクト: neoayi/Uno
        partial void NavigateWithHttpRequestMessagePartial(HttpRequestMessage requestMessage)
        {
            if (requestMessage == null)
            {
                this.Log().Warn("HttpRequestMessage is null. Please make sure the http request is complete.");
                return;
            }

            if (!this.VerifyNativeWebViewAvailability())
            {
                return;
            }

            var urlRequest        = new NSMutableUrlRequest(requestMessage.RequestUri);
            var headerDictionnary = new NSMutableDictionary();

            foreach (var header in requestMessage.Headers)
            {
                headerDictionnary.AddDistinct(new KeyValuePair <NSObject, NSObject>(NSObject.FromObject(header.Key), NSObject.FromObject(header.Value.JoinBy(", "))));
            }

            urlRequest.Headers = headerDictionnary;

            _nativeWebView.LoadRequest(urlRequest);
        }
コード例 #13
0
        public NativeMessageHandler(bool throwOnCaptiveNetwork, TLSConfig tLSConfig, NativeCookieHandler cookieHandler = null, IWebProxy proxy = null)
        {
            this.throwOnCaptiveNetwork = throwOnCaptiveNetwork;

            var configuration = NSUrlSessionConfiguration.DefaultSessionConfiguration;

            this.TLSConfig = tLSConfig;

            // System.Net.ServicePointManager.SecurityProtocol provides a mechanism for specifying supported protocol types
            // for System.Net. Since iOS only provides an API for a minimum and maximum protocol we are not able to port
            // this configuration directly and instead use the specified minimum value when one is specified.
            configuration.TLSMinimumSupportedProtocol = SslProtocol.Tls_1_2;

            if (!TLSConfig.DangerousAcceptAnyServerCertificateValidator &&
                TLSConfig.Pins != null &&
                TLSConfig.Pins.Count > 0 &&
                TLSConfig.Pins.FirstOrDefault(p => p.PublicKeys.Count() > 0) != null)
            {
                this.PinningMode = "PublicKeysOnly";

                this.CertificatePinner = new CertificatePinner();

                foreach (var pin in TLSConfig.Pins)
                {
                    this.CertificatePinner.AddPins(pin.Hostname, pin.PublicKeys);
                }
            }

            SetClientCertificate(TLSConfig.ClientCertificate);

            // NSUrlSessionConfiguration.DefaultSessionConfiguration uses the default NSHttpCookieStorage.SharedStorage

            // PR: Proxy has been supported on iOS #19
            if (proxy != null && proxy is WebProxy)
            {
                var webProxy = proxy as WebProxy;

                NSObject[] values =
                {
                    NSObject.FromObject(webProxy.Address.Host),
                    NSNumber.FromInt32(webProxy.Address.Port),
                    NSNumber.FromInt32(1)
                };

                NSObject[] keys =
                {
                    NSObject.FromObject("HTTPSProxy"),
                    NSObject.FromObject("HTTPSPort"),
                    NSObject.FromObject("HTTPSEnable")
                };

                var proxyDict = NSDictionary.FromObjectsAndKeys(values, keys);
                configuration.ConnectionProxyDictionary = proxyDict;

                if (webProxy.Credentials != null)
                {
                    var credentials = (NetworkCredential)webProxy.Credentials;

                    var authData        = string.Format("{0}:{1}", credentials.UserName, credentials.Password);
                    var authHeaderValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(authData));

                    NSObject[] hValues =
                    {
                        NSObject.FromObject(authHeaderValue)
                    };

                    NSObject[] hKeys =
                    {
                        NSObject.FromObject("Proxy-Authorization")
                    };

                    var headers = NSDictionary.FromObjectsAndKeys(hValues, hKeys);

                    configuration.HttpAdditionalHeaders = headers;
                }
            }

            var urlSessionDelegate = new DataTaskDelegate(this);

            session = NSUrlSession.FromConfiguration(configuration, (INSUrlSessionDelegate)urlSessionDelegate, null);
        }
コード例 #14
0
 public override NSObject ObjectValueForItem(NSComboBox comboBox, int index)
 {
     return(NSObject.FromObject((_filenames [index]).Name));
 }
コード例 #15
0
        internal NSDictionary ToDictionary()
        {
            // We now have 11 possible keys so begining with 6 *might* be optimal
            List <NSObject> keys   = new List <NSObject> (6);
            List <NSObject> values = new List <NSObject> (6);

            if (CIDetector.Accuracy != null)
            {
                keys.Add(CIDetector.Accuracy);
                values.Add(Accuracy == FaceDetectorAccuracy.High ? CIDetector.AccuracyHigh :CIDetector.AccuracyLow);
            }

            // MinFeatureSize exists only in iOS6+, before this the field is null (and would throw if used)
            if (CIDetector.MinFeatureSize != null && MinFeatureSize != null)
            {
                keys.Add(CIDetector.MinFeatureSize);
                values.Add(new NSNumber(MinFeatureSize.Value));
            }

            // Tracking exists only in iOS6+, before this the field is null (and would throw if used)
            if (CIDetector.Tracking != null && TrackingEnabled != null)
            {
                keys.Add(CIDetector.Tracking);
                values.Add(NSObject.FromObject(TrackingEnabled.Value));
            }

            // EyeBlink exists only in iOS7+, before this the field is null (and would throw if used)
            if (CIDetector.EyeBlink != null && EyeBlink != null)
            {
                keys.Add(CIDetector.EyeBlink);
                values.Add(NSObject.FromObject(EyeBlink.Value));
            }

            // Smile exists only in iOS7+, before this the field is null (and would throw if used)
            if (CIDetector.Smile != null && Smile != null)
            {
                keys.Add(CIDetector.Smile);
                values.Add(NSObject.FromObject(Smile.Value));
            }
            // AspectRation exists only in iOS8+, before this the field is null (and would throw if used)
            if (CIDetector.AspectRatio != null && AspectRatio != null)
            {
                keys.Add(CIDetector.AspectRatio);
                values.Add(new NSNumber(AspectRatio.Value));
            }
            // FocalLength exists only in iOS8+, before this the field is null (and would throw if used)
            if (CIDetector.FocalLength != null && FocalLength != null)
            {
                keys.Add(CIDetector.FocalLength);
                values.Add(new NSNumber(FocalLength.Value));
            }
            if (CIDetector.NumberOfAngles != null && NumberOfAngles != null)
            {
                keys.Add(CIDetector.NumberOfAngles);
                values.Add(new NSNumber(NumberOfAngles.Value));
            }

            if (CIDetector.ReturnSubFeatures != null && ReturnSubFeatures != null)
            {
                keys.Add(CIDetector.ReturnSubFeatures);
                values.Add(new NSNumber(ReturnSubFeatures.Value));
            }

            if (CIDetector.ImageOrientation != null && ImageOrientation != null)
            {
                keys.Add(CIDetector.ImageOrientation);
                values.Add(new NSNumber((int)ImageOrientation.Value));
            }

            if (CIDetector.MaxFeatureCount != null && MaxFeatureCount != null)
            {
                keys.Add(CIDetector.MaxFeatureCount);
                values.Add(new NSNumber((int)MaxFeatureCount.Value));
            }

            return(NSDictionary.FromObjectsAndKeys(values.ToArray(), keys.ToArray()));
        }
コード例 #16
0
ファイル: ComboBoxEntryBackend.cs プロジェクト: joncham/xwt
 public override NSObject ObjectValueForItem(NSComboBox comboBox, int index)
 {
     return(NSObject.FromObject(source.GetValue(index, 0)));
 }
コード例 #17
0
        public void DidOutputMetadataObjects(AVCaptureMetadataOutput captureOutput, AVMetadataObject[] faces, AVCaptureConnection connection)
        {
            List <int> unseen = faceViews.Keys.ToList();
            List <int> seen   = new List <int> ();

            CATransaction.Begin();
            CATransaction.SetValueForKey(NSObject.FromObject(true), (NSString)(CATransaction.DisableActions.ToString()));

            foreach (var face in faces)
            {
                // HACK: int faceId = (face as AVMetadataFaceObject).FaceID;
                int faceId = (int)(face as AVMetadataFaceObject).FaceID;
                unseen.Remove(faceId);
                seen.Add(faceId);

                FaceView view;
                if (faceViews.ContainsKey(faceId))
                {
                    view = faceViews [faceId];
                }
                else
                {
                    view = new FaceView();
                    view.Layer.CornerRadius = 10;
                    view.Layer.BorderWidth  = 3;
                    view.Layer.BorderColor  = UIColor.Green.CGColor;
                    previewView.AddSubview(view);
                    faceViews.Add(faceId, view);
                    view.Id       = faceId;
                    view.Callback = TouchCallBack;
                    if (lockedFaceID != null)
                    {
                        view.Alpha = 0;
                    }
                }

                AVMetadataFaceObject adjusted = (AVMetadataFaceObject)(previewView.Layer as AVCaptureVideoPreviewLayer).GetTransformedMetadataObject(face);
                view.Frame = adjusted.Bounds;
            }

            foreach (int faceId in unseen)
            {
                FaceView view = faceViews [faceId];
                view.RemoveFromSuperview();
                faceViews.Remove(faceId);
                if (faceId == lockedFaceID)
                {
                    clearLockedFace();
                }
            }

            if (lockedFaceID != null)
            {
                FaceView view = faceViews [lockedFaceID.GetValueOrDefault()];
                // HACK: Cast resulting nfloat to float
                // float size = (float)Math.Max (view.Frame.Size.Width, view.Frame.Size.Height) / device.VideoZoomFactor;
                float size      = (float)(Math.Max(view.Frame.Size.Width, view.Frame.Size.Height) / device.VideoZoomFactor);
                float zoomDelta = lockedFaceSize / size;
                float lockTime  = (float)(CATransition.CurrentMediaTime() - this.lockTime);
                float zoomRate  = (float)(Math.Log(zoomDelta) / lockTime);
                if (Math.Abs(zoomDelta) > 0.1)
                {
                    device.RampToVideoZoom(zoomRate > 0 ? MaxZoom : 1, zoomRate);
                }
            }

            CATransaction.Commit();
        }
コード例 #18
0
        /// <summary>
        /// Share a message with compatible services
        /// </summary>
        /// <param name="message">Message to share</param>
        /// <param name="options">Platform specific options</param>
        /// <param name="excludedActivityTypes">UIActivityTypes that should not be displayed</param>
        /// <returns>True if the operation was successful, false otherwise</returns>
        private async Task <bool> Share(ShareMessage message, ShareOptions options = null, params NSString[] excludedActivityTypes)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            try
            {
                // create activity items
                var items = new List <NSObject>();
                if (message.Text != null)
                {
                    items.Add(new ShareActivityItemSource(new NSString(message.Text), message.Title));
                }
                if (message.Url != null)
                {
                    items.Add(new ShareActivityItemSource(NSUrl.FromString(message.Url), message.Title));
                }
                if (message.Image != null)
                {
                    var handler = new ImageLoaderSourceHandler();

                    var uiImage = await handler.LoadImageAsync(message.Image);

                    items.Add(NSObject.FromObject(uiImage));
                }

                // create activity controller
                var activityController = new UIActivityViewController(items.ToArray(), null);

                // set excluded activity types
                if (excludedActivityTypes == null)
                {
                    // use ShareOptions.ExcludedUIActivityTypes
                    excludedActivityTypes = options?.ExcludedUIActivityTypes?.Select(x => GetUIActivityType(x)).Where(x => x != null).ToArray();
                }

                if (excludedActivityTypes == null)
                {
                    // use ShareImplementation.ExcludedUIActivityTypes
                    excludedActivityTypes = ExcludedUIActivityTypes?.ToArray();
                }

                if (excludedActivityTypes != null && excludedActivityTypes.Length > 0)
                {
                    activityController.ExcludedActivityTypes = excludedActivityTypes;
                }

                // show activity controller
                var vc = GetVisibleViewController();

                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    if (activityController.PopoverPresentationController != null)
                    {
                        activityController.PopoverPresentationController.SourceView = vc.View;

                        var rect = options?.PopoverAnchorRectangle;
                        if (rect != null)
                        {
                            activityController.PopoverPresentationController.SourceRect = new CGRect(rect.X, rect.Y, rect.Width, rect.Height);
                        }
                    }
                }

                await vc.PresentViewControllerAsync(activityController, true);

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unable to share: " + ex.Message);
                return(false);
            }
        }
コード例 #19
0
 public override NSObject ObjectValueForItem(NSComboBox comboBox, nint index)
 {
     return(NSObject.FromObject(ops [(int)index]));
 }
コード例 #20
0
        /// <summary>
        /// Cancel a local notification
        /// </summary>
        /// <param name="id">Id of the notification to cancel</param>
        public void Cancel(int id)
        {
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                UNUserNotificationCenter.Current.RemovePendingNotificationRequests(new string[] { id.ToString() });
                UNUserNotificationCenter.Current.RemoveDeliveredNotifications(new string[] { id.ToString() });
            }
            else
            {
                var notifications = UIApplication.SharedApplication.ScheduledLocalNotifications;
                var notification  = notifications.Where(n => n.UserInfo.ContainsKey(NSObject.FromObject(NotificationKey)))
                                    .FirstOrDefault(n => n.UserInfo[NotificationKey].Equals(NSObject.FromObject(id)));

                if (notification != null)
                {
                    UIApplication.SharedApplication.CancelLocalNotification(notification);
                }
            }
        }
コード例 #21
0
 void AddDataPointsForChart(String XValue, Double YValue, Double YValue1, Double YValue2)
 {
     DataPoints.Add(new SFChartDataPoint(NSObject.FromObject(XValue), NSObject.FromObject(YValue)));
     DataPoints1.Add(new SFChartDataPoint(NSObject.FromObject(XValue), NSObject.FromObject(YValue1)));
     DataPoints2.Add(new SFChartDataPoint(NSObject.FromObject(XValue), NSObject.FromObject(YValue2)));
 }
コード例 #22
0
ファイル: ComboBoxEntryBackend.cs プロジェクト: vipyami/xwt
 public override NSObject ObjectValueForItem(NSComboBox comboBox, nint index)
 {
     SetComboBox(comboBox);
     return(NSObject.FromObject(source.GetValue((int)index, TextColumn)));
 }
コード例 #23
0
        public void Cancel(int id)
        {
            var notifications = UIApplication.SharedApplication.ScheduledLocalNotifications;
            var notification  = notifications.Where(n => n.UserInfo.ContainsKey(NSObject.FromObject(NotificationKey)))
                                .FirstOrDefault(n => n.UserInfo[NotificationKey].Equals(NSObject.FromObject(id)));

            UIApplication.SharedApplication.CancelAllLocalNotifications();
            if (notification != null)
            {
                UIApplication.SharedApplication.CancelLocalNotification(notification);
                UIApplication.SharedApplication.CancelAllLocalNotifications();
            }
        }
コード例 #24
0
 public override MonoMac.Foundation.NSObject GetObjectValue(NSTableView tableView, NSTableColumn tableColumn, int row)
 {
     return(NSObject.FromObject(row));
 }
コード例 #25
0
 void UpdateShadowImages()
 {
     NavigationBar.SetValueForKey(NSObject.FromObject(true), new NSString("hidesShadow"));
 }
コード例 #26
0
 public void QueueFile(string fileName)
 {
     if (string.IsNullOrWhiteSpace(fileName))
     {
         return;
     }
     using (var url = NSUrl.FromString(fileName))
     {
         var asset = AVAsset.FromUrl(url);
         var playerItem = AVPlayerItem.FromAsset(asset);
         if (Player == null)
         {
             Player = AVPlayer.FromPlayerItem(playerItem);
             if (Player == null)
             {
                 return;
             }
             else
             {
                 NSNotificationCenter.DefaultCenter.AddObserver(AVPlayerItem.DidPlayToEndTimeNotification, OnPlayerDidFinishPlaying, NSObject.FromObject(playerItem));
             }
         }
     }
 }
コード例 #27
0
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                Console.WriteLine("Row value " + indexPath);

                switch (indexPath.Row)
                {
                //							Config
                //							"version",
                //							"privacyStatus",
                //							"setPrivacyStatus - in",
                //							"setPrivacyStatus - out",
                //							"setPrivacyStatus - unknown",
                //							"lifetimeValue",
                //							"userIdentifier",
                //							"setUserIdentifier",
                //							"debugLogging",
                //							"setDebugLogging - true",
                //							"setDebugLogging - false",
                //							"keepLifecycleSessionAlive",
                case 0:
                    new UIAlertView("Version", ADBMobile.Version(), null, "OK", null).Show();
                    break;

                case 1:
                    new UIAlertView("PrivacyStatus", ADBMobile.PrivacyStatus().ToString(), null, "OK", null).Show();
                    break;

                case 2:
                    ADBMobile.SetPrivacyStatus(ADBMobilePrivacyStatus.OptIn);
                    break;

                case 3:
                    ADBMobile.SetPrivacyStatus(ADBMobilePrivacyStatus.OptOut);
                    break;

                case 4:
                    ADBMobile.SetPrivacyStatus(ADBMobilePrivacyStatus.Unknown);
                    break;

                case 5:
                    new UIAlertView("LifetimeValue", ADBMobile.LifetimeValue().ToString(), null, "OK", null).Show();
                    break;

                case 6:
                    new UIAlertView("UserIdentifier", ADBMobile.UserIdentifier(), null, "OK", null).Show();
                    break;

                case 7:
                    ADBMobile.SetUserIdentifier("customUserIdentifier");
                    break;

                case 8:
                    new UIAlertView("DebugLogging", ADBMobile.DebugLogging().ToString(), null, "OK", null).Show();
                    break;

                case 9:
                    ADBMobile.SetDebugLogging(true);
                    break;

                case 10:
                    ADBMobile.SetDebugLogging(false);
                    break;

                case 11:
                    ADBMobile.KeepLifecycleSessionAlive();
                    break;

                //	Analytics
                case 12:                        //				"trackState",
                    ADBMobile.TrackState("stateName", cData);
                    break;

                case 13:                        //				"trackAction",
                    ADBMobile.TrackAction("actionName", cData);
                    break;

                case 14:                        //				"trackActionFromBackground",
                    ADBMobile.TrackActionFromBackground("actionNameFromBackground", cData);
                    break;

                case 15:                         //				"trackLocation",
                    CoreLocation.CLLocation l = new CoreLocation.CLLocation(111.111, 44.156);
                    ADBMobile.TrackLocation(l, null);
                    break;

                case 16:                         //				"trackBeacon", //doesn't work on iOS 10
                                                 //CoreLocation.CLBeacon b = new CoreLocation.CLBeacon();
                                                 //b.SetValueForKey(new NSNumber(1), new NSString("major"));
                                                 //b.SetValueForKey(new NSNumber(1), new NSString("minor"));
                                                 //b.SetValueForKey(new NSNumber(1), new NSString("proximity"));
                                                 //b.SetValueForKey(new NSUuid("5a2bf809-992f-42c2-8590-6793ecbe2437"), new NSString("proximityUUID"));

                    //ADBMobile.TrackBeacon(b, null);
                    break;

                case 17:                         // trackingClearCurrentBeacon
                    ADBMobile.TrackingClearCurrentBeacon();
                    break;

                case 18:                         // trackLifetimeValueIncrease
                    ADBMobile.TrackLifetimeValueIncrease(new NSDecimalNumber(10.4), cData);
                    break;

                case 19:                         // trackTimedActionStart
                    ADBMobile.TrackTimedActionStart("timedAction", cData);
                    break;

                case 20:                         // trackTimedActionUpdate
                    NSDictionary updatedData = NSDictionary.FromObjectAndKey(NSObject.FromObject("val2"), NSObject.FromObject("key2"));
                    ADBMobile.TrackTimedActionUpdate("timedAction", updatedData);
                    break;

                case 21:                         // trackTimedActionEnd
                    ADBMobile.TrackTimedActionEnd("timedAction", (double arg1, double arg2, NSMutableDictionary arg3) =>
                    {
                        return(true);
                    });
                    break;

                case 22:                         // trackTimedActionExists
                    new UIAlertView("TrackingTimedActionExists", ADBMobile.TrackingTimedActionExists("timedAction").ToString(), null, "OK", null).Show();
                    break;

                case 23:                         // trackIdentifier
                    new UIAlertView("TrackingIdentifier", ADBMobile.TrackingIdentifier(), null, "OK", null).Show();
                    break;

                case 24:                         // trackSendQueuedHits
                    ADBMobile.TrackingSendQueuedHits();
                    break;

                case 25:                         // trackingClearQueue
                    ADBMobile.TrackingClearQueue();
                    break;

                case 26:                         // trackingGetQueueSize
                    new UIAlertView("TrackingGetQueueSize", ADBMobile.TrackingGetQueueSize().ToString(), null, "OK", null).Show();
                    break;

                //	Media
                case 27:                         // mediaCreateSettingsWithName
                    settings            = ADBMobile.MediaCreateSettings("name1", 10, "playerName1", "playerID1");
                    settings.Milestones = "25,50,75";
                    break;

                case 28:                         // mediaAdCreateSettingsWithName
                    ADBMobile.MediaAdCreateSettings("adName1", 2, "playerName1", "name1", "podName1", 4, "CPM1");
                    break;

                case 29:                         // mediaOpenWithSettings
                    ADBMobile.MediaOpenWithSettings(settings, (state) =>
                    {
                        Console.WriteLine(state.Name);
                    });
                    break;

                case 30:                         //	mediaClose
                    if (settings.Name != null)
                    {
                        ADBMobile.MediaClose(settings.Name);
                    }
                    break;

                case 31:                         //	mediaPlay
                    if (settings.Name != null)
                    {
                        ADBMobile.MediaPlay(settings.Name, 0);
                    }
                    break;

                case 32:                         // mediaComplete
                    if (settings.Name != null)
                    {
                        ADBMobile.MediaComplete(settings.Name, 5);
                    }
                    break;

                case 33:                         // mediaStop
                    if (settings.Name != null)
                    {
                        ADBMobile.MediaStop(settings.Name, 3);
                    }
                    break;

                case 34:                         // mediaClick
                    if (settings.Name != null)
                    {
                        ADBMobile.MediaClick(settings.Name, 3);
                    }
                    break;

                case 35:                         // mediaTrack
                    if (settings.Name != null)
                    {
                        ADBMobile.MediaTrack(settings.Name, null);
                    }
                    break;

                // Target
                case 36:                         //	targetLoadRequest
                    ADBMobile.TargetLoadRequest(req, (context) =>
                    {
                        Console.WriteLine(context);
                    });
                    break;

                case 37:                         //					"targetCreateRequestWithName",
                    NSDictionary dict = NSDictionary.FromObjectAndKey(NSObject.FromObject("value2"), NSObject.FromObject("key1"));
                    req = ADBMobile.TargetCreateRequest("iOSTest", "defGal", dict);
                    break;

                case 38:                         //					"targetCreateOrderConfirmRequestWithName",
                    ADBMobile.TargetCreateOrderConfirmRequest("myOrder", "12345", "29.41", "cool stuff", null);
                    break;

                case 39:                         //					"targetClearCookies",
                    ADBMobile.TargetClearCookies();
                    break;

                // AAM
                case 40:                         //					"audienceVisitorProfile",
                    new UIAlertView("AudienceVisitorProfile", ADBMobile.AudienceVisitorProfile() != null ? ADBMobile.AudienceVisitorProfile().ToString() : "null", null, "OK", null).Show();
                    break;

                case 41:                         //					"audienceDpid",
                    new UIAlertView("AudienceDpid", ADBMobile.AudienceDpid(), null, "OK", null).Show();
                    break;

                case 42:                         //					"audienceDpuuid",
                    new UIAlertView("AudienceDpuuid", ADBMobile.AudienceDpuuid(), null, "OK", null).Show();
                    break;

                case 43:                         //					"audienceSetDpid",
                    ADBMobile.AudienceSetDpidAndDpuuid("testDppid", "testDpuuid");
                    break;

                case 44:                         //					"audienceSignalWithData",
                    //					"audienceReset",
                    ADBMobile.AudienceReset();
                    break;

                case 45:
                    //					"visitorMarketingCloudID",
                    new UIAlertView("VisitorMarketingCloudID", ADBMobile.VisitorMarketingCloudID(), null, "OK", null).Show();
                    break;

                case 46:
                    //					"visitorSyncIdentifiers",
                    NSDictionary vidDict = NSDictionary.FromObjectAndKey(NSObject.FromObject("value2"), NSObject.FromObject("pushID"));
                    ADBMobile.VisitorSyncIdentifiers(vidDict);
                    break;

                case 47:                         // "setAdvertisingIdentifier",
                    ADBMobile.SetAdvertisingIdentifier("testAdid");
                    break;

                case 48:                         // "setPushIdentifier",
                    ADBMobile.SetPushIdentifier(NSData.FromString("testPushId"));
                    break;

                case 49:                         // "setAppGroup",
                    ADBMobile.SetAppGroup("testAppGroup");
                    break;

                case 50:                         // "setAppExtensionType"
                    ADBMobile.SetAppExtensionType(ADBMobileAppExtensionType.Regular);
                    break;

                case 51:                         // "registerAdobeDataCallback"
                    ADBMobile.RegisterAdobeDataCallback((adobeMobileDataEvent, callbackData) =>
                    {
                        Console.WriteLine("event: " + adobeMobileDataEvent + "\ndata: " + callbackData);
                    });
                    break;

                case 52:                         // "trackPushMessageClickthrough"
                    ADBMobile.TrackPushMessageClickThrough(NSDictionary.FromObjectAndKey(NSObject.FromObject("97f8db20-bb28-4c1a-8cda-78c6ba98f87d"), NSObject.FromObject("adb_m_id")));
                    break;

                case 53:                         // "trackLocalNotificationClickthrough"
                    ADBMobile.TrackLocalNotificationClickThrough(NSDictionary.FromObjectAndKey(NSObject.FromObject("97f8db20-bb28-4c1a-8cda-78c6ba98f87d"), NSObject.FromObject("adb_m_id")));
                    break;

                case 54:                         // "trackAdobeDeepLink"
                    ADBMobile.TrackAdobeDeepLink(NSUrl.FromString("https://adobe.com?a.deeplink.id=12345678"));
                    break;

                case 55:                         // "acquisitionCampaignStartForApp"
                    ADBMobile.AcquisitionCampaignStartForApp("com.adobe.test", NSDictionary.FromObjectAndKey(NSObject.FromObject("value"), NSObject.FromObject("key")));
                    break;

                case 56:                         // "targetLoadRequestWithRequestLocation"
                    ADBMobile.TargetLoadRequest("someMbox",
                                                "defaultContent",
                                                NSDictionary.FromObjectAndKey(NSObject.FromObject("value"), NSObject.FromObject("key")),
                                                NSDictionary.FromObjectAndKey(NSObject.FromObject("value"), NSObject.FromObject("key")),
                                                NSDictionary.FromObjectAndKey(NSObject.FromObject("value"), NSObject.FromObject("key")),
                                                NSDictionary.FromObjectAndKey(NSObject.FromObject("value"), NSObject.FromObject("key")),
                                                (context) =>
                    {
                        Console.WriteLine(context);
                    });
                    break;

                case 57:                         // "targetThirdPartyId"
                    new UIAlertView("target thirdPartyId", ADBMobile.TargetThirdPartyID(), null, "OK", null).Show();
                    break;

                case 58:                         // "targetSetThirdPartyId"
                    ADBMobile.TargetSetThirdPartyID("testThirdPartyId");
                    break;

                case 59:                         // "targetPcID"
                    new UIAlertView("target PcID", ADBMobile.TargetPcID(), null, "OK", null).Show();
                    break;

                case 60:                         // "targetSessionID"
                    new UIAlertView("target SessionID", ADBMobile.TargetSessionID(), null, "OK", null).Show();
                    break;

                case 61:                         // "visitorSyncIdentifiers"
                    ADBMobile.VisitorSyncIdentifier("idType", "identifier0", ADBMobileVisitorAuthenticationState.Authenticated);
                    break;

                case 62:                         // "visitorSyncIdentifiersAuthState"
                    ADBMobile.VisitorSyncIdentifiers(NSDictionary.FromObjectAndKey(NSObject.FromObject("value"), NSObject.FromObject("key")));
                    break;

                case 63:                         // "visitorSyncIdentifierWithTypeAuthState"
                    ADBMobile.VisitorSyncIdentifiers(NSDictionary.FromObjectAndKey(NSObject.FromObject("value"), NSObject.FromObject("key")), ADBMobileVisitorAuthenticationState.Unknown);
                    break;

                case 64:                         // "visitorGetIDs"
                    new UIAlertView("visitor ids", ADBMobile.VisitorGetIDs().ToString(), null, "OK", null).Show();
                    break;

                case 65:                         // "visitorAppendToURL"
                    new UIAlertView("visitor appendToURL", ADBMobile.VisitorAppendToURL(NSUrl.FromString("https://adobe.com")).ToString(), null, "OK", null).Show();
                    break;

                default:
                    new UIAlertView("Option Invalid", "Could not find the API!", null, "OK", null).Show();
                    break;
                }

                tableView.DeselectRow(indexPath, true);                 // normal iOS behaviour is to remove the blue highlight
            }
コード例 #28
0
        private static UIImageView CreateAnimatedImageView(CGImageSource imageSource, UIImageView imageView = null)
        {
            var frameCount = imageSource.ImageCount;

            var frameImages    = new List <NSObject>(Convert.ToInt32(frameCount));
            var frameCGImages  = new List <CGImage>(Convert.ToInt32(frameCount));
            var frameDurations = new List <double>(Convert.ToInt32(frameCount));

            var totalFrameDuration = 0.0;

            for (int i = 0; i < frameCount; i++)
            {
                var frameImage = imageSource.CreateImage(i, null);

                frameCGImages.Add(frameImage);
                frameImages.Add(NSObject.FromObject(frameImage));

                var properties = imageSource.GetProperties(i, null);
                var duration   = properties.Dictionary["{GIF}"];
                var delayTime  = duration.ValueForKey(new NSString("DelayTime"));
                duration.Dispose();
                var realDuration = double.Parse(delayTime.ToString());
                frameDurations.Add(realDuration);
                totalFrameDuration += realDuration;
                frameImage.Dispose();
            }

            var      framePercentageDurations       = new List <NSNumber>(Convert.ToInt32(frameCount));
            var      framePercentageDurationsDouble = new List <double>(Convert.ToInt32(frameCount));
            NSNumber currentDurationPercentage      = 0.0f;
            double   currentDurationDouble          = 0.0f;

            for (int i = 0; i < frameCount; i++)
            {
                if (i != 0)
                {
                    var previousDuration           = frameDurations[i - 1];
                    var previousDurationPercentage = framePercentageDurationsDouble[i - 1];

                    var number = previousDurationPercentage + (previousDuration / totalFrameDuration);
                    currentDurationDouble     = number;
                    currentDurationPercentage = new NSNumber(number);
                }
                framePercentageDurationsDouble.Add(currentDurationDouble);
                framePercentageDurations.Add(currentDurationPercentage);
            }

            var imageSourceProperties    = imageSource.GetProperties(null);
            var imageSourceGIFProperties = imageSourceProperties.Dictionary["{GIF}"];
            var loopCount            = imageSourceGIFProperties.ValueForKey(new NSString("LoopCount"));
            var imageSourceLoopCount = float.Parse(loopCount.ToString());
            var frameAnimation       = new CAKeyFrameAnimation();

            frameAnimation.KeyPath = "contents";
            if (imageSourceLoopCount <= 0.0f)
            {
                frameAnimation.RepeatCount = float.MaxValue;
            }
            else
            {
                frameAnimation.RepeatCount = imageSourceLoopCount;
            }

            imageSourceGIFProperties.Dispose();


            frameAnimation.CalculationMode     = CAAnimation.AnimationDescrete;
            frameAnimation.Values              = frameImages.ToArray();
            frameAnimation.Duration            = totalFrameDuration;
            frameAnimation.KeyTimes            = framePercentageDurations.ToArray();
            frameAnimation.RemovedOnCompletion = false;
            var firstFrame = frameCGImages[0];

            if (imageView == null)
            {
                imageView = new UIImageView(new RectangleF(0.0f, 0.0f, firstFrame.Width, firstFrame.Height));
            }
            else
            {
                imageView.Layer.RemoveAllAnimations();
            }

            imageView.Layer.AddAnimation(frameAnimation, "contents");

            frameAnimation.Dispose();
            return(imageView);
        }
コード例 #29
0
        public void Show(string title, string body, int id, DateTime notifyTime)
        {
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                using (var trigger = UNCalendarNotificationTrigger.CreateTrigger(GetNsDateComponentsFromDateTime(notifyTime), false))
                    ShowUserNotification(title, body, id, trigger);
            }
            else
            {
                var notification = new UILocalNotification
                {
                    FireDate   = (NSDate)notifyTime,
                    AlertTitle = title,
                    AlertBody  = body,
                    UserInfo   = NSDictionary.FromObjectAndKey(NSObject.FromObject(id), NSObject.FromObject(NotificationKey))
                };

                UIApplication.SharedApplication.ScheduleLocalNotification(notification);
            }
        }
コード例 #30
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            NSDictionary dictionary = NSDictionary.FromObjectAndKey(NSObject.FromObject(userAgent), NSObject.FromObject("UserAgent"));

            NSUserDefaults.StandardUserDefaults.RegisterDefaults(dictionary);

            PlacesClient.ProvideApiKey("AIzaSyC0m0Td_wjHRWlS9uCOyFpZ_0kt6JYPRl8");
            MapServices.ProvideAPIKey("AIzaSyC0m0Td_wjHRWlS9uCOyFpZ_0kt6JYPRl8");

            global::Xamarin.Forms.Forms.Init();
            CarouselViewRenderer.Init();


            MobileAds.Configure("ca-app-pub-8565023384951297/2042844969");
            FormsMaps.Init();
            //Paypal initialization
            CrossPayPalManager.Init(new PayPalConfiguration(
                                        PayPalEnvironment.Sandbox,
                                        "APP-80W284485P519543T"
                                        )
            {
                AcceptCreditCards     = true,
                Language              = "en_US",
                ShippingAddressOption = ShippingAddressOption.None
            }
                                    );

            ImageCircleRenderer.Init();
            FFImageLoading.Forms.Touch.CachedImageRenderer.Init();
            PrepareRemoteNotification();
            App.ScreenHeight = (double)UIScreen.MainScreen.Bounds.Height;
            App.ScreenWidth  = (double)UIScreen.MainScreen.Bounds.Width;

            Xamarin.Auth.Presenters.OAuthLoginPresenter.PlatformLogin = (authenticator) =>
            {
                var oAuthLogin = new OAuthLoginPresenter();
                oAuthLogin.Login(authenticator);
            };
            MessagingCenter.Subscribe <ImageSource>(this, "Share", IosMethods.Share, null);
            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }