if(!nexacro.Sketch){nexacro.SketchLoadEventInfo=function(_a,_b,_c){this.id=this.eventid=_b||"onload";this.fromobject=this.fromreferenceobject=_a;this.url=_c;};var _pSketchLoadEventInfo=nexacro._createPrototype(nexacro.Event,nexacro.LoadEventInfo);nexacro.LoadEventInfo.prototype=_pSketchLoadEventInfo;_pSketchLoadEventInfo._type_name="SketchLoadEventInfo";delete _pSketchLoadEventInfo;_pSketchLoadEventInfo=null;nexacro.SketchErrorEventInfo=function(_a,_b,_c,_d,_e,_f,_g,_h){this.id=this.eventid=_b||"onerror";this.errormsg=_d;this.errorobj=_a;this.errortype=_e;this.locationuri=_f;this.requesturi=_g;this.statuscode=_h;};var _pSketchErrorEventInfo=nexacro._createPrototype(nexacro.Event,nexacro.ErrorEventInfo);nexacro.ErrorEventInfo.prototype=_pSketchErrorEventInfo;_pSketchErrorEventInfo._type_name="SketchErrorEventInfo";delete _pSketchErrorEventInfo;_pSketchErrorEventInfo=null;nexacro.SuccessEventInfo=function(_a,_b,_c){this.id=this.eventid=_b||"onsuccess";this.handle=_c;this.fromobject=this.fromreferenceobject=_a;};var _pSketchSuccessEventInfo=nexacro._createPrototype(nexacro.Event,nexacro.SuccessEventInfo);nexacro.SuccessEventInfo.prototype=_pSketchSuccessEventInfo;_pSketchSuccessEventInfo._type_name="SketchSuccessEventInfo";nexacro.SketchSuccessEventInfo=nexacro.SuccessEventInfo;delete _pSketchSuccessEventInfo;_pSketchSuccessEventInfo=null;nexacro.CharEventInfo=function(_a,_b,_c,_d,_e){this.id=this.eventid=_b||"onchar";this.fromobject=this.fromreferenceobject=_a;this.chartext=_c;this.posttext=_e;this.pretext=_d;};var _pSketchCharEventInfo=nexacro._createPrototype(nexacro.Event,nexacro.CharEventInfo);nexacro.CharEventInfo.prototype=_pSketchCharEventInfo;_pSketchCharEventInfo._type_name="SketchCharEventInfo";delete _pSketchCharEventInfo;_pSketchCharEventInfo=null;nexacro.Sketch=function(_a,_b,_c,_d,_e,_f,_g,_h,_i){nexacro.Component.call(this,_a,_b,_c,_d,_e,_f,_g,_h,_i);this.value=null;this.textedit=null;this.undoable=false;this.redoable=false;this.editmode="stroke";this.imemode="none";this.usecontextmenu=true;this.text="";this.updatebindingvalue="default";this.readonly=false;this._canvas_elem_bg=null;this._canvas_elem=null;this._canvas_elem_tmp=null;this._history=[];this._current_state= -1;this._freeze_state= -1;this._current_strokes=null;this._const_stroke="stroke";this._const_stroke_user="strokeu";this._const_text="text";this._const_erase="erase";this._const_none="none";this._const_erase_user="eras_handleeu";this._const_image="image";this._const_composit_source_over="source-over";this._const_composit_destination_out="destination-out";this._const_form="this.parent";this._const_dot=".";this._default_stroke_style=nexacro._getCachedStyleObj("color","black");this._default_line_cap="round";this._default_line_join="round";this._default_line_width=1;this._default_font_size=9;this._default_font_face="monaco";this._default_edit_gap=0.5;this._default_edit_x=0;this._default_edit_y=0;this._default_edit_width=100;this._default_edit_height=24;this._default_edit_border="1px solid blue";this._default_edit_align="left";this._startDrawStroke=true;this._startDrawErase=true;this._image_format=["bmp","gif","jpeg","jpg","png","tiff","icon"];this._save_image_formattype=["BMP","PNG","JPG","GIF","TIF","BMP,Mono"];this._image=null;this._clr_history=true;this._currentPath=[];this._pre_draw_status="";this._butt_count=0;this._const_code_parameter="0001";this._const_code_io="1101";this._const_code_permission="1102";this._const_code_Irregular="1103";this._const_code_target="1104";this._const_code_loadinvalidimage="1105";this._const_code_incorrectfile="1106";this._const_code_savefile="1107";this._const_errortype_obj="ObjectError";this._const_errortype_type="TypeError";this._const_code_parameter_msg="comp_fail_parameter";this._const_code_loadinvalidimage_msg="comm_fail_loadinvalidimage";this._const_code_incorrectfile_msg="comp_incorrect_file";this._const_code_savefile_msg="comp_fail_save_file";this._is_undo=false;this._apply_client_padding=true;this._is_touch=false;this._img_type="url";this._const_textcolor="#000000ff";this._event_list={"oninit":1,"onkillfocus":1,"onsetfocus":1,"ontouch":1,"ontouchstart":1,"ontouchmove":1,"ontouchend":1,"onlbuttondown":1,"onlbuttonup":1,"onmousemove":1,"onload":1,"onerror":1,"onsuccess":1,"onsize":1,"onmove":1,"onrbuttondown":1,"onrbuttonup":1,"onmousedown":1,"onmouseup":1,"onmouseenter":1,"onmouseleave":1,"onmousewheel":1,"onkeydown":1,"onkeyup":1,"onchar":1,"ondrag":1,"ondrop":1,"ondragenter":1,"ondragleave":1,"ondragmove":1};this._path_style={tool:this._const_stroke,globalCompositeOperation:this._const_composit_source_over,strokeStyle:this._default_stroke_style,lineWidth:this._default_line_width,eraseWidth:this._default_line_width,lineCap:this._default_line_cap,lineJoin:this._default_line_join,fontface:this._default_font_face,fontsize:this._default_font_size,fontfill:this._default_stroke_style,text:""};};var _pSketch=nexacro._createPrototype(nexacro.Component,nexacro.Sketch);nexacro.Sketch.prototype=_pSketch;_pSketch._type_name="Sketch";_pSketch.touchStatus=0;_pSketch.on_create_contents=function(){var _a=this.getElement();if(_a){application.addErrorMessage(system._language,this._const_code_parameter_msg,"Parameter Error.");application.addErrorMessage(system._language,this._const_code_savefile_msg,"Failed to save file.");this._canvas_elem_bg=new nexacro.CanvasElement(_a);this._canvas_elem=new nexacro.CanvasElement(_a);this._canvas_elem_tmp=new nexacro.CanvasElement(_a);this.textedit=new nexacro.SketchEditCtrl("sketchedit","absolute",this._default_edit_x,this._default_edit_y,this._default_edit_width,this._default_edit_height,null,null,this);this.textedit.createComponent();this.textedit._setEventHandler("onchar",this.on_notify_onchar,this);this.textedit._setEventHandler("onkillfocus",this.on_notify_edit_onkillfocus,this);var _b=this.currentstyle;if(this.text){var _c=new nexacro.TextBoxElement(_a);var _d=((_b.align==null||_b.align.halign=="")?"center":_b.align._halign);var _e=((_b.align==null||_b.align.valign=="")?"middle":_b.align._valign);_c.setElementSize(this._client_width,this._client_height);_b.font=this.textedit.on_find_CurrentStyle_font(this._pseudo);_b.color=this.textedit.on_find_CurrentStyle_color(this._pseudo);_c.setElementFont(_b.font);_c.setElementColor(_b.color);_c.setElementAlignXY(_d,_e);_c.setElementText(this.text);this._text_elem=_c;_c=null;_b=null;_d=null;_e=null;}_b=null;}_a=null;};_pSketch.on_created_contents=function(){var _a=this.getElement();if(_a){var _d=[this._canvas_elem_bg,this._canvas_elem,this._canvas_elem_tmp];for(var _e=0;_e<_d.length;_e++ ){var _f=_d[_e];if(_f){_f.create();_f.setElementLineCap(this._default_line_cap);_f.setElementLineJoin(this._default_line_join);_f.setElementSize(this._client_width,this._client_height);}}_d=null;this.on_apply_applystyletype();this.on_apply_text();var _g=this._text_elem;if(_g){_g.create();_g=null;}this.textedit.on_created();this.textedit.set_width(this._default_edit_width);this.textedit.set_height(this._default_edit_height);this.textedit.set_imemode(this.imemode);this.textedit.set_usecontextmenu(this.usecontextmenu);this.textedit.set_readonly(this.readonly);this.textedit.set_visible(false);this._canvas_elem.setElementTextBaseline("top");this._canvas_elem_tmp.setElementTextBaseline("top");this._canvas_elem_bg.setElementTextBaseline("top");}var _b=this._canvas_elem;var _c=_b._handle;if(_c){var _h=_c.ownerDocument||_c.document;var _i=nexacro.__getHTMLNodePositionInFrame(_h,_c);if(_i){this.m_screenX=_i.x;this.m_screenY=_i.y;}}};_pSketch.on_destroy_contents=function(){var _a=[this._canvas_elem_bg,this._canvas_elem,this._canvas_elem_tmp,this.textedit];for(var _b=0;_b<_a.length;_b++ ){if(_a[_b]){_a[_b].destroy();_a[_b]=null;}}_a=null;};_pSketch.on_change_containerRect=function(_a,_b){var _c=[this._canvas_elem,this._canvas_elem_bg,this._canvas_elem_tmp];for(var _d=0;_d<_c.length;_d++ ){var _e=_c[_d];if(_e){_e.setElementSize(_a,_b);}}if(this._currentPath.length>0){this._regenStroke(this._currentPath,this._canvas_elem_tmp);}_c=null;};_pSketch.on_change_containerPos=function(_a,_b){};_pSketch.on_change_bindSource=function(_a,_b,_c,_d,_e){this.binddataset=_b;if(_a=="value"){return true;}return false;};_pSketch.set_enableredraw=function(_a){this.enableredraw=nexacro._toBoolean(_a);if(this.enableredraw){this._redrawPath();this._refresh_style_contents();}return _a;};_pSketch.set_editmode=function(_a){var _b=this._const_stroke;switch(_a){case this._const_text:case this._const_erase:case this._const_none:_b=_a;break;case this._const_stroke:default:break;}this.editmode=_b;};_pSketch.set_imemode=function(_a){if(_a!=this.imemode){this.imemode=nexacro._toString(_a);this.on_apply_imemode();}};_pSketch.on_apply_imemode=function(){this.textedit.set_imemode(this.imemode);};_pSketch.set_usecontextmenu=function(_a){if(_a!=this.usecontextmenu){this.usecontextmenu=_a;this.on_apply_usecontextmenu();}};_pSketch.on_apply_usecontextmenu=function(){this.textedit.set_usecontextmenu(this.usecontextmenu);};_pSketch.set_readonly=function(_a){_a=nexacro._toBoolean(_a);if(_a!=this.readonly){this.readonly=_a;this.on_apply_readonly(_a);}};_pSketch.on_apply_readonly=function(_a){if(_a){this._stat_change("readonly",this._pseudo);}else{this._stat_change("writable",this._pseudo=="readonly"?"normal":this._pseudo);}this.textedit.set_readonly(this.readonly);};_pSketch.set_value=function(_a){};_pSketch._setValue=function(_a){if(_a!=this.value){this.value=_a;}};_pSketch.on_apply_value=function(_a){this.textedit.set_value(this.value);};_pSketch.set_updatebindingvalue=function(_a){if(_a!=this.updatebindingvalue){this.updatebindingvalue=_a;}this.on_apply_updatebindingvalue(_a);};_pSketch.set_text=function(_a){var _b=nexacro._toString(_a);if(_b!=this.text&&this._current_state== -1){this.text=_b;this._display_text=_b;this.on_apply_text();}};_pSketch.on_apply_updatebindingvalue=function(_a){switch(_a){case "nosetvalue":break;default:this.updateToDataset();break;}};_pSketch.on_apply_applystyletype=function(){var _a=this.getElement();if(_a){var _b=["align","background","border","bordertype","color","cursor","font","glow","gradation","margin","opacity","padding","shadow","accessibility"];var _c;if(!this._url||this._url.length==0){this._oldstyletype=this._styletype;this._styletype=1;_c=this._find_style(_b);this._styletype=this._oldstyletype;this.cssclass=this._cssclass;}else{switch(this.applystyletype){case "keep":this._styletype=1;this.cssclass=this._cssclass;break;case "apply":this._styletype=4;this.cssclass=this._linkedcssclass;break;case "cascade":this._styletype=5;this.cssclass=this._linkedcssclass;break;case "cascade,keep":this._styletype=3;this.cssclass=this._linkedcssclass;break;default:this._styletype=3;this.cssclass=this._linkedcssclass;v="cascade,keep";break;}_c=this._find_style(_b);}this._apply_style(_c);_b=null;_c=null;}_a=null;};_pSketch.on_apply_text=function(){var _a=this._control_element;if(_a){var _b=this.currentstyle;var _c=this._text_elem;if(!_c){_c=new nexacro.TextBoxElement(_a);this._text_elem=_c;this.on_apply_wordwrap();var _d=(_b.align.halign==""?"center":_b.align._halign);var _e=(_b.align.valign==""?"middle":_b.align._valign);_c.setElementSize(this._client_width,this._client_height);_c.setElementColor(_b.color);_c.setElementFont(_b.font);_c.setElementAlignXY(_d,_e);if(this._is_created){_c.create();}}var _f=this.expr;if(_f&&_f.length>0){_f=_f.trim().split(":");var _g=new nexacro.ExprParser();var _h,_i;var _j;if(_f.length==1){_j=_f[0];}else{if(_f[0].trim().toUpperCase()!="EXPR"){_j=_f.join(":");}else{_j=_f.slice(1).join(":");}}_h=_g.makeExpr(this,_j);_g=null;_i=nexacro._createInlineFunc(this._checkExprFunction(_h,this),["comp"]);if(_i){try{var _k=nexacro._toString(_i.call(this,this));if(_k!=this.displaytext){this.displaytext=_k;}}catch(e){return;}}}else{this.displaytext=this.text;}_f=null;_c.setElementText(this.displaytext);if(this.displaytext&&this.displaytext!=""){this._text_width= -1;this._text_height= -1;}else{this._text_width=0;this._text_height=0;}if(this._img_elem){this._updateElementPositions(_b.align,_b.imagealign);}_c=null;_b=null;}};_pSketch._checkExprFunction=function(_a,_b){try{nexacro._executeEvalStr(_a);return _a;}catch(e){try{nexacro._executeEvalStr(this._const_form+this._const_dot+_a);return _a=this._const_form+this._const_dot+_a;}catch(e){return _a;}}};_pSketch.on_apply_wordwrap=function(){if(this._text_elem){this._text_elem.setElementWordWrap(this.wordwrap);}};_pSketch.on_apply_expr=function(){if(this._currentPath.length>0){return;}this.on_apply_text();};_pSketch.set_cssclass=function(_a){_a=_a.split(",");for(var _b=0;_b<_a.length;_b++ ){if(_a[_b]!=this.cssclass){this.className=this.cssclass=_a[_b];if(this.parent){if(this._is_created){this.on_apply_prop_class();}}else{this.new_class=true;}}}this.className=this.cssclass=_a;};_pSketch.on_update_style_font=function(){var _a=this.currentstyle.font=this.on_find_CurrentStyle_font(this._pseudo);this.on_apply_style_font(_a);this.setTextFont(_a.face,_a.size);};_pSketch.on_update_style_color=function(){var _a=this.currentstyle.color=this.on_find_CurrentStyle_color(this._pseudo);this.on_apply_style_color(_a);this.setTextColor(_a.value);};_pSketch._apply_style=function(_a){this.on_apply_style_align(_a.align);this.on_apply_style_background(_a.background);this.on_apply_style_border(_a.border);this.on_apply_style_bordertype(_a.bordertype);this.on_apply_style_color(_a.color);this.on_apply_style_cursor(_a.cursor);this.on_apply_style_font(_a.font);this.on_apply_style_glow(_a.glow);this.on_apply_style_gradation(_a.gradation);this.on_apply_style_margin(_a.margin);this.on_apply_style_opacity(_a.opacity);this.on_apply_style_padding(_a.padding);this.on_apply_style_shadow(_a.shadow);this.on_apply_style_accessibility(_a.accessibility);};_pSketch._find_style=function(_a){var _b={};var _c=_a.length;var _d=this._pseudo;for(var _e=0;_e<_c;_e++ ){var _f=_a[_e];switch(_f){case "accessibility":_b["accessibility"]=this._make_accessibility_value(this.on_find_CurrentStyle_accessibility(_d));if(!_b["accessibility"]){_b["accessibility"]=nexacro._getCachedAccessibilityObj("");}break;case "align":_b["align"]=this.on_find_CurrentStyle_align(_d);if(!_b["align"]){_b["align"]=nexacro._getCachedAlignObj("");}break;case "background":_b["background"]=this.on_find_CurrentStyle_background(_d);if(!_b["background"]){_b["background"]=nexacro._getCachedBackgroundObj("");}break;case "border":_b["border"]=this.on_find_CurrentStyle_border(_d);if(!_b["border"]){_b["border"]=nexacro._getCachedBorderObj("");}break;case "bordertype":_b["bordertype"]=this.on_find_CurrentStyle_bordertype(_d);if(!_b["bordertype"]){_b["bordertype"]=nexacro._getCachedBordertypeObj("");}break;case "color":_b["color"]=this.on_find_CurrentStyle_color(_d);if(!_b["color"]){_b["color"]=nexacro._getCachedColorObj("");}break;case "cursor":_b["cursor"]=this.on_find_CurrentStyle_cursor(_d);if(!_b["cursor"]){_b["cursor"]=nexacro._getCachedStyleObj("");}case "font":_b["font"]=this.on_find_CurrentStyle_font(_d);if(!_b["font"]){_b["font"]=nexacro._getCachedFontObj("");}case "glow":_b["glow"]=this.on_find_CurrentStyle_glow(_d);if(!_b["glow"]){_b["glow"]=nexacro._getCachedGlowObj("");}case "gradation":_b["gradation"]=this.on_find_CurrentStyle_gradation(_d);if(!_b["gradation"]){_b["gradation"]=nexacro._getCachedGradationObj("");}case "margin":_b["margin"]=this.on_find_CurrentStyle_margin(_d);if(!_b["margin"]){_b["margin"]=nexacro._getCachedMarginObj("");}case "opacity":_b["opacity"]=this.on_find_CurrentStyle_opacity(_d);if(!_b["opacity"]){_b["opacity"]=nexacro._getCachedStyleObj("opacity","100");}case "padding":_b["padding"]=this.on_find_CurrentStyle_padding(_d);if(!_b["padding"]){_b["padding"]=nexacro._getCachedPaddingObj("");}case "shadow":_b["shadow"]=this.on_find_CurrentStyle_shadow(_d);if(!_b["shadow"]){_b["shadow"]=nexacro._getCachedShadowObj("");}break;}this.currentstyle[_f]=_b[_f];}return _b;};_pSketch.loadSketch=function(_a){if(this.readonly){return;}return this._loadSketch(_a);};_pSketch.saveSketch=function(){var _a=this._canvas_elem_tmp;if(_a){if(nexacro.Browser=="Runtime"){var _b=this.saveToImageObject();var _c=new nexacro.Image();_c._handle_id=_b;_c.width=this.width;_c.height=this.height;this._setValue(_c);this.on_fire_onsuccess(_b);if(this.updatebindingvalue!="nosetvalue"){this.updateToDataset();}return true;}else{var _d=_a.toDataURL();if(_d&&_d.src){_d.setBase64String(_d.src);this._setValue(_d);if(this.updatebindingvalue!="nosetvalue"){this.updateToDataset();}return true;}}}return false;};_pSketch.saveSketchToFile=function(_a,_b,_c){if(!_a){return false;}_b=_b?_b:this._save_image_formattype[0];if(_b==this._save_image_formattype[2]&&!_c){_c=100;}if(_a.lastIndexOf(".")<0){var _e=this._saveImageFileFormatType(_b);_a=_a+this._const_dot+_e;}var _d=this.parent.saveToImageFile(_a,_b,_c);if(nexacro.Browser=="Runtime"){if(_d){var _f=this.saveToImageObject();var _g=new nexacro.Image();_g._handle_id=_f;this._setValue(_g);this.on_fire_onsuccess(_f);return true;}else{var _h=nexacro._GetSystemErrorMsg(this,this._const_code_savefile_msg);this.on_fire_onerror(this,this._const_code_savefile,_h,this._const_errortype_obj,this._getRefFormBaseUrl(),url,this._const_code_savefile);return false;}}return false;};_pSketch._saveImageFileFormatType=function(_a){switch(_a){case "PNG":fileformattype="png";break;case "JPG":fileformattype="jpg";break;case "GIF":fileformattype="gif";break;case "TIF":fileformattype="tif";break;case "BMP,Mono":fileformattype="bmp";break;default:fileformattype="bmp";break;}return fileformattype;};_pSketch.undo=function(){if(this._checkEditmode()==false||this.readonly){return;}this._undo();};_pSketch.redo=function(){if(this._checkEditmode()==false||this.readonly){return;}this._redo();};_pSketch.on_getBindableProperties=function(){return "value";};_pSketch.updateToDataset=function(){};_pSketch.setBrushType=function(_a){if(this._checkEditmode()==false){return;}switch(_a){case "square":case "butt":this._path_style.lineCap=_a;break;default:this._path_style.lineCap=this._default_line_cap;break;}};_pSketch.setBrushSize=function(_a){if(this._checkEditmode()==false){return;}if(_a>0){this._path_style.lineWidth=_a;}else{this._path_style.lineWidth=this._default_line_width;}};_pSketch.setBrushColor=function(_a){if(this._checkEditmode()==false){return;}this._path_style.strokeStyle=nexacro._getCachedStyleObj("color",_a);};_pSketch.setTextFont=function(_a,_b){if(this._checkEditmode()==false){return;}_b=(_b==undefined||_b=="")?this._default_font_size:_b;this._path_style.fontface=_a;this._path_style.fontsize=_b;this.style.set_font_face(_a);this.style.set_font_size(_b);if(this.textedit){this.textedit.style.set_font_face(_a);this.textedit.style.set_font_size(_b);}};_pSketch.setTextColor=function(_a){if(this._checkEditmode()==false){return;}_a=(this._isCheckColor(_a))?_a:this._const_textcolor;this.style.set_color(_a);if(this.textedit){this.textedit.style.set_color(_a);}this._path_style.fontfill._setValue(_a);};_pSketch._isCheckColor=function(_a){_a=_a.replace(/^'/,"").replace(/'$/,"");if(_a.substring(1)=="gradation"){return true;}if(_a=="transparent"){return true;}if(!_a){return false;}if(nexacro._xreNamedColorList){if(_a in nexacro._xreNamedColorList){return true;}}if(_a.charAt(0)=="#"&&(_a.length==7||_a.length==9)){return true;}return false;};_pSketch.setEraseSize=function(_a){if(this._checkEditmode()==false){return;}this._path_style.eraseWidth=(_a>0)?_a:1;};_pSketch.drawText=function(_a,_b,_c,_d){if(this._checkEditmode()==false){return;}if(this.readonly){return;}var _e=this._canvas_elem;if(_e){this._initPath(this._path_style,this._const_text,_a,_b,true);var _f=this._currentPath[0];_f.text=_c;_f.globalCompositeOperation=this._const_composit_source_over;this._drawText(_f,_f.x,_f.y,_f.text,_d);}};_pSketch.drawStroke=function(_a,_b,_c){if(this._checkEditmode()==false||this.readonly){return;}if(!_a&&_a==undefined){return;}if(!_b&&_b==undefined){return;}_a=(_a>=0||_a<0)?_a:this._default_edit_x;_b=(_b>=0||_a<0)?_b:this._default_edit_y;_c=(!_c&&_c==undefined)?false:_c;if(this._startDrawStroke){_c=true;this._startDrawStroke=false;}this._drawStroke(this._path_style,this._const_stroke,_a,_b,_c);};_pSketch.drawErase=function(_a,_b,_c){if(this._checkEditmode()==false||this.readonly){return;}if(!_a&&_a==undefined){return;}if(!_b&&_b==undefined){return;}_a=(_a>=0||_a<0)?_a:this._default_edit_x;_b=(_b>=0||_a<0)?_b:this._default_edit_y;_c=(!_c&&_c==undefined)?false:_c;if(this._startDrawErase){_c=true;this._startDrawErase=false;}this._drawStroke(this._path_style,this._const_erase,_a,_b,_c);};_pSketch.clear=function(){this._apply_client_padding=true;if(this._checkEditmode()==false){return;}this._clear(this._isEnableRedraw());if(this._current_state== -1){this.on_apply_text();}};_pSketch.showTextEditor=function(_a,_b,_c,_d,_e){if(!(arguments.length>=4&&arguments.length<6)){return;}var _f=false;this._initPath(this._path_style,this._const_text,_a,_b,null,_c,_d,_e);this._drawPath(_a-this._default_edit_gap,_b);this._endPath();if(_e&&_e!==undefined&&_e!=""){_f=true;}return this._showTextEditor(_a,_b,_c,_d,_e,_f);};_pSketch.hideTextEditor=function(_a){_a=(_a==true||_a==false)?_a:true;return this._hideTextEditor(_a);};_pSketch.redraw=function(){var _a=this.enableredraw;this.enableredraw=true;this._refresh_style_contents();this._redrawPath();this.enableredraw=_a;};_pSketch.on_notify_edit_onkillfocus=function(_a,_b){var _c=_a.text;var _d=(_c.length>0)?true:false;var _e=true;if(_d){var _f=this._canvas_elem;if(_f){this._initPath(this._path_style,this._const_text,_a._left,_a._top,true);var _g=this._currentPath[0];_g.text=_c;_g.globalCompositeOperation=this._const_composit_source_over;this._drawText(_g,_g.x,_g.y,_g.text,_e);}}this._resetTextEdit(_d);if(this.updatebindingvalue=="nosetvalue"){this.updateToDataset();}};_pSketch.on_fire_ontouchmove=function(_a,_b,_c,_d){if(_a.length==0){return;}var _e=_a[0];this.on_fire_onmousemove("lbutton",null,null,null,_e.screenX,_e.screenY,_e.canvasX,_e.canvasY,_e.clientX-this.m_screenX,_e.clientY-this.m_screenY,_c,_d);};_pSketch.on_fire_sys_ontouchmove=_pSketch.on_fire_ontouchmove;_pSketch.on_fire_onmousemove=function(_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l){this._moveAction(_a,_i,_j);};_pSketch.on_fire_sys_ondragmove=function(_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m,_n,_o,_p){var _q=nexacro.Component.prototype.on_fire_sys_ondragmove.call(this,_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m,_n,_o,_p);this._moveAction(_e,_m,_n);return _q;};_pSketch.on_fire_sys_onmousemove=_pSketch.on_fire_onmousemove;_pSketch._moveAction=function(_a,_b,_c){if(_a=="lbutton"||_a=="touch"){if(this._checkEditmode()==false||this.readonly){return;}if(_a=="touch"){if(this.touchStatus==3){this.touchStatus=0;}else if(this.touchStatus==1){this.touchStatus=2;}if(this.touchStatus!=0){if(this._path_style.lineCap=="butt"){if(this._butt_count==3){this._drawPath(_b,_c);this._butt_count=0;}this._butt_count++ ;}else{this._drawPath(_b,_c);}}}else{if(this._path_style.lineCap=="butt"){if(this._butt_count==3){this._drawPath(_b,_c);this._butt_count=0;}this._butt_count++ ;}else{this._drawPath(_b,_c);}}}};_pSketch.on_fire_ontouchstart=function(_a,_b,_c,_d){if(_a.length==0){return;}var _e=_a[0];this.on_fire_onlbuttondown("lbutton",null,null,null,_e.screenX,_e.screenY,_e.canvasX,_e.canvasY,_e.clientX-this.m_screenX,_e.clientY-this.m_screenY,_c,_d);};_pSketch._on_touch_lbuttondown=function(_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l){application._skipDragEventAfterMsgBox=false;var _m;var _n=this._getFromComponent(this);if(!_n.onlbuttondown||(_n.onlbuttondown&&!_n.onlbuttondown.defaultprevented)){this.on_fire_onlbuttondown(_b,_c,_d,_e,_f,_g,_h,_i,_f,_g,_k,_l,false);_m=this._on_bubble_touch_lbuttondown(_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,false);}return _m;};_pSketch.on_fire_sys_ontouchstart=_pSketch.on_fire_ontouchstart;_pSketch.on_fire_onlbuttondown=function(_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l){if(this._checkEditmode()==false){return;}if(this.readonly){if(this.textedit.visible){this.textedit.set_visible(false);}return;}if(_a=="touch"){this.touchStatus=1;this._is_touch=true;}this.button==_a;this._initPath(this._path_style,this.editmode,_i,_j);if(this._path_style.lineCap!="butt"){this._drawPath(_i-this._default_edit_gap,_j);this._endPath();}};_pSketch.on_fire_sys_onlbuttondown=_pSketch.on_fire_onlbuttondown;_pSketch.on_fire_ontouchend=function(_a,_b,_c,_d){if(_a.length==0){return;}var _e=_a[0];this.on_fire_onlbuttonup("lbutton",null,null,null,_e.screenX,_e.screenY,_e.canvasX,_e.canvasY,_e.clientX-this.m_screenX,_e.clientY-this.m_screenY,_c,_d);};_pSketch.on_fire_sys_ontouchend=_pSketch.on_fire_ontouchend;_pSketch.on_fire_onlbuttonup=function(_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l){if(this._checkEditmode()==false||this.readonly){return;}if(_a=="touch"){this.touchStatus=3;}this._endPath();if(_a=="touch"){this._delete_text();this.displaytext="";}};_pSketch.on_fire_sys_onlbuttonup=_pSketch.on_fire_onlbuttonup;_pSketch._on_touch_lbuttonup=function(_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m){var _n;var _o=this._getFromComponent(this);if(_o&&(!_o.onlbuttonup||(_o.onlbuttonup&&!_o.onlbuttonup.defaultprevented))){this.on_fire_onlbuttonup(_b,_c,_d,_e,_f,_g,_h,_i,_f,_g,from_comp,_l);_n=this._on_bubble_touch_lbuttonup(_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m,false);}return _n;};_pSketch._endPath=function(){var _a=this._canvas_elem;if(!_a||this._currentPath.length==0){return;}var _b=this._currentPath[0];var _c=this._path_style;if(this.editmode==this._const_text&&!this.textedit.visible&&_b){_b.fontface=_c.fontface;_b.fontsize=_c.fontsize;_b.fontfill._setValue(_c.fontfill.value);}this._regenStroke(this._currentPath,_a);this._regenStroke(this._currentPath,this._canvas_elem_tmp);};_pSketch.on_notify_onchar=function(_a,_b){return this.on_fire_onchar(_a,_b.chartext,_b.pretext,_b.posttext);};_pSketch.on_fire_onchar=function(_a,_b,_c,_d){if(this.onchar&&this.onchar._has_handlers){var _e=new nexacro.CharEventInfo(this,"onchar",_b,_c,_d);return this.onchar._fireCheckEvent(this,_e);}return true;};_pSketch.on_fire_onload=function(_a,_b){var _c=this.onload;if(_c&&_c._has_handlers){var _d=new nexacro.SketchLoadEventInfo(this,"onload",_b);_c._fireEvent(this,_d);}};_pSketch.on_fire_onerror=function(_a,_b,_c,_d,_e,_f,_g){var _h=this.onerror;if(_h&&_h._has_handlers){var _i=new nexacro.SketchErrorEventInfo(this,"onerror",_b,_c,_d,_e,_f,_g);_h._fireEvent(this,_i);}};_pSketch.on_fire_onsuccess=function(_a){var _b=this.onsuccess;if(_b&&_b._has_handlers){var _c=new nexacro.SuccessEventInfo(this,"onsuccess",_a);return this.onsuccess._fireEvent(this,_c);}};_pSketch._getDlgCode=function(_a,_b,_c,_d){return {want_tab:false,want_return:false,want_escape:false,want_chars:false,want_arrows:false,want_touchstart:true,want_touchmove:true};};_pSketch._refresh_style_contents=function(){this.on_update_style_align();this.on_update_style_background();this.on_update_style_border();this.on_update_style_bordertype();this.on_update_style_color();this.on_update_style_cursor();this.on_update_style_font();this.on_update_style_gradation();this.on_update_style_opacity();this.on_update_style_padding();this.on_update_style_shadow();if(nexacro._enableaccessibility){this.on_update_style_accessibility();}};_pSketch._setImageValue=function(_a){if(_a instanceof nexacro.ImageSketchBackGround){var _b=_a.getBase64String();if(!_b){var _a=this._canvas_elem_bg.toDataURL();if(_a&&_a.src){_a.setBase64String(_a.src);this.value=this._image=_a;}}}};_pSketch._setImageType=function(_a){if(_a){if(_a instanceof nexacro.Image){_a=_a._base64str;this._img_type="base64";}else{_a=_a.toString();var _b=nexacro._checkBase64String(_a);if(_b){if(_a.substring(0,10).toLowerCase()=="data:image"){if(_a.substring(0,17).toLowerCase()!="data:image;base64"){var _c=_a.indexOf(",");if(_c> -1){var _d=_a.slice(_c+1,_a.legnth);_a="data:image;base64,"+_d;}}}else{_a="data:image;base64,"+_a;}this._img_type="base64";}else{this._img_type="url";}}}else{_a="";this._img_type="url";}};_pSketch._loadSketch=function(_a){if(this._image){this._image=null;}this._setImageType(_a);var _b=this._img_type;if(_b=="url"){_a=nexacro._getURIValue(_a);_a=nexacro._getImageLocation(_a,this._getRefFormBaseUrl());}if(_a==undefined||arguments.length>1){var _d=nexacro._GetSystemErrorMsg(this,this._const_code_parameter_msg);this.on_fire_onerror(this,this._const_code_parameter,_d,this._const_errortype_obj,this._getRefFormBaseUrl(),_a,this._const_code_parameter);return false;}if(_a&&_a!==undefined){var _e=_a.substring(_a.lastIndexOf(".")+1).toLowerCase();if((this._image_format).indexOf(_e)== -1){var _d=nexacro._GetSystemErrorMsg(this,this._const_code_incorrectfile_msg);this.on_fire_onerror(this,this._const_code_incorrectfile,_d,this._const_errortype_type,this._getRefFormBaseUrl(),_a,this._const_code_incorrectfile);return false;}}var _c=nexacro._getImageSize(_a,this._imageload,this,this.parent._getRefFormBaseUrl());if(_c){this._clearCanvas(this._isEnableRedraw());return this._drawImage(_a);}};_pSketch._drawImage=function(_a){this._image=new nexacro.ImageSketchBackGround(this);var _b=this._image.set_src(_a);if(_b){if(this._apply_client_padding){this._delete_text();this.displaytext="";}this._setValue(this._image);if(this._clr_history){this._initHistory();this._setRedoUndo();}return true;}return false;};_pSketch._imageload=function(_a,_b,_c,_d,_e){if(_b<=0){this._image=null;delete nexacro._ImgInfoCacheList[_a];nexacro._ImgInfoCacheList[_a]=null;var _f=nexacro._GetSystemErrorMsg(this,this._const_code_loadinvalidimage_msg);this.on_fire_onerror(this,this._const_code_loadinvalidimage_msg,_f,this._const_errortype_type,this._getRefFormBaseUrl(),_a,this._const_code_loadinvalidimage_msg);}else{this._clearCanvas(this._isEnableRedraw());this._drawImage(_a);}};_pSketch._drawText=function(_a,_b,_c,_d,_e){if(this.readonly){return;}if(!_d||_d.length==0){return;}var _f=this._canvas_elem;var _g=this._canvas_elem_tmp;if(_f){if(this._apply_client_padding){this._delete_text();this.displaytext="";}_b=(_b>=0||_b<0)?_b:this._default_edit_x;_c=(_c>=0||_b<0)?_c:this._default_edit_y;var _h=this.textedit;var _i=_h.currentstyle;var _j=this.currentstyle.font;if(_j==null){var _j=new nexacro.Style_font();}var _k=_j.size;_j.set_face(_a.fontface);_j.set_size(_a.fontsize);_f.setElementFont(_j);_f.setElementGlobalCompositeOperation(_a.globalCompositeOperation);_g.setElementFont(_j);_g.setElementGlobalCompositeOperation(_a.globalCompositeOperation);var _l;if(_a.fontfill instanceof nexacro.Style_color){_l=_a.fontfill;}else{_l=new nexacro.Style_color(_a.fontfill);}_f.setElementFillStyle(_l);_g.setElementFillStyle(_l);var _m=Number(_c);if(_e){v=nexacro._toString(_d);if(_d&&_d!==undefined&&_d!=""){_d=_d.replace(/"/g,"\"");if(_d.indexOf("\r\n")!= -1||_d.indexOf("\n\r")!= -1){_d=_d.replace(/\r\n/g,"\n").replace(/\n\r/g,"\n");}else{if(_d.indexOf("\r")!= -1){_d=_d.replace(/\r/g,"");}}var _n=(_d.replace(/\\n/g,'\n')).split("\n");var _o=_i.linespace.value;for(var _p=0;_p<_n.length;_p++ ){if(this._isEnableRedraw()){_f.drawFillText(_n[_p],_b,_m);_g.drawFillText(_n[_p],_b,_m);}_m+=Number(_o)+Number(_k);}}}else{if(this._isEnableRedraw()){_f.drawFillText(_d,_b,_m);_g.drawFillText(_d,_b,_m);}}}};_pSketch._drawStroke=function(_a,_b,_c,_d,_e){if(this._checkEditmode()==false||this.readonly){return;}if(this._apply_client_padding){this._delete_text();this.displaytext="";}var _f=Number(_c);var _g=Number(_d);if(this._currentPath[0]&&this._currentPath[0].tool!=_b){_e=true;}switch(_e){case true:this._initPath(this._path_style,_b,_f,_g);this._drawPath(_f-this._default_edit_gap,_g);break;default:this._drawPath(_f-this._default_edit_gap,_g);this._endPath();break;}};_pSketch._showTextEditor=function(_a,_b,_c,_d,_e){if(this._checkEditmode()==false){return;}var _f=0;var _g=null;var _h=this.textedit.value;var _i=this.textedit;var _j=_i.vscrollbar.scrollbarsize;var _k=_i.hscrollbar.scrollbarsize;if(_e){_g=_e;_f= -1;}else{_g=_h;}if(_a>=0||_a<0){this.textedit.set_left(_a);}else{this.textedit.set_left(this._default_edit_x);}if(_b>=0||_a<0){this.textedit.set_top(_b);}else{this.textedit.set_top(this._default_edit_y);}if(_c>=0||_a<0){this.textedit.set_width(Number(_c)+Number(_k));}else{this.textedit.set_width(Number(this._default_edit_width)+Number(_k));}if(_d>=0||_a<0){this.textedit.set_height(Number(_d)+Number(_j));}else{this.textedit.set_height(Number(this._default_edit_height)+Number(_j));}this.textedit.set_value(_g);if(this._isEnableRedraw()){this.textedit.set_visible(true);this.textedit.setFocus(true);this.textedit.setCaretPos(_f);if(_e&&_e!==undefined&&_e!=""){if(_e.length>0){this.textedit.setSelect(0,_e.length);}}}return _h;};_pSketch._hideTextEditor=function(_a){if(this._checkEditmode()==false){return;}var _b=this.textedit.value;if(_a){this.textedit.set_value(null);}if(this._isEnableRedraw()){this.textedit.set_visible(false);this.textedit.set_left(this._default_edit_x);this.textedit.set_top(this._default_edit_y);this._control_element.setElementFocus();}return _b;};_pSketch._redrawPathData=function(_a){this._clearCanvas(this._isEnableRedraw());if(this._image){this._loadSketch(this._image.src);}var _b=_a.length;for(var _c=0;_c<_b;_c++ ){this._regenStroke(_a[_c],this._canvas_elem);this._regenStroke(_a[_c],this._canvas_elem_tmp);this._regenStroke(_a[_c],this._canvas_elem_bg);}};_pSketch._drawBcurve=function(_a,_b){var _c=_a.length-1;if(_c<1){return;}for(var _d=0;_d<_c;_d++ ){var _e=_a[_d];var _f=_a[_d+1];if(_d==0){this._setupCanvasElem(_b,_e,_e);}_b.lineTo(_f.x,_f.y);}_b.stroke();};_pSketch._drawUserStroke=function(_a,_b){var _c=_a.length-1;if(_c<1){return;}for(var _d=0;_d<_c;_d++ ){var _e=_a[_d];var _f=_a[_d+1];if(_d==0){this._setupCanvasElem(_b,_e,_e);_b.lineTo(_f.x,_f.y);_b.lineTo(_e.x,_e.y);}_b.lineTo(_f.x,_f.y);}_b.stroke();};_pSketch._setupCanvasElem=function(_a,_b,_c){_a.beginPath();_a.moveTo(_c.x,_c.y);_a.setElementLineCap(_b.lineCap);_a.setElementGlobalCompositeOperation(_b.globalCompositeOperation);switch(_b.tool){case this._const_erase:case this._const_erase_user:_a.setElementStrokeStyle(this._default_stroke_style);_a.setElementLineWidth(_b.eraseWidth);break;case this._const_stroke:case this._const_stroke_user:default:_a.setElementStrokeStyle(_b.strokeStyle);_a.setElementLineWidth(_b.lineWidth);}};_pSketch._regenStroke=function(_a,_b){if(this._isEnableRedraw()){var _c=this._clone(_a);var _d=(this._is_undo&&_c[0].tool!=this._const_text)?this._const_stroke_user:_c[0].tool;switch(_d){case this._const_text:{var _e=_c[0];this._drawText(_e,_e.x,_e.y,_e.text,true);}break;case this._const_stroke:case this._const_erase:{this._drawBcurve(_c,_b);}break;case this._const_stroke_user:case this._const_erase_user:{this._drawUserStroke(_c,_b);}break;}}};_pSketch._clone=function(_a){if(!_a||typeof (_a)!=='object'){return _a;}var _b=new _a.constructor();for(var _c in _a){if(!_a[_c]||typeof (_a[_c])!=='object'){_b[_c]=_a[_c];}else{_b[_c]=this._clone(_a[_c]);}}return _b;};_pSketch._undo=function(){if(this._undoable()){this._current_state-- ;this._current_strokes=null;this._is_undo=true;this._redrawPath();if(this.updatebindingvalue!="nosetvalue"){this.updateToDataset();}this._is_undo=false;if(this._current_state== -1){this.on_apply_text();}}};_pSketch._redo=function(){if(this._redoable()){if(this._current_state== -1){this._delete_text();this.displaytext="";}this._current_state++ ;this._current_strokes=null;this._redrawPath();if(this.updatebindingvalue!="nosetvalue"){this.updateToDataset();}}};_pSketch._redrawPath=function(){var _a=this._currentStrokes();this._clr_history=false;this._redrawPathData(_a);this._setRedoUndo();this._clr_history=true;};_pSketch._checkEditmode=function(){if(this.editmode==this._const_none){return false;}return true;};_pSketch._clearCanvasElem=function(_a){if(_a){_a.clearRect(_a.left,_a.top,_a.width,_a.height);}};_pSketch._clearCanvas=function(_a){if(_a){var _b=[this._canvas_elem,this._canvas_elem_bg,this._canvas_elem_tmp];for(var _c=0;_c<_b.length;_c++ ){this._clearCanvasElem(_b[_c]);}_b=null;}};_pSketch._clear=function(_a){this._hideTextEditor(true);if(_a){this._clearCanvas(_a);}this._image=null;this._initHistory();this._setRedoUndo();this._setValue(null);if(this.updatebindingvalue!="nosetvalue"){this.updateToDataset();}};_pSketch._setRedoUndo=function(){this.redoable=this._redoable();this.undoable=this._undoable();};_pSketch._drawPath=function(_a,_b){var _c={};_c.x=_a;_c.y=_b;var _d=this._canvas_elem;if(!_d||!this._currentPath[0]){return;}var _e=_d;var _f=this._currentPath[0].tool;if(_f!=this._const_text&&!this._is_touch){this._delete_text();this.displaytext="";}switch(_f){case this._const_text:return;case this._const_erase:case this._const_erase_user:{_e=_d;}break;}this._currentPath.push(_c);this._regenStroke(this._currentPath,_e);this._regenStroke(this._currentPath,this._canvas_elem_tmp);};_pSketch._initPath=function(_a,_b,_c,_d,_e,_f,_g,_h){switch(this._currentPath[0]&&this._currentPath[0].tool){case this._const_stroke_user:this._endPath();break;}var _i=this._clone(_a);var _j={};_j.x=_c;_j.y=_d;_j.beginPath=true;_i.tool=_b;var _k=this._const_composit_source_over;if(_i.tool!=this._const_text&&this.textedit.visible){this._resetTextEdit(true);return;}switch(_i.tool){case this._const_erase:case this._const_erase_user:_k=this._const_composit_destination_out;break;case this._const_text:{if(_e==null){if(this.textedit.visible){this._resetTextEdit(true);return;}else{this._showTextEditor(_j.x,_j.y,_f,_g,_h);}}}break;case this._const_stroke:case this._const_stroke_user:default:break;}_i.globalCompositeOperation=_k;for(var _l in _i){_j[_l]=_i[_l];}this._currentPath=this._add({type:_b,stroke:[_j]});this._setRedoUndo();};_pSketch._resetTextEdit=function(_a){if(this.textedit.visible==false){return;}var _b=this.textedit.value;if(nexacro.Browser=="Safari"||nexacro.Browser=="MobileSafari"){var _c=this.textedit._input_element;_b=_c.getElementValue();this.textedit.set_value(_b);}this._hideTextEditor(true);if(_b&&_a){this._currentPath[0].text=_b;}else{this._undo();this._setRedoUndo();}this.textedit.set_left(this._default_edit_x);this.textedit.set_top(this._default_edit_y);};_pSketch._initHistory=function(){this._history=[];this._current_state= -1;this._freeze_state= -1;this._current_strokes=null;};_pSketch._add=function(_a){if(this._current_state+1 -1&&this._current_state>this._freeze_state);};_pSketch._redoable=function(){return this._current_state