public static MemoryStream Create(LabelStyle style, string text)
        {
            UIImage image  = null;
            var     handle = new ManualResetEvent(false);

            var view = new UIView();

            view.InvokeOnMainThread(() =>
            {
                view.Opaque          = false;
                view.BackgroundColor = UIColor.Clear;

                var bitmapSize = UIStringDrawing.StringSize(text, UIFont.SystemFontOfSize(14), new CGSize(115, float.MaxValue), UILineBreakMode.WordWrap);

                view.Layer.AddSublayer(CreateCATextLayer(style, text));
                view.BackgroundColor = new UIColor(ToCGColor(style.BackColor.Color));

                image = ToImage(view, new CGRect(0, 0, (float)bitmapSize.Width, (float)bitmapSize.Height));
                handle.Set();
            });

            handle.WaitOne();
            using (var nsdata = image.AsPNG())
            {
                return(new MemoryStream(nsdata.ToArray()));
            }
        }
示例#2
0
        //
        // Computes the X position for the entry by aligning all the entries in the Section
        //
        CGSize ComputeEntryPosition(UITableView tv, UITableViewCell cell)
        {
            if (Section.EntryAlignment.Width != 0)
            {
                return(Section.EntryAlignment);
            }

            // If all EntryElements have a null Caption, align UITextField with the Caption
            // offset of normal cells (at 10px).
            var max = new CGSize(-15, UIStringDrawing.StringSize("M", TitleFont).Height);

            foreach (var e in Section)
            {
                var ee = e as EntryElement;
                if (ee == null)
                {
                    continue;
                }

                if (ee.Caption != null)
                {
                    var size = UIStringDrawing.StringSize(ee.Caption, TitleFont);
                    if (size.Width > max.Width)
                    {
                        max = size;
                    }
                }
            }

            Section.EntryAlignment = new CGSize(25f + (nfloat)Math.Min(max.Width, 160), max.Height);
            return(Section.EntryAlignment);
        }
示例#3
0
        UITableViewCell CellForRow(UITableView tableView, NSIndexPath indexPath)
        {
            NSString CellIdentifier = new NSString("ThemeListCellTop");

            if (indexPath.Row > 0 && indexPath.Row < updates.Length - 1)
            {
                CellIdentifier = new NSString("ThemeListCellMiddle");
            }
            else if (indexPath.Row == updates.Length - 1)
            {
                CellIdentifier = new NSString("ThemeListCellBottom");
            }

            ThemeListCell cell = (ThemeListCell)tableView.DequeueReusableCell(CellIdentifier);

            cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            cell.MakeRoundedEdges();

            Update update = updates [indexPath.Row];

            cell.UpdateTitle(update.title);
            cell.UpdateAuthor(update.author);
            cell.UpdateLabel(update.updateText);

            var updateFrame = cell.LabelFrame;

            updateFrame.Height = UIStringDrawing.StringSize(update.updateText, UIFont.SystemFontOfSize(12f), new SizeF(222, 1000)).Height;
            cell.LabelFrame    = updateFrame;
            cell.SetAvatarImage(update.avatar);
            cell.SetTypeImage(update.updateTypeImage);

            return(cell);
        }
示例#4
0
        public ProgressLabel(string text)
            : base(new RectangleF(0, 0, 200, 44))
        {
            BackgroundColor = UIColor.Clear;

            activity = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White)
            {
                Frame            = new RectangleF(0, 11.5f, 21, 21),
                HidesWhenStopped = false,
                Hidden           = false,
            };
            AddSubview(activity);

            var label = new UILabel()
            {
                Text            = text,
                TextColor       = UIColor.White,
                Font            = UIFont.BoldSystemFontOfSize(20),
                BackgroundColor = UIColor.Clear,
                                #if !__UNIFIED__
                Frame = new RectangleF(25f, 0f, Frame.Width - 25, 44f),
                                #else
                Frame = new RectangleF(25f, 0f, (float)(Frame.Width - 25), 44f),
                                #endif
            };

            AddSubview(label);

            var f = Frame;

            f.Width = label.Frame.X + UIStringDrawing.StringSize(label.Text, label.Font).Width;
            Frame   = f;
        }
示例#5
0
        void UpdateUI()
        {
            var x = 44 + 6;

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                x += 15;                 // okay, we need a more thorough iOS 7 update than this, but for now this'll have to do
            }
            var fn = person.FirstNameAndInitials;

            firstNameLabel.Text = fn;
            var fnw = string.IsNullOrEmpty(fn) ?
                      0.0f :
                      UIStringDrawing.StringSize(fn, NormalFont).Width;
            var f = new CGRect(x, 4, fnw + 4, 20);

            firstNameLabel.Frame = f;

            var ln = person.SafeLastName;

            lastNameLabel.Text = ln;
            var lnw = string.IsNullOrEmpty(ln) ?
                      0.0f :
                      UIStringDrawing.StringSize(ln, BoldFont).Width;

            f.X                 = f.Right;
            f.Width             = lnw;
            lastNameLabel.Frame = f;

            detailsLabel.Text  = person.TitleAndDepartment ?? string.Empty;
            detailsLabel.Frame = new CGRect(x, 25, 258, 14);
        }
示例#6
0
        public override void LayoutSubviews()
        {
            if (EmptyOverlay.ShowIfRequired(ref emptyOverlay, showSpeaker, this, "No speaker info", EmptyOverlayType.Speaker))
            {
                return;
            }

            var full     = Bounds;
            var bigFrame = full;

            bigFrame.X      = ImageSpace + 13 + 17;
            bigFrame.Y      = y + 27;        // 15 -> 13
            bigFrame.Height = 26;
            bigFrame.Width -= (ImageSpace + 13 + 17);
            nameLabel.Frame = bigFrame;

            var smallFrame = full;

            smallFrame.X      = ImageSpace + 13 + 17;
            smallFrame.Y      = y + 27 + 26;
            smallFrame.Height = 15;             // 12 -> 15
            smallFrame.Width -= (ImageSpace + 13 + 17);
            titleLabel.Frame  = smallFrame;

            smallFrame.Y      += y + 17;
            companyLabel.Frame = smallFrame;

            image.Frame = new CGRect(13, y + 15, 80, 80);

            if (!String.IsNullOrEmpty(showSpeaker.Bio))
            {
                if (AppDelegate.IsPhone)
                {
                    // for now, hardcode iPhone dimensions to reduce regressions
                    CGSize size = UIStringDrawing.StringSize(showSpeaker.Bio
                                                             , bioTextView.Font
                                                             , new SizeF(310, 580)
                                                             , UILineBreakMode.WordWrap);
                    bioTextView.Frame = new CGRect(5, y + 115, 310, size.Height);
                }
                else
                {
                    var f = new CGSize(full.Width - 13 * 2, full.Height - (image.Frame.Y + 80 + 20));
//					SizeF size = bioTextView.StringSize (showSpeaker.Bio
//										, bioTextView.Font
//										, f
//										, UILineBreakMode.WordWrap);
                    bioTextView.Frame = new CGRect(5, image.Frame.Y + 80 + 10
                                                   , f.Width
                                                   , f.Height);
                }
            }
            else
            {
                bioTextView.Frame = new CGRect(5, y + 115, 310, 30);
            }
        }
示例#7
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();
            var full            = ContentView.Bounds;
            var titleAdjustment = 0;
            var titleFrame      = full;

            titleFrame.X      = padding;
            titleFrame.Y      = 12;                      //15 ?
            titleFrame.Height = 25;
            titleFrame.Width -= (padding + buttonSpace); // +10

            CGSize size = UIStringDrawing.StringSize(titleLabel.Text
                                                     , titleLabel.Font
                                                     , new CGSize(titleFrame.Width, 400));

            if (size.Height > 27)
            {
                titleAdjustment   = 27;
                titleFrame.Height = titleFrame.Height + titleAdjustment;                 //size.Height;
                titleLabel.Lines  = 2;
            }
            else
            {
                titleLabel.Lines = 1;
            }

            titleLabel.Frame = titleFrame;

            var locationImagePadding = 18 + 5;

            if (speakerLabel.Text == "")
            {
                locationImagePadding    = 0;
                locationImageView.Alpha = 0f;
            }
            else
            {
                locationImageView.Alpha = 1f;
            }

            var companyFrame = full;

            companyFrame.X = padding + locationImagePadding;                    // image is
            var bottomRowY = 15 + 23 + titleAdjustment;

            companyFrame.Y      = bottomRowY;
            companyFrame.Height = 14;             // 12 -> 14
            companyFrame.Width  = titleFrame.Width - locationImagePadding;
            speakerLabel.Frame  = companyFrame;

            locationImageView.Frame = new CGRect(padding, bottomRowY, 18, 16);

            button.Frame = new CGRect(full.Width - buttonSpace                          //-5
                                      , titleAdjustment / 2, buttonSpace, buttonSpace); // 10 +
        }
        /// <summary>
        ///
        /// </summary>
        public void Show()
        {
            UIButton v = UIButton.FromType(UIButtonType.Custom);

            view = v;

            UIFont font     = UIFont.SystemFontOfSize(16);
            CGSize textSize = UIStringDrawing.StringSize(Text, font, new CoreGraphics.CGSize(280, 60));

            UILabel label = new UILabel(new CGRect(0, 0, textSize.Width + 5, textSize.Height + 5));

            label.BackgroundColor = UIColor.Clear;
            label.TextColor       = UIColor.White;
            label.Font            = font;
            label.Text            = Text;
            label.Lines           = 0;
            label.ShadowColor     = UIColor.DarkGray;
            label.ShadowOffset    = new CGSize(1, 1);


            v.Frame      = new CGRect(0, 0, textSize.Width + 10, textSize.Height + 10);
            label.Center = new CGPoint(v.Frame.Size.Width / 2, v.Frame.Height / 2);
            v.AddSubview(label);

            v.BackgroundColor    = UIColor.FromRGBA(0, 0, 0, 0.7f);
            v.Layer.CornerRadius = 5;

            UIWindow window = UIApplication.SharedApplication.Windows[0];

            CGPoint point = new CGPoint(window.Frame.Size.Width / 2, window.Frame.Size.Height / 2);

            if (Gravity == ToastGravity.Top)
            {
                point = new CGPoint(window.Frame.Size.Width / 2, 45);
            }
            else if (Gravity == ToastGravity.Bottom)
            {
                point = new CGPoint(window.Frame.Size.Width / 2, window.Frame.Size.Height - 45);
            }
            else if (Gravity == ToastGravity.Center)
            {
                point = new CGPoint(window.Frame.Size.Width / 2, window.Frame.Size.Height / 2);
            }

            ///point = new CGPoint(point.X + offsetLeft, point.Y + offsetTop);
            point    = new CGPoint(point.X, point.Y);
            v.Center = point;
            window.AddSubview(v);
            v.AllTouchEvents += delegate { HideToast(); };


            Device.BeginInvokeOnMainThread(async() => {
                await Task.Delay(DurationSeconds);
                HideToast();
            });
        }
            public override void Draw(CGRect rect)
            {
                using (CGContext context = UIGraphics.GetCurrentContext())
                {
                    UIColor.Black.SetColor();

                    var boldFont    = UIFont.BoldSystemFontOfSize((nfloat)14.0f);
                    var regularFont = UIFont.SystemFontOfSize((nfloat)14.0f);

                    UIStringDrawing.DrawString(Title, new CGRect(4, 2, 320, 20), boldFont);
                    UIStringDrawing.DrawString(Subtitle, new CGRect(54, 22, 450, 20), regularFont);
                }
            }
示例#10
0
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                if (indexPath.Section == 0)
                {
                    if (fieldCells == null)
                    {
                        var fieldXPosition = (nfloat)controller
                                             .authenticator
                                             .Fields
                                             .Select(f => UIStringDrawing.StringSize(f.Title, FieldCell.LabelFont).Width)
                                             .Max();
                        fieldXPosition += 36;

                        fieldCells = controller
                                     .authenticator
                                     .Fields
                                     .Select(f => new FieldCell(f, fieldXPosition, SelectNext))
                                     .ToArray();
                    }

                    return(fieldCells[indexPath.Row]);
                }
                else if (indexPath.Section == 1)
                {
                    var cell = tableView.DequeueReusableCell("SignIn");
                    if (cell == null)
                    {
                        cell = new UITableViewCell(UITableViewCellStyle.Default, "SignIn");
                        cell.TextLabel.TextAlignment = UITextAlignment.Center;
                    }

                    cell.TextLabel.Text = NSBundle.MainBundle.LocalizedString("Sign In", "Sign In button title");

                    return(cell);
                }
                else
                {
                    var cell = tableView.DequeueReusableCell("CreateAccount");
                    if (cell == null)
                    {
                        cell = new UITableViewCell(UITableViewCellStyle.Default, "CreateAccount");
                        cell.TextLabel.TextAlignment = UITextAlignment.Center;
                    }

                    cell.TextLabel.Text = NSBundle.MainBundle.LocalizedString("Create Account", "Create Account button title");

                    return(cell);
                }
            }
示例#11
0
 public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
 {
     if (_ns.NewsFeed.Count > indexPath.Row)
     {
         var    t    = _ns.NewsFeed [indexPath.Row];
         CGSize size = UIStringDrawing.StringSize(t.Title
                                                  , UIFont.FromName("Helvetica-Light", AppDelegate.Font16pt)
                                                  , new SizeF(230, 400), UILineBreakMode.WordWrap);
         return(size.Height + 20);
     }
     else
     {
         return(40f);
     }
 }
示例#12
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();
            // this sizing code repreated in TwitterScreenSizingSource.GetHeightForRow()
            CGSize size = UIStringDrawing.StringSize(tweet.Title
                                                     , tweetLabel.Font
                                                     , new SizeF(239, 120)
                                                     , UILineBreakMode.WordWrap);

            image.Frame      = new CGRect(8, 8, 48, 48);
            user.Frame       = new CGRect(69, 14, 239, 24);
            handle.Frame     = new CGRect(69, 39, 239, 14);     // 35 -> 39
            tweetLabel.Frame = new CGRect(69, 57, 239, size.Height);
            date.Frame       = new CGRect(230, 2, 80, 15);      // 8 -> 2
        }
示例#13
0
 public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
 {
     if (twitterScreen.TwitterFeed.Count > indexPath.Row)
     {
         var    t    = twitterScreen.TwitterFeed [indexPath.Row];
         CGSize size = UIStringDrawing.StringSize(t.Title
                                                  , UIFont.FromName("Helvetica-Light", AppDelegate.Font10_5pt)
                                                  , new SizeF(239, 140), UILineBreakMode.WordWrap);
         return(14 + 21 + 22 + size.Height + 8);
     }
     else
     {
         return(40f);
     }
 }
        public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
        {
            float height     = 60f;
            SizeF maxSize    = new SizeF(230, float.MaxValue);
            var   favSession = groupedFavorites[indexPath.Section].Sessions[indexPath.Row];
            // test if we need two lines to display more of the Session.Title
            CGSize size = UIStringDrawing.StringSize(favSession.Title
                                                     , UIFont.FromName("Helvetica-Light", AppDelegate.Font16pt)
                                                     , maxSize);

            if (size.Height > 27)
            {
                height += 27;
            }
            return(height);
        }
示例#15
0
        public nfloat GetHeight(UITableView tableView, NSIndexPath indexPath)
        {
            float  height  = 60f;
            CGSize maxSize = new SizeF(262, float.MaxValue);              //273

            // test if we need two lines to display more of the Session.Title
            CGSize size = UIStringDrawing.StringSize(session.Title
                                                     , UIFont.FromName("Helvetica-Light", AppDelegate.Font16pt)
                                                     , maxSize);

            if (size.Height > 27)
            {
                height += 27;
            }

            return(height);
        }
示例#16
0
        protected void OnDeviceRotated(NSNotification notification)
        {
            if (AppDelegate.IsPad)
            {
                CGSize size;
                if (IsPortrait)
                {
                    XamLogoImageView.Image = UIImage.FromBundle("/Images/About-Portrait~iPad");
                    ScrollView.ContentSize = new CGSize(768, 1004);

                    size = UIStringDrawing.StringSize(AboutTextView.Text
                                                      , AboutTextView.Font
                                                      , new SizeF(738, 500)
                                                      , UILineBreakMode.WordWrap);

                    AboutTextView.Frame = new CGRect(
                        15,
                        650,
                        size.Width,
                        size.Height + 30);
                }
                else
                {
                    // IsLandscape
                    XamLogoImageView.Image = UIImage.FromBundle("/Images/About-Landscape~iPad");
                    ScrollView.ContentSize = new CGSize(1024, 748);

                    size = UIStringDrawing.StringSize(AboutTextView.Text
                                                      , AboutTextView.Font
                                                      , new SizeF(1004, 500)
                                                      , UILineBreakMode.WordWrap);

                    AboutTextView.Frame = new CGRect(
                        15,
                        500,
                        size.Width,
                        size.Height + 30);
                }
                var Y = AboutTextView.Frame.Y + size.Height + 30;
                LayoutButtons(Y);
            }
        }
示例#17
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();
            var full = ContentView.Bounds;

            // this sizing code repreated in TwitterScreenSizingSource.GetHeightForRow()
            CGSize size = UIStringDrawing.StringSize(captionLabel.Text
                                                     , bigFont
                                                     , new CGSize(full.Width - 90, 400)
                                                     , UILineBreakMode.WordWrap);

            var captionFrame = full;

            captionFrame.X      = 8 + 57 + 13;
            captionFrame.Y      = 10;
            captionFrame.Height = size.Height;
            captionFrame.Width  = full.Width - 90;            //230;
            captionLabel.Frame  = captionFrame;

            imageView.Frame = new CGRect(8, 12, 57, 57);
        }
        private void AddLabel()
        {
            // Create the label
            var label = new UILabel()
            {
                Text = "Third View"
            };

            // Update font size
            nfloat fontSize = 36.0f;

            label.Font = label.Font.WithSize(fontSize);

            // Measure the label
            var labelSize = UIStringDrawing.StringSize(label.Text, label.Font);

            // and adjust the frame accordingly
            label.Frame = new CGRect(View.Frame.Width / 2 - labelSize.Width / 2,
                                     View.Frame.Height / 2 - labelSize.Height / 2,
                                     labelSize.Width,
                                     labelSize.Height);

            Add(label);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            int width = 245;

            if (!UserInterfaceIdiomIsPhone)
            {
                width = 700;
            }

            session = BL.Managers.SessionManager.GetSession(sessionId);

            Title             = "Session Detail";
            TitleLabel.Text   = session.Title;
            SpeakerLabel.Text = session.SpeakerNames;
            TimeLabel.Text    = session.Start.ToString("dddd") + " " +
                                session.Start.ToString("H:mm") + " - " +
                                session.End.ToString("H:mm");
            LocationLabel.Text = session.Room;
            OverviewLabel.Text = session.Overview;

            CGSize titleSize = UIStringDrawing.StringSize(session.Title
                                                          , UIFont.FromName("Helvetica-Light", AppDelegate.Font16pt)
                                                          , new SizeF(245, 400), UILineBreakMode.WordWrap);

            TitleLabel.Font      = UIFont.FromName("Helvetica-Light", AppDelegate.Font16pt);
            TitleLabel.TextColor = UIColor.Black;
            TitleLabel.Frame     = new CGRect(13, 15, width, titleSize.Height);
            TitleLabel.Lines     = 0;
            TitleLabel.Font      = UIFont.FromName("Helvetica-Light", AppDelegate.Font16pt);

            CGSize speakerSize = UIStringDrawing.StringSize(session.SpeakerNames
                                                            , UIFont.FromName("Helvetica-LightOblique", AppDelegate.Font10pt)
                                                            , new SizeF(245, 400), UILineBreakMode.WordWrap);

            SpeakerLabel.Font  = UIFont.FromName("Helvetica-LightOblique", AppDelegate.Font10pt);
            SpeakerLabel.Frame = new CGRect(13
                                            , 15 + 13 + titleSize.Height
                                            , width, speakerSize.Height);
            TimeLabel.Font  = UIFont.FromName("Helvetica-Light", AppDelegate.Font7_5pt);
            TimeLabel.Frame = new CGRect(13
                                         , 15 + titleSize.Height + 13 + speakerSize.Height + 5
                                         , width, 10);

            LocationLabel.Font  = UIFont.FromName("Helvetica-Light", AppDelegate.Font7_5pt);
            LocationLabel.Frame = new CGRect(13
                                             , 15 + titleSize.Height + 13 + speakerSize.Height + 7 + 12
                                             , width, 10);

            float  overviewLabelWidth  = 310;
            var    overviewLabelY      = 15 + titleSize.Height + 13 + speakerSize.Height + TimeLabel.Frame.Height + LocationLabel.Frame.Height + 20;
            nfloat overviewLabelHeight = (UserInterfaceIdiomIsPhone?360:854) - overviewLabelY;

            OverviewLabel.Editable = false;
            OverviewLabel.Font     = UIFont.FromName("Helvetica-Light", AppDelegate.Font10_5pt);
            if (AppDelegate.IsPhone)
            {
                // going to scroll the whole thing!
                OverviewLabel.ScrollEnabled = false;

                CGSize overviewSize = UIStringDrawing.StringSize(
                    session.Overview
                    , UIFont.FromName("Helvetica-Light", AppDelegate.Font10_5pt)
                    , new CGSize(overviewLabelWidth, 2500)                                             // just width wasn't working...
                    , UILineBreakMode.WordWrap);

                overviewLabelHeight = overviewSize.Height + 30;

                ScrollView.ContentSize = new CGSize(320, overviewLabelY + overviewLabelHeight + 10);
            }

            OverviewLabel.Frame = new CGRect(5
                                             , overviewLabelY
                                             , UserInterfaceIdiomIsPhone?overviewLabelWidth:700
                                             , overviewLabelHeight);


            FavoriteButton.TouchUpInside += (sender, e) => {
                ToggleFavorite();
            };

            if (FavoritesManager.IsFavorite(session.Key))
            {
                FavoriteButton.SetImage(new UIImage(AppDelegate.ImageIsFavorite), UIControlState.Normal);
            }
            else
            {
                FavoriteButton.SetImage(new UIImage(AppDelegate.ImageNotFavorite), UIControlState.Normal);
            }
        }
示例#20
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "About Xamarin";

            StackOverflowButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_stackoverflow.png"), UIControlState.Normal);
            LinkedInButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_linkedin.png"), UIControlState.Normal);
            TwitterButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_twitter.png"), UIControlState.Normal);
            YouTubeButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_youtube.png"), UIControlState.Normal);
            FacebookButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_facebook.png"), UIControlState.Normal);
            BlogRssButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_rss.png"), UIControlState.Normal);


            StackOverflowButton.TouchUpInside += (sender, e) => { OpenUrl(Constants.AboutUrlStackOverflow); };
            LinkedInButton.TouchUpInside      += (sender, e) => { OpenUrl(Constants.AboutUrlLinkedIn); };
            TwitterButton.TouchUpInside       += (sender, e) => { OpenUrl(Constants.AboutUrlTwitter); };
            YouTubeButton.TouchUpInside       += (sender, e) => { OpenUrl(Constants.AboutUrlYouTube); };
            FacebookButton.TouchUpInside      += (sender, e) => { OpenUrl(Constants.AboutUrlFacebook); };
            BlogRssButton.TouchUpInside       += (sender, e) => { OpenUrl(Constants.AboutUrlBlogRss); };


            if (AppDelegate.IsPhone)
            {
                ScrollView.Frame       = new CGRect(0, 43, 320, 367);
                ScrollView.ContentSize = new CGSize(320, 610);

                XamLogoImageView.Image = UIImage.FromBundle("/Images/About");

                AboutTextView.Frame = new CGRect(
                    AboutTextView.Frame.X,
                    AboutTextView.Frame.Y,
                    320,
                    240);

                var Y = AboutTextView.Frame.Y + 240;

                StackOverflowButton.Frame = new CGRect(StackOverflowButton.Frame.X, Y, StackOverflowButton.Frame.Width, StackOverflowButton.Frame.Height);
                LinkedInButton.Frame      = new CGRect(LinkedInButton.Frame.X, Y, LinkedInButton.Frame.Width, LinkedInButton.Frame.Height);
                TwitterButton.Frame       = new CGRect(TwitterButton.Frame.X, Y, TwitterButton.Frame.Width, TwitterButton.Frame.Height);
                YouTubeButton.Frame       = new CGRect(YouTubeButton.Frame.X, Y, YouTubeButton.Frame.Width, YouTubeButton.Frame.Height);
                FacebookButton.Frame      = new CGRect(FacebookButton.Frame.X, Y, FacebookButton.Frame.Width, FacebookButton.Frame.Height);
                BlogRssButton.Frame       = new CGRect(BlogRssButton.Frame.X, Y, BlogRssButton.Frame.Width, BlogRssButton.Frame.Height);
            }
            else
            {
                // IsPad
                ScrollView.Frame       = new CGRect(0, 0, 768, 1004);
                ScrollView.ContentSize = new CGSize(768, 1024);

                XamLogoImageView.Image = UIImage.FromBundle("/Images/About-Portrait~iPad");
                XamLogoImageView.Frame = ScrollView.Frame;

                CGSize size = UIStringDrawing.StringSize(AboutTextView.Text
                                                         , AboutTextView.Font
                                                         , new SizeF(738, 500)
                                                         , UILineBreakMode.WordWrap);

                AboutTextView.Frame = new CGRect(
                    15,
                    650,
                    size.Width,
                    size.Height + 30);
                //AboutTextView.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth;

                var Y = AboutTextView.Frame.Y + size.Height + 40;

                StackOverflowButton.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                LinkedInButton.AutoresizingMask      = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                TwitterButton.AutoresizingMask       = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                YouTubeButton.AutoresizingMask       = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                BlogRssButton.AutoresizingMask       = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                FacebookButton.AutoresizingMask      = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;

                LayoutButtons(Y);
            }
            AboutTextView.Text = Constants.AboutText;             // @"Xamarin was founded in 2011 with the mission to make it fast, easy and fun to build great mobile apps. Xamarin’s products are used by individual developers and companies, including VMware, Target, Rdio, Medtronic and Unity Technologies, to simplify creation and operation of high-performance, cross-platform mobile consumer and corporate applications, targeting phones and tablets running iOS, Android and Windows. For more information, visit http://xamarin.com.";
        }
示例#21
0
        public override void LayoutSubviews()
        {
            if (EmptyOverlay.ShowIfRequired(ref emptyOverlay, showSession, this, "No session info", EmptyOverlayType.Session))
            {
                return;
            }

            var full = Bounds;

            if (AppDelegate.IsPad)
            {
                toolbar.Frame = new CGRect(0, 0, this.Bounds.Width, 40);
            }

            int    sideMargin = 13, topMargin = 10;
            CGSize titleSize = UIStringDrawing.StringSize(showSession.Title
                                                          , UIFont.FromName("Helvetica-Light", AppDelegate.Font16pt)
                                                          , new CGSize(full.Width - sideMargin, 400), UILineBreakMode.WordWrap);
            // Session.Title
            var titleFrame = full;

            titleFrame.X      = sideMargin;
            titleFrame.Y      = y + topMargin;
            titleFrame.Height = titleSize.Height;
            titleFrame.Width -= (sideMargin * 2);
            titleLabel.Frame  = titleFrame;
            // Session.StartTime, EndTime
            var timeFrame = full;

            timeFrame.X      = sideMargin;
            timeFrame.Y      = y + 15 + titleFrame.Height;
            timeFrame.Height = 15;
            timeFrame.Width -= (sideMargin * 2);
            timeLabel.Frame  = timeFrame;
            // Session.Room
            timeFrame.Y         = timeLabel.Frame.Y + timeLabel.Frame.Height + 10;
            locationLabel.Frame = timeFrame;
            // Session.IsFavorite ~ star (favorites) button
            button.Frame = new CGRect(full.Width - buttonSpace - 15
                                      , y + topMargin + titleLabel.Frame.Height
                                      , buttonSpace
                                      , buttonSpace); // just under the title, right of the small text
            // Session.Overview
            // Now determine how big the Overview text is, and adjust sizes accordingly
            // iPad requires scrolling of the TextView
            // iPhone requires the TextView to be expanded to encompass all text
            if (!String.IsNullOrEmpty(showSession.Overview))
            {
                if (AppDelegate.IsPad)
                {
                    var f = new CGSize(full.Width - sideMargin * 2, full.Height - (locationLabel.Frame.Y + 20));
                    descriptionTextView.Frame         = new CGRect(5, locationLabel.Frame.Y + 15, f.Width, f.Height);
                    descriptionTextView.ScrollEnabled = true;
                }
                else
                {
                    var    f    = new CGSize(290, 4000);
                    CGSize size = UIStringDrawing.StringSize(showSession.Overview
                                                             , descriptionTextView.Font
                                                             , f);                    //, UILineBreakMode.WordWrap);
                    descriptionTextView.Frame = new CGRect(5
                                                           , locationLabel.Frame.Y + 15
                                                           , size.Width + 10                      // hack: measure seems to underestimate
                                                           , size.Height + 50);
                    // going to scroll the whole thing!
                    descriptionTextView.ScrollEnabled = false;
                }
            }
            else
            {
                descriptionTextView.Frame = new CGRect(5, locationLabel.Frame.Y + 15, full.Width - sideMargin * 2, 30);
            }

            nfloat bottomOfTheseControls = descriptionTextView.Frame.Y + descriptionTextView.Frame.Height;

            // now add the Session.Speakers table underneath (if there _are_ speakers)
            // iPad fixes it to the bottom, and makes the Overview TextView smaller (View height is constant)
            // iPhone adds it to the bottom, and makes the View itself longer to fit
            if (shouldShowSpeakers && showSession.Speakers != null && showSession.Speakers.Count > 0)
            {
                CGRect frame;
                if (AppDelegate.IsPhone)
                {
                    frame = new CGRect(5
                                       , bottomOfTheseControls
                                       , 310
                                       , showSession.Speakers.Count * 40 + 60); // plus 40 for header
                }
                else                                                            // IsPad, fixed height
                {
                    frame = new CGRect(5
                                       , full.Height - 40 - (showSession.Speakers.Count * 40) - 5                // 5 is for margin
                                       , 310
                                       , showSession.Speakers.Count * 40 + 60);                                  // plus 40 for header
                }

                if (speakerTable == null)
                {
                    speakerTable = new UITableView(frame, UITableViewStyle.Grouped);
                    speakerTable.BackgroundColor = UIColor.White;
                    var whiteView = new UIView();
                    whiteView.BackgroundColor   = UIColor.White;
                    speakerTable.BackgroundView = whiteView;
                    speakerTable.ScrollEnabled  = false;
                    AddSubview(speakerTable);
                }
                speakerTable.Frame  = frame;
                speakerTable.Source = new SpeakersTableSource(showSession.Speakers, this);

                if (AppDelegate.IsPad)                   // shrink the overview to accomodate speakers
                {
                    var df = descriptionTextView.Frame;
                    df.Height = df.Height - 40 - (showSession.Speakers.Count * 40) - 5;                     // 5 is for margin
                    descriptionTextView.Frame = df;

                    // set the highlight for whatever speaker is showing in the other column (only iPad, obviously)
                    if (speakerTable.IndexPathForSelectedRow == null)
                    {
                        speakerTable.SelectRow(NSIndexPath.FromRowSection(0, 0), true, UITableViewScrollPosition.Top);
                    }
                    else
                    {
                        speakerTable.SelectRow(speakerTable.IndexPathForSelectedRow, true, UITableViewScrollPosition.Top);
                    }
                }
                else                                                                                       // extend the Frame to encompass the speakers table
                {
                    Frame = new CGRect(0, 0, 320, bottomOfTheseControls + speakerTable.Frame.Height + 20); // 10 margin top & bottom
                }
            }
            else                 // there are NO speakers, remove the table if it exists
            {
                if (speakerTable != null)
                {
                    speakerTable.RemoveFromSuperview();
                    speakerTable.Dispose();
                    speakerTable = null;
                }
                if (AppDelegate.IsPhone)
                {
                    Frame = new CGRect(0, 0, 320, bottomOfTheseControls);
                }
            }

            if (AppDelegate.IsPhone && Bounds.Size.Height < 370)
            {
                // if the view is smaller than the display area, enlarge it to fit snugly
                Frame = new CGRect(0, 0, 320, 370);
            }
        }
示例#22
0
        public CGRect LayoutForWidth(float width)
        {
            float buttonHeight = 50.0f;
            float spacing      = Spacing;
            float height       = 0.0f;

            if (TitleLabel != null)
            {
                height += spacing;
                TitleLabel.SizeToFit();
                height          += (float)TitleLabel.Frame.Height * 1.5f;
                TitleLabel.Frame = new CGRect(new CGPoint(spacing, spacing), new CGSize(width - spacing * 2.0f, TitleLabel.Frame.Height * 1.5f));
            }

            if (MessageLabel != null)
            {
                height += spacing;

                CGSize maxLabelSize       = new CGSize(width - spacing * 2.0f, width);
                float  messageLabelHeight = 0.0f;

                if (iOS7)
                {
                    var attributes = MessageLabel.Font;
                    messageLabelHeight = (float)MessageLabel.AttributedText.GetBoundingRect(maxLabelSize, NSStringDrawingOptions.UsesLineFragmentOrigin, null).Height;
                }
                else
                {
                    messageLabelHeight = (float)UIStringDrawing.StringSize(MessageLabel.Text, MessageLabel.Font, maxLabelSize).Height;
                }

                MessageLabel.Frame = new CGRect(new CGPoint(spacing, height), new CGSize(width - spacing * 2.0f, messageLabelHeight));
                height            += messageLabelHeight;
            }

            int lineIndex = 0;

            //Add the title dividing line
            UIView line = horizontalLines.ElementAt(lineIndex);

            line.Frame = new CGRect(new CGPoint(0.0f, height + 1), new CGSize(width, 1.0f));
            height++;
            lineIndex++;

            ASMultiSelectActionSheetButton cancel = null;
            ASMultiSelectActionSheetButton action = null;

            foreach (ASMultiSelectActionSheetButton button in Buttons)
            {
                height += spacing;
                if (button.Style == ASMultiSelectActionSheetButtonStyle.Cancel)
                {
                    float x = 1.0f;
                    float y = height;
                    if (action != null)
                    {
                        y = (float)action.Frame.Y;
                    }
                    button.Frame = new CGRect(new CGPoint(x, y), new CGSize(((width - spacing * 2.0f) / 2) - 2, buttonHeight));
                    cancel       = button;
                    height      += buttonHeight;
                }
                else if (button.Style == ASMultiSelectActionSheetButtonStyle.PerformAction)
                {
                    float x = width / 2 + 1;
                    float y = height;
                    if (cancel != null)
                    {
                        y       = (float)cancel.Frame.Y;
                        height -= buttonHeight -= spacing;

                        controlLine.Frame = new CGRect(new CGPoint(width / 2, height - 2), new CGSize(1.0f, buttonHeight + spacing + 2));
                    }
                    button.Frame = new CGRect(new CGPoint(x, y), new CGSize(((width - spacing * 2.0f) / 2) - 1, buttonHeight));
                    action       = button;
                    height      += buttonHeight;
                }
                else
                {
                    button.Frame = new CGRect(new CGPoint(spacing, height), new CGSize(width - spacing * 2.0f, buttonHeight));
                    height      += buttonHeight;

                    //UIView buttonLine = horizontalLines.ElementAt(lineIndex);
                    line.Frame = new CGRect(new CGPoint(0.0f, height + 1), new CGSize(width, 1.0f));
                    height++;
                    lineIndex++;
                }
            }

            if (ContentView != null)
            {
                height           += spacing;
                ContentView.Frame = new CGRect(new CGPoint(spacing, height), new CGSize(width - spacing * 2.0f, ContentView.Frame.Height));
                height           += (float)ContentView.Frame.Height;
            }

            height += spacing;
            Frame   = new CGRect(CGPoint.Empty, new CGSize(width, height));
            return(Frame);
        }
示例#23
0
        UITableViewCell TableViewCellForRowAtIndexPath(UITableView aTableView, NSIndexPath indexPath)
        {
            UITableViewCell cell;

            cell = aTableView.DequeueReusableCell("MenuCell");
            if (indexPath.Section == 0)
            {
                cell.BackgroundColor = UIColor.Clear;

                UIImageView imgRow = (UIImageView)cell.ViewWithTag(1);
                imgRow.Image = UIImage.FromFile("Images/Common/user_1.png");

                UILabel lblText = (UILabel)cell.ViewWithTag(2);
                lblText.Text = "Virgil Pana";
            }
            else
            {
                cell.BackgroundColor = UIColor.Clear;
                MenuItem item = dataSource.items [indexPath.Row];

                UIImageView imgRow = (UIImageView)cell.ViewWithTag(1);
                imgRow.Image = item.Image;
                UILabel lblText = (UILabel)cell.ViewWithTag(2);
                lblText.Text = item.Name;

                UIView countView = null;
                if (item.EventCount > 0)
                {
                    string countString = item.EventCount.ToString();
                                        #if __UNIFIED__
                    SizeF sizeCount = UIStringDrawing.StringSize(countString, UIFont.SystemFontOfSize(14.0f));
                                        #else
                    SizeF sizeCount = View.StringSize(countString, UIFont.SystemFontOfSize(14.0f));
                                        #endif

                    UIImage bkgImg = UIImage.FromFile("Images/iPhone/sidemenu-count.png");
                    countView = new UIImageView(bkgImg.StretchableImage(12, 0));

                                        #if __UNIFIED__
                    countView.Frame =
                        new RectangleF(0, 0, (float)sizeCount.Width + 2 * 10, (float)bkgImg.Size.Height)
                        //.Inegral()
                    ;
                    UILabel lblCount =
                        new UILabel
                        (
                            new RectangleF(10, (float)(bkgImg.Size.Height - sizeCount.Height) / 2 - 2, (float)sizeCount.Width, (float)sizeCount.Height)
                        );
                                        #else
                    countView.Frame =
                        new RectangleF(0, 0, (float)sizeCount.Width + 2 * 10, (float)bkgImg.Size.Height)
                        .Integral()
                    ;
                    UILabel lblCount =
                        new UILabel
                        (
                            new RectangleF(10, (float)(bkgImg.Size.Height - sizeCount.Height) / 2 - 2, sizeCount.Width, sizeCount.Height)
                            .Integral()
                        );
                                        #endif
                    lblCount.Text            = countString;
                    lblCount.BackgroundColor = UIColor.Clear;
                    lblCount.TextColor       = UIColor.White;
                    lblCount.TextAlignment   = UITextAlignment.Center;
                    lblCount.Font            = UIFont.SystemFontOfSize(14.0f);
                    lblCount.ShadowColor     = UIColor.Black;
                    lblCount.ShadowOffset    = new SizeF(0, 1);
                    countView.AddSubview(lblCount);
                }
                cell.AccessoryView = countView;
            }
            return(cell);
        }
示例#24
0
        public static ChartSize Measure(this UIFont self, string text)
        {
            var size = UIStringDrawing.StringSize(text, self);

            return(new ChartSize((float)size.Width, (float)size.Height));
        }
示例#25
0
 public static float MeasureWidth(this UIFont self, string text)
 {
     return((float)UIStringDrawing.StringSize(text, self).Width);
 }
示例#26
0
        nfloat HeightForRow(UITableView tableView, NSIndexPath indexPath)
        {
            Update update = updates [indexPath.Row];

            return(49 + UIStringDrawing.StringSize(update.updateText, UIFont.SystemFontOfSize(12f), new SizeF(222, 1000)).Height);
        }
示例#27
0
文件: BubbleCell.cs 项目: Sankra/DIRC
 static internal CGSize GetSizeForText(UIView tv, string text)
 {
     return(UIStringDrawing.StringSize(text, font, new CGSize(tv.Bounds.Width * .8f - 10 - 22, 99999)));
 }
示例#28
0
        void LayoutSubviews()
        {
            var full     = View.Bounds;
            var bigFrame = full;

            scrollView.Frame = full;

            bigFrame.X      = ImageSpace + 13 + 17;
            bigFrame.Y      = y + 27;        // 15 -> 13
            bigFrame.Height = 26;
            bigFrame.Width -= (ImageSpace + 13 + 17);
            nameLabel.Frame = bigFrame;

            var smallFrame = full;

            smallFrame.X      = ImageSpace + 13 + 17;
            smallFrame.Y      = y + 27 + 26;
            smallFrame.Height = 15;             // 12 -> 15
            smallFrame.Width -= (ImageSpace + 13 + 17);
            titleLabel.Frame  = smallFrame;

            smallFrame.Y      += y + 17;
            companyLabel.Frame = smallFrame;

            image.Frame = new CGRect(13, y + 15, 80, 80);

            bioTextView.Font = UIFont.FromName("Helvetica-Light", AppDelegate.Font10_5pt);

            if (!String.IsNullOrEmpty(speaker.Bio))
            {
                var    f    = new CGSize(full.Width - 13 * 2, 4000);
                CGSize size = UIStringDrawing.StringSize(speaker.Bio
                                                         , this.bioTextView.Font
                                                         , f);
                bioTextView.Frame = new CGRect(5
                                               , y + 115
                                               , f.Width
                                               , size.Height + 120);                          // doesn't seem to measure properly... CR/LF issues?

                bioTextView.ScrollEnabled = true;

                scrollView.ContentSize = new CGSize(320, bioTextView.Frame.Y + bioTextView.Frame.Height + 20);
            }
            else
            {
                bioTextView.ScrollEnabled = false;
                bioTextView.Frame         = new CGRect(5, y + 115, 310, 30);;
            }


            nfloat bottomOfTheseControls = bioTextView.Frame.Y + bioTextView.Frame.Height;

            if (ShouldShowSessions && speaker.Sessions != null && speaker.Sessions.Count > 0)
            {
                CGRect frame;
                //if (AppDelegate.IsPhone) {
                frame = new CGRect(5
                                   , bottomOfTheseControls
                                   , 310
                                   , speaker.Sessions.Count * 40 + 50);                                      // plus 40 for header
                //}

                if (sessionTable == null)
                {
                    sessionTable = new UITableView(frame, UITableViewStyle.Grouped);
                    sessionTable.BackgroundColor = UIColor.White;
                    var whiteView = new UIView();
                    whiteView.BackgroundColor   = UIColor.White;
                    sessionTable.BackgroundView = whiteView;
                    sessionTable.ScrollEnabled  = false;
                    scrollView.AddSubview(sessionTable);
                }
                sessionTable.Frame  = frame;
                sessionTable.Source = new SessionsTableSource(speaker.Sessions, this);

                scrollView.ContentSize = new CGSize(320, bottomOfTheseControls + sessionTable.Frame.Height + 20);
            }
            else                 // there are NO sessions, remove the table if it exists
            {
                if (sessionTable != null)
                {
                    sessionTable.RemoveFromSuperview();
                    sessionTable.Dispose();
                    sessionTable = null;
                }
                if (AppDelegate.IsPhone)
                {
                    scrollView.ContentSize = new CGSize(320, bottomOfTheseControls);
                }
            }
        }
示例#29
0
        void LayoutSubviews()
        {
            if (EmptyOverlay.ShowIfRequired(ref emptyOverlay, exhibitor, View, "No exhibitor selected", EmptyOverlayType.Exhibitor))
            {
                return;
            }
//			if (exhibitor == null) {
//				if (emptyOverlay == null) {
//					emptyOverlay = new EmptyOverlay(View.Bounds, "No exhibitor selected");
//					View.AddSubview (emptyOverlay);
//				}
//				return;
//			} else{
//				if (emptyOverlay != null) {
//					emptyOverlay.RemoveFromSuperview ();
//					emptyOverlay = null;
//				}
//			}
            var full     = View.Bounds;
            var bigFrame = full;

            bigFrame.X      = imageSpace + 13 + 17;
            bigFrame.Y      = 27;        // 15 -> 13
            bigFrame.Height = 26;
            bigFrame.Width -= (imageSpace + 13 + 17);
            nameLabel.Frame = bigFrame;

            var smallFrame = full;

            smallFrame.X       = imageSpace + 13 + 17;
            smallFrame.Y       = 27 + 26;
            smallFrame.Height  = 15;            // 12 -> 15
            smallFrame.Width  -= (imageSpace + 13 + 17);
            addressLabel.Frame = smallFrame;

            smallFrame.Y       += 17;
            locationLabel.Frame = smallFrame;

            image.Frame = new CGRect(13, 15, 80, 80);

            if (AppDelegate.IsPhone)
            {
                scrollView.Frame = full;


                var    f    = new CGSize(full.Width - 13 * 2, 4000);
                CGSize size = UIStringDrawing.StringSize(exhibitor.Overview
                                                         , descriptionTextView.Font
                                                         , f);
                descriptionTextView.Frame = new CGRect(5
                                                       , 115
                                                       , f.Width
                                                       , size.Height + 20);                          // doesn't seem to measure properly... CR/LF issues?

                descriptionTextView.ScrollEnabled = true;

                scrollView.ContentSize = new CGSize(320, descriptionTextView.Frame.Y + descriptionTextView.Frame.Height + 10);


                descriptionTextView.Frame = new CGRect(10, 115, 300, f.Height);
            }
            else
            {
                // IsPad
                descriptionTextView.Frame = new CGRect(10, 115, 400, 900);
                //_descriptionTextView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            }
        }
 static internal SizeF GetSizeForText(UIView tv, string text)
 {
     return((SizeF)UIStringDrawing.StringSize(text, font, new SizeF((float)(tv.Bounds.Width * .7f - 10 - 22), 99999)));
 }