Пример #1
0
		static bool EtoLoadNibNamed (IntPtr self, IntPtr sel, IntPtr filePath, IntPtr owner)
		{
			var str = new NSString (filePath);
			if (str.Length == 0)
				return true;
			return Messaging.bool_objc_msgSend_IntPtr_IntPtr (self, selEtoLoadNibNamed, filePath, owner);
		}
Пример #2
0
        public SparkleMacWatcher (string path)
        {
            Path       = path;
            m_callback = DoCallback;

            NSString [] s  = new NSString [1];
            s [0]          = new NSString (path);
            NSArray path_p = NSArray.FromNSObjects (s);

            m_stream = FSEventStreamCreate ( // note that the stream will always be valid
                IntPtr.Zero, // allocator
                m_callback, // callback
                IntPtr.Zero, // context
                path_p.Handle, // pathsToWatch
                kFSEventStreamEventIdSinceNow, // sinceWhen
                2, // latency (in seconds)
                FSEventStreamCreateFlags.kFSEventStreamCreateFlagNone); // flags

            FSEventStreamScheduleWithRunLoop (
                m_stream, // streamRef
                CFRunLoopGetMain(), // runLoop
                kCFRunLoopDefaultMode); // runLoopMode

            bool started = FSEventStreamStart (m_stream);
            if (!started) {
                GC.SuppressFinalize (this);
                throw new InvalidOperationException ("Failed to start FSEvent stream for " + path);
            }
        }
Пример #3
0
		public void SetFont (string fontName)
		{
			if (fontName == null)
				throw new ArgumentNullException ("fontName");
			using (var nss = new NSString (fontName))
				_Font = nss.Handle;
		}
Пример #4
0
		public static NSWindowDepth BestDepth (NSString colorspace, int bitsPerSample, int bitsPerPixel, bool planar, ref bool exactMatch)
		{
			if (colorspace == null)
				throw new ArgumentNullException ("colorpsace");
			
			return NSBestDepth (colorspace.Handle, bitsPerSample, bitsPerPixel, planar, ref exactMatch);
		}
Пример #5
0
		static CTFontNameKeyId ()
		{
			var handle = Dlfcn.dlopen (Constants.CoreTextLibrary, 0);
			if (handle == IntPtr.Zero)
				return;
			try {
				Copyright     = Dlfcn.GetStringConstant (handle, "kCTFontCopyrightNameKey");
				Family        = Dlfcn.GetStringConstant (handle, "kCTFontFamilyNameKey");
				SubFamily     = Dlfcn.GetStringConstant (handle, "kCTFontSubFamilyNameKey");
				Style         = Dlfcn.GetStringConstant (handle, "kCTFontStyleNameKey");
				Unique        = Dlfcn.GetStringConstant (handle, "kCTFontUniqueNameKey");
				Full          = Dlfcn.GetStringConstant (handle, "kCTFontFullNameKey");
				Version       = Dlfcn.GetStringConstant (handle, "kCTFontVersionNameKey");
				PostScript    = Dlfcn.GetStringConstant (handle, "kCTFontPostScriptNameKey");
				Trademark     = Dlfcn.GetStringConstant (handle, "kCTFontTrademarkNameKey");
				Manufacturer  = Dlfcn.GetStringConstant (handle, "kCTFontManufacturerNameKey");
				Designer      = Dlfcn.GetStringConstant (handle, "kCTFontDesignerNameKey");
				Description   = Dlfcn.GetStringConstant (handle, "kCTFontDescriptionNameKey");
				VendorUrl     = Dlfcn.GetStringConstant (handle, "kCTFontVendorURLNameKey");
				DesignerUrl   = Dlfcn.GetStringConstant (handle, "kCTFontDesignerURLNameKey");
				License       = Dlfcn.GetStringConstant (handle, "kCTFontLicenseNameKey");
				LicenseUrl    = Dlfcn.GetStringConstant (handle, "kCTFontLicenseURLNameKey");
				SampleText    = Dlfcn.GetStringConstant (handle, "kCTFontSampleTextNameKey");
				PostscriptCid = Dlfcn.GetStringConstant (handle, "kCTFontPostScriptCIDNameKey");
			}
			finally {
				Dlfcn.dlclose (handle);
			}
		}
Пример #6
0
		static CFHTTPStream ()
		{
			var handle = Dlfcn.dlopen (Constants.CFNetworkLibrary, 0);
			if (handle == IntPtr.Zero)
				throw new InvalidOperationException ();

			try {
				_AttemptPersistentConnection = GetStringConstant (
					handle, "kCFStreamPropertyHTTPAttemptPersistentConnection");
				_FinalURL = GetStringConstant (
					handle, "kCFStreamPropertyHTTPFinalURL");
				_FinalRequest = GetStringConstant (
					handle, "kCFStreamPropertyHTTPFinalRequest");
				_Proxy = GetStringConstant (
					handle, "kCFStreamPropertyHTTPProxy");
				_RequestBytesWrittenCount = GetStringConstant (
					handle, "kCFStreamPropertyHTTPRequestBytesWrittenCount");
				_ResponseHeader = GetStringConstant (
					handle, "kCFStreamPropertyHTTPResponseHeader");
				_ShouldAutoredirect = GetStringConstant (
					handle, "kCFStreamPropertyHTTPShouldAutoredirect");
			} finally {
				Dlfcn.dlclose (handle);
			}
		}
Пример #7
0
		public void SetItem(IListItem value)
		{
			var imgitem = value as IImageListItem;
			if (imgitem != null && imgitem.Image != null)
				Image = ((IImageSource)imgitem.Image.Handler).GetImage();
			Text = (NSString)value.Text;
		}
Пример #8
0
        public static CFProxy[] GetProxiesForAutoConfigurationScript(NSString proxyAutoConfigurationScript, NSUrl targetURL)
        {
            if (proxyAutoConfigurationScript == null)
                throw new ArgumentNullException ("proxyAutoConfigurationScript");

            if (targetURL == null)
                throw new ArgumentNullException ("targetURL");

            NSArray array = CopyProxiesForAutoConfigurationScript (proxyAutoConfigurationScript, targetURL);

            if (array == null)
                return null;

            NSDictionary[] dictionaries = NSArray.ArrayFromHandle<NSDictionary> (array.Handle);
            array.Dispose ();

            if (dictionaries == null)
                return null;

            CFProxy[] proxies = new CFProxy [dictionaries.Length];
            for (int i = 0; i < dictionaries.Length; i++)
                proxies[i] = new CFProxy (dictionaries[i]);

            return proxies;
        }
Пример #9
0
 static CVPixelBuffer()
 {
     var handle = Dlfcn.dlopen (Constants.CoreVideoLibrary, 0);
     if (handle == IntPtr.Zero)
         return;
     try {
         PixelFormatTypeKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferPixelFormatTypeKey");
         MemoryAllocatorKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferMemoryAllocatorKey");
         WidthKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferWidthKey");
         HeightKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferHeightKey");
         ExtendedPixelsLeftKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferExtendedPixelsLeftKey");
         ExtendedPixelsTopKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferExtendedPixelsTopKey");
         ExtendedPixelsRightKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferExtendedPixelsRightKey");
         ExtendedPixelsBottomKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferExtendedPixelsBottomKey");
         BytesPerRowAlignmentKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferBytesPerRowAlignmentKey");
         CGBitmapContextCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferCGBitmapContextCompatibilityKey");
         CGImageCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferCGImageCompatibilityKey");
         OpenGLCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferOpenGLCompatibilityKey");
         IOSurfacePropertiesKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferIOSurfacePropertiesKey");
         PlaneAlignmentKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferPlaneAlignmentKey");
         CVImageBufferType = CVPixelBufferGetTypeID ();
     }
     finally {
         Dlfcn.dlclose (handle);
     }
 }
Пример #10
0
		static CFHTTPMessage ()
		{
			var handle = Dlfcn.dlopen (Constants.CFNetworkLibrary, 0);
			if (handle == IntPtr.Zero)
				throw new InvalidOperationException ();

			try {
				_HTTPVersion1_0 = GetStringConstant (handle, "kCFHTTPVersion1_0");
				_HTTPVersion1_1 = GetStringConstant (handle, "kCFHTTPVersion1_1");

				_AuthenticationSchemeBasic = GetStringConstant (
					handle, "kCFHTTPAuthenticationSchemeBasic");
				_AuthenticationSchemeNegotiate = GetStringConstant (
					handle, "kCFHTTPAuthenticationSchemeNegotiate");
				_AuthenticationSchemeNTLM = GetStringConstant (
					handle, "kCFHTTPAuthenticationSchemeNTLM");
				_AuthenticationSchemeDigest = GetStringConstant (
					handle, "kCFHTTPAuthenticationSchemeDigest");

				_AuthenticationUsername = GetStringConstant (
					handle, "kCFHTTPAuthenticationUsername");
				_AuthenticationPassword = GetStringConstant (
					handle, "kCFHTTPAuthenticationPassword");
				_AuthenticationAccountDomain = GetStringConstant (
					handle, "kCFHTTPAuthenticationAccountDomain");
			} finally {
				Dlfcn.dlclose (handle);
			}
		}
		static CVPixelFormatDescription ()
		{
			var handle = Dlfcn.dlopen (Constants.CoreVideoLibrary, 0);
			if (handle == IntPtr.Zero)
				return;
			try {
				NameKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatName");
				ConstantKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatConstant");
				CodecTypeKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatCodecType");
				FourCCKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatFourCC");
				PlanesKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatPlanes");
				BlockWidthKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBlockWidth");
				BlockHeightKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBlockHeight");
				BitsPerBlockKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBitsPerBlock");
				BlockHorizontalAlignmentKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBlockHorizontalAlignment");
				BlockVerticalAlignmentKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBlockVerticalAlignment");
				BlackBlockKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatBlackBlock");
				HorizontalSubsamplingKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatHorizontalSubsampling");
				VerticalSubsamplingKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatVerticalSubsampling");
				OpenGLFormatKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatOpenGLFormat");
				OpenGLTypeKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatOpenGLType");
				OpenGLInternalFormatKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatOpenGLInternalFormat");
				CGBitmapInfoKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatCGBitmapInfo");
				QDCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatQDCompatibility");
				CGBitmapContextCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatCGBitmapContextCompatibility");
				CGImageCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatCGImageCompatibility");
				OpenGLCompatibilityKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatOpenGLCompatibility");
				FillExtendedPixelsCallbackKey = Dlfcn.GetStringConstant (handle, "kCVPixelFormatFillExtendedPixelsCallback");
			}
			finally {
				Dlfcn.dlclose (handle);
			}
		}
Пример #12
0
 public CFException(string description, NSString domain, int code, string failureReason, string recoverySuggestion)
     : base(description)
 {
     Code                = code;
     Domain              = domain;
     FailureReason       = failureReason;
     RecoverySuggestion  = recoverySuggestion;
 }
		public NSObject this [NSString key] {
			get {
				return ObjectForKey (key);
			}
			set {
				SetObjectForKey (value, key);
			}
		}
Пример #14
0
		void CalculateSize ()
		{
			NSString str = new NSString (badgeNumber.ToString());
			NSDictionary attibutedStringAttributed = NSDictionary.FromObjectAndKey(Font, NSAttributedString.FontAttributeName);

			numberSize = str.StringSize (attibutedStringAttributed);
			Frame = new RectangleF (Frame.Location, new SizeF (Math.Max (numberSize.Width, height), height));
		}
		static NSHttpCookieStorage ()
		{
			var handle = Libraries.Foundation.Handle;
			if (handle == IntPtr.Zero)
				return;

			CookiesChangedNotification = Dlfcn.GetStringConstant (handle, "NSHTTPCookieManagerAcceptPolicyChangedNotification");
			AcceptPolicyChangedNotification = Dlfcn.GetStringConstant (handle, "NSHTTPCookieManagerCookiesChangedNotification");
		}
Пример #16
0
 public static Class GlobalGetClass(string codedName)
 {
     if (codedName == null)
         throw new ArgumentNullException ("codedName");
     using (var nsname = new NSString (codedName))
         return new Class (
                 MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (
                     class_ptr, selClassForClassName_, nsname.Handle));
 }
Пример #17
0
		static bool NeedsDisplayForKey (NSString key)
		{
			switch (key.ToString ()) {
			case "clockColor":
				return true;
			default:
				return CALayer.NeedsDisplayForKey (key);
			}
		}
Пример #18
0
		public static ProcessSerialNumber OpenApplication (ApplicationStartInfo application)
		{
			if (application == null)
				throw new ArgumentNullException ("application");
			
			if (string.IsNullOrEmpty (application.Application) || !System.IO.Directory.Exists (application.Application))
				throw new ArgumentException ("Application is not valid");
			
			var appParams = new LSApplicationParameters ();
			if (application.NewInstance)
				appParams.flags |= LSLaunchFlags.NewInstance;
			if (application.Async)
				appParams.flags |= LSLaunchFlags.Async;
			
			NSArray argv = null;
			if (application.Args != null && application.Args.Length > 0) {
				var args = application.Args;
				NSObject[] arr = new NSObject[args.Length];
				for (int i = 0; i < args.Length; i++)
					arr[i] = new NSString (args[i]);
				argv = NSArray.FromNSObjects (arr);
				appParams.argv = argv.Handle;
			}
			
			NSDictionary dict = null;
			if (application.Environment.Count > 0) {
				dict = new NSMutableDictionary ();
				foreach (var kvp in application.Environment)
					dict.SetValueForKey (new NSString (kvp.Value), new NSString (kvp.Key));
				appParams.environment = dict.Handle;
			}
			
			var cfUrl = global::MonoMac.CoreFoundation.CFUrl.FromFile (application.Application);
			ProcessSerialNumber psn;
			
			try {
				appParams.application = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (FSRef)));
			
				if (!CoreFoundation.CFURLGetFSRef (cfUrl.Handle, appParams.application))
					throw new Exception ("Could not create FSRef from CFUrl");
				
				var status = LSOpenApplication (ref appParams, out psn);
				if (status != OSStatus.Ok)
					throw new Exception ("Failed to start process: " + ((int)status).ToString ());
			} finally {
				if (appParams.application != IntPtr.Zero)
					Marshal.FreeHGlobal (appParams.application);
				appParams.application = IntPtr.Zero;
				if (dict != null)
					dict.Dispose (); //also ensures the NSDictionary is kept alive for the params
				if (argv != null)
					argv.Dispose (); //also ensures the NSArray is kept alive for the params
			}
			
			return psn;
		}
Пример #19
0
        public static void GlobalSetClass(Class kls, string codedName)
        {
            if (codedName == null)
                throw new ArgumentNullException ("codedName");
            if (kls == null)
                throw new ArgumentNullException ("kls");

            using (var nsname = new NSString (codedName))
                MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (class_ptr, selSetClassForClassName_, kls.Handle, nsname.Handle);
        }
Пример #20
0
        public LibraryBrowserItem(LibraryBrowserEntity entity)
        {
            Entity = entity;
            StringValue = new NSString(entity.Title);

            // Create empty list of subitems
            SubItems = new List<LibraryBrowserItem>();
            foreach(LibraryBrowserEntity subEntity in entity.SubItems)
                SubItems.Add(new LibraryBrowserItem(subEntity));
        }
Пример #21
0
		public static void AddLoginItem (string path)
		{
			if (path == null)
				throw new ArgumentNullException ("path");
			var nspath = new NSString (path);

			MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (class_ptr, selAddLoginItem, nspath.Handle);
			nspath.Dispose ();

		}
		static CVPixelBufferPoolAllocationSettings ()
		{
			var handle = Dlfcn.dlopen (Constants.CoreVideoLibrary, 0);
			if (handle == IntPtr.Zero)
				return;
			try {
				ThresholdKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferPoolAllocationThresholdKey");
			} finally {
				Dlfcn.dlclose (handle);
			}
		}
Пример #23
0
        public NSObject AddObserver(NSString aName, Action<NSNotification> notify, NSObject fromObject)
        {
            if (notify == null)
                throw new ArgumentNullException ("notify");

            var proxy = new InternalNSNotificationHandler (this, notify);

            AddObserver (proxy, postSelector, aName, fromObject);

            return proxy;
        }
Пример #24
0
		static new NSObject DefaultAnimationFor (NSString key)
		{
			if (key == "drawnLineWidth"){
				if (drawnLineWidthBasicAnimation == null) {
					drawnLineWidthBasicAnimation = new CABasicAnimation ();
					//drawnLineWidthBasicAnimation.Duration = 2.0f;
				}
				return drawnLineWidthBasicAnimation;
			} else
				return NSView.DefaultAnimationFor (key);
		}
Пример #25
0
		public static void GlobalSetClassName (string name, Class kls)
		{
			if (name == null)
				throw new ArgumentNullException ("name");
			if (kls == null)
				throw new ArgumentNullException ("kls");

			var nsname = new NSString (name);
			MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (class_ptr, Selector.GetHandle (selSetClassNameForClass_), nsname.Handle, kls.Handle);
			nsname.Dispose ();
		}
Пример #26
0
		static CTFontCollectionOptionKey ()
		{
			var handle = Dlfcn.dlopen (Constants.CoreTextLibrary, 0);
			if (handle == IntPtr.Zero)
				return;
			try {
				RemoveDuplicates = Dlfcn.GetStringConstant (handle, "kCTFontCollectionRemoveDuplicatesOption");
			}
			finally {
				Dlfcn.dlclose (handle);
			}
		}
Пример #27
0
		// Get a value for a key.  Not using this method but instead
		//  used the [Export("xxxxxx")] method.
		//public override NSObject ValueForKey (NSString key)
		//{
		//	return attributeValues[key];
		//}
		
		public override void SetValueForKey (NSObject value, NSString key)
		{
			
			if (personValues.ContainsKey (key))
				personValues [key] = value;	
			else
				base.SetValueForKey (value, key);

			// you can also just do a simple:
			//attributeValues[key] = value;
			
		}
Пример #28
0
		static CTTextTabOptionKey ()
		{
			var handle = Dlfcn.dlopen (Constants.CoreTextLibrary, 0);
			if (handle == IntPtr.Zero)
				return;
			try {
				ColumnTerminators = Dlfcn.GetStringConstant (handle, "kCTTabColumnTerminatorsAttributeName");
			}
			finally {
				Dlfcn.dlclose (handle);
			}
		}
Пример #29
0
        static NSHttpCookieStorage()
        {
            var handle = Dlfcn.dlopen (Constants.FoundationLibrary, 0);
            if (handle == IntPtr.Zero)
                return;

            try {
                CookiesChangedNotification = Dlfcn.GetStringConstant (handle, "NSHTTPCookieManagerAcceptPolicyChangedNotification");
                AcceptPolicyChangedNotification = Dlfcn.GetStringConstant (handle, "NSHTTPCookieManagerCookiesChangedNotification");
            } finally {
                Dlfcn.dlclose (handle);
            }
        }
Пример #30
0
 static CVPixelBufferPool()
 {
     var handle = Dlfcn.dlopen (Constants.CoreVideoLibrary, 0);
     if (handle == IntPtr.Zero)
         return;
     try {
         MinimumBufferCountKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferPoolMinimumBufferCountKey");
         MaximumBufferAgeKey = Dlfcn.GetStringConstant (handle, "kCVPixelBufferPoolMaximumBufferAgeKey");
     }
     finally {
         Dlfcn.dlclose (handle);
     }
 }
Пример #31
0
 public NSError(NSString domain, int code) : this(domain, code, null)
 {
 }
Пример #32
0
 protected void SetStringValue(NSString key, string value)
 {
     SetStringValue(key, value == null ? (NSString)null : new NSString(value));
 }
Пример #33
0
 public static NSError FromDomain(NSString domain, int code)
 {
     return(FromDomain(domain, code, null));
 }