Esempio n. 1
0
        void InitializeWhatNewView()
        {
            if (BookInfo == null)
            {
                return;
            }
            WhatNewLabel.StringValue    = "What's New";
            CurrentDayLabel.StringValue = BookInfo.LastUpdatedDate.Value.ToString("dd MMM yyyy");
            whatnewViewHeight           = WhatNewView.Frame.Size.Height;

            nfloat height = HeightOfWhatNewInfoView();

            if (height > TEXTVIEW_SIXLINE_HEIGHT)
            {
                NSButton moreButton = CreateMoreButton();
                WhatNewView.WantsLayer = true;
                moreButton.Action      = new Selector("WhatNewViewShowAll:");
                moreButton.Target      = this;
                WhatNewView.AddSubview(moreButton);

                isWhatsNewExpand = false;
            }
            else
            {
                nfloat orgHeight = WhatNewInfoLabel.Frame.Size.Height;
                nfloat offset    = height - orgHeight;
                var    oldSize   = WhatNewInfoLabel.Frame.Size;
                var    newSize   = new CGSize(oldSize.Width, whatnewViewHeight + offset);
                WhatNewView.SetFrameSize(newSize);
            }
        }
Esempio n. 2
0
        void WhatNewViewShowAll(NSObject sender)
        {
            var oldSize = WhatNewView.Frame.Size;

            if (!isWhatsNewExpand)
            {
                var newSize = new CGSize(oldSize.Width, whatsNewViewMaxHeight);
                WhatNewView.SetFrameSize(newSize);

                CGPoint orgPoint = WhatNewInfoView.Frame.Location;
                WhatNewInfoView.SetFrameOrigin(new CGPoint(orgPoint.X, 5));

                var button = (NSButton)WhatNewView.Subviews [4];
                NSAttributedString title = Utility.AttributeTitle("...less", Utility.ColorWithRGB(44, 117, 252), 12);
                button.Cell.AttributedTitle = title;

                isWhatsNewExpand = true;
            }
            else
            {
                var newSize = new CGSize(oldSize.Width, whatsNewViewMinHeight);
                WhatNewView.SetFrameSize(newSize);

                CGPoint orgPoint = whatsNewInfoOrgPoint;
                WhatNewInfoView.SetFrameOrigin(orgPoint);

                var button = (NSButton)WhatNewView.Subviews [4];
                NSAttributedString title = Utility.AttributeTitle("...more", Utility.ColorWithRGB(44, 117, 252), 12);
                button.Cell.AttributedTitle = title;

                isWhatsNewExpand = false;
            }

            LayoutSubViews();
        }
Esempio n. 3
0
        void ResetInfoViewFrame()
        {
            var  subviews  = WhatNewInfoView.Subviews;
            nint infoCount = subviews.Length;
            nint index     = 0;

            foreach (NSView view in subviews)
            {
                index++;
                if (index == 1)
                {
                    continue;
                }

                view.RemoveFromSuperview();
            }

            var views  = WhatNewView.Subviews;
            var count  = views.Length;
            var button = views [count - 1];

            if (button.Class.Name == "NSButton")
            {
                button.RemoveFromSuperview();
            }

            if (infoCount > 1)
            {
                var oldSize      = WhatNewView.Frame.Size;
                var newFrameSize = new CGSize(oldSize.Width, whatsNewViewMinHeight);
                WhatNewView.SetFrameSize(newFrameSize);

                CGRect  frame    = WhatNewInfoView.Frame;
                CGSize  newSize  = new CGSize(frame.Width, 114);
                CGPoint newPoint = new CGPoint(0, 5);

                WhatNewInfoView.SetFrameSize(newSize);
                WhatNewInfoView.SetFrameOrigin(newPoint);
            }
        }
Esempio n. 4
0
        void WhatNewViewShowAll(NSObject sender)
        {
            float  fontSize = 13.0f;
            nfloat height   = HeightWrappedToWidth(WhatNewInfoLabel, fontSize);

            if (!isWhatsNewExpand)
            {
                nfloat orgHeight = WhatNewInfoLabel.Frame.Size.Height;
                nfloat offset    = height - orgHeight;
                var    oldSize   = WhatNewView.Frame.Size;
                var    newSize   = new CGSize(oldSize.Width, whatnewViewHeight + offset);
                WhatNewView.SetFrameSize(newSize);

                var subviews             = WhatNewView.Subviews;
                int index                = subviews.Length - 1;
                var button               = (NSButton)subviews [index];
                NSAttributedString title = Utility.AttributeTitle("...less", Utility.ColorWithRGB(44, 117, 252, 1.0f), 12);
                button.Cell.AttributedTitle = title;

                isWhatsNewExpand = true;
            }
            else
            {
                var oldSize = WhatNewView.Frame.Size;
                var newSize = new CGSize(oldSize.Width, whatnewViewHeight);
                WhatNewView.SetFrameSize(newSize);

                var subviews = WhatNewView.Subviews;
                int index    = subviews.Length - 1;
                var button   = (NSButton)subviews [index];

                NSAttributedString title = Utility.AttributeTitle("...more", Utility.ColorWithRGB(44, 117, 252, 1.0f), 12);
                button.Cell.AttributedTitle = title;

                isWhatsNewExpand = false;
            }

            LayoutSubViews();
        }
Esempio n. 5
0
        void LayoutSubViews()
        {
            if (BookInfo == null)
            {
                return;
            }

            //calculate the subview size
            CGSize infoViewSize     = InformationView.Frame.Size;
            CGSize whatsNewViewSize = WhatNewView.Frame.Size;

            CGSize casesViewSize;

            if (CaseView.Hidden)
            {
                casesViewSize = new CGSize(0, 0);
            }
            else
            {
                casesViewSize = CaseView.Frame.Size;
            }

            CGSize despViewSize = DescriptionView.Frame.Size;

            CGSize expiredViewSize;

            if (BookInfo.DaysRemaining < 0)
            {
                expiredViewSize = ExpiredView.Frame.Size;
            }
            else
            {
                expiredViewSize = new CGSize(0, 0);
            }

            CGSize titleViewSize = TitleView.Frame.Size;

            //set scrollview contentview size
            nfloat caseSpace   = casesViewSize.Height == 0 ? 0 : VERTICAL_SPACING;
            nfloat expirdSpace = expiredViewSize.Height == 0 ? 0 : VERTICAL_SPACING;
            nfloat height      = VERTICAL_SPACING +
                                 infoViewSize.Height + VERTICAL_SPACING +
                                 whatsNewViewSize.Height + VERTICAL_SPACING +
                                 casesViewSize.Height + caseSpace +
                                 despViewSize.Height + VERTICAL_SPACING +
                                 expiredViewSize.Height + expirdSpace +
                                 titleViewSize.Height;

            CGRect scrollFrame = ScrollView.Frame;

            nfloat contentHeight = scrollFrame.Bottom > height ? scrollFrame.Bottom : height;

            var contentSize = new CGSize(AContentView.Frame.Size.Width, contentHeight);

            AContentView.SetFrameSize(contentSize);

            //add subview to document view
            var docView = (NSView)ScrollView.DocumentView;

            docView.SetFrameSize(contentSize);

            foreach (NSView view in docView.Subviews)
            {
                view.RemoveFromSuperview();
            }

            docView.AddSubview(AContentView);
            AContentView.SetFrameOrigin(new CGPoint(0, 0));

            //recalulate subviews origin point
            nfloat startOffset = scrollFrame.Bottom >= height ? (scrollFrame.Bottom - height + VERTICAL_SPACING) : VERTICAL_SPACING;
            nfloat yOffset;

            var InfoViewPoint = InformationView.Frame.Location;

            InfoViewPoint.Y = startOffset;
            InformationView.SetFrameOrigin(InfoViewPoint);

            var WhatsViewPoint = new CGPoint(InfoViewPoint.X, InfoViewPoint.Y + infoViewSize.Height + VERTICAL_SPACING);

            WhatNewView.SetFrameOrigin(WhatsViewPoint);

            var CaseViewPoint = new CGPoint(InfoViewPoint.X, WhatsViewPoint.Y + whatsNewViewSize.Height + VERTICAL_SPACING);

            CaseView.SetFrameOrigin(CaseViewPoint);

            if (casesViewSize.Height > 0)
            {
                yOffset = VERTICAL_SPACING;
            }
            else
            {
                yOffset = 0;
            }

            var DesViewPoint = new CGPoint(InfoViewPoint.X, CaseViewPoint.Y + casesViewSize.Height + yOffset);

            DescriptionView.SetFrameOrigin(DesViewPoint);

            var ExpireViewPoint = new CGPoint(InfoViewPoint.X, DesViewPoint.Y + despViewSize.Height + VERTICAL_SPACING);

            ExpiredView.SetFrameOrigin(ExpireViewPoint);

            if (expiredViewSize.Height > 0)
            {
                yOffset = VERTICAL_SPACING;
            }
            else
            {
                yOffset = 0;
            }

            var TitleViewPoint = new CGPoint(InfoViewPoint.X, ExpireViewPoint.Y + expiredViewSize.Height + yOffset);

            TitleView.SetFrameOrigin(TitleViewPoint);

            ScrollToTop();
        }
Esempio n. 6
0
        void InitializeWhatNewView()
        {
            if (BookInfo == null)
            {
                return;
            }

            ResetInfoViewFrame();

            WhatNewLabel.StringValue    = "What's New";
            CurrentDayLabel.StringValue = BookInfo.LastUpdatedDate.Value.ToString("dd MMM yyyy");
            UpdateInfoLabel.Hidden      = true;

            List <GuideCard> addedGuideCardList  = BookInfo.AddedGuideCard;
            List <GuideCard> delGuideCardList    = BookInfo.DeletedGuideCard;
            List <GuideCard> updateGuideCardList = BookInfo.UpdatedGuideCard;

            nfloat addHeight    = HeightCardList(addedGuideCardList);
            nfloat delHeight    = HeightCardList(delGuideCardList);
            nfloat updateHeight = HeightCardList(updateGuideCardList);
            nfloat height       = CELL_VERTICAL_SPACEING + addHeight + CELL_VERTICAL_SPACEING + delHeight + CELL_VERTICAL_SPACEING + updateHeight;

            whatsNewViewMinHeight = WhatNewView.Frame.Height;
            whatsNewViewMaxHeight = WhatNewView.Frame.Height - WhatNewInfoView.Frame.Bottom + height + VERTICAL_SPACING;
            whatsNewInfoHeight    = height;

            //fontsize:13:height:17 fontsize:12 height:16  space:3
            //6line 20*6+9
            nfloat curPointT = CurrentDayLabel.Frame.Top - 18;
            CGRect frame     = WhatNewInfoView.Frame;

            whatsNewInfoOrgPoint = new CGPoint(frame.Location.X, curPointT - whatsNewInfoHeight);

            if (height > 133)
            {
                isWhatsNewExpand = false;

                var nSize = new CGSize(frame.Size.Width, whatsNewInfoHeight);
                WhatNewInfoView.SetFrameSize(nSize);

                NSButton moreButton = CreateMoreButton();
                WhatNewView.WantsLayer = true;
                moreButton.Action      = new Selector("WhatNewViewShowAll:");
                moreButton.Target      = this;
                WhatNewView.AddSubview(moreButton);
            }
            else
            {
                if (frame.Size.Height < whatsNewInfoHeight)
                {
                    var nSize = new CGSize(frame.Size.Width, whatsNewInfoHeight);
                    WhatNewInfoView.SetFrameSize(nSize);
                }
            }

            nfloat curOrgy = WhatNewInfoView.Frame.Bottom - CELL_VERTICAL_SPACEING;

            curOrgy = AddGuidCardsToCustomView(addedGuideCardList, GuideCardMode.Added, curOrgy);

            curOrgy -= CELL_VERTICAL_SPACEING;
            curOrgy  = AddGuidCardsToCustomView(delGuideCardList, GuideCardMode.Deleted, curOrgy);

            curOrgy -= CELL_VERTICAL_SPACEING;
            curOrgy  = AddGuidCardsToCustomView(updateGuideCardList, GuideCardMode.Updated, curOrgy);

            WhatNewInfoView.SetFrameOrigin(whatsNewInfoOrgPoint);
        }