//
//  LabelViewController.m
//  SDK212
//
//  Created by woosimsystems on 2016. 7. 04..
//  Copyright © 2016년 woosimsystems. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "LabelViewController.h"
#import "WSSessionController.h"
#import "WSEncoder.h"

//@interface LabelViewController ()

//@end

WSEncoder *_wsLabel;
NSMutableData *_printDataLabel;

@implementation LabelViewController

NSInteger sensorValue = 0x80;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setTitle:@"Label"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_wifiDidDisConnect:) name:socketDidDisconnectNotification object:nil];
    
    _sessionController = [[WSSessionController sharedController]init];
    _wsLabel = [[WSEncoder alloc]init];
    
}



-(void)viewWillDisappear:(BOOL)animated{
    
    [super viewWillDisappear:animated];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:socketDidDisconnectNotification object:nil];
    
    if(_sessionController != nil) _sessionController = nil;
    if (_wsLabel != nil) _wsLabel = nil;
    if (_printDataLabel != nil) _printDataLabel = nil;
    
}



- (void)_wifiDidDisConnect:(NSNotification *)notification{
    
    [self.navigationController popToRootViewControllerAnimated:YES];
}


-(IBAction)Btn_LabelSample1:(id)sender
{
    
    [_sessionController writeData:[self sample1Form]];
    
}
-(IBAction)Btn_LabelSample1WithCut:(id)sender
{
    _wsLabel = [[WSEncoder alloc] init];
    
    [_sessionController writeData:[self sample1Form]];
    [_sessionController writeData:[_wsLabel cutPaper:CUT_PARTIAL]];
    
}

-(IBAction)Btn_LabelSample2:(id)sender
{
    _printDataLabel = [[NSMutableData alloc]init];
    _wsLabel = [[WSEncoder alloc] init];
    
    [_printDataLabel appendData:[_wsLabel clearPrinterBuffer]];
    [_printDataLabel appendData:[_wsLabel addString:@"*Sample\n\n" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel enterPageMode]];
    

    
    //sample 1 box
    [_printDataLabel appendData:[_wsLabel setPrintingDirectionInPageMode:DIRECTION_TOPTOBOTTOM]];
    [_printDataLabel appendData:[_wsLabel createDrawingAreaWithStartPositionX:0xC0 withStartPositionY:0x00 withAreaWidth:0x180 withAreaHeight:[_wsLabel changeDotFromCentimeter:10]]];
    [_printDataLabel appendData:[_wsLabel drawBoxWithWidth:[_wsLabel changeDotFromCentimeter:3] withHeight:[_wsLabel changeDotFromCentimeter:2.3] withLineThickness:2]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x10 toY:0x10]];
    [_printDataLabel appendData:[_wsLabel drawBoxWithWidth:[_wsLabel changeDotFromCentimeter:1.2] withHeight:[_wsLabel changeDotFromCentimeter:0.4] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x15 toY:0x15]];
    [_printDataLabel appendData:[_wsLabel setTextBold:YES]];
    [_printDataLabel appendData:[_wsLabel addString:@"BOX 1" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel setTextBold:NO]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x40 toY:0x23]];
    [_printDataLabel appendData:[_wsLabel addString:@"QR 1" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x58 toY:0x15]];
    [_printDataLabel appendData:[_wsLabel createBarcodeQRCode:@"http://www.woosim.com" symbolVersion:0 ECLevel:'M' moduleSize:3]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x40 toY:0xa5]];
    [_printDataLabel appendData:[_wsLabel addString:@"QR 2" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x58 toY:0x95]];
    [_printDataLabel appendData:[_wsLabel createBarcodeQRCode:@"http://www.woosim.com" symbolVersion:0 ECLevel:'M' moduleSize:3]];
    
    
    
    //sample 2 box
    [_printDataLabel appendData:[_wsLabel setPrintingDirectionInPageMode:DIRECTION_BOTTOMTOTOP]];
    [_printDataLabel appendData:[_wsLabel createDrawingAreaWithStartPositionX:0x00 withStartPositionY:0x00 withAreaWidth:0xc0 withAreaHeight:[_wsLabel changeDotFromCentimeter:3]]];
    [_printDataLabel appendData:[_wsLabel drawBoxWithWidth:[_wsLabel changeDotFromCentimeter:3] withHeight:[_wsLabel changeDotFromCentimeter:2.3] withLineThickness:2]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x10 toY:0x10]];
    [_printDataLabel appendData:[_wsLabel drawBoxWithWidth:[_wsLabel changeDotFromCentimeter:1.2] withHeight:[_wsLabel changeDotFromCentimeter:0.4] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x15 toY:0x15]];
    [_printDataLabel appendData:[_wsLabel setTextBold:YES]];
    [_printDataLabel appendData:[_wsLabel addString:@"BOX 2" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel setTextBold:NO]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x40 toY:0x23]];
    [_printDataLabel appendData:[_wsLabel addString:@"QR 1" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x58 toY:0x15]];
    [_printDataLabel appendData:[_wsLabel createBarcodeQRCode:@"http://www.woosim.com" symbolVersion:0 ECLevel:'M' moduleSize:3]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x40 toY:0xa5]];
    [_printDataLabel appendData:[_wsLabel addString:@"QR 2" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x58 toY:0x95]];
    [_printDataLabel appendData:[_wsLabel createBarcodeQRCode:@"http://www.woosim.com" symbolVersion:0 ECLevel:'M' moduleSize:3]];
    
    
    //sample 3 box
    [_printDataLabel appendData:[_wsLabel setPrintingDirectionInPageMode:DIRECTION_LEFTTORIGHT]];
    [_printDataLabel appendData:[_wsLabel createDrawingAreaWithStartPositionX:0x00 withStartPositionY:[_wsLabel changeDotFromCentimeter:3.2] withAreaWidth:0x180 withAreaHeight:[_wsLabel changeDotFromCentimeter:3]]];
    [_printDataLabel appendData:[_wsLabel drawBoxWithWidth:0x180 withHeight:[_wsLabel changeDotFromCentimeter:3] withLineThickness:2]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x10 toY:0x10]];
    [_printDataLabel appendData:[_wsLabel drawBoxWithWidth:[_wsLabel changeDotFromCentimeter:1.2] withHeight:[_wsLabel changeDotFromCentimeter:0.4] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x15 toY:0x15]];
    [_printDataLabel appendData:[_wsLabel setTextBold:YES]];
    [_printDataLabel appendData:[_wsLabel addString:@"BOX 3" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel setTextBold:NO]];
    [_printDataLabel appendData:[_wsLabel setFontSize:FONTSIZE_B]];
    [_printDataLabel appendData:[_wsLabel reverseTextColor:YES]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x1a toY:0x3d]];
    [_printDataLabel appendData:[_wsLabel addString:@"WOOSIM SYSTEMS" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel reverseTextColor:NO]];
    [_printDataLabel appendData:[_wsLabel setFontSize:FONTSIZE_C]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x1a toY:0x65]];
    [_printDataLabel appendData:[_wsLabel addString:@"911 ho, 115," encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x1a toY:0x85]];
    [_printDataLabel appendData:[_wsLabel addString:@"Gasan digital 2-ro," encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x1a toY:0xa5]];
    [_printDataLabel appendData:[_wsLabel addString:@"Geumchen-gu, Seoul," encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x1a toY:0xc5]];
    [_printDataLabel appendData:[_wsLabel addString:@"Rep. of Korea" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel setFontSize:FONTSIZE_A]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0xd5 toY:0x48]];
    [_printDataLabel appendData:[_wsLabel createBarcodeQRCode:@"http://www.woosim.com" symbolVersion:0 ECLevel:'M' moduleSize:6]];
    
    //sample 4 box
    [_printDataLabel appendData:[_wsLabel setPrintingDirectionInPageMode:DIRECTION_RIGHTTOLEFT]];
    [_printDataLabel appendData:[_wsLabel createDrawingAreaWithStartPositionX:0x00 withStartPositionY:[_wsLabel changeDotFromCentimeter:6.4] withAreaWidth:0x180 withAreaHeight:[_wsLabel changeDotFromCentimeter:3]]];
    [_printDataLabel appendData:[_wsLabel drawBoxWithWidth:0x180 withHeight:[_wsLabel changeDotFromCentimeter:3] withLineThickness:2]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x10 toY:0x10]];
    [_printDataLabel appendData:[_wsLabel drawBoxWithWidth:[_wsLabel changeDotFromCentimeter:1.2] withHeight:[_wsLabel changeDotFromCentimeter:0.4] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x15 toY:0x15]];
    [_printDataLabel appendData:[_wsLabel setTextBold:YES]];
    [_printDataLabel appendData:[_wsLabel addString:@"BOX 3" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel setTextBold:NO]];
    [_printDataLabel appendData:[_wsLabel setFontSize:FONTSIZE_B]];
    [_printDataLabel appendData:[_wsLabel reverseTextColor:YES]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x1a toY:0x3d]];
    [_printDataLabel appendData:[_wsLabel addString:@"WOOSIM SYSTEMS" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel reverseTextColor:NO]];
    [_printDataLabel appendData:[_wsLabel setFontSize:FONTSIZE_C]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x1a toY:0x65]];
    [_printDataLabel appendData:[_wsLabel addString:@"911 ho, 115," encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x1a toY:0x85]];
    [_printDataLabel appendData:[_wsLabel addString:@"Gasan digital 2-ro," encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x1a toY:0xa5]];
    [_printDataLabel appendData:[_wsLabel addString:@"Geumchen-gu, Seoul," encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x1a toY:0xc5]];
    [_printDataLabel appendData:[_wsLabel addString:@"Rep. of Korea" encoding:NSASCIIStringEncoding]];
    [_printDataLabel appendData:[_wsLabel setFontSize:FONTSIZE_A]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0xd5 toY:0x48]];
    [_printDataLabel appendData:[_wsLabel createBarcodeQRCode:@"http://www.woosim.com" symbolVersion:0 ECLevel:'M' moduleSize:6]];
    
    
    //print page mode data
    [_printDataLabel appendData:[_wsLabel printDataInPageMode]];
    
    //exit page mode
    [_printDataLabel appendData:[_wsLabel exitPageMode]];
    
    //print out 5 lines
    [_printDataLabel appendData:[_wsLabel printAndFeedNLineInStandardMode:5]];
    
    [_sessionController writeData:_printDataLabel];
    
    
}
-(IBAction)Btn_LabelSample3:(id)sender
{
    
    _printDataLabel = [[NSMutableData alloc]init];
    _wsLabel = [[WSEncoder alloc] init];
    
    [_printDataLabel appendData:[_wsLabel clearPrinterBuffer]];
    [_printDataLabel appendData:[_wsLabel printDataInStandardMode]];
    [_printDataLabel appendData:[_wsLabel enterPageMode]];
    [_printDataLabel appendData:[_wsLabel createDrawingAreaWithStartPositionX:0x00 withStartPositionY:0x00 withAreaWidth:[_wsLabel changeDotFromCentimeter:5] withAreaHeight:[_wsLabel changeDotFromCentimeter:13]]];
    
    UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"woosim" ofType:@"bmp"]];
    [_printDataLabel appendData:[_wsLabel createImageInPageMode:[image CGImage] withStartPositionX:0x00 withStartPositionY:0x00 withDithering:NO]];
    
    [_printDataLabel appendData:[_wsLabel selectTrueTypeFontFile:@"WSTTFL.ttf"]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:145 toY:0]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"#815, 115, Gasan digital 2-ro," withStringWidth:20 withStringHeight:20]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:200 toY:25]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Geumchen-gu, Seoul" withStringWidth:20 withStringHeight:20]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:258 toY:50]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Rep. of Korea" withStringWidth:20 withStringHeight:20]];
    
    
    [_printDataLabel appendData:[_wsLabel setPrintingDirectionInPageMode:DIRECTION_TOPTOBOTTOM]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:0 toY:[_wsLabel changeDotFromCentimeter:1.5]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Date:  " withStringWidth:30 withStringHeight:30]];
    //1D Barcode
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
    [dateFormat setDateFormat:@"yyyy-MM-dd"];
    NSDate *now = [NSDate date];
    NSString *dateStr = [dateFormat stringFromDate:now];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:dateStr withStringWidth:30 withStringHeight:30]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:0 toY:[_wsLabel changeDotFromCentimeter:8.0]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Account No. 20150430001" withStringWidth:30 withStringHeight:30]];
    
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:0.5] toY:[_wsLabel changeDotFromCentimeter:1.5]]];
    [_printDataLabel appendData:[_wsLabel drawBoxWithWidth:[_wsLabel changeDotFromCentimeter:11] withHeight:[_wsLabel changeDotFromCentimeter:4.3] withLineThickness:3]];
    
    
    //From
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:0.65] toY:[_wsLabel changeDotFromCentimeter:1.7]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"From" withStringWidth:30 withStringHeight:30]];
    
    //horizontal line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:1.1] toY:[_wsLabel changeDotFromCentimeter:1.5]]];
    [_printDataLabel appendData:[_wsLabel drawHorizontalLineWithLength:[_wsLabel changeDotFromCentimeter:11] withLineThickness:1]];
    
    //Adress
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:1.15] toY:[_wsLabel changeDotFromCentimeter:1.7]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Address" withStringWidth:25 withStringHeight:25]];
    
    //vertical line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:1.1] toY:[_wsLabel changeDotFromCentimeter:3.0]]];
    [_printDataLabel appendData:[_wsLabel drawVerticalLineWithLength:[_wsLabel changeDotFromCentimeter:1.5] withLineThickness:1]];
    
    //주소
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:1.15] toY:[_wsLabel changeDotFromCentimeter:3.3]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"#815, 115, Gasan digital 2-ro, Geumcheon-gu, Seoul Rep, of Korea" withStringWidth:25 withStringHeight:25]];
    
    //horizontal line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:1.6] toY:[_wsLabel changeDotFromCentimeter:1.5]]];
    [_printDataLabel appendData:[_wsLabel drawHorizontalLineWithLength:[_wsLabel changeDotFromCentimeter:11] withLineThickness:1]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:1.65] toY:[_wsLabel changeDotFromCentimeter:1.7]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Name" withStringWidth:25 withStringHeight:25]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:1.65] toY:[_wsLabel changeDotFromCentimeter:3.3]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Woosim Systems" withStringWidth:25 withStringHeight:25]];
    
    //horizontal line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:2.1] toY:[_wsLabel changeDotFromCentimeter:1.5]]];
    [_printDataLabel appendData:[_wsLabel drawHorizontalLineWithLength:[_wsLabel changeDotFromCentimeter:11] withLineThickness:1]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:2.15] toY:[_wsLabel changeDotFromCentimeter:1.7]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Phone" withStringWidth:25 withStringHeight:25]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:2.15] toY:[_wsLabel changeDotFromCentimeter:3.3]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"+82 2 2107 3714" withStringWidth:25 withStringHeight:25]];
    
    //vertical line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:2.1] toY:[_wsLabel changeDotFromCentimeter:6.0]]];
    [_printDataLabel appendData:[_wsLabel drawVerticalLineWithLength:[_wsLabel changeDotFromCentimeter:0.5] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:2.15] toY:[_wsLabel changeDotFromCentimeter:6.3]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"e-Mail" withStringWidth:25 withStringHeight:25]];
    
    
    
    //vertical line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:2.1] toY:[_wsLabel changeDotFromCentimeter:7.5]]];
    [_printDataLabel appendData:[_wsLabel drawVerticalLineWithLength:[_wsLabel changeDotFromCentimeter:0.5] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:2.15] toY:[_wsLabel changeDotFromCentimeter:7.55]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"woosimsystems@_wsLabel.com" withStringWidth:25 withStringHeight:25]];
    
    
    
    //horizontal line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:2.6] toY:[_wsLabel changeDotFromCentimeter:1.5]]];
    [_printDataLabel appendData:[_wsLabel drawHorizontalLineWithLength:[_wsLabel changeDotFromCentimeter:11] withLineThickness:3]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:2.65] toY:[_wsLabel changeDotFromCentimeter:1.7]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"To" withStringWidth:30 withStringHeight:30]];
    
    //vertial line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:3.2] toY:[_wsLabel changeDotFromCentimeter:3.0]]];
    [_printDataLabel appendData:[_wsLabel drawVerticalLineWithLength:[_wsLabel changeDotFromCentimeter:1.6] withLineThickness:1]];
    
    //horizontal line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:3.2] toY:[_wsLabel changeDotFromCentimeter:1.5]]];
    [_printDataLabel appendData:[_wsLabel drawHorizontalLineWithLength:[_wsLabel changeDotFromCentimeter:11] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:3.25] toY:[_wsLabel changeDotFromCentimeter:1.7]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Address" withStringWidth:25 withStringHeight:25]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:3.25] toY:[_wsLabel changeDotFromCentimeter:3.3]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"172, Yeomgok-ro, Seo-gu, Incheon, Korea" withStringWidth:25 withStringHeight:25]];
    
    
    //horizontal line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:3.7] toY:[_wsLabel changeDotFromCentimeter:1.5]]];
    [_printDataLabel appendData:[_wsLabel drawHorizontalLineWithLength:[_wsLabel changeDotFromCentimeter:11] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:3.75] toY:[_wsLabel changeDotFromCentimeter:1.7]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Name" withStringWidth:25 withStringHeight:25]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:3.75] toY:[_wsLabel changeDotFromCentimeter:3.3]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Hong Gil-dong" withStringWidth:25 withStringHeight:25]];
    
    
    //horizontal line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:4.2] toY:[_wsLabel changeDotFromCentimeter:1.5]]];
    [_printDataLabel appendData:[_wsLabel drawHorizontalLineWithLength:[_wsLabel changeDotFromCentimeter:11] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:4.25] toY:[_wsLabel changeDotFromCentimeter:1.7]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"Phone" withStringWidth:25 withStringHeight:25]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:4.25] toY:[_wsLabel changeDotFromCentimeter:3.3]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"+82 2 2107 3700" withStringWidth:25 withStringHeight:25]];
    
    
    //vertical line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:4.2] toY:[_wsLabel changeDotFromCentimeter:6.0]]];
    [_printDataLabel appendData:[_wsLabel drawVerticalLineWithLength:[_wsLabel changeDotFromCentimeter:0.6] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:4.25] toY:[_wsLabel changeDotFromCentimeter:6.3]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"e-Mail" withStringWidth:25 withStringHeight:25]];
    
    //vertical line
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:4.2] toY:[_wsLabel changeDotFromCentimeter:7.5]]];
    [_printDataLabel appendData:[_wsLabel drawVerticalLineWithLength:[_wsLabel changeDotFromCentimeter:0.6] withLineThickness:1]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:[_wsLabel changeDotFromCentimeter:4.25] toY:[_wsLabel changeDotFromCentimeter:7.55]]];
    [_printDataLabel appendData:[_wsLabel addStringWithTrueTypeFont:@"woosimsystems1@woosim.com" withStringWidth:25 withStringHeight:25]];
    
    [_printDataLabel appendData:[_wsLabel printDataInPageMode]];
    [_printDataLabel appendData:[_wsLabel exitPageMode]];
    
    
    [_printDataLabel appendData:[_wsLabel shiftAbsolutePosition:25]];
    [_printDataLabel appendData:[_wsLabel createBarcode:dateStr barcodeType:BARCODE_CODE128]];
    [_printDataLabel appendData:[_wsLabel printAndFeedNLineInStandardMode:5]];
    
    [_sessionController writeData:_printDataLabel];
    
    
    
}
-(IBAction)Btn_PartialCut:(id)sender
{
    
    _printDataLabel = [[NSMutableData alloc]init];
    _wsLabel = [[WSEncoder alloc] init];
    
    [_printDataLabel appendData:[_wsLabel clearPrinterBuffer]];
    [_printDataLabel appendData:[_wsLabel cutPaper:CUT_PARTIAL]];
    
    [_sessionController writeData:_printDataLabel];
    
}
-(IBAction)Btn_FullCut:(id)sender
{
    
    _printDataLabel = [[NSMutableData alloc]init];
    WSEncoder *_wsLabel = [[WSEncoder alloc] init];
    
    [_printDataLabel appendData:[_wsLabel clearPrinterBuffer]];
    [_printDataLabel appendData:[_wsLabel cutPaper:CUT_FULL]];
    
    [_sessionController writeData:_printDataLabel];
    
}

-(NSData *)sample1Form
{
    _printDataLabel = [[NSMutableData alloc]init];
    _wsLabel = [[WSEncoder alloc] init];
    [_printDataLabel appendData:[_wsLabel clearPrinterBuffer]];
    
    NSString *line1 = @"SHIPT TO:\n";
    NSString *line2 = @"#501, Daerung Technotown 3rd\n";
    NSString *line3 = @"448, Gasan-dong Gumcheon-gu\n";
    NSString *line4 = @"Seoul, Rep. of Korea\n";
    NSString *line5 = @"ITEM    : Printer\n";
    NSString *line6 = @"Quantity : 10\n";
    NSString *line7 = @"TRACKING NUMBER:\n";
    NSString *line8 = @"134 35490 7564\n";
    
    uint16_t position = 0x40;
    
    [_printDataLabel appendData:[_wsLabel clearPrinterBuffer]];
    
    UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"woosim" ofType:@"bmp"]];
    [_printDataLabel appendData:[_wsLabel createImageInStandardMode:[image CGImage] withShiftPosition:0x00 withDithering:NO]];
    [_printDataLabel appendData:[_wsLabel printImageInStandardMode]];
    
    [_printDataLabel appendData:[_wsLabel selectTextCodeTable:LANGUAGE_CP437]];
    [_printDataLabel appendData:[_wsLabel setFontSize:FONTSIZE_B]];
    
    [_printDataLabel appendData:[_wsLabel addString:line1 encoding:0x80000400]];
    [_printDataLabel appendData:[_wsLabel shiftAbsolutePosition:position]];
    [_printDataLabel appendData:[_wsLabel addString:line2 encoding:0x80000400]];
    [_printDataLabel appendData:[_wsLabel shiftAbsolutePosition:position]];
    [_printDataLabel appendData:[_wsLabel addString:line3 encoding:0x80000400]];
    [_printDataLabel appendData:[_wsLabel shiftAbsolutePosition:position]];
    [_printDataLabel appendData:[_wsLabel addString:line4 encoding:0x80000400]];
    
    
    [_printDataLabel appendData:[_wsLabel enterPageMode]];
    [_printDataLabel appendData:[_wsLabel createDrawingAreaWithStartPositionX:0 withStartPositionY:0 withAreaWidth:0x180 withAreaHeight:0x16c]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x02 toY:0x01]];
    [_printDataLabel appendData:[_wsLabel drawHorizontalLineWithLength:0x172 withLineThickness:0x04]];
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x00 toY:0x07]];
    [_printDataLabel appendData:[_wsLabel createBarcodeQRCode:@"http://woosim.com" symbolVersion:0x00 ECLevel:'M' moduleSize:0x03]];
    
    [_printDataLabel appendData:[_wsLabel setFontSize:FONTSIZE_A]];
    [_printDataLabel appendData:[_wsLabel setTextBold:YES]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x70 toY:0x1a]];
    [_printDataLabel appendData:[_wsLabel addString:line5 encoding:0x80000400]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x70 toY:0x35]];
    [_printDataLabel appendData:[_wsLabel addString:line6 encoding:0x80000400]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x02 toY:0x5a]];
    [_printDataLabel appendData:[_wsLabel drawHorizontalLineWithLength:0x172 withLineThickness:0x04]];
    
    [_printDataLabel appendData:[_wsLabel setTextBold:NO]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x00 toY:0x64]];
    [_printDataLabel appendData:[_wsLabel addString:line7 encoding:NSASCIIStringEncoding]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x82 toY:0x82]];
    [_printDataLabel appendData:[_wsLabel addString:line8 encoding:NSASCIIStringEncoding]];
    
    [_printDataLabel appendData:[_wsLabel movePositionToX:0x14 toY:0xa0]];
    [_printDataLabel appendData:[_wsLabel setBarcodeWidth:0x02]];
    [_printDataLabel appendData:[_wsLabel setBarcodeHeight:0x64]];
    [_printDataLabel appendData:[_wsLabel enableHRI:NO]];
    
    [_printDataLabel appendData:[_wsLabel createBarcode:@"34 35490 7564" barcodeType:BARCODE_CODE128]];
    [_printDataLabel appendData:[_wsLabel printDataInPageMode]];
    [_printDataLabel appendData:[_wsLabel feedToBlackMarkPosition]];
    [_printDataLabel appendData:[_wsLabel exitPageMode]];
    
    return _printDataLabel;
}



@end