Example #1
0
        public void TableViewWillDisplayCell(NSTableView aView, Id aCell, NSTableColumn aTableColumn, int aRow)
        {
            NSString identifier = aTableColumn.Identifier.CastTo <NSString>();

            if (identifier.Compare(NSString.StringWithUTF8String("standby")) == NSComparisonResult.NSOrderedSame)
            {
                NSButtonCell cell = aCell.CastTo <NSButtonCell>();

                Room r = iModel.Items[aRow];
                cell.Image          = r.Standby ?  Properties.Resources.IconStandby : Properties.Resources.IconStandbyOn;
                cell.AlternateImage = r.Standby ? Properties.Resources.IconStandby : Properties.Resources.IconStandbyOn;
                cell.IsEnabled      = !r.Standby;
            }
            if (identifier.Compare(NSString.StringWithUTF8String("selected")) == NSComparisonResult.NSOrderedSame)
            {
                NSImageCell cell = aCell.CastTo <NSImageCell>();

                if (aRow == SelectedIndex)
                {
                    cell.Image     = Properties.Resources.IconTick;
                    cell.IsEnabled = true;
                }
                else
                {
                    cell.Image     = null;
                    cell.IsEnabled = false;
                }
            }
        }
Example #2
0
        private void ModelChanged(object sender, EventArgs e)
        {
            // clear existing room list
            iRooms.Release();
            iRooms = new NSMutableArray();

            bool roomsOutOfStandby = false;

            // add current list of rooms
            foreach (Linn.Kinsky.Room room in iModel.Items)
            {
                if (!room.Standby)
                {
                    roomsOutOfStandby = true;
                }
                RoomData data = new RoomData();
                data.SetName(room.Name);

                iRooms.AddObject(data);
                data.Release();
            }

            ButtonStandbyAll.IsEnabled = roomsOutOfStandby;
            ButtonStandbyAll.Image     = roomsOutOfStandby ? Properties.Resources.IconStandbyOn : Properties.Resources.IconStandby;

            // notify that there has been a change in the room list **before** the change in selection
            WillChangeValueForKey(NSString.StringWithUTF8String("rooms"));
            DidChangeValueForKey(NSString.StringWithUTF8String("rooms"));

            WillChangeValueForKey(NSString.StringWithUTF8String("selectionIndices"));
            DidChangeValueForKey(NSString.StringWithUTF8String("selectionIndices"));
        }
Example #3
0
        public string DeleteContact(string id)
        {
            try
            {
                CNContactStore contactStore = new CNContactStore();
                CNSaveRequest  saveRequest  = new CNSaveRequest();

                NSError   searchError;
                NSString  searchId      = NSString.StringWithUTF8String(id);
                CNContact nativeContact = contactStore.UnifiedContactWithIdentifier(searchId, GetPropertyKeys(), out searchError);

                if (searchError != null)
                {
                    return(searchError.LocalizedDescription);
                }

                saveRequest.DeleteContact(nativeContact.MutableCopy());

                NSError deleteError;
                bool    executeSuccess = contactStore.ExecuteSaveRequest(saveRequest, out deleteError);
                return(executeSuccess
                    ? null
                    : deleteError != null
                        ? deleteError.LocalizedDescription
                        : ExecuteSaveRequestFailedMessage);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Example #4
0
        private void UpdateControls()
        {
            switch (iState)
            {
            case EState.eChecking:
                Text.StringValue         = NSString.StringWithUTF8String("Checking for updates...");
                Progress.IsIndeterminate = true;
                Progress.StartAnimation(this);
                DisableButton(ButtonDetails);
                DisableButton(ButtonUpdate);
                EnableButton(ButtonClose, true);
                break;

            case EState.eUnavailable:
                Progress.StopAnimation(this);
                Progress.IsIndeterminate = false;
                Text.StringValue         = NSString.StringWithUTF8String("There are no updates available.");
                DisableButton(ButtonDetails);
                DisableButton(ButtonUpdate);
                EnableButton(ButtonClose, true);
                break;

            case EState.eAvailable:
                Progress.StopAnimation(this);
                Progress.IsIndeterminate = false;
                Text.StringValue         = NSString.StringWithUTF8String(string.Format("There is a new version of {0} ({1}) available.", iUpdateInfo.Name, iUpdateInfo.Version));
                EnableButton(ButtonDetails, false);
                EnableButton(ButtonClose, false);
                EnableButton(ButtonUpdate, true);
                break;

            case EState.eDownloading:
                Text.StringValue = NSString.StringWithUTF8String(string.Format("Downloading {0} ({1}).", iUpdateInfo.Name, iUpdateInfo.Version));
                EnableButton(ButtonDetails, false);
                EnableButton(ButtonClose, false);
                DisableButton(ButtonUpdate);
                break;

            case EState.eUpdating:
                Progress.IsIndeterminate = true;
                Progress.StartAnimation(this);
                Text.StringValue = NSString.StringWithUTF8String(string.Format("Updating {0} to {1}.", iUpdateInfo.Name, iUpdateInfo.Version));
                DisableButton(ButtonDetails);
                DisableButton(ButtonClose);
                DisableButton(ButtonUpdate);
                break;

            case EState.eFailed:
                Progress.IsIndeterminate = false;
                Progress.StopAnimation(this);
                Progress.DoubleValue = 0;
                Text.StringValue     = NSString.StringWithUTF8String(string.Format("The update failed."));
                DisableButton(ButtonDetails);
                EnableButton(ButtonClose, true);
                DisableButton(ButtonUpdate);
                break;
            }
        }
Example #5
0
 private static UIImage LoadImageAtPath(string url, int maxSize)
 {
     try
     {
         var nsurl = NSURL.URLWithString(NSString.StringWithUTF8String(url));
         return(UIImage.ImageWithContentsOfFile(nsurl.Path));
     }
     catch (Exception e)
     {
         Debug.LogWarning(string.Format("Exception when trying to load image from url: {0}. Exception: {1}", url ?? "null", e.ToString()));
         return(null);
     }
 }
Example #6
0
        private void ModelTransportChanged(object sender, EventArgs e)
        {
            switch (iModelTransport.TransportState)
            {
            case ETransportState.ePlaying:
            case ETransportState.eBuffering:
                MenuItemPlayPauseStop.Title = NSString.StringWithUTF8String(iModelTransport.PauseNotStop ? "Pause" : "Stop");
                break;

            default:
                MenuItemPlayPauseStop.Title = NSString.StringWithUTF8String("Play");
                break;
            }
        }
Example #7
0
        private void ModelChanged(object sender, EventArgs e)
        {
            iBookmarks.Release();
            iBookmarks = new NSMutableArray();

            foreach (Bookmark b in iBookmarkManager.Bookmarks)
            {
                BookmarkData data = new BookmarkData(b);
                iBookmarks.AddObject(data);
                data.Release();
            }

            WillChangeValueForKey(NSString.StringWithUTF8String("bookmarks"));
            DidChangeValueForKey(NSString.StringWithUTF8String("bookmarks"));
        }
Example #8
0
        private static NSArray <CNLabeledValue <CNPhoneNumber> > ToCNContactPhoneNumbers(KeyValuePair <string, string>[] phoneNumbers)
        {
            if (phoneNumbers == null)
            {
                return(null);
            }

            var result = new NSMutableArray <CNLabeledValue <CNPhoneNumber> >();

            foreach (var phoneNumber in phoneNumbers)
            {
                NSString      label  = NSString.StringWithUTF8String(phoneNumber.Key);
                CNPhoneNumber number = CNPhoneNumber.PhoneNumberWithStringValue(phoneNumber.Value);
                result.AddObject(CNLabeledValue <CNPhoneNumber> .LabeledValueWithLabel(label, number));
            }
            return(result);
        }
Example #9
0
        private static NSArray <CNLabeledValue <NSString> > ToCNCotactEmails(KeyValuePair <string, string>[] emails)
        {
            if (emails == null)
            {
                return(null);
            }

            var result = new NSMutableArray <CNLabeledValue <NSString> >();

            foreach (var email in emails)
            {
                NSString label       = NSString.StringWithUTF8String(email.Key);
                NSString nativeEmail = NSString.StringWithUTF8String(email.Value);
                result.AddObject(CNLabeledValue <NSString> .LabeledValueWithLabel(label, nativeEmail));
            }
            return(result);
        }
Example #10
0
        public static CNMutableContact ToCNMutableContact(this Contact contact)
        {
            if (contact == null)
            {
                return(null);
            }

            CNMutableContact nativeContact = new CNMutableContact();

            if (contact.FirstName != null)
            {
                nativeContact.GivenName = NSString.StringWithUTF8String(contact.FirstName);
            }

            if (contact.MiddleName != null)
            {
                nativeContact.MiddleName = NSString.StringWithUTF8String(contact.MiddleName);
            }

            if (contact.LastName != null)
            {
                nativeContact.FamilyName = NSString.StringWithUTF8String(contact.LastName);
            }

            if (contact.Company != null)
            {
                nativeContact.OrganizationName = NSString.StringWithUTF8String(contact.Company);
            }


            if (contact.Birthday != null)
            {
                nativeContact.Birthday = contact.Birthday.Value.ToNSDateComponents();
            }

            nativeContact.EmailAddresses = ToCNCotactEmails(contact.Emails);
            nativeContact.PhoneNumbers   = ToCNContactPhoneNumbers(contact.PhoneNumbers);

            if (contact.Photo != null)
            {
                byte[] rawData = TextureUtilities.EncodeAsByteArray(contact.Photo, ImageFormat.PNG);
                nativeContact.ImageData = NSData.DataWithBytes(rawData, (uint)rawData.Length);
            }

            return(nativeContact);
        }
Example #11
0
        public void Draw(NSRect aCellFrame, NSView aControlView)
        {
            BookmarkData item = ObjectValue.CastAs <BookmarkData>();

            // create attributes for the title and subtitle text
            NSMutableParagraphStyle style = new NSMutableParagraphStyle();

            style.SetParagraphStyle(NSParagraphStyle.DefaultParagraphStyle);
            style.SetLineBreakMode(NSLineBreakMode.NSLineBreakByTruncatingTail);

            NSDictionary titleAttr = NSDictionary.DictionaryWithObjectsAndKeys(FontManager.FontMedium, NSAttributedString.NSFontAttributeName,
                                                                               NSColor.WhiteColor, NSAttributedString.NSForegroundColorAttributeName,
                                                                               style, NSAttributedString.NSParagraphStyleAttributeName,
                                                                               null);
            NSDictionary subtitleAttr = NSDictionary.DictionaryWithObjectsAndKeys(FontManager.FontSmall, NSAttributedString.NSFontAttributeName,
                                                                                  NSColor.WhiteColor, NSAttributedString.NSForegroundColorAttributeName,
                                                                                  style, NSAttributedString.NSParagraphStyleAttributeName,
                                                                                  null);

            style.Release();

            NSPoint pt = aCellFrame.origin;

            // draw title
            NSString title = NSString.StringWithUTF8String(item.Bookmark.Title);

            title.DrawAtPointWithAttributes(pt, titleAttr);

            NSSize size = title.SizeWithAttributes(titleAttr);

            pt.y += size.height;

            // draw breadcrumb
            List <string> titleTrail = new List <string>();

            foreach (Breadcrumb bc in item.Bookmark.BreadcrumbTrail)
            {
                titleTrail.Add(bc.Title);
            }
            string   breadcrumb  = string.Join("/", titleTrail.ToArray());
            NSString breadcrumb2 = NSString.StringWithUTF8String(breadcrumb);

            breadcrumb2.DrawAtPointWithAttributes(pt, subtitleAttr);
        }
Example #12
0
        private void ButtonDetailsClicked(Id aSender)
        {
            try
            {
                System.Diagnostics.Process.Start(iUpdateInfo.History.AbsoluteUri);
            }
            catch (Exception)
            {
                NSAlert alert = new NSAlert();

                alert.AddButtonWithTitle(NSString.StringWithUTF8String("Close"));
                alert.MessageText     = NSString.StringWithUTF8String("Failed to retrieve update details.");
                alert.InformativeText = NSString.StringWithUTF8String("Failed to contact " + iUpdateInfo.History);
                alert.AlertStyle      = NSAlertStyle.NSWarningAlertStyle;

                alert.BeginSheetModalForWindowModalDelegateDidEndSelectorContextInfo(Window, null, IntPtr.Zero);

                alert.Release();
            }
        }
Example #13
0
        private void ButtonUpdateClicked(Id aSender)
        {
            if (iUpdateInfo.IsCompatibilityFamilyUpgrade)
            {
                NSAlert alert = new NSAlert();

                alert.AddButtonWithTitle(NSString.StringWithUTF8String("Update"));
                alert.AddButtonWithTitle(NSString.StringWithUTF8String("Cancel"));
                alert.MessageText     = NSString.StringWithUTF8String("This is a compatibility family upgrade. Do you wish to continue with the upgrade?");
                alert.InformativeText = NSString.StringWithUTF8String("Updating " + iUpdateInfo.Name + " to a new compatibility family will also require updating Linn DS firmware.");
                alert.AlertStyle      = NSAlertStyle.NSWarningAlertStyle;

                alert.BeginSheetModalForWindowModalDelegateDidEndSelectorContextInfo(Window, CompatibilityAlertEnd, IntPtr.Zero);

                alert.Release();
            }
            else
            {
                CompatibilityAlertEnd(null, NSAlert.NSAlertFirstButtonReturn, IntPtr.Zero);
            }
        }
Example #14
0
        private void ModelChanged(object sender, EventArgs e)
        {
            // clear existing source list
            iSources.Release();
            iSources = new NSMutableArray();

            // add current list of sources
            foreach (Linn.Kinsky.Source source in iModel.Items)
            {
                SourceData data = new SourceData(source);
                iSources.AddObject(data);
                data.Release();
            }

            // notify that there has been a change in the source list **before** the change in selection
            WillChangeValueForKey(NSString.StringWithUTF8String("sources"));
            DidChangeValueForKey(NSString.StringWithUTF8String("sources"));

            WillChangeValueForKey(NSString.StringWithUTF8String("selectionIndices"));
            DidChangeValueForKey(NSString.StringWithUTF8String("selectionIndices"));
        }
Example #15
0
        public void AwakeFromNib()
        {
            // set appearance of view
            LabelHeader.TextColor = NSColor.WhiteColor;
            LabelHeader.Font      = FontManager.FontLarge;

            LabelTitle.TextColor = NSColor.WhiteColor;
            LabelTitle.Font      = FontManager.FontMedium;

            LabelLocation.TextColor = NSColor.WhiteColor;
            LabelLocation.Font      = FontManager.FontMedium;

            TextFieldTitle.BackgroundColor = NSColor.BlackColor;
            TextFieldTitle.TextColor       = NSColor.WhiteColor;
            TextFieldTitle.Font            = FontManager.FontMedium;

            TextFieldLocation.TextColor = NSColor.WhiteColor;
            TextFieldLocation.Font      = FontManager.FontMedium;

            IButtonHoverType2 button = ButtonAdd.Initialise();

            button.Text = NSString.StringWithUTF8String("Add");

            ButtonAdd.EventClicked += ButtonAddClicked;
            ButtonAdd.KeyEquivalent = NSString.StringWithUTF8String("\r");
            TextFieldTitle.Delegate = this;

            // set the data for the current location
            TextFieldTitle.StringValue = NSString.StringWithUTF8String(iBookmark.Title);

            List <string> titleTrail = new List <string>();

            foreach (Breadcrumb bc in iBookmark.BreadcrumbTrail)
            {
                titleTrail.Add(bc.Title);
            }
            TextFieldLocation.StringValue = NSString.StringWithUTF8String(string.Join("/", titleTrail.ToArray()));
        }
Example #16
0
        public void AwakeFromNib()
        {
            TextFieldName.Font      = FontManager.FontSemiLarge;
            TextFieldVersion.Font   = FontManager.FontMedium;
            TextFieldCopyright.Font = FontManager.FontMedium;

            IHelper helper = ModelMain.Instance.Helper;

            string version = "Version " + helper.Version;

            if (helper.Title.ToLowerInvariant().Contains("nightly"))
            {
                NSString buildVersion = NSBundle.MainBundle.InfoDictionary[NSString.StringWithUTF8String("CFBundleVersion")].CastAs <NSString>();

                version += "." + buildVersion.ToString();
            }
            version += " (" + helper.Family + ")";

            ImageAppIcon.Image             = Properties.Resources.ImageAbout;
            TextFieldName.StringValue      = NSString.StringWithUTF8String(helper.Product);
            TextFieldVersion.StringValue   = version;
            TextFieldCopyright.StringValue = NSString.StringWithUTF8String(helper.Copyright + " " + helper.Company);
        }
Example #17
0
        public void TableViewWillDisplayCell(NSTableView aView, NSCell aCell, NSTableColumn aTableColumn, int aRow)
        {
            NSString identifier = aTableColumn.Identifier.CastTo <NSString>();

            if (identifier.Compare(NSString.StringWithUTF8String("selected")) == NSComparisonResult.NSOrderedSame)
            {
                NSImageCell cell = aCell.CastTo <NSImageCell>();
                if (aRow == SelectedIndex)
                {
                    cell.Image     = Properties.Resources.IconTick;
                    cell.IsEnabled = true;
                }
                else
                {
                    cell.Image     = null;
                    cell.IsEnabled = false;
                }
            }
            else
            {
                aCell.RepresentedObject = iSources.ObjectAtIndex((uint)aRow);
            }
        }
Example #18
0
        private MediaResult CreateResult(PickerOperation operation, NSDictionary <NSString, iOSObjectProxy> info)
        {
            if (info == null)
            {
                return(null);
            }

            switch (Operation)
            {
            case PickerOperation.PickGallery:
                // User can either pick an image or a video
                NSURL pickedURL = null;
                if (TryGetUrl(info, UIImagePickerController.UIImagePickerControllerImageURL, out pickedURL))
                {
                    return(new MediaResult(MediaType.Image, null, pickedURL.AbsoluteString.UTF8String));
                }
                else if (TryGetUrl(info, UIImagePickerController.UIImagePickerControllerMediaURL, out pickedURL))
                {
                    return(new MediaResult(MediaType.Video, null, pickedURL.AbsoluteString.UTF8String));
                }
                else
                {
                    return(null);
                }

            case PickerOperation.TakePicture:
                // Get the newly taken image, save it into the into user temporary folder and return the URL.
                // The image name will be "IMG_" + timestamp and format is JPG.
                UIImage picture = (UIImage)info.ValueForKey(UIImagePickerController.UIImagePickerControllerOriginalImage,
                                                            ptr => PInvokeUtil.IsNull(ptr) ? null : new UIImage(ptr));

                if (picture == null)
                {
                    Debug.LogError("Couldn't get the taken picture.");
                    return(null);
                }

                // Save the image into user temporary folder and return the URL.
                NSString tempDir = NSFileManager.NSTemporaryDirectory();

                if (tempDir == null)
                {
                    Debug.LogError("Couldn't find the path of user's temporary directory.");
                    return(null);
                }

                // The image name is "IMG_" + timestamp and format is JPG.
                NSString pictureName = NSString.StringWithUTF8String("IMG_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg");
                NSURL    pictureURL  = NSURL.FileURLWithPath(tempDir).URLByAppendingPathComponent(pictureName);

                if (pictureURL != null)
                {
                    NSData imageData = UIFunctions.UIImageJPEGRepresentation(picture, 1f);
                    NSFileManager.DefaultManager.CreateFileAtPath(pictureURL.Path, imageData, null);
                    return(new MediaResult(MediaType.Image, null, pictureURL.AbsoluteString.UTF8String));
                }
                else
                {
                    return(null);
                }

            case PickerOperation.RecordVideo:
                NSURL videoURL = null;
                if (TryGetUrl(info, UIImagePickerController.UIImagePickerControllerMediaURL, out videoURL))
                {
                    return(new MediaResult(MediaType.Video, null, videoURL.AbsoluteString.UTF8String));
                }
                else
                {
                    return(null);
                }

            default:
                return(null);
            }
        }
Example #19
0
 private void EnableButton(NSButton aButton, bool aDefault)
 {
     aButton.IsEnabled     = true;
     aButton.KeyEquivalent = aDefault ? NSString.StringWithUTF8String("\r") : NSString.Empty;
 }
Example #20
0
        private void ProcessRequests()
        {
            while (true)
            {
                // wait for an artwork request
                iPendingRequests.Wait();

                // get the first request in the queue - leave the request in the queue for now so that if
                // the main thread requests it again, it will not get re-added and downloaded again
                string uri;
                ScalingUriConverter uriConverter;
                lock (iLock)
                {
                    uri          = iPendingRequests.FirstRequest;
                    uriConverter = iUriConverter;
                }

                Trace.WriteLine(Trace.kKinskyDesktop, "ArtworkCache requesting  " + uri);

                // download the image
                NSAutoreleasePool pool = new NSAutoreleasePool();
                pool.Init();

                NSImage image = null;
                try
                {
                    string requestUri = uri;
                    if (uriConverter != null)
                    {
                        requestUri = uriConverter.Convert(requestUri);
                    }
                    NSString s   = NSString.StringWithUTF8String(Uri.UnescapeDataString(requestUri));
                    NSURL    url = NSURL.URLWithString(s.StringByAddingPercentEscapesUsingEncoding(NSStringEncoding.NSUTF8StringEncoding));

                    image = new NSImage(url);
                }
                catch (Exception e)
                {
                    UserLog.WriteLine("ArtworkCache.ProcessRequests: " + uri + " (" + e.Message + ")");
                }

                pool.Release();

                // insert the image into the cache
                List <Item> staleItems;
                lock (iLock)
                {
                    // add to the cache
                    Item item = new Item(uri, image);
                    staleItems = iCacheData.Add(item);

                    // remove the request
                    iPendingRequests.Remove(uri);
                }

                // send notification that the image was added to the cache
                if (EventImageAdded != null)
                {
                    EventImageAdded(this, new EventArgsArtwork(uri));
                }

                // clean up all stale items outside of the lock
                foreach (Item item in staleItems)
                {
                    if (item.Image != null)
                    {
                        item.Image.Release();
                    }
                }
            }
        }
Example #21
0
        public void Draw(NSRect aCellFrame, NSView aControlView)
        {
            WrappedDataTrackItem wrapped = ObjectValue.CastAs <WrappedDataTrackItem>();
            IDataTrackItem       item    = wrapped.Item;

            // create attributes for the title and subtitle text
            NSMutableParagraphStyle style = new NSMutableParagraphStyle();

            style.SetParagraphStyle(NSParagraphStyle.DefaultParagraphStyle);
            style.SetLineBreakMode(NSLineBreakMode.NSLineBreakByTruncatingTail);

            // set font sizes depending on whether this item is a group or track
            NSFont titleFont    = item.IsGroup ? FontManager.FontLarge : FontManager.FontSemiLarge;
            NSFont subtitleFont = item.IsGroup ? FontManager.FontMedium : FontManager.FontSmall;

            NSDictionary titleAttr = NSDictionary.DictionaryWithObjectsAndKeys(titleFont, NSAttributedString.NSFontAttributeName,
                                                                               NSColor.WhiteColor, NSAttributedString.NSForegroundColorAttributeName,
                                                                               style, NSAttributedString.NSParagraphStyleAttributeName,
                                                                               null);
            NSDictionary subtitleAttr = NSDictionary.DictionaryWithObjectsAndKeys(subtitleFont, NSAttributedString.NSFontAttributeName,
                                                                                  NSColor.WhiteColor, NSAttributedString.NSForegroundColorAttributeName,
                                                                                  style, NSAttributedString.NSParagraphStyleAttributeName,
                                                                                  null);

            style.Release();

            float  vertPos     = aCellFrame.origin.y;
            float  titleIndent = 0.0f;
            NSSize size;
            NSRect rect;

            // draw index for non-group items
            if (!item.IsGroup)
            {
                NSString index = NSString.StringWithUTF8String(string.Format("{0}. ", item.Index + 1));

                size = index.SizeWithAttributes(titleAttr);
                rect = new NSRect(aCellFrame.MinX, vertPos, size.width, size.height);
                index.DrawInRectWithAttributes(rect, titleAttr);

                titleIndent = size.width;
            }

            // draw the title
            NSString title = NSString.StringWithUTF8String(item.Title);

            size = title.SizeWithAttributes(titleAttr);
            rect = new NSRect(aCellFrame.MinX + titleIndent, vertPos, aCellFrame.Width - titleIndent, size.height);
            title.DrawInRectWithAttributes(rect, titleAttr);

            vertPos += size.height;

            // draw subtitle 1 aligned with the left of the cell
            if (item.Subtitle1 != string.Empty)
            {
                NSString subtitle1 = NSString.StringWithUTF8String(item.Subtitle1);

                size = subtitle1.SizeWithAttributes(subtitleAttr);
                rect = new NSRect(aCellFrame.MinX, vertPos, aCellFrame.Width, size.height);
                subtitle1.DrawInRectWithAttributes(rect, subtitleAttr);

                vertPos += size.height;
            }

            // draw subtitle 2 aligned with the left of the cell
            if (item.Subtitle2 != string.Empty)
            {
                NSString subtitle2 = NSString.StringWithUTF8String(item.Subtitle2);

                size = subtitle2.SizeWithAttributes(subtitleAttr);
                rect = new NSRect(aCellFrame.MinX, vertPos, aCellFrame.Width, size.height);
                subtitle2.DrawInRectWithAttributes(rect, subtitleAttr);
            }
        }
Example #22
0
    protected override void OnRun()
    {
        float bannerWidth  = 320;
        float bannerHeight = 50;

        if (iPhone.generation.ToString().StartsWith("iPad"))
        {
            bannerWidth  = 728;
            bannerHeight = 90;
        }

        // --------------------

        var keyWindow      = UIApplication.SharedApplication.KeyWindow;
        var viewController = keyWindow.RootViewController;
        var unityView      = keyWindow.Subviews.ObjectAtIndex(0);

        //var sz = new GADAdSize { Size_Width = 300, Size_Height = 250, Flags = 0 };
        //var sz = new GADAdSize { Size_Width = 320, Size_Height = 50, Flags = 0 };
        var sz = new GADAdSize {
            Size_Width = bannerWidth, Size_Height = bannerHeight, Flags = 0
        };
        var currentBannerView = GADBannerView.AllocInitWithAdSize(sz);

        if (currentBannerView.IsNil)
        {
            LOG("https://developers.google.com/mobile-ads-sdk/docs/#ios");
            LOG(" - Other Linker Flags: -ObjC");
            LOG(" - Frameworks:");
            LOG("    - AdSupport");
            LOG("    - AudioToolbox");
            LOG("    - AVFoundation");
            LOG("    - CoreGraphics");
            LOG("    - MessageUI");
            LOG("    - StoreKit");
            LOG("    - SystemConfiguration");
        }

        unityView.AddSubview(currentBannerView);

        currentBannerView.RootViewController = viewController;
        currentBannerView.AdUnitID           = NSString.StringWithUTF8String(admobId);

        var bannerDelegte = new ExampleOfBannerDelegate();

        currentBannerView.Delegate = bannerDelegte;

        var request     = GADRequest.New();
        var testDevices = AKiOS.NSMutableArray <NSString> .Array();

        testDevices.AddObject(NSString.StringWithUTF8String("1cf5076f1d9f0cd99458fd28e29dc3ea"));
        request.TestDevices = testDevices;
        currentBannerView.LoadRequest(request);

        float screenScale = AKiOS.UIScreen.MainScreen.Scale;

        currentBannerView.Center = new CGPoint()
        {
            x = Screen.width / 2 / screenScale, y = bannerHeight / 2
        };
        currentBannerView.Hidden = true;
    }
Example #23
0
 public NSObject tableView_objectValueForTableColumn_row(NSTableView aTableView, NSTableColumn aTableColumn, int aRowIndex)
 {
     return(NSString.StringWithUTF8String(iPages[aRowIndex].Name));
 }
Example #24
0
        public OptionDialogMonobjc(IList <IOptionPage> aOptionPages)
        {
            // create a list of option pages
            iPages = new List <OptionPageMonobjc>();

            NSRect windowRect     = new NSRect(0, 0, kWidth, kHeight);
            float  division       = kWidth / 4;
            NSRect scrollViewRect = new NSRect(kPadding, kPadding, division - (kPadding * 2), kHeight - (kPadding * 2));
            NSRect pageRect       = new NSRect(division + kPadding, kPadding, kWidth - division - (kPadding * 2), kHeight - (kPadding * 2));

            foreach (IOptionPage page in aOptionPages)
            {
                iPages.Add(new OptionPageMonobjc(page, pageRect));
            }

            // create main window for the dialog
            iWindow = new NSWindow(windowRect,
                                   NSWindowStyleMasks.NSClosableWindowMask |
                                   NSWindowStyleMasks.NSTitledWindowMask,
                                   NSBackingStoreType.NSBackingStoreBuffered,
                                   false);
            iWindow.Title = NSString.StringWithUTF8String("User Options");
            iWindow.SetDelegate(d =>
            {
                d.WindowShouldClose += delegate(Id aSender) { return(true); };
                d.WindowWillClose   += delegate(NSNotification aNotification) { NSApplication.NSApp.AbortModal(); };
            });
            iWindow.IsReleasedWhenClosed = false;

            // create a view for the window content
            NSView view = new NSView();

            iWindow.ContentView = view;

            iOptionsContainer       = new NSView();
            iOptionsContainer.Frame = new NSRect(view.Frame.origin.x, view.Frame.origin.y, view.Frame.Width, view.Frame.Height);

            NSScrollView scrollView = new NSScrollView();

            scrollView.HasVerticalScroller   = true;
            scrollView.HasHorizontalScroller = true;
            scrollView.AutohidesScrollers    = true;

            NSTableColumn tableColumn = new NSTableColumn();

            tableColumn.ResizingMask = NSTableColumnResizingMasks.NSTableColumnAutoresizingMask | NSTableColumnResizingMasks.NSTableColumnUserResizingMask;
            tableColumn.IsEditable   = false;

            iTableDelegate   = new OptionDialogMonobjcDelegate(iPages);
            iTableDataSource = new OptionDialogMonobjcDataSource(iPages);

            iTableDelegate.EventSelectedPage += EventSelectedPageHandler;

            iTableView            = new NSTableView();
            iTableView.DataSource = iTableDataSource;
            iTableView.HeaderView = null;
            iTableView.UsesAlternatingRowBackgroundColors = true;
            iTableView.AddTableColumn(tableColumn);
            iTableView.Delegate                = iTableDelegate;
            iTableView.AllowsEmptySelection    = false;
            iTableView.AllowsMultipleSelection = false;

            scrollView.Frame  = scrollViewRect;
            iTableView.Frame  = scrollView.ContentView.Bounds;
            tableColumn.Width = iTableView.Bounds.Width - 3;

            scrollView.DocumentView = iTableView;

            view.AddSubview(iOptionsContainer);
            iOptionsContainer.AddSubview(scrollView);

            iTableView.ReloadData();

            // view have been added to the window so they can be released
            view.Release();
            tableColumn.Release();
            scrollView.Release();
        }