$PBExportHeader$w_fx_ip_setting.srw
forward
global type w_fx_ip_setting from window
end type
type st_1 from statictext within w_fx_ip_setting
end type
type cb_back from commandbutton within w_fx_ip_setting
end type
type cb_del from commandbutton within w_fx_ip_setting
end type
type dw_1 from datawindow within w_fx_ip_setting
end type
end forward

global type w_fx_ip_setting from window
integer width = 1152
integer height = 804
windowtype windowtype = response!
long backcolor = 16777215
string icon = "AppIcon!"
st_1 st_1
cb_back cb_back
cb_del cb_del
dw_1 dw_1
end type
global w_fx_ip_setting w_fx_ip_setting

type variables
s_fx_ip_setting ins_parm, ins_empty
end variables

forward prototypes
public function integer wf_retrieve ()
public function integer wf_save ()
end prototypes

public function integer wf_retrieve ();int rslt = 1

long i, insertRow
string temp_ip
dw_1.Reset()
dw_1.SetRedraw(false)
for i = 1 to 9
	temp_ip = Trim(ProfileString(sys_fx_ini, 'server_' + string(i), 'ip', ''))
	if (temp_ip = '') then continue
	
	insertRow = dw_1.InsertRow(0)
	dw_1.Object.ip[insertRow] = temp_ip
	dw_1.Object.port[insertRow] = ProfileInt(sys_fx_ini, 'server_' + string(i), 'port', 0)
	dw_1.Object.name[insertRow] = Trim(ProfileString(sys_fx_ini, 'server_' + string(i), 'name', ''))
	dw_1.Object.printid[insertRow] = i
next
dw_1.AcceptText()
dw_1.SetRedraw(true)

return rslt
end function

public function integer wf_save ();int rslt = 1

long i, cnt = 0
string temp_ip, temp_name
long temp_port
dw_1.AcceptText()
for i = 1 to dw_1.RowCount()
	cnt++
	//SetProfileString
	temp_ip = Trim(dw_1.Object.ip[i])
	temp_port = dw_1.Object.port[i]
	temp_name = Trim(dw_1.Object.name[i])
	SetProfileString(sys_fx_ini, 'server_' + string(i), 'ip', temp_ip)
	SetProfileString(sys_fx_ini, 'server_' + string(i), 'port', string(temp_port))
	SetProfileString(sys_fx_ini, 'server_' + string(i), 'name', temp_name)
next

if (cnt < 9) then
	for i = cnt + 1 to 9
		SetProfileString(sys_fx_ini, 'server_' + string(i), 'ip', '')
		SetProfileString(sys_fx_ini, 'server_' + string(i), 'port', '')
		SetProfileString(sys_fx_ini, 'server_' + string(i), 'name', '')
	next
end if

return rslt
end function

on w_fx_ip_setting.create
this.st_1=create st_1
this.cb_back=create cb_back
this.cb_del=create cb_del
this.dw_1=create dw_1
this.Control[]={this.st_1,&
this.cb_back,&
this.cb_del,&
this.dw_1}
end on

on w_fx_ip_setting.destroy
destroy(this.st_1)
destroy(this.cb_back)
destroy(this.cb_del)
destroy(this.dw_1)
end on

event open;ins_parm = Message.PowerObjectParm
if (IsNull(ins_parm)) then
	Close(this)
	return
end if
if (not IsValid(ins_parm)) then
	Close(this)
	return
end if

this.X = ins_parm.x
this.Y = ins_parm.y

wf_retrieve()
end event

event close;wf_save()

CLoseWithReturn(this, ins_parm)
end event

type st_1 from statictext within w_fx_ip_setting
integer x = 50
integer y = 708
integer width = 507
integer height = 48
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 16711680
long backcolor = 16777215
string text = "双击列表项进行选择"
boolean focusrectangle = false
end type

type cb_back from commandbutton within w_fx_ip_setting
integer x = 914
integer y = 688
integer width = 210
integer height = 88
integer taborder = 20
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "返回"
boolean cancel = true
end type

event clicked;ins_parm = ins_empty
Close(parent)
end event

type cb_del from commandbutton within w_fx_ip_setting
integer x = 622
integer y = 688
integer width = 210
integer height = 88
integer taborder = 20
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "删除"
end type

event clicked;long row
row = dw_1.GetRow()
if (row > 0) then
	if (dw_1.IsSelected(row)) then
		dw_1.DeleteRow(row)
		
		if (dw_1.RowCount() >= row) then
			dw_1.SelectRow(0, false)
			dw_1.SelectRow(row, true)
			dw_1.SetRow(row)
		elseif (dw_1.RowCount() > 0) then
			row = dw_1.RowCount()
			
			dw_1.SelectRow(0, false)
			dw_1.SelectRow(row, true)
			dw_1.SetRow(row)
		end if
	end if
end if
end event

type dw_1 from datawindow within w_fx_ip_setting
integer width = 1143
integer height = 680
integer taborder = 10
string title = "none"
string dataobject = "dw_fx_ip_setting"
boolean hscrollbar = true
boolean vscrollbar = true
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event doubleclicked;if (row > 0) then
	ins_parm.ip = Trim(this.Object.ip[row])
	ins_parm.port = this.Object.port[row]
	Close(parent)
end if
end event

event clicked;if (row > 0) then
	this.SelectRow(0, false)
	this.SelectRow(row, true)
	this.SetRow(row)
end if
end event

event rowfocuschanged;if (currentrow > 0) then
	this.SelectRow(0, false)
	this.SelectRow(currentrow, true)
	this.SetRow(currentrow)
end if
end event

