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

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



WSEncoder *_wsText;
NSMutableData *_printDataText;

@implementation TextViewController

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

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


-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    
    [[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_accessoryDidDisconnect:) name:EAAccessoryDidDisconnectNotification object:nil];
    //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_accessoryDidConnect:) name:EAAccessoryDidConnectNotification object:nil];
    //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_sessionDataReceived:) name:WSDataReceivedNotification object:nil];
    
    _sessionController = [[WSSessionController sharedController]init];
    _wsText = [[WSEncoder alloc]init];
    
}


-(void)viewWillDisappear:(BOOL)animated{
    
    [super viewWillDisappear:animated];
    
    [[EAAccessoryManager sharedAccessoryManager] unregisterForLocalNotifications];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:EAAccessoryDidDisconnectNotification object:nil];
    //[[NSNotificationCenter defaultCenter] removeObserver:self name:EAAccessoryDidConnectNotification object:nil];
    //[[NSNotificationCenter defaultCenter] removeObserver:self name:WSDataReceivedNotification object:nil];
    
    if(_sessionController != nil) _sessionController = nil;
    if(_wsText != nil) _wsText = nil;
    if (_printDataText != nil) _printDataText = nil;
    
}

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


/*
//no use in this viewcontroller

- (void)_accessoryDidConnect:(NSNotification *)notification{
 
}
- (void)_sessionDataReceived:(NSNotification *)notification
{
    
    NSInteger bytesAvailable = 0;
    NSMutableData *rcvData = [[NSMutableData alloc] init];
    
    while ((bytesAvailable = [_sessionController getAvailableReadBytes]) > 0) {
        NSData *data = [_sessionController readData:bytesAvailable];
        if (data) {
            [rcvData appendData:data];
        }
    }
    
}*/


//text style = reverse, bold, underline,
//spacing = line, letter, reset
-(IBAction)Btn_MultiLanguage:(id)sender
{

   
    _printDataText = [[NSMutableData alloc]init];
    _wsText = [[WSEncoder alloc]init];
    [_printDataText appendData:[_wsText clearPrinterBuffer]];
    [_printDataText appendData:[_wsText addString:@"*Multilanguage" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP437]];
    [_printDataText appendData:[_wsText addString:@"*CP437\nÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñÑªº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■" encoding:0x80000400]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP850]];
    [_printDataText appendData:[_wsText addString:@"*CP850\nÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø×ƒáíóúñÑªº¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ðÐÊËÈıÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµþÞÚÛÙýÝ¯´±‗¾¶§÷¸°¨·¹³²■" encoding:0x80000410]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP860]];
    [_printDataText appendData:[_wsText addString:@"*CP860\nÇüéâãàÁçêÊèÍÔìÃÂÉÀÈôõòÚùÌÕÜ¢£Ù₧ÓáíóúñÑªº¿Ò¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■" encoding:0x80000415]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP852]];
    [_printDataText appendData:[_wsText addString:@"*CP852\nÇüéâäůćçłëŐőîŹÄĆÉĹĺôöĽľŚśÖÜŤťŁ×čáíóúĄąŽžĘę¬źČş«»░▒▓│┤ÁÂĚŞ╣║╗╝Żż┐└┴┬├─┼Ăă╚╔╩╦╠═╬¤đĐĎËďŇÍÎě┘┌█▄ŢŮ▀ÓßÔŃńňŠšŔÚŕŰýÝţ´˝˛ˇ˘§÷¸°¨˙űŘř■" encoding:0x80000412]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP857]];
    [_printDataText appendData:[_wsText addString:@"*CP857\nÇüéâäàåçêëèïîıÄÅÉæÆôöòûùİÖÜø£ØŞşáíóúñÑĞğ¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ºªÊËÈ€ÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµ×ÚÛÙìÿ¯´±¾¶§÷¸°¨·¹³²■" encoding:0x80000414]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP737]];
    [_printDataText appendData:[_wsText addString:@"*CP737\nΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρσςτυφχψ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ωάέήϊίόύϋώΆΈΉΊΌΎΏ±≥≤ΪΫ÷≈°∙·√ⁿ²■" encoding:0x80000405]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP866]];
    [_printDataText appendData:[_wsText addString:@"*CP866\nАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№¤■" encoding:0x8000041b]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP775]];
    [_printDataText appendData:[_wsText addString:@"*CP775\nĆüéāäģåćłēŖŗīŹÄÅÉæÆōöĢ¢ŚśÖÜø£Ø×¤ĀĪóŻżź”¦©®¬½¼Ł«»░▒▓│┤ĄČĘĖ╣║╗╝ĮŠ┐└┴┬├─┼ŲŪ╚╔╩╦╠═╬Žąęėįšųūž┘┌█▄▌▐▀ÓßŌŃõÕµńĶķĻļņĒŅ’±“¾¶§÷„°∙·¹³²■" encoding:0x80000406]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_ISO8859_15]];
    [_printDataText appendData:[_wsText addString:@"*ISO8859-15\n¡¢£€¥Š§š©ª«¬®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" encoding:0x8000020f]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_WIN1252]];
    [_printDataText appendData:[_wsText addString:@"*Windows1252\n€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" encoding:NSWindowsCP1252StringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP858]];
    [_printDataText appendData:[_wsText addString:@"*CP858\nÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø×ƒáíóúñÑªº¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ðÐÊËÈ€ÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµþÞÚÛÙýÝ¯´±‗¾¶§÷¸°¨·¹³²■" encoding:0x80000410]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_WIN1251]];
    [_printDataText appendData:[_wsText addString:@"*Windows1251\nЂЃ‚ѓ„…†‡€‰Љ‹ЊЌЋЏђ‘’“”•–—™љ›њќћџЎўЈ¤Ґ¦§Ё©Є«¬®Ї°±Ііґµ¶·ё№є»јЅѕїАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя" encoding:NSWindowsCP1251StringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_WIN1250]];
    [_printDataText appendData:[_wsText addString:@"*Windows1250\n€‚„…†‡‰Š‹ŚŤŽŹ‘’“”•–—™š›śťžźˇ˘Ł¤Ą¦§¨©Ş«¬®Ż°±˛ł´µ¶·¸ąş»Ľ˝ľżŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖ×ŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőö÷řůúűüýţ˙" encoding:NSWindowsCP1250StringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_WIN1253]];
    [_printDataText appendData:[_wsText addString:@"*Windows1253\n€‚ƒ„…†‡‰‹‘’“”•–—™›΅Ά£¤¥¦§¨©«¬®―°±²³΄µ¶·ΈΉΊ»Ό½ΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ" encoding:NSWindowsCP1253StringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_WIN1254]];
    [_printDataText appendData:[_wsText addString:@"*Windows1254\n€‚ƒ„…†‡ˆ‰Š‹Œ‘’“”•–—˜™š›œŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏĞÑÒÓÔÕÖ×ØÙÚÛÜİŞßàáâãäåæçèéêëìíîïğñòóôõö÷øùúûüışÿ" encoding:NSWindowsCP1254StringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_WIN1255]];
    [_printDataText appendData:[_wsText addString:@"*Windows1255\n€‚ƒ„…†‡ˆ‰‹‘’“”•–—˜™›¡¢£₪¥¦§¨©×«¬®¯°±²³´µ¶·¸¹÷»¼½¾¿ְֱֲֳִֵֶַָֺֻּֽ־ֿ׀ׁׂ׃װױײ׳״אבגדהוזחטיךכלםמןנסעףפץצקרשת" encoding:0x80000505]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_WIN1258]];
    [_printDataText appendData:[_wsText addString:@"*Windows1258\n€‚ƒ„…†‡ˆ‰‹Œ‘’“”•–—˜™›œŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂĂÄÅÆÇÈÉÊË̀ÍÎÏĐÑ̉ÓÔƠÖ×ØÙÚÛÜỮßàáâăäåæçèéêë́íîïđṇ̃óôơö÷øùúûüư₫ÿ" encoding:0x80000508]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_WIN1257]];
    [_printDataText appendData:[_wsText addString:@"*Windows1257\n€‚„…†‡‰‹¨ˇ¸‘’“”•–—™›¯˛¢£¤¦§Ø©Ŗ«¬®Æ°±²³´µ¶·ø¹ŗ»¼½¾æĄĮĀĆÄÅĘĒČÉŹĖĢĶĪĻŠŃŅÓŌÕÖ×ŲŁŚŪÜŻŽßąįāćäåęēčéźėģķīļšńņóōõö÷ųłśūüżž˙" encoding:0x80000507]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP874]];
    [_printDataText appendData:[_wsText addString:@"*CP874\n€…‘’“”•–—กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาำเแโใไๅๆ๏๐๑๒๓๔๕๖๗๘๙๚๛" encoding:0x8000041d]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:5]];
    
    
    
    [_sessionController writeData:_printDataText];
    
    
}

-(IBAction)Btn_TextStyle:(id)sender
{
    _printDataText = [[NSMutableData alloc]init];
    _wsText = [[WSEncoder alloc]init];
    [_printDataText appendData:[_wsText clearPrinterBuffer]];
    NSString *underLine = @"Text Under Line";
    NSString *emphasized = @"Text Emphasized";
    NSString *invertColor = @"Text Invert Color";
    
    [_printDataText appendData:[_wsText addString:@"*Text style" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextUnderline:true withLineThickness:2]];
    [_printDataText appendData:[_wsText addString:underLine encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText setTextUnderline:false withLineThickness:0]];
    [_printDataText appendData:[_wsText setTextBold:YES]];
    [_printDataText appendData:[_wsText addString:emphasized encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText setTextBold:NO]];
    [_printDataText appendData:[_wsText reverseTextColor:YES]];
    [_printDataText appendData:[_wsText addString:invertColor encoding:NSASCIIStringEncoding ]];
    [_printDataText appendData:[_wsText reverseTextColor:NO]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:5]];
    
    [_sessionController writeData:_printDataText];
    
}
-(IBAction)Btn_FontSize:(id)sender
{
    _printDataText = [[NSMutableData alloc]init];
    _wsText = [[WSEncoder alloc]init];
    [_printDataText appendData:[_wsText clearPrinterBuffer]];
    
    
    [_printDataText appendData:[_wsText selectTextCodeTable:LANGUAGE_CP437]];
    [_printDataText appendData:[_wsText setFontSize:FONTSIZE_A]];
    [_printDataText appendData:[_wsText addString:@"* Font size" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:@"Font Size: 12 X 24" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZ" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText setFontSize:FONTSIZE_B]];
    [_printDataText appendData:[_wsText addString:@"Font Size:  9 X 24" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZ" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    [_printDataText appendData:[_wsText setFontSize:FONTSIZE_C]];
    [_printDataText appendData:[_wsText addString:@"Font Size:  8 X 16" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZ" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:5]];
    
    [_sessionController writeData:_printDataText];
}
-(IBAction)Btn_TextSize:(id)sender
{
    _printDataText = [[NSMutableData alloc]init];
    _wsText = [[WSEncoder alloc]init];
    
    [_printDataText appendData:[_wsText clearPrinterBuffer]];
    
    
    NSString *expansion12 = @"Expansion W: 1 H: 2";
    NSString *expansion21 = @"Expansion W: 2 H: 1";
    NSString *expansion22 = @"Expansion W: 2 H: 2";
    NSString *str1 = @"AAA";
    NSString *str2 = @"BBB";
    NSString *str3 = @"CCC";
    
    
    [_printDataText appendData:[_wsText setFontSize:FONTSIZE_A]];
    [_printDataText appendData:[_wsText addString:@"* Font Size: 12 X 24" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:expansion12 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_1 withHeight:TEXTHEIGHT_2]];
    [_printDataText appendData:[_wsText addString:str1 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_1 withHeight:TEXTHEIGHT_1]];
    [_printDataText appendData:[_wsText addString:expansion21 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_2 withHeight:TEXTHEIGHT_1]];
    [_printDataText appendData:[_wsText addString:str2 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_1 withHeight:TEXTHEIGHT_1]];
    [_printDataText appendData:[_wsText addString:expansion22 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_2 withHeight:TEXTHEIGHT_2]];
    [_printDataText appendData:[_wsText addString:str3 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    
    [_printDataText appendData:[_wsText setFontSize:FONTSIZE_B]];
    [_printDataText appendData:[_wsText addString:@"* Font Size: 9 X 24" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:expansion12 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_1 withHeight:TEXTHEIGHT_2]];
    [_printDataText appendData:[_wsText addString:str1 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_1 withHeight:TEXTHEIGHT_1]];
    [_printDataText appendData:[_wsText addString:expansion21 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_2 withHeight:TEXTHEIGHT_1]];
    [_printDataText appendData:[_wsText addString:str2 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_1 withHeight:TEXTHEIGHT_1]];
    [_printDataText appendData:[_wsText addString:expansion22 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_2 withHeight:TEXTHEIGHT_2]];
    [_printDataText appendData:[_wsText addString:str3 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:1]];
    
    [_printDataText appendData:[_wsText setFontSize:FONTSIZE_C]];
    [_printDataText appendData:[_wsText addString:@"* Font Size: 8 X 16" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:expansion12 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_1 withHeight:TEXTHEIGHT_2]];
    [_printDataText appendData:[_wsText addString:str1 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_1 withHeight:TEXTHEIGHT_1]];
    [_printDataText appendData:[_wsText addString:expansion21 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_2 withHeight:TEXTHEIGHT_1]];
    [_printDataText appendData:[_wsText addString:str2 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_1 withHeight:TEXTHEIGHT_1]];
    [_printDataText appendData:[_wsText addString:expansion22 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setTextSizeWithWidth:TEXTWIDTH_2 withHeight:TEXTHEIGHT_2]];
    [_printDataText appendData:[_wsText addString:str3 encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:5]];
    
    
    [_sessionController writeData:_printDataText];
    
    
}
-(IBAction)Btn_Spacing:(id)sender
{
    
    _printDataText = [[NSMutableData alloc]init];
    _wsText = [[WSEncoder alloc]init];
    
    [_printDataText appendData:[_wsText clearPrinterBuffer]];
    [_printDataText appendData:[_wsText addString:@"* Text spacing" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:@"Letter spacing" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setLetterSpacing:0]];
    [_printDataText appendData:[_wsText addString:@"0: ABCDEFGHIJKLM" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setLetterSpacing:3]];
    [_printDataText appendData:[_wsText addString:@"3: ABCDEFGHIJKLM" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setLetterSpacing:5]];
    [_printDataText appendData:[_wsText addString:@"5: ABCDEFGHIJKLM" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setLetterSpacing:10]];
    [_printDataText appendData:[_wsText addString:@"10: ABCDEFGHIJKLM" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText setLetterSpacing:0]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:3]];
    
    
    [_printDataText appendData:[_wsText addString:@"Line Spacing" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setLineSpacing:0]];
    [_printDataText appendData:[_wsText addString:@"Start: 0 dot" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:@"The End" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setLineSpacing:60]];
    [_printDataText appendData:[_wsText addString:@"Start: 60 dot" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:@"The End" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText resetLineSpacing]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setLineSpacing:100]];
    [_printDataText appendData:[_wsText addString:@"Start: 100 dot" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:@"The End" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText resetLineSpacing]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:5]];
    
    [_sessionController writeData:_printDataText];
    
}
-(IBAction)Btn_ShiftPosition:(id)sender
{
    _printDataText = [[NSMutableData alloc]init];
    _wsText = [[WSEncoder alloc]init];
    
    [_printDataText appendData:[_wsText clearPrinterBuffer]];
    
    [_printDataText appendData:[_wsText addString:@"* Shift Absolute Position" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:@"0" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText shiftAbsolutePosition:20]];
    [_printDataText appendData:[_wsText addString:@"20" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText shiftAbsolutePosition:50]];
    [_printDataText appendData:[_wsText addString:@"50" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText shiftAbsolutePosition:90]];
    [_printDataText appendData:[_wsText addString:@"90" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:2]];
    
    [_printDataText appendData:[_wsText addString:@"* Shift Relative Position" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText addString:@"0" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText shiftRelativePosition:20]];
    [_printDataText appendData:[_wsText addString:@"20" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText shiftRelativePosition:50]];
    [_printDataText appendData:[_wsText addString:@"50" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText shiftRelativePosition:90]];
    [_printDataText appendData:[_wsText addString:@"90" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:5]];
    
    
    [_sessionController writeData:_printDataText];
    
}

-(NSData*)printByteTTF:(Byte*)str{
    NSMutableData *data = [[NSMutableData alloc]init];
    Byte frontCmd[] = {0x1b, 0x67, 0x55, 200, 200};
    Byte tailCmd[] = {0x00, 0x00, 0x0a};
    
    [data appendBytes:frontCmd length:sizeof(frontCmd)];
    [data appendBytes:str length:sizeof(str)];
    [data appendBytes:tailCmd length:sizeof(tailCmd)];
    
    
    
    return data;
    
}

-(IBAction)Btn_TrueTypeFont:(id)sender
{


    _printDataText = [[NSMutableData alloc]init];
    _wsText = [[WSEncoder alloc]init];
    
    NSString *title = @"*True Type Font\n";
    
    [_printDataText appendData:[_wsText clearPrinterBuffer]];
    
    [_printDataText appendData:[_wsText addString:title encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    
    [_printDataText appendData:[_wsText selectTrueTypeFontFile:@"WSTTFL.ttf"]];
    [_printDataText appendData:[_wsText addStringWithTrueTypeFont:@"30X30 WSTTFL" withStringWidth:30 withStringHeight:30]];
    
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    
    [_printDataText appendData:[_wsText selectTrueTypeFontFile:@"WSTTFB.ttf"]];
    [_printDataText appendData:[_wsText addStringWithTrueTypeFont:@"30X30 WSTTFB" withStringWidth:30 withStringHeight:30]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    
    [_printDataText appendData:[_wsText selectTrueTypeFontFile:@"WSTTFL.ttf"]];
    [_printDataText appendData:[_wsText addStringWithTrueTypeFont:@"40X40 WSTTFL" withStringWidth:40 withStringHeight:40]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    
    [_printDataText appendData:[_wsText selectTrueTypeFontFile:@"WSTTFB.ttf"]];
    [_printDataText appendData:[_wsText addStringWithTrueTypeFont:@"40X40 WSTTFB" withStringWidth:40 withStringHeight:40]];
    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:5]];
    
 
    
    [_sessionController writeData:_printDataText];

    
}


-(IBAction)Btn_TextAlign:(id)sender
{
    _printDataText = [[NSMutableData alloc]init];
    _wsText = [[WSEncoder alloc]init];
    
    [_printDataText appendData:[_wsText clearPrinterBuffer]];
    
    [_printDataText appendData:[_wsText addString:@"* Align Text" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    
    [_printDataText appendData:[_wsText setAlignInStandardMode:ALIGN_RIGHT]];
    [_printDataText appendData:[_wsText addString:@"Right" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setAlignInStandardMode:ALIGN_CENTER]];
    [_printDataText appendData:[_wsText addString:@"Center" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];
    [_printDataText appendData:[_wsText setAlignInStandardMode:ALIGN_LEFT]];
    [_printDataText appendData:[_wsText addString:@"Left" encoding:NSASCIIStringEncoding]];
    [_printDataText appendData:[_wsText printDataInStandardMode]];

    [_printDataText appendData:[_wsText printAndFeedNLineInStandardMode:3]];
    
    
    [_sessionController writeData:_printDataText];
    
}

@end
