Beispiel #1
0
		internal NSDictionary ToDictionary ()
		{
			var ret = new NSMutableDictionary ();

			if (AffineMatrix.HasValue){
				var a = AffineMatrix.Value;
				var affine = new NSNumber [6];
				affine [0] = NSNumber.FromFloat (a.xx);
				affine [1] = NSNumber.FromFloat (a.yx);
				affine [2] = NSNumber.FromFloat (a.xy);
				affine [3] = NSNumber.FromFloat (a.yy);
				affine [4] = NSNumber.FromFloat (a.x0);
				affine [5] = NSNumber.FromFloat (a.y0);
				ret.SetObject (NSArray.FromNSObjects (affine), CISampler.AffineMatrix);
			}
			if (WrapMode.HasValue){
				var k = WrapMode.Value == CIWrapMode.Black ? CISampler.WrapBlack : CISampler.FilterNearest;
				ret.SetObject (k, CISampler.WrapMode);
			}
			if (FilterMode.HasValue){
				var k = FilterMode.Value == CIFilterMode.Nearest ? CISampler.FilterNearest : CISampler.FilterLinear;
				ret.SetObject (k, CISampler.FilterMode);
			}
			return ret;
		}
Beispiel #2
0
 public void updateMarker(NSString id, NSNumber lat, NSNumber lng)
 {
     logger.Info("updateMarker: {0} to {1}, {2}", id, lat, lng);
     var ms = GetMarker(id);
     if (ms == null)
     {
         logger.Warn("Unable to find marker: '{0}'", id);
     }
     else
     {
         UpdateMarker(ms, lat.DoubleValue, lng.DoubleValue);
     }
 }
Beispiel #3
0
        public void clicked(NSNumber lat, NSNumber lng)
        {
            var location = new Location(lat.DoubleValue, lng.DoubleValue);
            var message = string.Format("Looking up {0}...", location.ToDms()).Replace("\"", "\\\"");
            MapWebView.InvokeMapScript("setPopup([{0}, {1}], \"{2}\")", lat, lng, message);

            MapController.NameFromLocation(
                location,
                Location.PlaceNameFilter.Minimal,
                (s) =>
            {
                BeginInvokeOnMainThread(delegate
                {
                    MapWebView.InvokeMapScript("setPopup([{0}, {1}], \"{2}\")", lat, lng, s);
                });
            });
        }
		public static object ConvertNumber (NSNumber num)
		{
			char kind;
			unsafe {
				kind = (char)*((byte *)MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend (num.Handle, selObjCType));
			}
		
			switch (kind) {
			case 'c':
			//HACK: bools always seem to be encoded as char type so inspect the class
				if (num.ClassHandle == clsNSCFBoolean)
					goto case 'B';
				return num.SByteValue;
			case 'C':
			//HACK: bools always seem to be encoded as char type so inspect the class
				if (num.ClassHandle == clsNSCFBoolean)
					goto case 'B';
				return num.ByteValue;
			case 'B':
				return num.BoolValue;
			case 's':
				return num.Int16Value;
			case 'S':
				return num.UInt16Value;
			case 'i':
			case 'l':
				return num.Int32Value;
			case 'I':
			case 'L':
				return num.UInt32Value;
			case 'q':
				return num.Int64Value;
			case 'Q':
				return num.UInt64Value;
			case 'f':
				return num.FloatValue;
			case 'd':
				return num.DoubleValue;
			default:
				throw new NotSupportedException ("NSNumber of type " + kind);
			}
		}
 public override void ExecuteScriptFunction(string functionName, params object[] args)
 {
     if (args == null)
         args = new object[0];
     NSObject[] nsArgs = new NSObject[args.Length];
     for (int i = 0; i < args.Length; i++)
     {
         if (args[i] != null)
         {
             if (args[i] is Int32)
                 nsArgs[i] = new NSNumber((int)args[i]);
             else if (args[i] is Boolean)
                 nsArgs[i] = new NSNumber(((bool)args[i]) ? 1 : 0);
             nsArgs[i] = new NSString(args[i].ToString());
         }
         else
             nsArgs[i] = new NSNull();
     }
     webBrowser.WindowScriptObject.CallWebScriptMethod(functionName, nsArgs);
 }
		private static string StringForPhyMode (NSNumber mode)
		{
			if (mode == null)
				return String.Empty;
			
			string phyModeStr = String.Empty;
			switch ((CWPHYMode)mode.IntValue) {
			case CWPHYMode.CWPHYMode11A:
				
				{
					phyModeStr = "802.11a";
					break;
				}

			case CWPHYMode.CWPHYMode11B:
				
				{
					phyModeStr = "802.11b";
					break;
				}

			case CWPHYMode.CWPHYMode11G:
				
				{
					phyModeStr = "802.11g";
					break;
				}

			case CWPHYMode.CWPHYMode11N:
				
				{
					phyModeStr = "802.11n";
					break;
				}

				
			}
			return phyModeStr;
		}
		static AccessoryInfo[] ExtractAccessoryInfo (IntPtr ptr, NSString id, NSString description)
		{
			using (var array = new CFArray (ptr)) {
				var res = new AccessoryInfo [array.Count];
				for (int i = 0; i < res.Length; ++i) {
					var dict = array.GetValue (i);
					var n = new NSNumber (CFDictionary.GetValue (dict, id.Handle));
					var desc = CFString.FetchString (CFDictionary.GetValue (dict, description.Handle));

					res [i] = new AccessoryInfo ((int) n, desc);
					id.Dispose ();
				}
				return res;
			}
		}
Beispiel #8
0
        //public bool? ProtectedFile { get; set; }

        internal NSDictionary ToDictionary()
        {
            var dict = new NSMutableDictionary();

            if (AppendOnly.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(AppendOnly.Value), NSFileManager.AppendOnly);
            }
            if (Busy.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(Busy.Value), NSFileManager.Busy);
            }
            if (CreationDate != null)
            {
                dict.SetObject(CreationDate, NSFileManager.CreationDate);
            }
            if (ModificationDate != null)
            {
                dict.SetObject(ModificationDate, NSFileManager.ModificationDate);
            }
            if (OwnerAccountName != null)
            {
                dict.SetObject(new NSString(OwnerAccountName), NSFileManager.OwnerAccountName);
            }
            if (DeviceIdentifier.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(DeviceIdentifier.Value), NSFileManager.DeviceIdentifier);
            }
            if (FileExtensionHidden.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(FileExtensionHidden.Value), NSFileManager.ExtensionHidden);
            }
            if (FileGroupOwnerAccountID.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(FileGroupOwnerAccountID.Value), NSFileManager.GroupOwnerAccountID);
            }
            if (FileOwnerAccountID.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(FileOwnerAccountID.Value), NSFileManager.OwnerAccountID);
            }
            if (HfsTypeCode.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(HfsTypeCode.Value), NSFileManager.HfsTypeCode);
            }
            if (PosixPermissions.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(PosixPermissions.Value), NSFileManager.PosixPermissions);
            }
            if (FileReferenceCount.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(FileReferenceCount.Value), NSFileManager.ReferenceCount);
            }
            if (FileSystemFileNumber.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt32(FileSystemFileNumber.Value), NSFileManager.SystemFileNumber);
            }
            if (FileSize.HasValue)
            {
                dict.SetObject(NSNumber.FromUInt64(FileSize.Value), NSFileManager.Size);
            }
            if (Immutable.HasValue)
            {
                dict.SetObject(NSNumber.FromBoolean(Immutable.Value), NSFileManager.Immutable);
            }
            //if (ProtectedFile.HasValue)
            //dict.SetObject (NSNumber.FromBoolean (ProtectedFile.Value), NSFileManager.ProtectedFile);
            if (FileType.HasValue)
            {
                NSString v = null;
                switch (FileType.Value)
                {
                case NSFileType.Directory:
                    v = NSFileManager.TypeDirectory; break;

                case NSFileType.Regular:
                    v = NSFileManager.TypeRegular; break;

                case NSFileType.SymbolicLink:
                    v = NSFileManager.TypeSymbolicLink; break;

                case NSFileType.Socket:
                    v = NSFileManager.TypeSocket; break;

                case NSFileType.CharacterSpecial:
                    v = NSFileManager.TypeCharacterSpecial; break;

                case NSFileType.BlockSpecial:
                    v = NSFileManager.TypeBlockSpecial; break;

                default:
                    v = NSFileManager.TypeUnknown; break;
                }
                dict.SetObject(v, NSFileManager.NSFileType);
            }
            return(dict);
        }
Beispiel #9
0
 public CTFontDescriptor WithVariation(uint variationIdentifier, float variationValue)
 {
     using (var id = new NSNumber (variationIdentifier))
         return CreateDescriptor (CTFontDescriptorCreateCopyWithVariation  (handle,
                     id.Handle, variationValue));
 }
 void IncrementSignificantEventAndRate(NSNumber _canPromptForRating)
 {
     try {
     using (new NSAutoreleasePool ()) {
         IncrementSignificantEventCount ();
         if (_canPromptForRating.BoolValue && RatingConditionsHaveBeenMet () && ConnectedToNetwork ())
             InvokeOnMainThread (ShowRatingAlert);
     }
     }
     catch {
     }
 }
		CTFontDescriptor WithFeature (FontFeatureGroup featureGroup, int featureSelector)
		{
			using (NSNumber t = new NSNumber ((int) featureGroup), f = new NSNumber (featureSelector)) {
				return CreateDescriptor (CTFontDescriptorCreateCopyWithFeature (handle, t.Handle, f.Handle));
			}
		}
Beispiel #12
0
 public CTFontDescriptor WithFeature(NSNumber featureTypeIdentifier, NSNumber featureSelectorIdentifier)
 {
     if (featureTypeIdentifier == null)
         throw new ArgumentNullException ("featureTypeIdentifier");
     if (featureSelectorIdentifier == null)
         throw new ArgumentNullException ("featureSelectorIdentifier");
     return CreateDescriptor (CTFontDescriptorCreateCopyWithFeature (handle, featureTypeIdentifier.Handle, featureSelectorIdentifier.Handle));
 }
 public override IEnumerable<KeyValuePair<string, object>> GetAvailableFamilyFaces(string family)
 {
     foreach (var nsFace in NSFontManager.SharedFontManager.AvailableMembersOfFontFamily(family)) {
         var name = (string)new NSString(nsFace.ValueAt(1));
         var weight = new NSNumber (nsFace.ValueAt (2)).Int32Value;
         var traits = (NSFontTraitMask)new NSNumber (nsFace.ValueAt (3)).Int32Value;
         yield return new KeyValuePair<string, object>(name, FontData.FromFamily(family, traits, weight, 0));
     }
     yield break;
 }
		partial void ibssOKButtonPressed (NSObject sender)
		{
			ibssSpinner.Hidden = false;
			ibssSpinner.StartAnimation (this);
			
			string networkName = ibssNetworkNameField.StringValue;
			NSNumber channel = new NSNumber(Convert.ToInt32(ibssChannelPopupButton.SelectedItem.Title));
			string passPhrase = ibssPassphraseField.StringValue;
			
			NSMutableDictionary ibssParams = new NSMutableDictionary ();
			if (!(String.IsNullOrEmpty (networkName)))
				ibssParams.SetValueForKey (ibssNetworkNameField.ObjectValue, CWConstants.CWIBSSKeySSID);
			
			
			if (channel.IntValue > 0)
				ibssParams.SetValueForKey (channel, CWConstants.CWIBSSKeyChannel);
			
			if (!(String.IsNullOrEmpty (passPhrase)))
				ibssParams.SetValueForKey (ibssPassphraseField.ObjectValue, CWConstants.CWIBSSKeyPassphrase);
			
			NSError error = null;
			
			bool created = CurrentInterface.EnableIBSSWithParameters (NSDictionary.FromDictionary (ibssParams), out error);
			
			ibssSpinner.StopAnimation (this);
			ibssSpinner.Hidden = true;
			
			if (!created)
				NSAlert.WithError (error).RunModal ();
			else
				ibssCancelButtonPressed(this);
		}
Beispiel #15
0
        internal NSDictionary ToDictionary()
        {
            int n = 0;
            if (Enhance.HasValue && Enhance.Value == false)
                n++;
            if (RedEye.HasValue && RedEye.Value == false)
                n++;
            if (ImageOrientation.HasValue)
                n++;
            if (Features != null && Features.Length != 0)
                n++;
            if (n == 0)
                return null;
            var keys = new NSString [n];
            var values = new NSObject [n];

            int i = 0;
            if (Enhance.HasValue && Enhance.Value == false){
                keys [i] = CIImage.AutoAdjustEnhanceKey;
                values [i] = CFBoolean.FalseObject;
                i++;
            }
            if (RedEye.HasValue && RedEye.Value == false){
                keys [i] = CIImage.AutoAdjustRedEyeKey;
                values [i] = CFBoolean.FalseObject;
                i++;
            }
            if (Features != null && Features.Length != 0){
                keys [i] = CIImage.AutoAdjustFeaturesKey;
                values [i] = NSArray.FromObjects (Features);
                i++;
            }
            if (ImageOrientation.HasValue){
                keys [i] = CIImage.ImagePropertyOrientation;
                values [i] = new NSNumber ((int)ImageOrientation.Value);
                i++;
            }
            for (i = 0; i < n; i++){
                Console.WriteLine ("{0} {1}-{2}", i, keys [i], values [i]);
            }

            return NSDictionary.FromObjectsAndKeys (values, keys);
        }
		private static string StringForOpMode (NSNumber mode)
		{
			if (mode == null)
				return String.Empty;
			
			string opModeStr = String.Empty;
			switch ((CWOpMode)mode.IntValue) {
			case CWOpMode.CWOpModeIBSS:
				
				{
					opModeStr = "IBSS";
					break;
				}

			case CWOpMode.CWOpModeStation:
				
				{
					opModeStr = "Infrastructure";
					break;
				}

			case CWOpMode.CWOpModeHostAP:
				
				{
					opModeStr = "Host Access Point";
					break;
				}

			case CWOpMode.CWOpModeMonitorMode:
				
				{
					opModeStr = "Monitor Mode";
					break;
				}

			}
			return opModeStr;
		}
		private static string StringForSecurityMode (NSNumber mode)
		{
			if (mode == null)
				return String.Empty;
			
			string securityModeStr = String.Empty;
			switch ((CWSecurityMode)mode.IntValue) {
			case CWSecurityMode.CWSecurityModeOpen:
				
				{
					securityModeStr = "Open";
					break;
				}

			case CWSecurityMode.CWSecurityModeWEP:
				
				{
					securityModeStr = "WEP";
					break;
				}

			case CWSecurityMode.CWSecurityModeWPA_PSK:
				
				{
					securityModeStr = "WPA Personal";
					break;
				}

			case CWSecurityMode.CWSecurityModeWPA_Enterprise:
				
				{
					securityModeStr = "WPA Enterprise";
					break;
				}

			case CWSecurityMode.CWSecurityModeWPA2_PSK:
				
				{
					securityModeStr = "WPA2 Personal";
					break;
				}

			case CWSecurityMode.CWSecurityModeWPA2_Enterprise:
				
				{
					securityModeStr = "WPA2 Enterprise";
					break;
				}

			case CWSecurityMode.CWSecurityModeWPS:
				
				{
					securityModeStr = "WiFI Protected Setup";
					break;
				}

			case CWSecurityMode.CWSecurityModeDynamicWEP:
				
				{
					securityModeStr = "802.1X WEP";
					break;
				}

			}
			return securityModeStr;
		}