// // WelcomeWindowController.m // PDF Reader // // Created by wangshuai on 13-12-11. // Copyright (c) 2013年 zhangjie. All rights reserved. // #import "WelcomeWindowController.h" #import "WaitingView.h" #if VERSION_DMG #import #else #import #endif #import "TCPageIndicator.h" #import "NSButton+TitleColor.h" static WelcomeWindowController *windowController = nil; static NSString * const kKMWelcomeHasShowKey = @"WelcomeHasShowKey"; static NSString * const kKMWelcomeRemindMeLaterKey = @"WelcomeRemindMeLaterKey"; @interface WelcomeWindowController () @property (nonatomic,assign) IBOutlet NSScrollView *scrollView; @property (nonatomic,assign) IBOutlet NSView *content1View; @property (nonatomic,assign) IBOutlet NSView *content2View; @property (nonatomic,assign) IBOutlet NSView *content3View; @property (nonatomic,assign) IBOutlet NSView *content4View; @property (strong) IBOutlet NSView *content5View; @property (nonatomic,assign) IBOutlet NSTextField *title1Label; @property (nonatomic,assign) IBOutlet NSTextField *subtitle1Label; @property (nonatomic,assign) IBOutlet NSTextField *title2Label; @property (nonatomic,assign) IBOutlet NSTextField *subtitle2Label; @property (nonatomic,assign) IBOutlet NSTextField *title3Label; @property (nonatomic,assign) IBOutlet NSTextField *subtitle3Label; @property (nonatomic,assign) IBOutlet NSTextField *title4Label; @property (nonatomic,assign) IBOutlet NSTextField *subtitle4Label; @property (weak) IBOutlet NSTextField *title5Label; @property (weak) IBOutlet NSTextField *subtitle5Label; @property (weak) IBOutlet NSBox *preBox; @property (weak) IBOutlet NSBox *nextBox; @property (nonatomic, strong) KMDesignButton *preButtonVC; @property (nonatomic, strong) KMDesignButton *nextButtonVC; @property (weak) IBOutlet NSBox *next1Box; @property (weak) IBOutlet NSBox *remindMeLaterBox; @property (weak) IBOutlet NSBox *next2Box; @property (weak) IBOutlet NSBox *next3Box; @property (weak) IBOutlet NSBox *next4Box; @property (weak) IBOutlet NSBox *signUpBox; @property (nonatomic, strong) KMDesignButton *next1ButtonVC; @property (nonatomic, strong) KMDesignButton *remindMeLaterButtonVC; @property (nonatomic, strong) KMDesignButton *next2ButtonVC; @property (nonatomic, strong) KMDesignButton *next3ButtonVC; @property (nonatomic, strong) KMDesignButton *next4ButtonVC; @property (nonatomic, strong) KMDesignButton *signUpButtonVC; @property (weak) IBOutlet TCPageIndicator *pageIndicator1; @property (weak) IBOutlet TCPageIndicator *pageIndicator2; @property (weak) IBOutlet TCPageIndicator *pageIndicator3; @property (weak) IBOutlet TCPageIndicator *pageIndicator4; @property (weak) IBOutlet TCPageIndicator *pageIndicator5; @property (nonatomic,retain) NSArray *contentViews; @property (nonatomic,assign) NSInteger currentIndex; @property (weak) IBOutlet NSButton *closeButton; @property (weak) IBOutlet KMBox *closeBox; @end @implementation WelcomeWindowController - (void)dealloc { #if DEBUG NSLog(@"%s", __func__); #endif } + (void)load { // 处理再次提醒 if ([[NSUserDefaults standardUserDefaults] boolForKey:kKMWelcomeRemindMeLaterKey]) { [[NSUserDefaults standardUserDefaults] setBool:NO forKey:kKMWelcomeRemindMeLaterKey]; [[NSUserDefaults standardUserDefaults] setBool:NO forKey:kKMWelcomeHasShowKey]; [[NSUserDefaults standardUserDefaults] synchronize]; } } + (BOOL)welcomeHasShow { return [[NSUserDefaults standardUserDefaults] boolForKey:kKMWelcomeHasShowKey]; } #pragma mark Init Methods - (id)init { if (self = [super initWithWindowNibName:@"WelcomeWindowController"]) { windowController = self; } return self; } - (void)awakeFromNib { [super awakeFromNib]; NSClipView *clipView = self.scrollView.contentView; // ,self.content4View self.contentViews = @[self.content1View,self.content2View,self.content5View]; for (int i=0; i= self.contentViews.count-1) { return; } self.currentIndex++; [NSAnimationContext beginGrouping]; NSClipView *clipView = [self.scrollView contentView]; NSPoint newOrigin = [clipView bounds].origin; newOrigin.x = clipView.bounds.size.width*self.currentIndex; [[clipView animator] setBoundsOrigin:newOrigin]; [NSAnimationContext endGrouping]; [self reloadData]; } - (IBAction)closeAction:(id)sender { if (self.itemClick) { self.itemClick(1, self); } [self close]; } - (void)signUpButtonAction:(NSButton *)sender { if (KMLightMemberManager.manager.isLogin) { [self closeAction:sender]; } else { if (self.itemClick) { self.itemClick(3, self); } [self close]; } } - (void)remindMeLaterButtonAction:(NSButton *)sender { [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kKMWelcomeRemindMeLaterKey]; [[NSUserDefaults standardUserDefaults] synchronize]; if (self.itemClick) { self.itemClick(2, self); } [self close]; } @end