// // KMVerificationMessageViewController.m // PDF Reader Pro Edition // // Created by 王帅 on 2018/5/9. // #import "KMVerificationMessageViewController.h" #import #import "VerificationManager.h" #import "AIInfoManager.h" #import "KMVerificationWindowController.h" #import "KMUnlockAlertViewController.h" #define kbottomGap 0 @interface KMVerificationMessageViewController ()< NSPopoverDelegate> @property (nonatomic, assign) IBOutlet NSTextField *label; @property (nonatomic, assign) IBOutlet NSButton *button; @property (nonatomic, assign) IBOutlet NSButton *secondTrialBtn; @property (assign) IBOutlet NSView *labelContentView; @property (assign) IBOutlet NSImageView *bgImg; @property (assign) IBOutlet NSView *aiContendView; @property (assign) IBOutlet NSImageView *aiIconImg; @property (assign) IBOutlet NSTextField *aiLabel; @property (weak) IBOutlet NSButton *userButton; @property (assign) IBOutlet NSView *signUpView; @property (assign) IBOutlet NSImageView *signUpImg; @property (assign) IBOutlet NSTextField *signUpLabel; @property (weak) IBOutlet NSButton *officeButton; @property (assign) IBOutlet NSImageView *officeImg; @property (nonatomic, retain) NSTrackingArea *trackingArea; @property (nonatomic, retain) NSPopover *popover; @property (nonatomic, assign) BOOL isPopoverShow; @property (nonatomic, assign) BOOL checkValue; @property (nonatomic, assign) BOOL stopPopOverHide; @property (nonatomic, retain) KMUnlockAlertViewController *testVC; @property (nonatomic, retain) NSMenu *userMenu; @end @implementation KMVerificationMessageViewController #pragma mark Init Methods - (instancetype)init { if (self = [super initWithNibName:@"KMVerificationMessageViewController" bundle:nil]) { #if VERSION_DMG [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceActivateStatusChangeNotification:) name:kDeviceActivateStatusChangeNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceActivateStatusChangeNotification:) name:KMIAPSubscriptionLoadedNotification object:nil]; #else [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IAPResultReceived:) name:KMIAPSubscriptionLoadedNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IAPPurchaseSuccess:) name:KMIAPProductPurchasedNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IAPRestoreFinish:) name:KMIAPProductRestoreFinishedNotification object:nil]; #endif } return self; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; if (self.trackingArea) { [self.button removeTrackingArea:self.trackingArea]; } } #pragma mark Setter Methods - (void)loadView { [super loadView]; // Do view setup here. self.button.wantsLayer = YES; self.button.layer.masksToBounds = YES; self.button.layer.cornerRadius = 4.0; self.button.font = [NSFont SFProTextSemiboldFont:11]; self.button.layer.backgroundColor = [NSColor colorWithDeviceRed:121.0/255.0 green:196.0/255.0 blue:66.0/255.0 alpha:1.0].CGColor; [self.button setAlignment:NSTextAlignmentCenter]; self.userButton.font = [NSFont SFProTextSemiboldFont:11]; self.secondTrialBtn.wantsLayer = YES; self.secondTrialBtn.layer.masksToBounds = YES; self.secondTrialBtn.layer.cornerRadius = 4.0; self.secondTrialBtn.font = [NSFont SFProTextSemiboldFont:11]; self.secondTrialBtn.layer.backgroundColor = [NSColor colorWithDeviceRed:121.0/255.0 green:196.0/255.0 blue:66.0/255.0 alpha:1.0].CGColor; [self.secondTrialBtn setAlignment:NSTextAlignmentCenter]; NSString *tTips = NSLocalizedString(@"Upgrade to Pro", nil); #if VERSION_DMG tTips = @""; #else tTips = [NSString stringWithFormat:@"%@\n%@", NSLocalizedString(@"Subscribe to All Access Pack to enjoy more expanded features.", nil), NSLocalizedString(@"Choose your favorite payment and enjoy flexible upgrades.", nil)]; #endif self.button.toolTip = tTips; self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)]; [self.button setTitleColor:[NSColor whiteColor]]; [self.button setAlignment:NSTextAlignmentCenter]; self.secondTrialBtn.toolTip = tTips; self.secondTrialBtn.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Free Trial", nil)]; [self.secondTrialBtn setTitleColor:[NSColor whiteColor]]; [self.secondTrialBtn setAlignment:NSTextAlignmentCenter]; self.secondTrialBtn.hidden = YES; self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO; self.bgImg.wantsLayer = YES; self.bgImg.image = [NSImage imageNamed:@"Upgarde_bg_icon"]; self.bgImg.layer.masksToBounds = YES; self.bgImg.layer.cornerRadius = 4.; self.bgImg.hidden = YES; self.aiLabel.font = [NSFont SFProTextSemiboldFont:11]; self.aiLabel.textColor = [NSColor whiteColor]; [self reloadData]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popoverShowNoti:) name:@"KMVerificationMessagePopShowNoti" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccessNotification:) name:@"MemberCenterLoginSuccess" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(logoutSuccessNotification:) name:@"MemberCenterLogoutSuccess" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(expandPersonalCenterNotification:) name:@"ExpandPersonalCenter" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closeMenu:) name:@"CloseMenuNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(subscriptionLoadedNotification:) name:KMIAPSubscriptionLoadedNotification object:nil]; } - (void)reloadData { self.label.textColor = [NSColor blackColor]; self.label.hidden = NO; self.secondTrialBtn.hidden = YES; if (self.frameUpdateHandle) { self.frameUpdateHandle(self.view.frame); } CGFloat totalWidth = 8; self.button.hidden = NO; self.officeButton.hidden = NO; self.bgImg.hidden = NO; self.officeImg.hidden = NO; self.label.hidden = YES; self.secondTrialBtn.hidden = YES; self.labelContentView.hidden = YES; self.aiContendView.hidden = YES; self.userButton.hidden = YES; self.signUpView.hidden = YES; self.signUpLabel.stringValue = NSLocalizedStringFromTable(@"Sign in", @"MemberCenterLocalizable", nil); self.signUpLabel.font = [NSFont SFProTextSemiboldFont:11]; [self.signUpLabel sizeToFit]; CGFloat signUpWidth = self.signUpLabel.frame.size.width; signUpWidth += 4; signUpWidth += 8; signUpWidth += 8; signUpWidth += 12; self.signUpImg.frame = CGRectMake(8, CGRectGetHeight(self.view.frame)/2.-6, 12, 12); CGRect signUplabelRect = self.signUpLabel.frame; signUplabelRect.origin.x = CGRectGetMaxX(self.signUpImg.frame) + 4; self.signUpLabel.frame = signUplabelRect; self.button.layer.backgroundColor = [NSColor clearColor].CGColor; self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade to Pro", nil)]; [self.button setTitleColor:[NSColor whiteColor]]; self.officeButton.layer.backgroundColor = [NSColor clearColor].CGColor; self.officeButton.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"PDF to Office", nil)]; [self.officeButton setTitleColor:[NSColor whiteColor]]; self.aiLabel.stringValue = NSLocalizedStringFromTable(@"Free Use 1-Year AI Tools", @"MemberCenterLocalizable", nil); [self.aiLabel sizeToFit]; CGFloat aiWidth = self.aiLabel.frame.size.width; aiWidth += 4; aiWidth += 16; aiWidth += 16; self.aiIconImg.frame = CGRectMake(8, CGRectGetHeight(self.view.frame)/2.-8, 16, 16); self.aiContendView.frame = CGRectMake(totalWidth, 0, aiWidth, self.view.frame.size.height); CGRect ailabelRect = self.aiLabel.frame; ailabelRect.origin.x = CGRectGetMaxX(self.aiIconImg.frame) + 4; self.aiLabel.frame = ailabelRect; // totalWidth+=aiWidth; // totalWidth+=4; // self.aiContendView.hidden = NO; CGFloat userImageWidth = 24; if ([KMMemberInfo shared].isLogin) { self.userButton.image = [NSImage imageNamed:@"UserProfilePicture"]; } else { self.userButton.image = [NSImage imageNamed:@"UserProfilePicture1"]; } CGFloat buttonWidth = CGRectGetMaxX(self.button.frame); NSRect btnRect = [self.button.attributedTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, CGRectGetHeight(self.button.frame)) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading]; if (fabs(buttonWidth-btnRect.size.width)>50) { buttonWidth = btnRect.size.width + 10; } CGFloat officeWidth = CGRectGetMaxX(self.officeButton.frame); NSRect officeRect = [self.officeButton.attributedTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, CGRectGetHeight(self.officeButton.frame)) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading]; if (fabs(officeWidth-officeRect.size.width)>50) { officeWidth = officeRect.size.width + 10; } #if VERSION_DMG self.button.hidden = YES; self.officeButton.hidden = YES; self.bgImg.hidden = YES; self.officeImg.hidden = YES; if ([[KMMemberInfo shared].isHaveAIDiscount isEqualToString:@"1"]) { self.aiContendView.hidden = NO; totalWidth+=aiWidth; totalWidth+=4; } KMUserScenarioType type = [KMMemberInfo shared].userScenarioType; if (type == KMUserScenarioTypeDmg_type1 || type == KMUserScenarioTypeDmg_type2 || type == KMUserScenarioTypeDmg_type3 || type == KMUserScenarioTypeDmg_type5 || type == KMUserScenarioTypeDmg_type6 || type == KMUserScenarioTypeDmg_type7 || type == KMUserScenarioTypeDmg_type28 || type == KMUserScenarioTypeDmg_type29 || type == KMUserScenarioTypeDmg_type30 || type == KMUserScenarioTypeDmg_type43 || type == KMUserScenarioTypeDmg_type44 || type == KMUserScenarioTypeDmg_type45) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)]; } else if (type == KMUserScenarioTypeDmg_type4 ) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Free Trial", nil)]; } else if (type == KMUserScenarioTypeDmg_type11 || type == KMUserScenarioTypeDmg_type19 || type == KMUserScenarioTypeDmg_type22 || type == KMUserScenarioTypeDmg_type34 || type == KMUserScenarioTypeDmg_type37 ) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Buy Now", @"MemberCenterLocalizable", nil)]; } else if (type == KMUserScenarioTypeDmg_type18 || type == KMUserScenarioTypeDmg_type33 || type == KMUserScenarioTypeDmg_type48) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Renew now", @"MemberCenterLocalizable", nil)]; } if (type == KMUserScenarioTypeDmg_type2 || type == KMUserScenarioTypeDmg_type19 || type == KMUserScenarioTypeDmg_type20 || type == KMUserScenarioTypeDmg_type21 || type == KMUserScenarioTypeDmg_type22 || type == KMUserScenarioTypeDmg_type30 || type == KMUserScenarioTypeDmg_type31 || type == KMUserScenarioTypeDmg_type32 || type == KMUserScenarioTypeDmg_type33) { [self.officeButton setTitleColor:[NSColor whiteColor]]; self.officeButton.hidden = NO; self.officeImg.hidden = NO; self.officeButton.frame = CGRectMake(totalWidth, kbottomGap, officeWidth, self.view.frame.size.height -2 *kbottomGap); CGRect officeRect = self.officeButton.frame; self.officeImg.frame = officeRect; totalWidth+=CGRectGetWidth(self.officeButton.bounds); totalWidth+=4; } if (type == KMUserScenarioTypeDmg_type1 || type == KMUserScenarioTypeDmg_type2 || type == KMUserScenarioTypeDmg_type3 || type == KMUserScenarioTypeDmg_type4 || type == KMUserScenarioTypeDmg_type5 || type == KMUserScenarioTypeDmg_type6 || type == KMUserScenarioTypeDmg_type7 || type == KMUserScenarioTypeDmg_type11 || type == KMUserScenarioTypeDmg_type18 || type == KMUserScenarioTypeDmg_type19 || type == KMUserScenarioTypeDmg_type22 || type == KMUserScenarioTypeDmg_type28 || type == KMUserScenarioTypeDmg_type29 || type == KMUserScenarioTypeDmg_type30 || type == KMUserScenarioTypeDmg_type33 || type == KMUserScenarioTypeDmg_type34 || type == KMUserScenarioTypeDmg_type37 || type == KMUserScenarioTypeDmg_type43 || type == KMUserScenarioTypeDmg_type44 || type == KMUserScenarioTypeDmg_type45 || type == KMUserScenarioTypeDmg_type48) { [self.button setTitleColor:[NSColor whiteColor]]; if (KMAdvertisementManager.manager.info.topRightInfoContent != nil) { if (KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject != nil) { KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject; NSString *name = [KMAdvertisementModelTransition transitionLanguageWithLangeuage:info.name]; self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(name, nil)]; NSURL *url = [NSURL URLWithString: [KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight: YES]]; __weak typeof(self)weakSelf = self; NSImage * img = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage *image) { if (image != nil) { weakSelf.bgImg.image = image; } }]; } } self.bgImg.hidden = NO; self.button.hidden = NO; self.button.frame = CGRectMake(totalWidth, kbottomGap, buttonWidth, self.view.frame.size.height -2 *kbottomGap); CGRect rect = self.button.frame; self.bgImg.frame = rect; totalWidth+=CGRectGetWidth(self.button.bounds); totalWidth+=4; } #else if ([[KMMemberInfo shared].isHaveAIDiscount isEqualToString:@"1"]) { #if VERSION_FREE if(IAPProductsManager.defaultManager.aiAllAccessPack12month_lite.isTrialPeriod == false) { self.aiContendView.hidden = NO; totalWidth+=aiWidth; totalWidth+=4; } #else if(IAPProductsManager.defaultManager.aiAllAccessPack12month_pro.isTrialPeriod == false) { self.aiContendView.hidden = NO; totalWidth+=aiWidth; totalWidth+=4; } #endif } KMUserScenarioType type = [KMMemberInfo shared].userScenarioType; if (type == KMUserScenarioTypeLite_type1 || type == KMUserScenarioTypeLite_type3 || type == KMUserScenarioTypeLite_type5 || type == KMUserScenarioTypeLite_type7 || type == KMUserScenarioTypeLite_type9 || type == KMUserScenarioTypeLite_type11 || type == KMUserScenarioTypePro_type1 || type == KMUserScenarioTypePro_type3 || type == KMUserScenarioTypePro_type4) { if (type == KMUserScenarioTypeLite_type1) { //免费用户 #if !VERSION_DMG if(KMMemberInfo.shared.isLogin == NO) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)]; } else { if(IAPProductsManager.defaultManager.fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == YES) { //是否有试用 self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)]; } else { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Free Trial", nil)]; } } #else #endif } else if (type == KMUserScenarioTypeLite_type3 ) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Buy Now", @"MemberCenterLocalizable", nil)]; } else if (type == KMUserScenarioTypeLite_type5) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)]; } else if (type == KMUserScenarioTypeLite_type7) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Renew now", @"MemberCenterLocalizable", nil)]; } else if (type == KMUserScenarioTypeLite_type9) { if([KMMemberInfo shared].vip_status == 2) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Renew now",@"MemberCenterLocalizable", nil)]; } else if ([KMMemberInfo shared].vip_status == 4) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Buy Now",@"MemberCenterLocalizable", nil)]; } else { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)]; } } else if (type == KMUserScenarioTypeLite_type11) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)]; } else if (type == KMUserScenarioTypePro_type3) { if([KMMemberInfo shared].vip_status == 2) { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Renew now",@"MemberCenterLocalizable", nil)]; } else { self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)]; } } #if !VERSION_FREE BOOL isNoSupportMemberUpgrade = YES; if ([KMMemberInfo shared].vip_status == 1) { //订阅+永久 isNoSupportMemberUpgrade = NO; } if (![IAPProductsManager defaultManager].isAvailableAdvancedPDFToOffice && isNoSupportMemberUpgrade) { [self.officeButton setTitleColor:[NSColor whiteColor]]; self.officeButton.hidden = NO; self.officeImg.hidden = NO; self.officeButton.frame = CGRectMake(totalWidth, kbottomGap, officeWidth, self.view.frame.size.height -2 *kbottomGap); CGRect officeRect = self.officeButton.frame; self.officeImg.frame = officeRect; totalWidth+=CGRectGetWidth(self.officeButton.bounds); totalWidth+=4; } else { self.officeButton.hidden = YES; self.officeImg.hidden = YES; } #else self.officeButton.hidden = YES; self.officeImg.hidden = YES; #endif if (KMAdvertisementManager.manager.info.topRightInfoContent != nil) { if (KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject != nil) { KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject; NSString *name = [KMAdvertisementModelTransition transitionLanguageWithLangeuage:info.name]; self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(name, nil)]; NSURL *url = [NSURL URLWithString: [KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight: YES]]; __weak typeof(self)weakSelf = self; NSImage * img = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage *image) { if (image != nil) { weakSelf.bgImg.image = image; } }]; } } [self.button setTitleColor:[NSColor whiteColor]]; self.bgImg.hidden = NO; self.button.hidden = NO; BOOL isOldSubscribed = NO; #if VERSION_FREE #if !VERSION_DMG isOldSubscribed = (IAPProductsManager.defaultManager.allAccessPack6months_lite.isSubscribed == YES || IAPProductsManager.defaultManager.allAccessPack12months_lite.isSubscribed == YES); #endif #endif // 单平台高级版永久 未登录时 也不显示升级(因为点了也得先登录),但是登录后的卡片里是有升级按钮的,可以升级成全平台高级版年订阅 //原来是订阅的,不需要升级,因为目前不支持订阅升级订阅这种场景 if(type == KMUserScenarioTypeLite_type9 || type == KMUserScenarioTypeLite_type10 || type == KMUserScenarioTypeLite_type11) { if([KMMemberInfo shared].isLogin == NO) { //未登录 self.button.hidden = YES; self.bgImg.hidden = YES; } else { if(isOldSubscribed) { //老版本付费功能是订阅包 self.button.hidden = YES; self.bgImg.hidden = YES; } else { if((KMMemberInfo.shared.vip_status == 1) && [KMMemberInfo.shared.vip_paymentModel isEqualToString:@"1"]) { //会员订阅中 self.button.hidden = YES; self.bgImg.hidden = YES; } } } } buttonWidth = CGRectGetMaxX(self.button.frame); NSRect btnRect = [self.button.attributedTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, CGRectGetHeight(self.button.frame)) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading]; if (fabs(buttonWidth-btnRect.size.width)>50) { buttonWidth = btnRect.size.width + 10; } self.button.frame = CGRectMake(totalWidth, kbottomGap, buttonWidth, self.view.frame.size.height -2 *kbottomGap); CGRect rect = self.button.frame; self.bgImg.frame = rect; totalWidth+=CGRectGetWidth(self.button.bounds); totalWidth+=4; } else if (type == KMUserScenarioTypeLite_type12 || type == KMUserScenarioTypeLite_type13 || type == KMUserScenarioTypeLite_type2 || type == KMUserScenarioTypeLite_type4 || type == KMUserScenarioTypeLite_type6 || type == KMUserScenarioTypeLite_type8 || type == KMUserScenarioTypePro_type2 || type == KMUserScenarioTypePro_type5) { self.button.hidden = YES; self.bgImg.hidden = YES; #if !VERSION_FREE BOOL isNoSupportMemberUpgrade = YES; if ([KMMemberInfo shared].vip_status == 1) { //订阅+永久 isNoSupportMemberUpgrade = NO; } if (![IAPProductsManager defaultManager].isAvailableAdvancedPDFToOffice && isNoSupportMemberUpgrade) { [self.officeButton setTitleColor:[NSColor whiteColor]]; self.officeButton.hidden = NO; self.officeImg.hidden = NO; self.officeButton.frame = CGRectMake(totalWidth, kbottomGap, officeWidth, self.view.frame.size.height -2 *kbottomGap); CGRect officeRect = self.officeButton.frame; self.officeImg.frame = officeRect; totalWidth+=CGRectGetWidth(self.officeButton.bounds); totalWidth+=4; } else { self.officeButton.hidden = YES; self.officeImg.hidden = YES; } #else self.officeButton.hidden = YES; self.officeImg.hidden = YES; #endif } #endif if ([KMMemberInfo shared].isLogin) { self.userButton.hidden = NO; self.userButton.frame = CGRectMake(totalWidth, 0, userImageWidth, userImageWidth); totalWidth += userImageWidth; totalWidth += 8; } else { self.signUpView.hidden = NO; self.signUpView.frame = CGRectMake(totalWidth, 0, signUpWidth, self.view.frame.size.height); totalWidth+=CGRectGetWidth(self.signUpView.bounds); } self.view.frame = CGRectMake(MAX(0, CGRectGetWidth(self.view.superview.frame)-totalWidth - 8), (CGRectGetHeight(self.view.superview.frame)-CGRectGetHeight(self.view.frame))/2., totalWidth, self.view.frame.size.height); } #pragma mark - Button Actions - (IBAction)secondTrialAction:(NSButton *)sender { if ([VerificationManager manager].secondTrialEnabled) { KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialGuide]; [vc showWindow:nil]; } else { [[KMProductCompareWC shared] setOrientation:NO]; [[KMProductCompareWC shared] showWindow:nil]; } } - (IBAction)buttonAction:(id)sender { if (KMAdvertisementManager.manager.info.topRightInfoContent != nil) { if (KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject != nil) { [[KMProductCompareWC shared] setOrientation:YES]; #if VERSION_FREE #if VERSION_DMG // DMG [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeDmg_Base]; #else // AppStore 免费版本 [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeLite_Base]; #endif #else // AppStore 付费版 [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypePro_Base]; #endif [[KMProductCompareWC shared] showWindow:nil]; } else { KMUserScenarioType type = [KMMemberInfo shared].userScenarioType; if (type == KMUserScenarioTypeDmg_type4) { [[KMProductCompareWC shared] setOrientation:YES]; [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeTrial]; [[KMProductCompareWC shared] showWindow:nil]; } else { [[KMMemberInfo shared] advancedFunctionUsage]; } } } else { KMUserScenarioType type = [KMMemberInfo shared].userScenarioType; if (type == KMUserScenarioTypeDmg_type4) { [[KMProductCompareWC shared] setOrientation:YES]; [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeTrial]; [[KMProductCompareWC shared] showWindow:nil]; } else { [[KMMemberInfo shared] advancedFunctionUsage]; } } } - (IBAction)officeButtonAction:(id)sender { #if VERSION_DMG DMGEmbeddedOldWC *embeddedWC = [DMGEmbeddedOldWC currentFirstTrialWC:@"com.brother.pdfreaderpro.mac.product_2"]; [embeddedWC showWindow:nil]; [embeddedWC.window center]; #endif } - (NSAttributedString *)numberConvertColor:(NSColor*)color String:(NSString *)string { NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string]; NSString *temp = nil; for (NSUInteger i = 0; i