ImageManager.h
//
// ImageManager.h
// GrapeModule
//
//
#import <Foundation/Foundation.h>
@interface ImageManager : NSObject
@property (readonly) NSImage *imgPass;
@property (readonly) NSImage *imgFail;
@property (readonly) NSImage *imgTesting;
@property (readonly) NSImage *imgRebooting;
@property (readonly) NSImage *imgReady;
@property (readonly) NSImage *imgStopped;
@property (readonly) NSImage *imgFatalError;
@property (readonly) NSImage *imgBigPass;
@property (readonly) NSImage *imgBigFail;
@property (readonly) NSImage *imgLoopTest1;
@property (readonly) NSImage *imgLoopTest2;
@property (readonly) NSImage *imgCommError;
@property (readonly) NSImage *imgGreenLed ;
@property (readonly) NSImage *imgRedLed ;
@end
////////////////////////////////////////////////////////////////////////////////////////////////
//
// ImageManager.m
// GrapeModule
//
//
#import "ImageManager.h"
@implementation ImageManager
{
NSString* imageName;
}
@synthesize imgPass;
@synthesize imgFail;
@synthesize imgTesting;
@synthesize imgRebooting;
@synthesize imgReady;
@synthesize imgStopped;
@synthesize imgFatalError;
@synthesize imgBigPass;
@synthesize imgBigFail;
@synthesize imgLoopTest1;
@synthesize imgLoopTest2;
@synthesize imgCommError;
@synthesize imgGreenLed;
@synthesize imgRedLed;
- (id) init {
self = [super init];
if (self) {
do {
imageName = [[NSBundle mainBundle] pathForResource:@"pass" ofType:@"png"];
imgPass = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgPass == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"fail" ofType:@"png"];
imgFail = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgFail == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"testing" ofType:@"png"];
imgTesting = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgTesting == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"rebooting" ofType:@"png"];
imgRebooting = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgRebooting == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"ready" ofType:@"png"];
imgReady = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgReady == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"stopped" ofType:@"png"];
imgStopped = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgStopped == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"fatal_error" ofType:@"png"];
imgFatalError = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgFatalError == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"Pass1" ofType:@"png"];
imgBigPass = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgBigPass == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"Fail1" ofType:@"png"];
imgBigFail = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgBigFail == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"loopTest1" ofType:@"png"];
imgLoopTest1 = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgLoopTest1 == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"loopTest2" ofType:@"png"];
imgLoopTest2 = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgLoopTest2 == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"comm._error" ofType:@"png"];
imgCommError = [[NSImage alloc] initWithContentsOfFile:imageName];
if (imgCommError == nil) {
NSLog(@"Failed to load the following image:\n%@",imageName);
break;
}
imageName = [[NSBundle mainBundle] pathForResource:@"greenLed" ofType:@"png"] ;
imgGreenLed = [[NSImage alloc] initWithContentsOfFile:imageName] ;
if(imgGreenLed == nil){
NSLog(@"Fail to load the following image:\n%@",imageName);
break ;
}
imageName = [[NSBundle mainBundle] pathForResource:@"redLed" ofType:@"png"] ;
imgRedLed = [[NSImage alloc] initWithContentsOfFile:imageName] ;
if(imgRedLed == nil){
NSLog(@"Fail to load the following image:\n%@",imageName) ;
break ;
}
} while (0);
}
return self;
}
@end