Ejemplo n.º 1
0
 public void PanelDirectoryDidChange(Id sender, NSString path)
 {
     if (this.soundOnCheck.State > 0)
     {
         NSSound.SoundNamed("Frog").Play();
     }
 }
Ejemplo n.º 2
0
 public Texture(NSString path)
     : base()
 {
     if (this.GetImageDataFromPath (path)) {
         this.LoadTexture ();
     }
 }
Ejemplo n.º 3
0
        public static bool LoadNibResourceNamedOwner(this NSBundle bundle, Type type, NSString resourceName, Id owner)
        {
            bool result = false;
            Assembly assembly = type.Assembly;

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
            {
                if (stream != null)
                {
                    byte[] buffer = new byte[stream.Length];
                    stream.Read(buffer, 0, (int)stream.Length);
                    stream.Close();

                    String fileName = Path.GetTempFileName();
                    File.WriteAllBytes(fileName, buffer);

					NSNib nib = new NSNib(NSURL.URLWithString(fileName));
					NSArray topLevelObjects;
					result = nib.InstantiateNibWithOwnerTopLevelObjects(owner, out topLevelObjects);
					nib.Release();

                    File.Delete(fileName);
                }
            }

            return result;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// <para>Returns a localized version of a string.</para>
 /// <para>Original signature is 'NSString *NSLocalizedStringFromTableInBundle(NSString *key, NSString *tableName, NSBundle *bundle, NSString *comment)'</para>
 /// <para>Available in Mac OS X v10.0 and later.</para>
 /// </summary>
 public static NSString NSLocalizedStringFromTableInBundle(NSString key,
                                                           NSString tableName,
                                                           NSBundle bundle,
                                                           NSString comment)
 {
     return bundle.LocalizedStringForKeyValueTable(key, NSString.Empty, tableName);
 }
Ejemplo n.º 5
0
        public bool GetObjectValueForStringErrorDescription(IntPtr anObject, NSString str, IntPtr error)
        {
            // First, we convert the NSString to a String to parse it more easily
            String stringToParse = str;

            // If we cannot parse the string correctly into an IPAddress, then reject it
            IPAddress address;
            if (!IPAddress.TryParse(stringToParse, out address))
            {
                if (anObject != IntPtr.Zero)
                {
                    Marshal.WriteIntPtr(anObject, IntPtr.Zero);
                }
                if (error != IntPtr.Zero)
                {
                    // Marshal back the error message (the NSString is autoreleased)
                    NSString errorMessage = "Invalid IPv4 Address";
                    Marshal.WriteIntPtr(error, errorMessage.NativePointer);
                }
                return false;
            }

            // Marshal back the object (the NSString is autoreleased)
            NSString obj = address.ToString();
            if (anObject != IntPtr.Zero)
            {
                Marshal.WriteIntPtr(anObject, obj.NativePointer);
            }
            if (error != IntPtr.Zero)
            {
                Marshal.WriteIntPtr(error, IntPtr.Zero);
            }
            return true;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// <para>Returns a localized version of a string.</para>
 /// <para>Original signature is 'NSString *NSLocalizedStringWithDefaultValue(NSString *key, NSString *tableName, NSBundle *bundle, NSString *value, NSString *comment)'</para>
 /// <para>Available in Mac OS X v10.2 and later.</para>
 /// </summary>
 public static NSString NSLocalizedStringWithDefaultValue(NSString key,
                                                          NSString tableName,
                                                          NSBundle bundle,
                                                          NSString value,
                                                          NSString comment)
 {
     return bundle.LocalizedStringForKeyValueTable(key, value, tableName);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Returns an retained instance of NSString.
 /// </summary>
 public static NSString NSPinnedString(String value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     NSString str = new NSString(value);
     return str;
 }
Ejemplo n.º 8
0
		public static bool InstantiateNibWithOwnerTopLevelObjects (NSString resourceName, Id owner)
		{
			if (resourceName == null) {
				throw new ArgumentNullException("resourceName");
			}
			if (owner == null) {
				throw new ArgumentNullException("owner");
			}
			return InstantiateNibWithOwnerTopLevelObjects (owner.GetType (), resourceName, owner);
		}
Ejemplo n.º 9
0
 /// <summary>
 /// Create a <see cref="NSImage"/> from a file.
 /// </summary>
 /// <param name="filename">The filename.</param>
 /// <returns>An autoreleased <see cref="NSImage"/> instance</returns>
 public static NSImage ImageFromFile(NSString filename)
 {
     NSImage result = null;
     if (filename != null)
     {
         NSData data = NSData.DataWithContentsOfFile(filename);
         result = new NSImage(data);
         result.Autorelease();
     }
     return result;
 }
Ejemplo n.º 10
0
        public void BurnLayoutWithDescription(Id layout, NSString desc)
        {
            DRBurnSetupPanel bsp = DRBurnSetupPanel.SetupPanel;

            if (bsp.RunSetupPanel() == NSPanel.NSOKButton)
            {
                DRBurnProgressPanel bpp = DRBurnProgressPanel.ProgressPanel;

                bpp.Description = desc;
                bpp.BeginProgressPanelForBurnLayout(bsp.BurnObject, layout);
            }
        }
        public NSTextField AddTextFieldWithIdentifierSuperView(NSString identifier, NSView superview)
        {
            NSTextField textField = new NSTextField ();
            textField.Identifier = identifier;
            textField.Cell.ControlSize = NSControlSize.NSSmallControlSize;
            textField.IsBordered = true;
            textField.IsBezeled = true;
            textField.IsSelectable = true;
            textField.IsEditable = true;
            textField.Font = NSFont.SystemFontOfSize (11);
            textField.AutoresizingMask = NSAutoresizingMask.NSViewMaxXMargin | NSAutoresizingMask.NSViewMinYMargin;
            textField.TranslatesAutoresizingMaskIntoConstraints = false;
            superview.AddSubview (textField);

            return textField.Autorelease<NSTextField> ();
        }
        public NSButton AddPushButtonWithTitleIdentifierSuperView(NSString title, NSString identifier, NSView superview)
        {
            NSButton pushButton = new NSButton ();
            pushButton.Identifier = identifier;
            pushButton.BezelStyle = NSBezelStyle.NSRoundRectBezelStyle;
            pushButton.Font = NSFont.SystemFontOfSize (12);
            pushButton.AutoresizingMask = NSAutoresizingMask.NSViewMaxXMargin | NSAutoresizingMask.NSViewMinYMargin;
            pushButton.TranslatesAutoresizingMaskIntoConstraints = false;
            superview.AddSubview (pushButton);
            if (title != null) {
                pushButton.Title = title;
            }
            pushButton.Target = this;
            pushButton.Action = ObjectiveCRuntime.Selector ("shuffleTitleOfSender:");

            return pushButton.Autorelease<NSButton> ();
        }
Ejemplo n.º 13
0
        private static bool FindFirstMatch(ABMultiValue multiValue, NSString label, ref uint index)
        {
            uint mvCount;

            mvCount = multiValue.Count;
            if (mvCount > 0)
            {
                for (uint x = 0; x < mvCount; x++)
                {
                    NSString text = multiValue.LabelAtIndex(x);
                    NSComparisonResult result = text.Compare(label);

                    if (result == NSComparisonResult.NSOrderedSame)
                    {
                        index = x;
                        return true;
                    }
                }
            }
            return false;
        }
Ejemplo n.º 14
0
        private bool GetImageDataFromPath(NSString path)
        {
            this.data = Marshal.AllocHGlobal (TEXTURE_WIDTH * TEXTURE_HEIGHT * 4);

            NSURL url = NSURL.FileURLWithPath (path);
            IntPtr src = CGImageSource.CreateWithURL (url, null);

            if (src == IntPtr.Zero) {
                Marshal.FreeHGlobal (this.data);
                return false;
            }

            IntPtr image = CGImageSource.CreateImageAtIndex (src, 0, null);
            CFType.CFRelease (image);

            NSUInteger width = CGImage.GetWidth (image);
            NSUInteger height = CGImage.GetHeight (image);

            IntPtr colorSpace = CGColorSpace.CreateDeviceRGB ();
            IntPtr context = CGBitmapContext.Create (data, width, height, 8, 4 * width, colorSpace, (CGBitmapInfo)CGImageAlphaInfo.kCGImageAlphaPremultipliedFirst | CGBitmapInfo.kCGBitmapByteOrder32Little);
            CGColorSpace.Release (colorSpace);

            // Core Graphics referential is upside-down compared to OpenGL referential
            // Flip the Core Graphics context here
            // An alternative is to use flipped OpenGL texture coordinates when drawing textures
            CGContext.TranslateCTM (context, 0, height);
            CGContext.ScaleCTM (context, 1, -1);

            // Set the blend mode to copy before drawing since the previous contents of memory aren't used. This avoids unnecessary blending.
            CGContext.SetBlendMode (context, CGBlendMode.kCGBlendModeCopy);

            CGContext.DrawImage (context, new CGRect (0, 0, width, height), image);

            CGContext.Release (context);
            CGImage.Release (image);

            return true;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// <para>Returns the NSImage instance associated with the specified name (from an encrypted content).</para>
        /// </summary>
        /// <param name="name">The name associated with the desired image.</param>
        /// <param name="encryptionSeed">The encryption seed to use.</param>
        /// <returns>The NSImage object associated with the specified name, or nil if no such image was found.</returns>
        public static NSImage ImageEncryptedNamed(NSString name, NSString encryptionSeed)
        {
            NSString fullName = ENCRYPTED_PREFIX + name;

            // Search for an object whose name was explicitly set
            NSImage image = NSImage.ImageNamed(fullName);
            if (image != null)
            {
                return image;
            }

            // Search the application's main bundle for a file whose name matches the specified string.
            NSString path = NSBundle.MainBundle.PathForImageResource(name);
            if (path != null)
            {
                image = ImageFromEncryptedPath(path, encryptionSeed);
                if (image != null)
                {
                    image.SetName(fullName);
                }
            }

            return image;
        }
Ejemplo n.º 16
0
        public NSToolbarItem ToolbarItemForItemIdentifierWillBeInsertedIntoToolbar(NSToolbar toolbar, NSString itemIdentifier, bool flag)
        {
            // We create and autorelease a new NSToolbarItem, and then go through the process of setting up its
            // attributes from the master toolbar item matching that identifier in our dictionary of items.
            NSToolbarItem newItem = new NSToolbarItem(itemIdentifier);
            newItem.Autorelease();
            NSToolbarItem item = this.toolbarItems[itemIdentifier].CastTo<NSToolbarItem>();

            newItem.Label = item.Label;
            newItem.PaletteLabel = item.PaletteLabel;
            if (item.View != null)
            {
                newItem.View = item.View;
            }
            else
            {
                newItem.Image = item.Image;
            }
            newItem.ToolTip = item.ToolTip;
            newItem.Target = item.Target;
            newItem.Action = item.Action;
            newItem.MenuFormRepresentation = item.MenuFormRepresentation;
            // If we have a custom view, we *have* to set the min/max size - otherwise, it'll default to 0,0 and the custom
            // view won't show up at all!  This doesn't affect toolbar items with images, however.
            if (newItem.View != null)
            {
                newItem.MinSize = item.View.Bounds.size;
                newItem.MaxSize = item.View.Bounds.size;
            }

            return newItem;
        }
Ejemplo n.º 17
0
 public virtual void GetURL(NSString x)
 {
     ObjectiveCRuntime.SendMessage(this, "GetURL:", x);
 }
Ejemplo n.º 18
0
 public virtual void CreateCalendarWithName(NSString withName)
 {
     ObjectiveCRuntime.SendMessage(this, "createCalendarWithName:", withName);
 }
        /// <summary>
        /// <para>Displays a modal sheet that shows the results of a certificate trust evaluation and that allows the user to edit trust settings.</para>
        /// <para>Original signature is '- (void)beginSheetForWindow:(NSWindow *)docWindow modalDelegate:(id)delegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo trust:(SecTrustRef)trust message:(NSString *)message'</para>
        /// <para>Available in Mac OS X v10.3 and later.</para>
        /// </summary>
        /// <param name="docWindow">The parent window to which the sheet is attached.</param>

        /// <param name="modalDelegate">The delegate object in which the method specified in the didEndSelector parameter is implemented.</param>
        /// <param name="contextInfo">A pointer to data that is passed to the delegate method. You can use this data pointer for any purpose you wish.</param>
        /// <param name="trust">A trust management object. Use the SecTrustCreateWithCertificates function (in Security/SecTrust.h) to create the trust management object.</param>
        /// <param name="message">A message string to display in the sheet.</param>

        public void BeginSheetForWindowModalDelegateDidEndSelectorContextInfoTrustMessage(NSWindow docWindow, SheetDidEndReturnCodeContextInfoEventHandler<SFCertificateTrustPanel> modalDelegate, IntPtr contextInfo, IntPtr trust, NSString message)
        {

            SFCertificateTrustPanelSheetDispatcher sheetDispatcher = new SFCertificateTrustPanelSheetDispatcher(modalDelegate);
            ObjectiveCRuntime.SendMessage(this, "beginSheetForWindow:modalDelegate:didEndSelector:contextInfo:trust:message:", docWindow, sheetDispatcher, ObjectiveCRuntime.Selector("panelDidEnd:returnCode:contextInfo:"), contextInfo, trust, message);
        }
Ejemplo n.º 20
0
 public void PasteboardProvideDataForType(NSPasteboard sender, NSString type)
 {
     // Sender has accepted the drag and now we need to send the data for the type we promised
     if (type.Compare(NSPasteboard.NSTIFFPboardType) == NSComparisonResult.NSOrderedSame)
     {
         sender.SetDataForType(this.Image.TIFFRepresentation, NSPasteboard.NSTIFFPboardType);
     }
     else if (type.Compare(NSPasteboard.NSPDFPboardType) == NSComparisonResult.NSOrderedSame)
     {
         sender.SetDataForType(this.DataWithPDFInsideRect(this.Bounds), NSPasteboard.NSPDFPboardType);
     }
 }
		public PropertyPageRdpAdvancedPerformanceController(NSString nibNameOrNil, NSBundle nibBundleOrNil) : base("initWithNibName:bundle:", nibNameOrNil, nibBundleOrNil) { }
Ejemplo n.º 22
0
        private static void AddToolbarItem(NSMutableDictionary theDict, NSString identifier, NSString label, NSString paletteLabel, NSString toolTip, Id target, IntPtr settingSelector, Id itemContent, IntPtr action, NSMenu menu)
        {
            NSMenuItem mItem;

            // here we create the NSToolbarItem and setup its attributes in line with the parameters
            NSToolbarItem item = new NSToolbarItem(identifier);
            item.Autorelease();
            item.Label = label;
            item.PaletteLabel = paletteLabel;
            item.ToolTip = toolTip;
            // the settingSelector parameter can either be @selector(setView:) or @selector(setImage:).  Pass in the right
            // one depending upon whether your NSToolbarItem will have a custom view or an image, respectively
            // (in the itemContent parameter).  Then this next line will do the right thing automatically.
            item.PerformSelectorWithObject(settingSelector, itemContent);
            item.Target = target;
            item.Action = action;
            // If this NSToolbarItem is supposed to have a menu "form representation" associated with it (for text-only mode),
            // we set it up here.  Actually, you have to hand an NSMenuItem (not a complete NSMenu) to the toolbar item,
            // so we create a dummy NSMenuItem that has our real menu as a submenu.
            if (menu != null)
            {
                // we actually need an NSMenuItem here, so we construct one
                mItem = new NSMenuItem();
                mItem.Autorelease();
                mItem.Submenu = menu;
                mItem.Title = menu.Title;
                item.MenuFormRepresentation = mItem;
            }

            // Now that we've setup all the settings for this new toolbar item, we add it to the dictionary.
            // The dictionary retains the toolbar item for us, which is why we could autorelease it when we created
            // it (above).
            theDict[identifier] = item;
        }
Ejemplo n.º 23
0
        public NSArray ExtensionsForUTI(NSString uti)
        {
            // If anything goes wrong, we'll return nil, otherwise this will be the array of extensions for this image type.
            NSArray extensions = null;
            // Only get extensions for UTIs that are images (i.e. conforms to public.image aka kUTTypeImage)
            // This excludes PDF support that ImageIO advertises, but won't actually use.
            if (UTType.ConformsTo(uti, UTType.kUTTypeImage))
            {
                // Copy the declaration for the UTI (if it exists)
                NSDictionary declaration = UTType.CopyDeclaration(uti);
                if (declaration != null)
                {
                    // Grab the tags for this UTI, which includes extensions, OSTypes and MIME types.
                    Id specifications = declaration.ValueForKey(UTType.kUTTypeTagSpecificationKey);
                    if (specifications != null)
                    {
                        NSDictionary tags = specifications.CastTo<NSDictionary>();

                        // We are interested specifically in the extensions that this UTI uses
                        Id filenameExtensions = tags.ValueForKey(UTType.kUTTagClassFilenameExtension);
                        if (filenameExtensions != null)
                        {
                            // It is valid for a UTI to export either an Array (of Strings) representing multiple tags,
                            // or a String representing a single tag.
                            if (filenameExtensions.SendMessage<bool>("isKindOfClass:", NSString.NSStringClass))
                            {
                                // If a string was exported, then wrap it up in an array.
                                extensions = NSArray.ArrayWithObject(filenameExtensions);
                            }
                            else if (filenameExtensions.SendMessage<bool>("isKindOfClass:", NSArray.NSArrayClass))
                            {
                                // If an array was exported, then just return that array.
                                extensions = filenameExtensions.CastTo<NSArray>().Copy<NSArray>();
                                extensions.Autorelease();
                            }
                        }
                    }
                    declaration.Release();
                }
            }
            return extensions;
        }
Ejemplo n.º 24
0
 public override bool LoadDataRepresentationOfType(NSData data, NSString aType)
 {
     // Insert code here to read your document from the given data.  You can also choose to override
     // -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead.
     return true;
 }
Ejemplo n.º 25
0
 /// <summary>
 /// <para>Returns a localized version of a string.</para>
 /// <para>Original signature is 'NSString *NSLocalizedString(NSString *key, NSString *comment)'</para>
 /// <para>Available in Mac OS X v10.0 and later.</para>
 /// </summary>
 public static NSString NSLocalizedString(NSString key,
                                          NSString comment)
 {
     return NSBundle.MainBundle.LocalizedStringForKeyValueTable(key, NSString.Empty, null);
 }
Ejemplo n.º 26
0
 public void BeginSheetForDirectoryFileModalForWindowModalDelegateDidEndSelectorContextInfo(NSString path, NSString name, NSWindow docWindow, SheetDidEndReturnCodeContextInfoEventHandler<NSSavePanel> modalDelegate, IntPtr contextInfo)
 {
     NSSavePanelSheetDispatcher dispatcher = new NSSavePanelSheetDispatcher(modalDelegate);
     ObjectiveCRuntime.SendMessage(this, "beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:", path, name, docWindow, dispatcher, ObjectiveCRuntime.Selector("panelDidEnd:returnCode:contextInfo:"), contextInfo);
 }
Ejemplo n.º 27
0
 public override NSData DataRepresentationOfType(NSString aType)
 {
     // Insert code here to write your document from the given data.  You can also choose to override
     // -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.
     return null;
 }
Ejemplo n.º 28
0
		public static NSDecimal FromString (NSString value)
		{
			NSDecimalNumber number = new NSDecimalNumber (value);
			NSDecimal @decimal = number.DecimalValue;
			number.Release ();
			return @decimal;
		}
Ejemplo n.º 29
0
 /// <summary>
 /// Decrypts the given data by using the <see cref="ArtworkEncrypter"/> tool.
 /// </summary>
 /// <param name="encryptedData">The encrypted artwork data.</param>
 /// <param name="encryptionSeed">The encryption seed to use.</param>
 /// <returns>The decrypted artwork data.</returns>
 public static NSData DecryptData(NSData encryptedData, NSString encryptionSeed)
 {
     NSData result;
     try
     {
         Aes aes = FileEncrypter.GetProvider(encryptionSeed);
         byte[] encryptedBytes = encryptedData.GetBuffer();
         byte[] decryptedBytes = FileEncrypter.Decrypt(encryptedBytes, aes);
         result = new NSData(decryptedBytes);
     }
     catch (Exception e)
     {
         Logger.Warn("NSData", "Cannot decrypt encrypted data: " + e);
         result = NSData.Data.Copy<NSData>();
     }
     return result.SafeAutorelease<NSData>();
 }
Ejemplo n.º 30
0
 private void WebViewDidReceiveTitleForFrame(WebView sender, NSString title, WebFrame frame)
 {
     this.window.Title = title;
 }