コード例 #1
0
        void UpdateGlobalHotKey(NSString keyPath, NSObject currSelectHotKey, string selector)
        {
            uint  keyCode            = ((NSNumber)currSelectHotKey.ValueForKey(new NSString("keyCode"))).UInt32Value;
            ulong keyModifiers       = ((NSNumber)currSelectHotKey.ValueForKey(new NSString("modifierFlags"))).UInt64Value;
            uint  keyModifiersCarbon = ShortcutRecorder.CFunctions.SRCocoaToCarbonFlags((NSEventModifierMask)keyModifiers);

            _hotkeyBindings.Add(keyPath, _hotkeyManager.BindKeyRef(keyCode, keyModifiersCarbon, this, new ObjCRuntime.Selector(selector)));
        }
コード例 #2
0
        //
        // styleMode
        //
        public static PXStylingMode GetStyleMode(NSObject obj)
        {
            var mode       = obj.ValueForKey(new NSString("styleMode"));
            var modeString = mode.ToString();

            return((PXStylingMode)Enum.Parse(typeof(PXStylingMode), modeString));
        }
コード例 #3
0
ファイル: LoginViewController.cs プロジェクト: llenroc/chatty
        public void DataRequestHandler(GraphRequestConnection connection, NSObject result, NSError err)
        {
            try
            {
                string fbId    = result.ValueForKey(new NSString("id")).ToString();
                string fbToken = AccessToken.CurrentAccessToken.TokenString;
                string fbEmail = result.ValueForKey(new NSString("email")).ToString();

                _email = fbEmail;

                // Create a new cancellation token for this request
                _cts0 = new CancellationTokenSource();
                AppController.LoginUser(_cts0, fbId, fbEmail, fbToken,
                                        // Service call success
                                        (data) =>
                {
                    AppController.Settings.LastLoginUsernameUsed = _email;
                    AppController.Settings.AuthAccessToken       = data.AuthAccessToken;
                    AppController.Settings.AuthExpirationDate    = data.AuthExpirationDate.GetValueOrDefault().ToLocalTime();

                    ((AppDelegate)UIApplication.SharedApplication.Delegate).RegisterToNotificationsHub();

                    var c       = new ChatViewController();
                    c.Arguments = new UIBundle();
                    c.Arguments.PutString("Email", _email);
                    this.NavigationController.PushViewController(c, true);
                },
                                        // Service call error
                                        (error) =>
                {
                    UIToast.MakeText(error, UIToastLength.Long).Show();
                },
                                        // Service call finished
                                        () =>
                {
                    // Allow user to tap views
                    ((MainViewController)this.MainViewController).UnblockUI();
                });
            }
            catch (Exception ex)
            {
                ((MainViewController)this.MainViewController).UnblockUI();

                UIToast.MakeText("Error", UIToastLength.Long).Show();
            }
        }
コード例 #4
0
 public static FBGraphObject[] FromResultObject(NSObject resultObject)
 {
     var results = new List<FBGraphObject> ();
     var dataObject = resultObject.ValueForKey (new NSString ("data")) as NSMutableArray;
     for (uint i = 0; i < dataObject.Count; i++) {
         var o = Runtime.GetNSObject (dataObject.ValueAt (i));
         results.Add (o as FBGraphObject);
     }
     return results.ToArray ();
 }
コード例 #5
0
        public static FBGraphObject [] FromResultObject(NSObject resultObject)
        {
            var results    = new List <FBGraphObject> ();
            var dataObject = resultObject.ValueForKey(new NSString("data")) as NSMutableArray;

            for (uint i = 0; i < dataObject.Count; i++)
            {
                var o = Runtime.GetNSObject(dataObject.ValueAt(i));
                results.Add(o as FBGraphObject);
            }
            return(results.ToArray());
        }
コード例 #6
0
 void GetLikesRequestHandler(GraphRequestConnection connection, NSObject result, NSError error)
 {
     if (error != null)
     {
         _completionSource.TrySetResult(new LoginResult {
             LoginState = LoginState.Failed, ErrorString = error.LocalizedDescription
         });
     }
     else
     {
         var likes = result.ValueForKey((NSString)"fan_count");
     }
 }
コード例 #7
0
        void IMAMService.UtilMAMService()
        {
            try
            {
                //IntuneMAMAppConfigManager appConfig = IntuneMAMAppConfigManager.Instance;
                // IntuneMAMAppConfig conf = IntuneMAMAppConfig.;
                //  NSDictionary paramsGroups1 =IntuneMAMAppConfig_Extensions.

                IntuneMAMPolicyManager value = IntuneMAMPolicyManager.Instance;

                Utils.Print($"------ Es ManagementEnabled:  {value.IsManagementEnabled.ToString()}");

                NSDictionary dictionary   = value.DiagnosticInformation;
                NSString[]   keys         = { new NSString(Mobile.ID_DIC_INTUNE) };
                NSDictionary paramsGroups = dictionary.GetDictionaryOfValuesFromKeys(keys);
                //NSDictionary paramsGroups    = IntuneMAMAppConfigManager.Instance.GetDictionaryOfValuesFromKeys(keys);

                //IntuneMAMAppConfig_Extensions.GetFullData(AppConfig);
                NSObject paramsGroup = paramsGroups.ElementAt(0).Value;

                var data = Mobile.configData;

                // Convert parameters to string and regenerate the certificate
                data.ftpDownload_User = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_USER)).ToString();
                data.ftpDownload_Pass = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PASS)).ToString();
                data.ftpDownload_Host = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_HOST)).ToString();
                data.ftpDownload_Port = int.Parse(paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PORT)).ToString());
                data.ftpDownload_Path = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PATH)).ToString();
                data.HasIntune        = true;
                data.GenerateCert(paramsGroup.ValueForKey(new NSString(Mobile.ID_CERTIFICATE)).ToString());


                // Utils.Print("Intune parameters loaded..");
                // Utils.Print("FTP: " + data.ftpDownload_Host + ":" + data.ftpDownload_Port + " - " + data.ftpDownload_User + " [ " + data.ftpDownload_Pass + " ]");
                // Utils.Print("Certificate: " + data.certificate.FriendlyName + " [ " + data.certificate.NotAfter + " ]");

                // Free memory
                paramsGroup.Dispose();
                paramsGroups.Dispose();
                dictionary.Dispose();
                value.Dispose();
                paramsGroup  = null;
                paramsGroups = null;
                keys         = null;
                dictionary   = null;
                value        = null;
            }
            catch (Exception e)
            {
                return;
            }
        }
コード例 #8
0
        public static bool PrepareFromIntune()
        {
            List <string> listaDatos = new List <string> ();

            try
            {
                // Recover configuration parameters from Intune
                IntuneMAMPolicyManager value        = IntuneMAMPolicyManager.Instance;
                NSDictionary           dictionary   = value.DiagnosticInformation;
                NSString[]             keys         = new NSString[] { new NSString(Mobile.ID_DIC_INTUNE) };
                NSDictionary           paramsGroups = dictionary.GetDictionaryOfValuesFromKeys(keys);
                NSObject paramsGroup = paramsGroups.ElementAt(0).Value;

                var data = Mobile.configData;

                // Convert parameters to string and regenerate the certificate
                data.ftpDownload_User = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_USER)).ToString();
                data.ftpDownload_Pass = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PASS)).ToString();
                data.ftpDownload_Host = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_HOST)).ToString();
                data.ftpDownload_Port = int.Parse(paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PORT)).ToString());
                data.ftpDownload_Path = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PATH)).ToString();
                data.GenerateCert(paramsGroup.ValueForKey(new NSString(Mobile.ID_CERTIFICATE)).ToString());
                data.HasIntune = true;

                Utils.Print("Intune parameters loaded..");
                Utils.Print("FTP: " + data.ftpDownload_Host + ":" + data.ftpDownload_Port + " - " + data.ftpDownload_User + " [ " + data.ftpDownload_Pass + " ]");
                Utils.Print("Certificate: " + data.certificate.FriendlyName + " [ " + data.certificate.NotAfter + " ]");

                // Free memory
                paramsGroup.Dispose();
                paramsGroups.Dispose();
                dictionary.Dispose();
                value.Dispose();
                paramsGroup  = null;
                paramsGroups = null;
                keys         = null;
                dictionary   = null;
                value        = null;
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
コード例 #9
0
        public void DidProduceResult(ISNRequest request, ISNResult result)
        {
            // seems like SNClassificationResult is not properly bound yet
            // we can use valueForKey: to get results if we know what we're looking for
            // not sure whether i need to dispose after doing this
            using (var o = new NSObject(result.Handle))
            {
                var rawClassifications = (NSArray)o.ValueForKey(new NSString("classifications"));
                var results            = rawClassifications
                                         .AsEnumerable <SNClassification>()
                                         .OrderByDescending(x => x.Confidence)
                                         .ToDictionary(x => x.Identifier, x => Math.Round(x.Confidence, 2));

                var best = results.First();

                Console.WriteLine(JsonConvert.SerializeObject(results, Formatting.Indented));

                DispatchQueue.MainQueue.DispatchSync(() =>
                {
                    SetLabel(results);
                    OnClassification(best.Key, best.Value);
                });
            }
        }
コード例 #10
0
        private void OnRequestHandler(GraphRequestConnection connection, NSObject result, NSError error)
        {
            if (error != null || result == null)
            {
                OnLoginError?.Invoke(new Exception(error.LocalizedDescription));
            }
            else
            {
                var id         = string.Empty;
                var first_name = string.Empty;
                var email      = string.Empty;
                var last_name  = string.Empty;
                var url        = string.Empty;

                try
                {
                    id = result.ValueForKey(new NSString("id"))?.ToString();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }

                try
                {
                    first_name = result.ValueForKey(new NSString("first_name"))?.ToString();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }

                try
                {
                    email = result.ValueForKey(new NSString("email"))?.ToString();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }

                try
                {
                    last_name = result.ValueForKey(new NSString("last_name"))?.ToString();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }

                try
                {
                    url = ((result.ValueForKey(new NSString("picture")) as NSDictionary).ValueForKey(new NSString("data")) as NSDictionary).ValueForKey(new NSString("url")).ToString();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }

                //Grab the user and send the success event
                User = new FacebookUser(id, AccessToken.CurrentAccessToken.TokenString, first_name, last_name, email, url);
                OnLoginSuccess?.Invoke(User);
            }
        }
コード例 #11
0
 //
 // styleCSS
 //
 public static string GetStyleCSS(NSObject obj)
 {
     return((NSString)obj.ValueForKey(new NSString("styleCSS")));
 }
コード例 #12
0
		private void FacebookRequestForMeCompleted(FBRequestConnection connection, NSObject result, NSError error)
		{
			if (error == null)
			{
				Interfaces.Instance.FacebookInterface.UserEmail = result.ValueForKey(new NSString("email")) as NSString;
				Interfaces.Instance.FacebookInterface.UserId = result.ValueForKey(new NSString("id")) as NSString;
				if (!FBSession.ActiveSession.HasGranted("email"))
				{
					FBSession.ActiveSession.RequestNewReadPermissions(new string[] { "email" }, null);
					UIAlertView alertView = new UIAlertView("APP/ALERT/TITLE/ERROR".Localize(), "APP/FACEBOOK/ERRORS/NEED_EMAIL".Localize(), null, "APP/ALERT/BUTTON/OK".Localize(), null);
					alertView.Show();
					return;
				}
				FacebookLogin();
			}
			else
			{
				HandleFacebookError(error);
			}
		}
コード例 #13
0
        private void OnRequestHandler(GraphRequestConnection connection, NSObject result, NSError error)
        {
            if (error != null || result == null)
            {
                _onLoginComplete?.Invoke(null, new Exception(error.LocalizedDescription));
            }
            else
            {
                var id         = string.Empty;
                var first_name = string.Empty;
                var name       = string.Empty;
                var email      = string.Empty;
                var last_name  = string.Empty;
                var url        = string.Empty;

                try {
                    id = result.ValueForKey(new NSString("id"))?.ToString();
                } catch (Exception e) {
                    Debug.WriteLine(e.Message);
                }

                try {
                    name = result.ValueForKey(new NSString("name"))?.ToString();
                } catch (Exception e) {
                    Debug.WriteLine(e.Message);
                }

                try {
                    first_name = result.ValueForKey(new NSString("first_name"))?.ToString();
                } catch (Exception e) {
                    Debug.WriteLine(e.Message);
                }

                try {
                    email = result.ValueForKey(new NSString("email"))?.ToString();
                } catch (Exception e) {
                    Debug.WriteLine(e.Message);
                }

                try {
                    last_name = result.ValueForKey(new NSString("last_name"))?.ToString();
                } catch (Exception e) {
                    Debug.WriteLine(e.Message);
                }

                try {
                    url = ((result.ValueForKey(
                                new NSString("picture")) as NSDictionary).
                           ValueForKey(new NSString("data")) as NSDictionary).
                          ValueForKey(new NSString("url")).ToString();
                } catch (Exception e) {
                    Debug.WriteLine(e.Message);
                }

                _onLoginComplete?.Invoke(new FacebookUserModel(int.Parse(id),
                                                               AccessToken.CurrentAccessToken.TokenString,
                                                               name,
                                                               first_name,
                                                               last_name,
                                                               email,
                                                               new Uri(url)),
                                         null);
            }
        }
コード例 #14
0
ファイル: extra.cs プロジェクト: h2oman/MonoTouch-Pixate
 //
 // styleMode
 //
 public static PXStylingMode GetStyleMode(NSObject obj)
 {
     var mode = obj.ValueForKey (new NSString ("styleMode"));
     var modeString = mode.ToString ();
     return (PXStylingMode)Enum.Parse (typeof(PXStylingMode), modeString);
 }
コード例 #15
0
ファイル: extra.cs プロジェクト: h2oman/MonoTouch-Pixate
 //
 // styleId
 //
 public static string GetStyleId(NSObject obj)
 {
     return (NSString) obj.ValueForKey (new NSString ("styleId"));
 }