Changeset 23


Ignore:
Timestamp:
Nov 21, 2004, 1:41:09 PM (19 years ago)
Author:
altba\rryu
Message:

FaceDefクラスの顔パターンファイル読み込み処理を整理した。
PartクラスにあったY軸反転処理をFaceDefクラスに移した。

Location:
trunk/MacFaceLibrary
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MacFaceLibrary/FaceDef.cs

    r22 r23  
    1818        public class FaceDef
    1919        {
     20                // ƒpƒ^[ƒ“ƒXƒC[ƒgID
    2021                public enum PatternSuite
    2122                {
     
    2526                }
    2627
     28                public const int PatternCount = 11;
     29                public const int ImageWidth   = 128;
     30                public const int ImageHeight  = 128;
     31
     32                // ƒ}[ƒJ[
    2733                public const int MarkerNone    = 0x00;
    2834                public const int MarkerPageIn  = 0x01;
    2935                public const int MarkerPageOut = 0x02;
    3036
     37                // Šçƒpƒ^[ƒ“’è‹`ƒvƒƒpƒeƒBƒŠƒXƒgƒtƒ@ƒCƒ‹–¼
    3138                private const string FaceDefName = "faceDef.plist";
    32                 private const int PatternCols = 11;
    33                 private const int PatternRows = 3;
    34                 private const int ImageWidth = 128;
    35                 private const int ImageHeight = 128;
    36 
     39
     40                // Šçƒpƒ^[ƒ“’è‹`‚̃L[–¼Ì
     41                private const string KeyInfoTitle       = "title";
     42                private const string KeyInfoAuthor      = "author";
     43                private const string KeyInfoVersion     = "version";
     44                private const string KeyInfoSiteURL     = "web site";
     45               
     46                private const string KeyDefParts        = "parts";
     47                private const string KeyDefPatterns     = "pattern";
     48                private const string KeyDefMarkers      = "markers";
     49                private const string KeyDefTitlePattern = "title pattern";
     50
     51                private const string KeyPartImage       = "filename";
     52                private const string KeyPartPosX        = "pos x";
     53                private const string KeyPartPosY        = "pos y";
     54
     55                //
    3756                private string _path;
    3857                private string _title;
     
    5877                        // î•ñ
    5978                        _path = path;
    60                         _title = (def.ContainsKey("title") ? def["title"] as string : String.Empty);
    61                         _author = (def.ContainsKey("author") ? def["author"] as string : String.Empty);
    62                         _version = (def.ContainsKey("version") ? def["version"] as string : String.Empty);
    63 
    64                         if (def.ContainsKey("web site"))
     79                        _title = ReadInfoString(def, KeyInfoTitle);
     80                        _author = ReadInfoString(def, KeyInfoAuthor);
     81                        _version = ReadInfoString(def, KeyInfoVersion);
     82
     83                        if (def.ContainsKey(KeyInfoSiteURL))
    6584                        {
    6685                                try
    6786                                {
    68                                         _webSite = new Uri(def["web site"] as string);
     87                                        _webSite = new Uri(def[KeyInfoSiteURL] as string);
    6988                                }
    7089                                catch (UriFormatException) {}
     
    7392
    7493                        // ƒp[ƒc‚̓ǂݍž‚Ý
    75                         ArrayList partDefList = (ArrayList)def["parts"];
     94                        ArrayList partDefList = (ArrayList)def[KeyDefParts];
    7695                        if (partDefList == null)
    7796                        {
     
    82101                        for (int i = 0; i < partDefList.Count; i++)
    83102                        {
    84                                 Hashtable partDef = (Hashtable)partDefList[i];
    85                                 string filename = (String)partDef["filename"];
    86                                 int x = (int)partDef["pos x"];
    87                                 int y = (int)partDef["pos y"];
    88                                 _parts[i] = new Part(System.IO.Path.Combine(path, filename), x, y);
    89                         }
     103                                _parts[i] = ReadPart(path, (Hashtable)partDefList[i]);
     104            }
    90105
    91106                        // ƒpƒ^[ƒ“‚̓ǂݍž‚Ý
    92                         ArrayList suiteDefList = (ArrayList)def["pattern"];
    93                         _patternSuites = new Part[PatternRows][][];
    94                         for (int i = 0; i < PatternRows; i++)
    95                         {
    96                                 ArrayList suiteDef = (ArrayList)suiteDefList[i];
    97                                 Part[][] suite = new Part[PatternCols][];
    98                                 for (int j = 0; j < PatternCols; j++)
    99                                 {
    100                                         ArrayList patternDef = (ArrayList)suiteDef[j];
    101                                         Part[] pattern = new Part[patternDef.Count];
    102                                         for (int k = 0; k < patternDef.Count; k++)
    103                                         {
    104                                                 pattern[k] = _parts[(int)patternDef[k]];
    105                                         }
    106                                         suite[j] = pattern;
    107                                 }
    108                                 _patternSuites[i] = suite;
     107            int suiteCount = PatternSuite.GetNames(typeof(PatternSuite)).Length;
     108            ;
     109            ArrayList suiteDefList = (ArrayList)def[KeyDefPatterns];
     110            _patternSuites = new Part[suiteCount][][];
     111            for (int i = 0; i < suiteCount; i++)
     112            {
     113                                _patternSuites[i] = ReadPatternSuite(_parts, (ArrayList)suiteDefList[i]);
    109114                        }
    110115
    111116                        // ƒ}[ƒJ[‚̓ǂݍž‚Ý
    112                         ArrayList markerDefList = (ArrayList)def["markers"];
     117                        ArrayList markerDefList = (ArrayList)def[KeyDefMarkers];
    113118                        _markers = new Part[markerDefList.Count];
    114119                        for (int i = 0; i < markerDefList.Count; i++)
     
    118123
    119124                        // ƒ^ƒCƒgƒ‹ƒpƒ^[ƒ“‚̓ǂݍž‚Ý
    120                         ArrayList titlePatternDef = (ArrayList)def["title pattern"];
    121                         _titlePattern = new Part[titlePatternDef.Count];
    122                         for (int i = 0; i < titlePatternDef.Count; i++)
    123                         {
    124                                 _titlePattern[i] = _parts[(int)titlePatternDef[i]];
    125                         }
    126                 }
    127 
    128                 public Uri WebSite
    129                 {
     125                        _titlePattern = ReadPattern(_parts, (ArrayList)def[KeyDefTitlePattern]);
     126                }
     127
     128                private string ReadInfoString(Hashtable def, string key)
     129                {
     130                        string str = def[key] as string;
     131                        return str != null ? str : "";
     132                }
     133
     134                private Part ReadPart(string path, Hashtable partDef)
     135                {
     136                        string filename = (String)partDef[KeyPartImage];
     137                        string imgPath = System.IO.Path.Combine(path, filename);
     138                        Image img = Image.FromFile(imgPath);
     139
     140                        int x = (int)partDef[KeyPartPosX];
     141                        int y = ImageHeight - (int)partDef[KeyPartPosY] - img.Height;
     142
     143                        return new Part(imgPath, img, x, y);
     144                }
     145
     146                private Part[] ReadPattern(Part[] parts, ArrayList patternDef)
     147                {
     148                        Part[] pattern = new Part[patternDef.Count];
     149                        for (int i = 0; i < patternDef.Count; i++)
     150                        {
     151                                pattern[i] = _parts[(int)patternDef[i]];
     152                        }
     153                        return pattern;
     154                }
     155
     156                private Part[][] ReadPatternSuite(Part[] parts, ArrayList suiteDef)
     157                {
     158                        Part[][] suite = new Part[PatternCount][];
     159                        for (int i = 0; i < PatternCount; i++)
     160                        {
     161                                suite[i] = ReadPattern(_parts, (ArrayList)suiteDef[i]);
     162                        }
     163                        return suite;
     164                }
     165
     166
     167        public string Path
     168        {
     169            get { return _path; }
     170        }
     171
     172        public string Title
     173        {
     174            get { return _title; }
     175        }
     176
     177        public string Author
     178        {
     179            get { return _author; }
     180        }
     181
     182        public string Version
     183        {
     184            get { return _version; }
     185        }
     186
     187        public Uri WebSite
     188        {
    130189                        get { return _webSite; }
    131                 }
    132 
    133                 public string /*Version*/ Version
    134                 {
    135                         get { return _version; }
    136                 }
    137 
    138                 public string Author
    139                 {
    140                         get { return _author; }
    141                 }
    142 
    143                 public string Title
    144                 {
    145                         get { return _title; }
    146                 }
    147 
    148                 public string Path
    149                 {
    150                         get { return _path; }
    151190                }
    152191
     
    209248        }
    210249}
    211 
    212 
    213 /*
    214 #import <Cocoa/Cocoa.h>
    215 
    216 //
    217 #define FACE_ROWMAX     3
    218 #define FACE_COLMAX     11
    219 #define FACE_PATMAX     8
    220 #define FACE_IMGW       128
    221 #define FACE_IMGH       128
    222 #define FACE_IMGSIZE    (NSMakeSize(128,128))
    223 
    224 // ƒ}[ƒJ[ƒrƒbƒgƒ}ƒXƒN
    225 #define FDMARKER_PAGEIN         0x0001
    226 #define FDMARKER_PAGEOUT        0x0002
    227 
    228 //
    229 #define FACE_INFO_TITLE         @"title"
    230 #define FACE_INFO_AUTHOR        @"author"
    231 #define FACE_INFO_VERSION       @"version"
    232 #define FACE_INFO_SITE_URL      @"web site"
    233 
    234 #define FACE_INFO_PARTS         @"parts"
    235 #define FACE_INFO_PATTERN       @"pattern"
    236 #define FACE_INFO_MARKER        @"markers"
    237 #define FACE_INFO_TITLE_PATTERN @"title pattern"
    238 #define FACE_INFO_MARK_PGOUT    @"pagein pattern"
    239 #define FACE_INFO_MARK_PGIN     @"pageout pattern"
    240 
    241 #define FACE_PART_IMAGE         @"filename"
    242 #define FACE_PART_POSX          @"pos x"
    243 #define FACE_PART_POSY          @"pos y"
    244 
    245 typedef struct {
    246     NSString *filename;
    247     NSImage *image;
    248     NSPoint pos;
    249 } PartDef;
    250 
    251 typedef struct {
    252     unsigned count;
    253     int parts[FACE_PATMAX];
    254 } PatternDef;
    255 
    256 
    257 @interface FaceDef : NSObject
    258 {
    259     NSString *packagePath;
    260     NSDictionary *definition;
    261     int partCount;
    262     PartDef *parts;
    263     PatternDef patterns[FACE_ROWMAX][FACE_COLMAX];
    264     int markers[8];
    265     PatternDef titlePattern;
    266 }
    267 
    268 + (NSDictionary*)infoAtPath:(NSString*)path;
    269 
    270 + (id)faceDefWithContentOfFile:(NSString*)path;
    271 
    272 - (id)initWithContentOfFile:(NSString*)path;
    273 
    274 - (NSString*)path;
    275 
    276 - (NSString*)title;
    277 - (NSString*)author;
    278 - (NSString*)version;
    279 - (NSString*)siteURL;
    280 
    281 - (NSImage*)titleImage;
    282 
    283 - (int)partCount;
    284 - (const PartDef*)partOfIndex:(int)index;
    285 - (const PatternDef*)patternOfRow:(int)row col:(int)col;
    286 - (int)patternCountOfRow:(int)row col:(int)col;
    287 - (int)patternNoOfRow:(int)row col:(int)col index:(int)index;
    288 
    289 - (NSImage*)imageOfRow:(int)row col:(int)col marker:(int)marker;
    290 
    291 - (void)drawImageOfRow:(int)row col:(int)col marker:(int)marker atPoint:(NSPoint)pt;
    292 - (void)drawPart:(PartDef*)part atPoint:(NSPoint)point;
    293 
    294 - (void)dumpPattern:(NSString*)path;
    295 
    296 @end
    297 
    298 @implementation FaceDef
    299 
    300 + (NSDictionary*)infoAtPath:(NSString*)path
    301 {
    302     NSDictionary *info;
    303 
    304     info = [NSDictionary dictionaryWithContentsOfFile:
    305         [path stringByAppendingPathComponent:@"faceDef.plist"]];
    306 
    307     return info;
    308 }
    309 
    310 + (id)faceDefWithContentOfFile:(NSString*)path
    311 {
    312     return [[[self alloc] initWithContentOfFile:path] autorelease];
    313 }
    314 
    315 - (id)initWithContentOfFile:(NSString*)path
    316 {
    317     NSDictionary *partDefDict;
    318     NSArray *partArray,*patternArray,*colArray,*elemArray;
    319     NSEnumerator *enumerator;
    320     NSString *imagePath;
    321     NSNumber *value;
    322     int i,count;
    323     int row,col,no;
    324     int maxPartNo;
    325 
    326     [super init];
    327 
    328     NS_DURING
    329         definition = [FaceDef infoAtPath:path];
    330 
    331         if (definition == nil) {
    332             [NSException raise:@"FaceDefInfoLoadException" format:@"failuer loading faceDef.plist"];
    333         }
    334 
    335         [definition retain];
    336 
    337         packagePath = [path retain];
    338 
    339         // ƒp[ƒc’è‹`‚̓ǂݍž‚Ý
    340         partArray = [definition objectForKey:FACE_INFO_PARTS];
    341 
    342         if ([partArray isMemberOfClass:[NSArray class]]) {
    343             [NSException raise:@"FaceDefPartListLoadException" format:@"failed in reading part list."];
    344         }
    345 
    346         parts = calloc([partArray count],sizeof(PartDef));
    347         count = [partArray count];
    348 
    349         for (partCount = 0; partCount < count; partCount++){
    350             partDefDict = [partArray objectAtIndex:partCount];
    351             parts[partCount].filename = [[partDefDict objectForKey:FACE_PART_IMAGE] retain];
    352             parts[partCount].pos.x = [(NSNumber*)[partDefDict objectForKey:FACE_PART_POSX] floatValue];
    353             parts[partCount].pos.y = [(NSNumber*)[partDefDict objectForKey:FACE_PART_POSY] floatValue];
    354             imagePath = [path stringByAppendingPathComponent:parts[partCount].filename];
    355             parts[partCount].image = [[NSImage alloc]initWithContentsOfFile:imagePath];
    356 
    357             if (parts[partCount].image == nil){ // ‰æ‘œ‚ª“ǂݍž‚ß‚È‚©‚Á‚½
    358                 [NSException raise:@"FaceDefPartLoadException"
    359                     format:@"failed in loading of image '%@'",parts[partCount].filename];
    360             }
    361         }
    362 
    363         maxPartNo = count - 1;
    364 
    365         // ƒpƒ^[ƒ“’è‹`‚̓ǂݍž‚Ý
    366         patternArray = [definition objectForKey:FACE_INFO_PATTERN];
    367 
    368         for (row = 0; row < FACE_ROWMAX; row++){
    369             colArray = [patternArray objectAtIndex:row];
    370 
    371             if ([colArray count] != FACE_COLMAX) {
    372                 [NSException raise:@"FaceDefPatternLoadException"
    373                     format:@"number of pattern columns is not 10 at row %d",row];
    374             }
    375 
    376             for (col = 0; col < FACE_COLMAX; col++){
    377                 elemArray = [colArray objectAtIndex:col];
    378                 enumerator = [[colArray objectAtIndex:col] objectEnumerator];
    379                 for (i = 0; i <= FACE_PATMAX && (value = [enumerator nextObject]) != nil; i++){
    380                     no = [value intValue];
    381                     patterns[row][col].parts[i] = no;
    382                     if (0 > no || no > maxPartNo) { // ƒp[ƒc”ԍ†ƒ`ƒFƒbƒN
    383                         [NSException raise:@"FaceDefPatternLoadException"
    384                             format:@"illigal part no %d in patterns[%d,%d,%d]",no,row,col,i];
    385                     }
    386                 }
    387                 patterns[row][col].count = i;
    388             }
    389         }
    390 
    391         // ƒ}[ƒJ[ƒŠƒXƒg‚̓ǂݍž‚Ý
    392         enumerator = [[definition objectForKey:FACE_INFO_MARKER] objectEnumerator];
    393         for (i = 0; i < 8 && (value = [enumerator nextObject]) != nil; i++){
    394             markers[i] = [value intValue];
    395         }
    396 
    397         // ‘ã•\‰æ‘œƒpƒ^[ƒ“‚̓ǂݍž‚Ý
    398         enumerator = [[definition objectForKey:FACE_INFO_TITLE_PATTERN] objectEnumerator];
    399         for (i = 0; i <= FACE_PATMAX && (value = [enumerator nextObject]) != nil; i++){
    400             no = [value intValue];
    401             titlePattern.parts[i] = no;
    402             if (0 > no || no > maxPartNo) { // ƒp[ƒc”ԍ†ƒ`ƒFƒbƒN
    403                 [NSException raise:@"FaceDefPatternLoadException"
    404                     format:@"illigal part no %d in title pattern",no];
    405             }
    406         }
    407         titlePattern.count = i;
    408     NS_HANDLER
    409         NSLog(@"FaceDef load error: %@",localException);
    410         [self dealloc];
    411         self = nil;
    412     NS_ENDHANDLER
    413 
    414     return self;
    415 }
    416 
    417 - (void)dealloc
    418 {
    419     int i;
    420 
    421     [packagePath release];
    422     [definition release];
    423 
    424     if (parts != nil) {
    425         for (i = 0; i < partCount; i++){
    426             [parts[i].filename release];
    427             [parts[i].image release];
    428         }
    429         free(parts);
    430     }
    431 }
    432 
    433 -(NSString*)path
    434 {
    435     return packagePath;
    436 }
    437 
    438 -(NSString*)title
    439 {
    440     NSString *str;
    441     str = [definition objectForKey:@"title"];
    442     return  (str != nil) ? str : @"";
    443 }
    444 
    445 -(NSString*)author
    446 {
    447     NSString *str;
    448     str = [definition objectForKey:@"author"];
    449     return  (str != nil) ? str : @"";
    450 }
    451 
    452 -(NSString*)version
    453 {
    454     NSString *str;
    455     str = [definition objectForKey:@"version"];
    456     return  (str != nil) ? str : @"";
    457 }
    458 
    459 - (NSString*)siteURL
    460 {
    461     NSString *str;
    462     str = [definition objectForKey:@"web site"];
    463     return  (str != nil) ? str : @"";
    464 }
    465 
    466 - (NSImage*)titleImage
    467 {
    468     NSImage *image;
    469     int i;
    470 
    471     image = [[NSImage alloc] initWithSize:FACE_IMGSIZE];
    472     [image lockFocus];
    473 
    474     if (titlePattern.count > 0) {
    475         for (i=0; i<titlePattern.count; i++) {
    476             [self drawPart:&parts[titlePattern.parts[i]] atPoint:NSMakePoint(0,0)];
    477         }
    478     } else {
    479         [self drawImageOfRow:0 col:FACE_COLMAX marker:0 atPoint:NSMakePoint(0,0)];
    480     }
    481 
    482     [image unlockFocus];
    483     return [image autorelease];
    484 }
    485 
    486 - (int)partCount
    487 {
    488     return partCount;
    489 }
    490 
    491 - (const PartDef*)partOfIndex:(int)index
    492 {
    493     if (0 <= index && index < partCount) return &parts[index];
    494     else return nil;
    495 }
    496 
    497 - (const PatternDef*)patternOfRow:(int)row col:(int)col
    498 {
    499     if (0 <= row && row < FACE_ROWMAX
    500      && 0 <= col && col < FACE_COLMAX) return &patterns[row][col];
    501     else return nil;
    502 }
    503 
    504 - (int)patternCountOfRow:(int)row col:(int)col
    505 {
    506     if (0 <= row && row < FACE_ROWMAX
    507      && 0 <= col && col < FACE_COLMAX) return patterns[row][col].count;
    508     else return -1;
    509 }
    510 
    511 - (int)patternNoOfRow:(int)row col:(int)col index:(int)index
    512 {
    513     if (0 <= row && row < FACE_ROWMAX
    514      && 0 <= col && col < FACE_COLMAX
    515      && 0 <= index && index < patterns[row][col].count) return patterns[row][col].parts[index];
    516     else return -1;
    517 }
    518 
    519 - (NSImage*)imageOfRow:(int)row col:(int)col marker:(int)marker
    520 {
    521     NSImage *image;
    522     image = [[NSImage alloc] initWithSize:FACE_IMGSIZE];
    523     [image lockFocus];
    524     [self drawImageOfRow:row col:col marker:marker atPoint:NSMakePoint(0,0)];
    525     [image unlockFocus];
    526     return [image autorelease];
    527 }
    528 
    529 - (void)drawImageOfRow:(int)row col:(int)col marker:(int)marker atPoint:(NSPoint)point
    530 {
    531     int count;
    532     int i;
    533 
    534     count = patterns[row][col].count;
    535     for (i=0; i<count; i++){
    536         [self drawPart:&parts[patterns[row][col].parts[i]] atPoint:point];
    537     };
    538 
    539     if (marker != 0) {
    540         for (i=0; i<8; i++) {
    541             if (marker & (1<<i)) {
    542                 [self drawPart:&parts[markers[i]] atPoint:point];
    543             }
    544         }
    545     }
    546 }
    547 
    548 - (void)drawPart:(PartDef*)part atPoint:(NSPoint)point
    549 {
    550     point.x += part->pos.x;
    551     point.y += part->pos.y;
    552     [part->image compositeToPoint:point operation:NSCompositeSourceOver];
    553 }
    554 
    555 -(void)dumpPattern:(NSString*)path;
    556 {
    557     NSImage *img;
    558     NSSize imgSize;
    559     NSPoint pos;
    560     float offset;
    561     int i,j,rows;
    562     NSMutableDictionary *attr;
    563     NSString *str;
    564 
    565     rows = partCount / FACE_COLMAX + 1;
    566     offset = rows * FACE_IMGW + 10;
    567     imgSize.width = FACE_IMGW * FACE_COLMAX;
    568     imgSize.height = FACE_IMGH * FACE_ROWMAX + offset + 14;
    569 
    570     img = [[NSImage alloc] initWithSize:imgSize];
    571     if (img == nil) {
    572         NSLog(@"failure dump pattern!");
    573         return;
    574     }
    575 
    576     [img lockFocus];
    577     [[NSColor whiteColor] set];
    578     NSRectFill(NSMakeRect(0,0,imgSize.width,imgSize.height));
    579 
    580     [[NSColor blackColor] set];
    581     NSRectFill(NSMakeRect(0,offset-6,imgSize.width,2));
    582 
    583     attr = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    584                 [NSFont systemFontOfSize:14.0], NSFontAttributeName,
    585                 [NSColor blackColor], NSForegroundColorAttributeName,
    586                 nil];
    587 
    588     for (i = 0; i <= partCount; i++) {
    589         pos.x = (i % FACE_COLMAX) * FACE_IMGW;
    590         pos.y = (rows-1 - i / FACE_COLMAX) * FACE_IMGH;
    591         [self drawPart:&parts[i] atPoint:pos];
    592 
    593         str = [NSString stringWithFormat:@"%d",i];
    594         pos.x = (i % FACE_COLMAX) * FACE_IMGW;
    595         pos.y = (rows-1 - i / FACE_COLMAX) * FACE_IMGH + FACE_IMGH - 12;
    596         [str drawAtPoint:pos withAttributes:attr];
    597     }
    598 
    599     for (i = 0; i < FACE_ROWMAX; i++) {
    600         pos.y = (FACE_ROWMAX-1 - i) * FACE_IMGH + offset;
    601         for (j=0; j<FACE_COLMAX; j++) {
    602             pos.x = j * FACE_IMGW;
    603             [self drawImageOfRow:i col:j marker:0 atPoint:pos];
    604         }
    605     }
    606 
    607     pos.y = imgSize.height - 14;
    608     for (i = 0; i < FACE_COLMAX-1; i++) {
    609         str = [NSString stringWithFormat:@"%d-%d%%",i*10,(i+1)*10-1];
    610         pos.x = i * FACE_IMGW;
    611         [str drawAtPoint:pos withAttributes:attr];
    612     }
    613     str = [NSString stringWithFormat:@"%d%%",100];
    614     pos.x = (FACE_COLMAX-1) * FACE_IMGW;
    615     [str drawAtPoint:pos withAttributes:attr];
    616 
    617     [img unlockFocus];
    618 
    619     [[img TIFFRepresentation] writeToFile:path atomically:NO];
    620     [img release];
    621 }
    622 
    623 @end
    624 
    625 */
  • trunk/MacFaceLibrary/Part.cs

    r13 r23  
    1515        {
    1616                private Image _image;
    17                 private string _filename;
     17                private string _imagePath;
    1818                private Point _point;
    1919
    20                 /*public Part(string basePath, Hashtable partDef)
    21                 {
    22                         this.path = (string)Path.Combine(partDef["filename"]);
    23                         this.x = (int)partDef["pos x"];
    24                         this.y = (int)partDef["pos y"];
    25                 }*/
    26                
    2720                public Part(String path, int x, int y)
    2821                {
    29                         _filename = System.IO.Path.GetFileName(path);
     22                        _imagePath = path;
    3023                        _image = Image.FromFile(path);
    31                         this.X = x;
    32                         this.Y = y;
     24                        _point.X = x;
     25                        _point.Y = y;
    3326                }
    3427
    3528                public Part(String path, Image image, int x, int y)
    3629                {
    37                         _filename = System.IO.Path.GetFileName(path);
    38                         _image = image;
    39                         this.X = x;
    40                         this.Y = y;
     30            _imagePath = path;
     31            _image = image;
     32                        _point.X = x;
     33                        _point.Y = y;
    4134                }
    4235
    4336                public string FileName
    4437                {
    45                         get { return _filename; }
    46                 }
     38            get
     39            {
     40                return System.IO.Path.GetFileName(_imagePath);
     41            }
     42        }
    4743
    4844                public Image Image
     
    6460                public int Y
    6561                {
    66                         get { return 128 - _point.Y - _image.Height; }
    67                         set { _point.Y = 128 - value - _image.Height; }
     62                        get { return _point.Y; }
     63                        set { _point.Y = value; }
    6864                }
    6965
Note: See TracChangeset for help on using the changeset viewer.