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); } }
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(); }
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); } }
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(); }